/* ເກມແມວນ້ອຍ 共通スタイル（全ページ共通・各ゲームは css/<page>.css で上書き）
   縦構造: body(flex縦) = .sg-header / .sg-main(flex:1) / .sg-tabbar(通常フロー)
   - body 高さは --app-h(=window.innerHeight, core.js が設定)。100dvh は端末により可視域とズレる。
   - タブバーは position:fixed にしない。safe-area は standalone 時の .sg-tabbar 1か所だけ。
   - viewport meta に viewport-fit=cover は付けない（Android でナビバー裏に隠れる）。 */

:root {
  --bg: #FFF7F0;
  --bg2: #FFEAF1;
  --card: #FFFFFF;
  --ink: #5A4636;
  --ink-soft: #9C8676;
  --line: #F2DCD2;
  --accent: #FF8FB1;
  --accent-deep: #E5588A;
  --mint: #7FD6C2;
  --mint-deep: #3FB39A;
  --yellow: #FFD66B;
  --yellow-deep: #E9B53C;
  --danger: #FF6B6B;
  --header-h: 50px;
  --tab-h: 60px;
  --radius: 20px;
  --font: "Noto Sans Lao", "Noto Sans Lao UI", "Phetsarath OT", "Saysettha OT",
          "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI",
          system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  background: #F3E1D6;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 520px;
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;               /* ラオ文字は上下の母音記号があるので詰めない */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  box-shadow: 0 0 40px rgba(90, 70, 54, 0.12);
}

img { -webkit-user-drag: none; user-select: none; }
button { font-family: inherit; color: inherit; }

/* ---------- ヘッダー ---------- */
.sg-header {
  flex-shrink: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  background: var(--card);
  border-bottom: 2px solid var(--line);
  z-index: 20;
}
.sg-header .sg-title {
  flex: 1;
  min-width: 0;
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sg-lang-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.sg-lang-btn:active { transform: scale(0.95); }

/* ---------- 本体 ---------- */
.sg-main {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.sg-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 下タブ（通常フロー） ---------- */
.sg-tabbar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  background: var(--card);
  border-top: 2px solid var(--line);
  box-shadow: 0 -3px 14px rgba(229, 88, 138, 0.10);
  z-index: 20;
}
.sg-tab {
  flex: 1 1 0;
  min-height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 2px 5px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.3;
  text-decoration: none;
  touch-action: manipulation;
}
.sg-tab .sg-tab-ico { font-size: 25px; line-height: 1.15; }
.sg-tab.active { color: var(--accent-deep); }
.sg-tab.active .sg-tab-ico { transform: scale(1.1); filter: drop-shadow(0 2px 4px rgba(229, 88, 138, 0.35)); }
.sg-tab:active { opacity: 0.6; }
@media (display-mode: standalone) {
  .sg-tabbar { padding-bottom: max(env(safe-area-inset-bottom), 8px); }
}

/* プレイ中など全画面にしたい時: body に sg-immersive を付ける */
body.sg-immersive .sg-header,
body.sg-immersive .sg-tabbar { display: none; }

/* ---------- ボタン（子ども向けに大きく） ---------- */
.sg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 60px;
  min-width: 60px;
  padding: 6px 30px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.45;              /* ラオ文字の上下の記号が欠けないように */
  box-shadow: 0 5px 0 var(--accent-deep);
  cursor: pointer;
  touch-action: manipulation;
}
.sg-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-deep); }
.sg-btn.mint { background: var(--mint); box-shadow: 0 5px 0 var(--mint-deep); }
.sg-btn.mint:active { box-shadow: 0 1px 0 var(--mint-deep); }
.sg-btn.yellow { background: var(--yellow); color: var(--ink); box-shadow: 0 5px 0 var(--yellow-deep); }
.sg-btn.yellow:active { box-shadow: 0 1px 0 var(--yellow-deep); }
.sg-btn.sub { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--line); }
.sg-btn.sub:active { box-shadow: 0 1px 0 var(--line); }
.sg-btn[disabled] { opacity: 0.45; pointer-events: none; }

.sg-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(90, 70, 54, 0.08);
  padding: 16px;
}

/* ---------- 重ね表示（main の中に全面で出す） ---------- */
.sg-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 247, 240, 0.92);
  text-align: center;
}

.sg-hidden { display: none !important; }

/* 浮き上がる数字（+1,000 など） */
.sg-float {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  font-weight: 900;
  font-size: 22px;
  white-space: nowrap;
  text-shadow: 0 2px 0 #fff, 0 0 6px #fff;
  animation: sg-float-up 0.9s ease-out forwards;
}
@keyframes sg-float-up {
  from { transform: translate(-50%, 0) scale(0.9); opacity: 1; }
  to   { transform: translate(-50%, -52px) scale(1.12); opacity: 0; }
}

/* 小さな通知 */
.sg-toast {
  position: absolute;
  left: 50%;
  top: 14px;
  z-index: 60;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  pointer-events: none;
  animation: sg-toast 2.2s ease forwards;
}
@keyframes sg-toast {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  12%, 80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* 絵（SVG / 画像）共通 */
.sg-art, .sg-art-svg { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sg-emoji { display: inline-block; line-height: 1; font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
