/* ==========================================================
   style.css
   ----------------------------------------------------------
   スイーツ＆バーガー・キッチン 〜タイピングでクッキング！〜 の
   スタイルシート。セクションごとにコメントで区切り、
   「共通パーツ → 画面ごとのスタイル → アニメーション」の順に並べている。
   ========================================================== */

/* ---------- 0. リセット & 変数（デザイントークン） ---------- */
* {
  box-sizing: border-box;
}

/* iframe埋め込み時に「ページ全体の縦スクロールバー」が出ないようにする。
   html/body の高さを埋め込み先（iframe）ぴったりに固定し、
   はみ出す分は各画面（.tg-screen）の中だけでスクロールさせる。 */
html {
  height: 100%;
}

:root {
  /* カフェ・キッチン風のあたたかくポップな配色。
     バーガー（コーラル）× スイーツ（ピンク）× チーズ（イエロー）を軸にする */
  --emerald: #22c55e;       /* レタスグリーン（メインアクション） */
  --emerald-dark: #16a34a;
  --purple: #ec4899;        /* いちごピンク（サブアクション・リンク） */
  --purple-dark: #db2777;
  --yellow: #fde047;        /* チーズイエロー */
  --yellow-dark: #f59e0b;
  --coral: #ff6b5b;         /* パティ・トマトのコーラルレッド */
  --coral-dark: #e6503f;
  --red: #ef4444;
  --ink: #4a3728;           /* 木のカウンターのような、あたたかいこげ茶 */
  --shadow: rgba(74, 55, 40, 0.18);
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* ページ自体はスクロールさせない */
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff7ed 0%, #ffe4e6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  /* 埋め込み先の高さが小さいときは、余白そのものを自動的に減らす */
  padding: clamp(4px, 2vh, 24px) clamp(4px, 2vw, 12px);
}

h1, h2, h3, p, ul, li {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- 1. 全体の器（カード風コンテナ） ---------- */
.tg-app {
  width: 100%;
  max-width: 720px;
  height: 100%;
  max-height: 100%;
  background: #ffffff;
  border-radius: clamp(12px, 3vh, 28px);
  padding: clamp(10px, 2.5vh, 20px) clamp(12px, 3vw, 20px);
  position: relative;
  overflow: hidden;
  border: 4px solid #ffffff;
  box-shadow: 0 10px 0 var(--shadow), 0 10px 30px rgba(31, 41, 55, 0.15);
  display: flex;
  flex-direction: column;
}

.tg-screen { display: none; }
.tg-screen.active {
  /* 画面を「縦に並べたブロック」として扱い、
     内容がはみ出したときはこの画面の中だけでスクロールさせる
     （＝ページ全体やiframeにスクロールバーを出さない） */
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  animation: tg-fadein .35s ease;
}

/* ---------- 2. 共通パーツ（ロゴ・ボタン類） ---------- */
.tg-logo {
  text-align: center;
  font-size: clamp(14px, min(4vh, 5.2vw), 32px);
  font-weight: 800;
  color: var(--purple-dark);
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 var(--shadow);
  margin-bottom: 4px;
  animation: tg-bob 3s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}
.tg-logo img { width: clamp(20px, min(4vh, 6vw), 36px); height: clamp(20px, min(4vh, 6vw), 36px); flex-shrink: 0; }

.tg-subtitle {
  text-align: center;
  font-size: clamp(11px, 2vh, 14px);
  color: #6b7280;
  margin-bottom: clamp(6px, 1.5vh, 18px);
  font-weight: 700;
  flex-shrink: 0;
}

.tg-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(13px, 3vh, 15px);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: clamp(9px, 2.2vh, 13px) 22px;
  cursor: pointer;
  background: var(--emerald);
  box-shadow: 0 5px 0 var(--emerald-dark);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tg-btn:hover { transform: translateY(-2px); }
.tg-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--emerald-dark); }
.tg-btn.tg-purple { background: var(--purple); box-shadow: 0 5px 0 var(--purple-dark); }
.tg-btn.tg-yellow { background: var(--yellow-dark); box-shadow: 0 5px 0 #b45309; }
.tg-btn.tg-ghost { background: #fff; color: var(--purple-dark); box-shadow: 0 5px 0 #d1d5db; border: 2px solid #ede9fe; }
.tg-btn.tg-coral { background: var(--coral); box-shadow: 0 5px 0 var(--coral-dark); }

/* 出題モードの切りかえスイッチ（にほんご→えいご / えいご→ローマ字） */
.tg-mode-switch {
  display: flex; gap: 8px; margin-bottom: clamp(8px, 1.5vh, 16px);
  flex-shrink: 0;
}
.tg-mode-btn {
  flex: 1;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(11px, 2.2vh, 12.5px);
  line-height: 1.3;
  color: var(--ink);
  background: #fff;
  border: 3px solid #f3d9c4;
  border-radius: 16px;
  padding: clamp(5px, 1.2vh, 8px) 6px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.tg-mode-btn:hover { transform: translateY(-2px); }
.tg-mode-btn.active {
  background: linear-gradient(135deg, #fff7ed, #ffe4e6);
  border-color: var(--coral);
  color: var(--coral-dark);
}

/* プレイ中に今どちらのモードか分かるバッジ（注文伝票の右上に貼る） */
.tg-mode-hint {
  position: absolute;
  top: 6px; right: 10px;
  font-size: 10px; font-weight: 800; color: var(--coral-dark);
  background: #fff1ee; border: 2px solid #ffd7cf; border-radius: 999px;
  padding: 1px 8px;
}

/* ---------- 3. スタート画面（レベル選択） ---------- */
/* auto-fit: 横幅に余裕があるPCなどでは自動で2〜3列になって縦の高さを圧縮し、
   幅の狭いスマホでは自然に1列へ戻る（メディアクエリなしで両対応） */
.tg-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: clamp(6px, 1.5vh, 12px);
  margin-bottom: clamp(8px, 1.5vh, 16px);
  flex-shrink: 0;
}

.tg-level-card {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border: 3px solid #eef2f7;
  border-radius: 18px;
  padding: clamp(6px, 1.2vh, 12px) 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  box-shadow: 0 4px 0 #e5e7eb;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tg-level-card:hover { transform: translateY(-3px); border-color: var(--emerald); box-shadow: 0 6px 0 #d1fae5; }
.tg-level-card:active { transform: translateY(1px); }

.tg-level-num {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
}
.tg-level-card[data-level="1"] .tg-level-num { background: var(--emerald); }
.tg-level-card[data-level="2"] .tg-level-num { background: var(--yellow-dark); }
.tg-level-card[data-level="3"] .tg-level-num { background: var(--purple); }
.tg-level-card[data-level="4"] .tg-level-num { background: #38bdf8; }
.tg-level-card[data-level="5"] .tg-level-num { background: #92400e; }

.tg-level-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tg-level-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.tg-level-title { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-level-desc { font-size: 11.5px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-level-stars { font-size: 10px; color: var(--yellow-dark); letter-spacing: 1px; flex-shrink: 0; }

.tg-howto {
  background: #fff; border: 2px dashed #d1d5db; border-radius: 16px;
  padding: 10px 14px; font-size: 12px; color: #4b5563;
  flex-shrink: 0;
  /* 横幅に余裕があれば2段組みにして縦を圧縮する（220pxなら余裕を持って2列になる） */
  columns: 220px 2;
  column-gap: 18px;
}
.tg-howto div { margin-bottom: 4px; break-inside: avoid; }
.tg-howto b { color: var(--purple-dark); }

/* ---------- 4. ゲーム画面：HUD（スコア・タイマー・料理トレイ） ---------- */
.tg-hud { display: flex; align-items: center; gap: 12px; margin-bottom: clamp(6px, 1.2vh, 10px); flex-shrink: 0; }
.tg-timer-wrap { flex: 1; height: 18px; background: #e5e7eb; border-radius: 999px; overflow: hidden; border: 2px solid #fff; box-shadow: 0 2px 0 #d1d5db inset; }
.tg-timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--emerald), #34d399); transition: width .1s linear, background .3s ease; border-radius: 999px; }
.tg-timer-bar.danger { background: linear-gradient(90deg, var(--red), #f87171); }
.tg-timer-text { font-weight: 800; font-size: 13px; min-width: 34px; text-align: right; }

.tg-stats { display: flex; gap: 10px; margin-bottom: clamp(6px, 1.2vh, 10px); flex-shrink: 0; }
.tg-stat-pill {
  flex: 1; background: #fff; border-radius: 14px; padding: clamp(5px, 1vh, 8px) 10px; text-align: center;
  border: 2px solid #eef2f7; font-weight: 800; font-size: 13px;
}
.tg-stat-pill span { display: block; font-size: 10px; color: #9ca3af; font-weight: 700; margin-bottom: 2px; }
.tg-stat-pill.tg-combo { color: var(--purple-dark); }
.tg-stat-pill.tg-combo.pop { animation: tg-cardpulse .25s ease; }
.tg-stat-pill.tg-score { color: var(--emerald-dark); }
.tg-stat-pill.tg-served { color: var(--coral-dark); }

/* ---------- 5. ゲーム画面：出題カード（注文伝票ふうデザイン） ---------- */
.tg-prompt-card {
  position: relative;
  background: #fffdf7;
  border-radius: 18px 18px 0 0;
  border: 3px dashed #f3d9c4;
  border-bottom: none;
  padding: clamp(12px, 2.6vh, 22px) 16px clamp(14px, 3vh, 26px);
  text-align: center;
  box-shadow: 0 6px 0 #e9dcc9;
  margin-top: 10px;
  margin-bottom: clamp(6px, 1.6vh, 14px);
  flex-shrink: 0;
  /* 伝票の下端をギザギザに切り抜いて「ちぎれた紙」っぽく見せる。
     上側は -20px まで広げて、はみ出した「ごちゅうもん」ラベルが切れないようにする */
  clip-path: polygon(
    0 -20px, 100% -20px, 100% 90%,
    95% 100%, 90% 90%, 85% 100%, 80% 90%, 75% 100%, 70% 90%, 65% 100%,
    60% 90%, 55% 100%, 50% 90%, 45% 100%, 40% 90%, 35% 100%, 30% 90%,
    25% 100%, 20% 90%, 15% 100%, 10% 90%, 5% 100%, 0 90%
  );
}
.tg-prompt-card::before {
  content: "🎫 ごちゅうもん";
  position: absolute;
  top: -11px; left: 16px;
  background: var(--coral);
  color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--coral-dark);
}
.tg-prompt-card.success { animation: tg-cardpulse .3s ease; box-shadow: 0 0 0 6px rgba(34,197,94,.3), 0 6px 0 #e9dcc9; }
.tg-prompt-card.pass { animation: tg-cardpulse .3s ease; box-shadow: 0 0 0 6px rgba(253,224,71,.5), 0 6px 0 #e9dcc9; }

/* 伝票の「ご注文の料理」行 */
.tg-order {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: clamp(11px, 2.2vh, 13px); font-weight: 800; color: #92400e;
  margin-bottom: clamp(2px, .8vh, 6px);
}
.tg-order img { width: clamp(22px, 5vh, 32px); height: clamp(22px, 5vh, 32px); }

.tg-jp-word { font-size: clamp(18px, 4.6vh, 30px); font-weight: 800; margin-bottom: clamp(6px, 1.8vh, 14px); word-break: break-word; line-height: 1.2; }

.tg-letter-boxes { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: clamp(34px, 8vh, 52px); align-items: flex-end; }
.tg-lbox {
  width: clamp(28px, 8vw, 38px); height: clamp(34px, 8vh, 46px); border-radius: 10px; border: 3px solid #d1d5db;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(15px, 4vh, 19px); font-weight: 800; color: var(--ink); background: #f9fafb;
  transition: all .12s ease;
}
.tg-lbox.filled { background: #d1fae5; border-color: var(--emerald); color: var(--emerald-dark); animation: tg-popin .15s ease; }
.tg-lbox.hint { color: #9ca3af; border-style: dashed; animation: tg-hintfade 1.2s ease-in-out infinite; }
.tg-lbox.wrong { animation: tg-shake .35s ease; border-color: var(--red) !important; background: #fee2e2 !important; }
.tg-lbox.space-box { width: 20px; height: 46px; border: none; background: none; color: #cbd5e1; font-size: 16px; align-items: flex-end; padding-bottom: 8px; }
.tg-lbox.apos-box { color: #cbd5e1; font-weight: 800; }

.tg-points-popup {
  position: absolute; top: 6px; right: 16px; font-weight: 800; font-size: 18px;
  color: var(--emerald-dark); animation: tg-floatup .8s ease-out forwards; pointer-events: none;
}
.tg-points-popup.pass { color: var(--yellow-dark); }

/* 縦に余白が余る画面では、ゲーム画面全体を上下中央に寄せる
   （justify-content:center だと、はみ出したときに上が切れるため margin:auto を使う） */
#tg-screen-game > .tg-hud { margin-top: auto; }
#tg-screen-game > .tg-game-controls { margin-bottom: auto; }

.tg-game-controls { display: flex; justify-content: center; gap: 10px; margin-bottom: clamp(6px, 1.5vh, 14px); flex-shrink: 0; }
.tg-hidden-input { position: absolute; opacity: 0; width: 1px; height: 1px; top: -999px; left: -999px; }

/* ---------- 6. ゲーム画面：レストラン厨房ステージ ----------
   【重要】見える／見えないを CSS アニメーションの完了に頼らない。
   アニメーションは transform（位置・拡大）だけに使い、
   ブラウザが途中で止めても料理やお客さんが消えたままにならないようにする。 */
.tg-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: min(clamp(110px, 26vh, 170px), 46vw);
  /* 縦長のスマホで伸びすぎてキャラが巨大化しないよう、横幅に対する高さの上限も決める */
  max-height: min(260px, 46vw);
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #f3d9c4;
  box-shadow: 0 4px 0 #e9dcc9;
  margin-bottom: 4px;
}

/* 壁：クリーム色のタイル＋ストライプのひさし＋調理器具の棚 */
.tg-wall {
  position: absolute; inset: 0;
  background-color: #fff6e9;
  background-image:
    linear-gradient(90deg, rgba(232, 180, 140, .35) 2px, transparent 2px),
    linear-gradient(rgba(232, 180, 140, .35) 2px, transparent 2px);
  background-size: 26px 26px;
}
.tg-awning {
  position: absolute; left: 0; right: 0; top: 0; height: 13%;
  background: repeating-linear-gradient(90deg, var(--coral) 0 22px, #fff 22px 44px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .06);
}
.tg-awning::after {
  /* ひさしの下を丸いフリル状に */
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px;
  background: radial-gradient(circle at 11px 0, var(--coral) 8px, transparent 8.5px) 0 0 / 44px 8px repeat-x,
              radial-gradient(circle at 33px 0, #fff 8px, transparent 8.5px) 0 0 / 44px 8px repeat-x;
}
.tg-shelf {
  position: absolute; left: 50%; right: 3%; top: 17%; height: 28%;
  display: flex; align-items: flex-end; justify-content: space-around;
  border-bottom: 6px solid #c98a55;
  border-radius: 2px;
}
.tg-shelf img { height: 100%; width: auto; filter: drop-shadow(0 2px 0 rgba(0,0,0,.08)); }

/* お客さんの通路 */
.tg-lane { position: absolute; inset: 0; }

.tg-customer {
  position: absolute;
  bottom: 4%;                /* 足元はカウンターの下にかくし、上半身を大きく見せる */
  height: 120%;              /* コマ画像の上側は腕を上げるポーズ用の余白なので、はみ出してOK */
  aspect-ratio: 192 / 256;
  transform: translateX(-50%);
  will-change: left;
}
.tg-customer-sprite {
  position: absolute; inset: 0;
  background-repeat: no-repeat;
  background-size: 1500% 100%;       /* 15ポーズ横並びのスプライトシート */
  background-position: 0 0;
}
.tg-customer.flip .tg-customer-sprite { transform: scaleX(-1); } /* 左向きに歩くときは反転 */
.tg-customer.shake { animation: tg-cust-shake .3s ease; }

/* お客さんが持って帰る料理（受け取るまでは visibility で隠す） */
.tg-customer-dish {
  position: absolute; left: 50%; top: 44%;
  width: 46%; transform: translateX(-50%);
  visibility: hidden;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.12));
}
.tg-customer-dish.carry { visibility: visible; animation: tg-carry-pop .3s ease; }

/* 頭の上に出る吹き出し（Kenney Emotes） */
.tg-emote {
  position: absolute; left: 64%; top: 12%;
  width: 36%; aspect-ratio: 32 / 38;
  transform-origin: 10% 100%;
  visibility: hidden;
}
.tg-emote.show { visibility: visible; animation: tg-emote-pop .35s cubic-bezier(.3, 1.6, .5, 1); }

/* 手前のカウンター（木目） */
.tg-counter {
  position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.04) 0 2px, transparent 2px 60px),
    linear-gradient(#eab47e, #c9864f);
  border-top: 6px solid #f7d4a6;
  box-shadow: 0 -3px 0 rgba(0, 0, 0, .06);
}

/* まな板と材料 */
.tg-station {
  position: absolute; right: 2%; bottom: 3%;
  height: 72%; aspect-ratio: 1.2;
}
.tg-board {
  position: absolute; left: 0; right: 0; bottom: 6%;
  width: 100%; height: auto;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.12));
}
.tg-ingredients { position: absolute; left: 4%; right: 4%; top: 0; bottom: 20%; }
.tg-ing {
  position: absolute; bottom: 10%;
  width: 42%; height: auto;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.14));
  animation: tg-ing-drop .45s cubic-bezier(.3, 1.4, .5, 1) both;
}
.tg-ing.slot0 { left: -4%; }
.tg-ing.slot1 { left: 29%; bottom: 24%; }
.tg-ing.slot2 { left: 62%; }
.tg-ing.toss { animation: tg-ing-toss .45s ease-in both; }

/* 調理ゲージ */
.tg-gauge {
  position: absolute; left: 12%; right: 12%; bottom: 0; height: 11%;
  background: #fff; border: 2px solid #9a5b2e; border-radius: 999px; overflow: hidden;
}
.tg-gauge-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--yellow-dark), var(--coral));
  border-radius: 999px;
  transition: width .2s ease;
}

/* 演出レイヤー（完成品・キラキラ・コンボ表示） */
.tg-fx { position: absolute; inset: 0; pointer-events: none; }
.tg-made-dish {
  position: absolute; height: auto;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.15));
  animation: tg-made-pop .3s cubic-bezier(.3, 1.6, .5, 1);
}
.tg-fx-sparkle {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  animation: tg-fx-sparkle .55s ease-out both;
}
.tg-combo-fx {
  position: absolute; left: 50%; top: 18%;
  transform: translateX(-50%);
  font-size: clamp(16px, 4vh, 24px); font-weight: 800; color: var(--purple-dark);
  -webkit-text-stroke: 1px #fff;
  text-shadow: 0 3px 0 #fff, 0 4px 0 rgba(0,0,0,.12);
  white-space: nowrap;
  animation: tg-combo-rise .9s ease-out both;
}
.tg-combo-fx.hot { color: var(--coral-dark); }

/* ---------- 7. リザルト画面 ---------- */
/* スコアとランクバッジを横に並べて、縦の高さを節約する */
.tg-result-head {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "label  badge"
    "score  badge"
    "title  title"
    "summary summary"
    "menu   menu";
  justify-content: center; align-items: center; column-gap: 18px;
  text-align: center; margin-bottom: 4px; flex-shrink: 0;
}
.tg-result-score-label { grid-area: label; }
.tg-result-score { grid-area: score; font-size: clamp(28px, 6vh, 42px); font-weight: 800; color: var(--purple-dark); line-height: 1.1; }
.tg-result-head .tg-rank-badge { grid-area: badge; }
.tg-result-head .tg-title-display { grid-area: title; }
.tg-result-head .tg-dish-summary { grid-area: summary; }
.tg-result-head .tg-served-menu { grid-area: menu; }
.tg-result-score-label { font-size: 12px; font-weight: 700; color: #9ca3af; }
.tg-rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: clamp(48px, 10vh, 76px); height: clamp(48px, 10vh, 76px); border-radius: 50%;
  font-size: clamp(24px, 5vh, 38px); font-weight: 800; color: #fff;
  margin: clamp(4px, 1vh, 10px) auto; box-shadow: 0 5px 0 rgba(0,0,0,.15);
  animation: tg-badgepop .5s ease both;
}
.tg-rank-S { background: linear-gradient(150deg, #fbbf24, #f59e0b); }
.tg-rank-A { background: linear-gradient(150deg, #34d399, #10b981); }
.tg-rank-B { background: linear-gradient(150deg, #a78bfa, #8b5cf6); }
.tg-rank-C { background: linear-gradient(150deg, #93c5fd, #60a5fa); }
.tg-title-display { text-align: center; font-weight: 800; font-size: 16px; margin-bottom: 6px; }
.tg-dish-summary { text-align: center; font-size: 13px; font-weight: 700; color: var(--emerald-dark); margin-bottom: 2px; }
/* サーブした料理アイコンの一覧（1行に収めて、あふれた分は +N） */
.tg-served-menu {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px;
  height: clamp(28px, 6vh, 40px); overflow: hidden;
  margin-bottom: clamp(6px, 1.5vh, 12px);
}
.tg-served-menu img {
  height: 100%; width: auto;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.1));
  animation: tg-menu-pop .35s cubic-bezier(.3, 1.6, .5, 1) both;
}
.tg-served-menu span { font-size: 12px; font-weight: 800; color: var(--coral-dark); margin-left: 4px; }

/* ニガテ単語リストは、ほかのパーツを置いた残りの高さをもらって伸び縮みする。
   単語が多いときはリストの中だけがスクロールし、画面全体はスクロールしない。 */
.tg-weak-box { background: #fff; border: 3px solid #fee2e2; border-radius: 18px; padding: clamp(6px, 1.5vh, 14px) 14px; margin-bottom: clamp(6px, 1.5vh, 14px); flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tg-weak-box h3 { font-size: 13px; font-weight: 800; color: var(--red); margin-bottom: clamp(3px, 1vh, 8px); flex-shrink: 0; }
.tg-weak-list { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-height: 34px; max-height: min(220px, 30vh); overflow-y: auto; }
.tg-weak-list li { display: flex; align-items: center; gap: 8px; background: #fff7f7; border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.tg-weak-list li.perfect { justify-content: center; color: var(--emerald-dark); font-weight: 800; background: #ecfdf5; }
.ww-jp { color: #6b7280; flex: 1; }
.ww-en { font-weight: 800; }
.ww-link { font-size: 11px; color: #fff; background: var(--purple); padding: 4px 10px; border: none; border-radius: 999px; text-decoration: none; font-family: inherit; font-weight: 700; white-space: nowrap; cursor: pointer; }
.ww-link:hover { background: var(--purple-dark); }

/* ---------- SNSシェア ---------- */
.tg-share-box {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 6px 10px; flex-shrink: 0;
  background: #fff; border: 3px solid #e0e7ff; border-radius: 18px;
  padding: clamp(6px, 1.4vh, 12px) 12px; margin-bottom: clamp(6px, 1.5vh, 14px);
}
.tg-share-label { font-size: 12px; font-weight: 800; color: #4f46e5; }
.tg-share-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tg-share-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: none; border-radius: 999px; cursor: pointer;
  padding: 7px 13px; font-family: inherit; font-size: 12px; font-weight: 800; color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.18);
  transition: transform .08s ease, filter .15s ease;
}
.tg-share-btn svg { width: 14px; height: 14px; fill: currentColor; }
.tg-share-btn:hover { filter: brightness(1.08); }
.tg-share-btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0,0,0,.18); }
.tg-share-x { background: #000; }
.tg-share-threads { background: #1f2937; }
.tg-share-insta { background: linear-gradient(120deg, #f9ce34, #ee2a7b 45%, #6228d7); }
.tg-share-copy { background: var(--emerald); }
/* コピー完了などのお知らせ（文字が無いときは場所を取らない） */
.tg-share-note { width: 100%; text-align: center; font-size: 11px; font-weight: 700; color: var(--emerald-dark); }
.tg-share-note:empty { display: none; }
/* クリップボードが使えなかったとき用の、手でコピーするための欄 */
.tg-share-fallback {
  width: 100%; height: 72px; resize: none; font-family: inherit; font-size: 11px;
  border: 2px solid #e0e7ff; border-radius: 10px; padding: 6px 8px; color: var(--ink);
}

/* おすすめ記事は横並びにして、高さを取りすぎないようにする
   （画面が狭いときは折り返して縦積みになる） */
.tg-article-box {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: 18px; padding: clamp(6px, 1.4vh, 12px) 12px; margin-bottom: clamp(6px, 1.5vh, 14px);
  text-align: center; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 12px;
}
.tg-article-box p { font-size: 11px; color: #92400e; font-weight: 700; white-space: nowrap; }
.tg-article-label { font-size: 13px; font-weight: 800; color: #78350f; flex: 1 1 160px; min-width: 0; }
.tg-article-box a.tg-btn { display: inline-block; text-decoration: none; padding: 8px 16px; font-size: 13px; white-space: nowrap; }

.tg-result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; flex-shrink: 0; }

/* ---------- 単語のミニ解説ポップアップ ---------- */
/* 画面全体をうすく暗くして、まん中にカードを出す */
.tg-explain {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; background: rgba(60, 30, 20, .45);
}
.tg-explain[hidden] { display: none; }
/* 左にイラスト、右に解説（低い画面でも縦に収まるよう横並び） */
.tg-explain-card {
  position: relative; width: min(460px, 100%); max-height: 100%; overflow-y: auto;
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: 4px clamp(10px, 3vw, 18px);
  background: #fffdf8; border: 4px solid #fde68a; border-radius: 22px;
  padding: clamp(12px, 3vh, 20px) clamp(12px, 3vw, 20px) clamp(8px, 1.6vh, 12px);
  box-shadow: 0 8px 0 rgba(0,0,0,.12);
  animation: tg-explain-pop .25s cubic-bezier(.3, 1.5, .5, 1);
}
.tg-explain-img {
  width: clamp(64px, 22vh, 120px); height: clamp(64px, 22vh, 120px);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(48px, 16vh, 90px); line-height: 1;
  background: radial-gradient(circle, #fff7ed 55%, #ffedd5 100%); border-radius: 50%;
}
.tg-explain-img img { width: 76%; height: 76%; animation: tg-bob 2.4s ease-in-out infinite; }
.tg-explain-body { min-width: 0; padding-right: 18px; }
.tg-explain-word { font-size: clamp(20px, 5vh, 28px); font-weight: 800; color: var(--purple-dark); line-height: 1.15; overflow-wrap: anywhere; }
.tg-explain-jp { font-size: 13px; font-weight: 700; color: #9a6b4f; margin-bottom: 6px; }
.tg-explain-desc { font-size: clamp(13px, 3vh, 15px); font-weight: 700; color: var(--ink); line-height: 1.5; }
.tg-explain-ex {
  margin-top: 6px; padding: 5px 9px; border-radius: 10px;
  background: #ecfdf5; color: #065f46; font-size: 12px; font-weight: 700; line-height: 1.45;
}
.tg-explain-close {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  border: none; border-radius: 50%; cursor: pointer;
  background: #fee2e2; color: var(--red); font-size: 15px; font-weight: 800; font-family: inherit;
}
.tg-explain-close:hover { background: #fecaca; }
.tg-explain-credit { grid-column: 1 / -1; text-align: right; font-size: 9px; color: #b8a597; margin-top: 4px; }

/* 4:3のiframeをスマホで開いたときなど、画面の高さがとても低いときの詰め表示。
   見出しの文字を省いてボタンだけにし、リザルトが縦に収まるようにする。 */
@media (max-height: 430px) {
  .tg-share-label, .tg-article-box p { display: none; }
  .tg-share-box, .tg-article-box { padding: 5px 8px; margin-bottom: 5px; gap: 4px 8px; }
  /* ボタン名はかくして、アイコンだけの丸ボタンにして1行に収める */
  .tg-share-btn { padding: 6px 10px; font-size: 11px; }
  .tg-share-btn span { display: none; }
  .tg-share-btn svg { width: 16px; height: 16px; }
  .tg-share-note { font-size: 10px; }
  .tg-article-label { font-size: 12px; flex-basis: 140px; }
  .tg-article-box a.tg-btn, .tg-result-actions .tg-btn { padding: 7px 12px; font-size: 12px; }
  .tg-rank-badge { width: 44px; height: 44px; font-size: 22px; margin: 2px auto; }
  .tg-result-score { font-size: 28px; }
  .tg-served-menu { height: 24px; margin-bottom: 4px; }
  /* つぶれて読めなくならないよう、リストの高さは最低限確保する */
  .tg-weak-box { padding: 5px 10px; margin-bottom: 5px; min-height: 46px; }
}

/* ---------- 8. アニメーション定義 ---------- */
@keyframes tg-fadein { from { opacity:0; transform: translateY(8px);} to {opacity:1; transform: translateY(0);} }
@keyframes tg-popin { from { opacity:0; transform: scale(.75);} to {opacity:1; transform: scale(1);} }
@keyframes tg-bob { 0%,100%{transform: translateY(0);} 50%{transform: translateY(-6px);} }
@keyframes tg-shake { 10%,90%{transform:translateX(-5px);} 20%,80%{transform:translateX(7px);} 30%,50%,70%{transform:translateX(-9px);} 40%,60%{transform:translateX(9px);} }
@keyframes tg-floatup { 0%{transform:translateY(0) scale(1); opacity:1;} 100%{transform:translateY(-55px) scale(1.15); opacity:0;} }
@keyframes tg-cardpulse { 0%{transform:scale(1);} 45%{transform:scale(1.025);} 100%{transform:scale(1);} }
@keyframes tg-badgepop { 0%{transform:scale(0) rotate(-15deg); opacity:0;} 60%{transform:scale(1.15) rotate(6deg); opacity:1;} 100%{transform:scale(1) rotate(0);} }
/* ポップアップ用：透明度は変えず大きさだけ（アニメが止まっても必ず見える） */
@keyframes tg-explain-pop { from { transform: scale(.8); } to { transform: scale(1); } }
@keyframes tg-hintfade { 0%,100%{opacity:.15;} 50%{opacity:.55;} }

/* 材料が上から降ってきて、まな板の上でぽよんと弾む */
@keyframes tg-ing-drop {
  0%   { transform: translateY(-170%) scale(.7) rotate(-20deg); }
  60%  { transform: translateY(8%) scale(1.08, .9) rotate(4deg); }
  100% { transform: translateY(0) scale(1) rotate(0); }
}
/* パスしたとき、材料がくるくる飛んでいく */
@keyframes tg-ing-toss {
  to { transform: translate(60%, 160%) rotate(160deg) scale(.6); }
}
/* 材料が完成品に変身したときのポン */
@keyframes tg-made-pop {
  0%   { transform: scale(.3) rotate(-10deg); }
  70%  { transform: scale(1.18) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
/* 吹き出しがぴょこっと出る */
@keyframes tg-emote-pop {
  0%   { transform: scale(.3) translateY(20%); }
  100% { transform: scale(1) translateY(0); }
}
/* 受け取った料理が手元でポン */
@keyframes tg-carry-pop {
  0%   { transform: translateX(-50%) scale(.5); }
  100% { transform: translateX(-50%) scale(1); }
}
/* ミスタイプのとき、お客さんがびくっとする（translateX(-50%) を保ったまま揺らす） */
@keyframes tg-cust-shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 5px)); }
  75% { transform: translateX(calc(-50% + 5px)); }
}
/* キラキラが飛び散る */
@keyframes tg-fx-sparkle {
  0%   { transform: translate(0, 0) scale(.2); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}
/* コンボ表示がふわっと浮かんで消える */
@keyframes tg-combo-rise {
  0%   { transform: translateX(-50%) scale(.5); opacity: 1; }
  25%  { transform: translateX(-50%) scale(1.15); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-24px) scale(1); opacity: 0; }
}
/* リザルトの料理アイコンが順番にポンと並ぶ */
@keyframes tg-menu-pop {
  0%   { transform: scale(.3) translateY(10px); }
  100% { transform: scale(1) translateY(0); }
}

/* ---------- 9. レスポンシブ ----------
   幅・高さのほとんどは各パーツの clamp() で自動調整しているため、
   ここでは clamp() だけではカバーしにくい細部だけを調整する。 */
@media (max-width: 380px) {
  .tg-mode-btn { font-size: 11px; padding: 6px 4px; }
  .tg-level-desc { display: none; } /* 幅が極端に狭い時は説明文を隠して1行に収める */
}
