/* =========================================================
   保育クイズチャレンジ（ひとりで挑戦）― 森のようちえんテーマ
   ========================================================= */
:root {
  --ink: #4a3220;          /* こげ茶（文字） */
  --muted: #8a6a4c;
  --leaf: #6cbf3a;
  --leaf-d: #3d8a22;
  --moss: #a9d86e;
  --sky: #45aee6;
  --sun: #ffc93c;
  --orange: #ff9a3d;
  --berry: #e8615a;
  --wood: #c98f55;
  --wood-d: #8b5a2b;
  --wood-dd: #6a4020;
  --cream: #fffaf0;
  --paper: rgba(255, 251, 240, 0.94);
  --line: #ecd3ac;
  --radius: 24px;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --num: "Outfit", var(--font);

  /* キャラクターの大きさ（左右の余白はここから計算） */
  --kid-h: min(46vh, 26vw);
  --kid-x: 1.2vw;
  --kid-bottom: 1.5vh;
  --hud-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: #cfe8b0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }

/* ---------- 背景（森） ---------- */
.bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background: url("../assets/forest.jpg") center bottom / cover no-repeat, #cfe8b0;
}
.bg__veil {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 55% 55% at 50% 45%, rgba(255, 252, 235, 0.35), transparent 75%);
  transition: background-color .6s;
}
body.is-gloom .bg__veil { background-color: rgba(70, 80, 120, 0.28); }

/* 舞い落ちる葉っぱ */
.leaves { position: absolute; inset: 0; pointer-events: none; }
.leaves i {
  position: absolute; top: -40px; width: 22px; height: 14px;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg, var(--moss), var(--leaf-d));
  opacity: .85;
  animation: leafFall linear infinite;
}
.leaves i:nth-child(1) { left: 6%;  animation-duration: 14s; animation-delay: -2s; }
.leaves i:nth-child(2) { left: 18%; animation-duration: 18s; animation-delay: -9s; background: linear-gradient(135deg, #ffd27a, #e08a2c); }
.leaves i:nth-child(3) { left: 34%; animation-duration: 16s; animation-delay: -5s; transform: scale(.8); }
.leaves i:nth-child(4) { left: 52%; animation-duration: 20s; animation-delay: -13s; }
.leaves i:nth-child(5) { left: 67%; animation-duration: 15s; animation-delay: -7s; background: linear-gradient(135deg, #ffb38a, #d9603b); }
.leaves i:nth-child(6) { left: 80%; animation-duration: 19s; animation-delay: -1s; }
.leaves i:nth-child(7) { left: 92%; animation-duration: 17s; animation-delay: -11s; background: linear-gradient(135deg, #ffd27a, #e08a2c); }
@keyframes leafFall {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(40px, 25vh) rotate(120deg); }
  50% { transform: translate(-30px, 50vh) rotate(220deg); }
  75% { transform: translate(35px, 75vh) rotate(320deg); }
  100% { transform: translate(-10px, 110vh) rotate(420deg); }
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 40; pointer-events: none; }

/* ---------- 画面 ---------- */
#app {
  position: relative; z-index: 3;
  min-height: 100dvh;
  padding: 24px calc(var(--kid-h) * 0.677 + var(--kid-x) + 1.5vw);
  display: grid;
}
body[data-screen="screen-quiz"] #app { padding-top: calc(var(--hud-h) + 22px); }
.screen { display: none; min-height: 0; }
.screen.is-active { display: flex; flex-direction: column; justify-content: flex-start; animation: screenIn .5s cubic-bezier(.2, .8, .2, 1) both; }
/* 中央寄せは margin:auto で行う（画面に収まらない時に上側が HUD の下へ隠れないように） */
.screen.is-active > * { margin-top: auto; margin-bottom: auto; }
@keyframes screenIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* 共通：クリーム色のカード（木の縁どり） */
.card {
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 0 #d9b98a, 0 18px 40px rgba(60, 90, 30, .25);
}

/* ---------- ボタン ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 54px; padding: 0 30px;
  border: 0; border-radius: 999px;
  font-weight: 900; font-size: 18px; letter-spacing: .04em;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn:active { transform: translateY(3px) scale(.98); }
.btn:focus-visible, .icon-btn:focus-visible, .choice:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
.btn--primary {
  color: #fff;
  text-shadow: 0 2px 0 rgba(40, 90, 10, .45);
  background: linear-gradient(180deg, #9be05a, var(--leaf) 50%, #4fa52a);
  box-shadow: 0 6px 0 var(--leaf-d), 0 14px 26px rgba(61, 138, 34, .4), inset 0 2px 0 rgba(255, 255, 255, .55);
}
.btn--primary:hover { filter: brightness(1.06); transform: translateY(-2px); }
.btn--primary:active { box-shadow: 0 2px 0 var(--leaf-d), 0 6px 14px rgba(61, 138, 34, .35); }
.btn--ghost {
  color: var(--wood-dd);
  background: var(--cream);
  border: 3px solid var(--line);
  box-shadow: 0 5px 0 #d9b98a;
}
.btn--ghost:hover { transform: translateY(-2px); background: #fff; }
.btn--xl { min-height: 80px; padding: 0 70px; font-size: clamp(26px, 2.5vw, 36px); }
.btn--xl::after {
  content: ""; position: absolute; inset: -7px; border-radius: inherit;
  border: 4px solid rgba(108, 191, 58, .6);
  animation: ringPulse 1.8s ease-out infinite;
}
@keyframes ringPulse { from { opacity: .9; transform: scale(.96); } to { opacity: 0; transform: scale(1.14); } }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .18);
  font-size: 18px; display: grid; place-items: center; color: #fff;
  transition: background .2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .32); }

/* =========================================================
   タイトル
   ========================================================= */
.title { text-align: center; max-width: 840px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2vh, 22px); }
.title__eyebrow {
  margin: 0; padding: 6px 20px; border-radius: 999px;
  background: rgba(255, 255, 255, .85); border: 2px solid var(--moss);
  color: var(--leaf-d); font-weight: 800; font-size: clamp(13px, 1.1vw, 16px); letter-spacing: .08em;
}
/* 木の看板 */
.title__h1 {
  position: relative; margin: 30px 0 4px; padding: clamp(16px, 2vw, 26px) clamp(28px, 3.4vw, 56px) clamp(14px, 1.8vw, 22px);
  line-height: 1.15; display: flex; flex-direction: column; gap: 6px;
  border-radius: 26px;
  background:
    repeating-linear-gradient(180deg, transparent 0 34px, rgba(90, 50, 20, .14) 34px 37px),
    linear-gradient(180deg, #e2aa6c, var(--wood) 55%, #b77b42);
  border: 5px solid var(--wood-d);
  box-shadow: 0 10px 0 var(--wood-dd), 0 24px 40px rgba(70, 40, 10, .35), inset 0 3px 0 rgba(255, 255, 255, .35);
  animation: signIn .9s cubic-bezier(.2, 1.5, .4, 1) both;
}
.title__h1::before, .title__h1::after { /* 看板を吊るすロープ */
  content: ""; position: absolute; top: -34px; width: 6px; height: 34px; border-radius: 3px;
  background: repeating-linear-gradient(180deg, #c9a46a 0 5px, #9a7444 5px 8px);
}
.title__h1::before { left: 18%; } .title__h1::after { right: 18%; }
@keyframes signIn { 0% { opacity: 0; transform: translateY(-60px) rotate(-6deg); } 60% { opacity: 1; transform: translateY(6px) rotate(2deg); } 80% { transform: rotate(-1deg); } 100% { transform: none; } }
.title__main {
  font-size: clamp(28px, 4.4vw, 76px); font-weight: 900; letter-spacing: .02em; color: #fffaf0; white-space: nowrap;
  text-shadow: 0 4px 0 var(--wood-dd), 0 0 2px var(--wood-dd);
}
.title__main em { font-style: normal; color: #fff3a6; }
.title__sub { font-size: clamp(18px, 1.8vw, 27px); font-weight: 800; color: #fff3dc; text-shadow: 0 2px 0 var(--wood-dd); }
.title__sub i {
  font-style: normal; display: inline-block; padding: 2px 14px; border-radius: 999px;
  color: #fff; text-shadow: 0 2px 0 var(--leaf-d);
  background: linear-gradient(180deg, #9be05a, var(--leaf));
  border: 2px solid #fff; transform: rotate(-3deg);
}

.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.rule {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px 16px;
  animation: popIn .6s cubic-bezier(.2, 1.3, .4, 1) both;
}
.rule:nth-child(1) { animation-delay: .25s; } .rule:nth-child(2) { animation-delay: .33s; } .rule:nth-child(3) { animation-delay: .41s; } .rule:nth-child(4) { animation-delay: .49s; }
@keyframes popIn { from { opacity: 0; transform: scale(.8) translateY(14px); } to { opacity: 1; transform: none; } }
.rule__icon { font-size: 28px; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; background: #eef8de; flex: none; }
.rule p { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.rule b { font-size: clamp(16px, 1.3vw, 20px); font-weight: 900; }
.rule small { color: var(--muted); font-size: 13px; font-weight: 700; }
.rule--hot { border-color: #ffc98a; background: linear-gradient(135deg, #fff1dc, var(--paper)); }
.rule--hot .rule__icon { background: #ffe7c7; }

.speed-demo {
  width: 100%; padding: 8px 18px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px;
  animation: popIn .6s .55s cubic-bezier(.2, 1.3, .4, 1) both;
}
.speed-demo__row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-weight: 700; font-size: 14px; color: var(--muted); border-bottom: 2px dotted var(--line); }
.speed-demo__row b { color: var(--ink); font-family: var(--num); font-size: 16px; }
.speed-demo__row--hot b { color: #e0731c; }

.title__best { margin: 0; padding: 4px 18px; border-radius: 999px; background: rgba(255, 255, 255, .8); color: var(--muted); font-weight: 800; }
.title__best b { color: #e0731c; font-family: var(--num); font-size: 22px; }

/* =========================================================
   ステージ紹介
   ========================================================= */
.stage-intro { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: clamp(20px, 3vw, 36px); width: min(820px, 100%); margin: 0 auto; }
.stage-intro__label { margin: 0; font-family: var(--num); font-weight: 900; letter-spacing: .5em; color: var(--leaf-d); font-size: clamp(18px, 2vw, 26px); }
.stage-intro__num {
  margin: -14px 0 -6px; font-family: var(--num); font-weight: 900; line-height: 1;
  font-size: clamp(110px, 14vw, 200px); color: var(--leaf);
  text-shadow: 0 8px 0 var(--leaf-d), 0 18px 30px rgba(61, 138, 34, .35);
  animation: stagePop .8s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes stagePop { from { transform: scale(.2) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
.stage-intro__title { margin: 0; font-size: clamp(28px, 3vw, 42px); font-weight: 900; }
.stage-intro__title small { font-size: .6em; color: var(--muted); margin-left: .4em; }
.stage-intro__desc { margin: 0; color: var(--muted); font-weight: 700; font-size: 18px; }
.stage-intro__desc b { color: #e0731c; }
.stage-intro__choices { list-style: none; margin: 8px 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.stage-intro__choices li {
  padding: 12px 16px; border-radius: 14px; font-weight: 800; text-align: left;
  background: #fff; border: 2px solid var(--line); border-left: 8px solid var(--c);
  animation: popIn .5s cubic-bezier(.2, 1.2, .4, 1) both;
}
.stage-intro__choices li span { font-family: var(--num); color: var(--c); margin-right: 10px; font-weight: 900; }
.stage-intro__bar { width: min(420px, 80%); height: 8px; border-radius: 99px; background: #efe2c8; overflow: hidden; }
.stage-intro__bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--moss), var(--leaf)); }

/* =========================================================
   HUD（木の板）
   ========================================================= */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: var(--hud-h);
  display: none; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 20px; color: #fff;
  background:
    repeating-linear-gradient(180deg, transparent 0 20px, rgba(80, 45, 15, .12) 20px 22px),
    linear-gradient(180deg, #d79c5f, #b47843);
  border-bottom: 4px solid var(--wood-d);
  box-shadow: 0 6px 18px rgba(70, 40, 10, .3);
}
body[data-screen="screen-quiz"] .hud { display: flex; }
.hud__progress { display: flex; align-items: center; gap: 16px; min-width: 0; }
.hud__qno { font-family: var(--num); font-weight: 900; font-size: 26px; white-space: nowrap; text-shadow: 0 2px 0 var(--wood-dd); }
.hud__qno small { font-size: 15px; opacity: .85; }
.hud__dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 5px; flex-wrap: wrap; }
.hud__dots li { width: 15px; height: 15px; border-radius: 50%; background: rgba(90, 50, 20, .35); box-shadow: inset 0 2px 2px rgba(0, 0, 0, .2); transition: background .3s, transform .3s; }
.hud__dots li.is-stage2 { margin-left: 8px; }
.hud__dots li.is-now { background: #fff6dc; box-shadow: 0 0 0 3px var(--sun); transform: scale(1.15); }
.hud__dots li.is-ok { background: radial-gradient(circle at 35% 35%, #c8f58e, var(--leaf)); box-shadow: 0 0 0 2px #fff; }
.hud__dots li.is-ng { background: radial-gradient(circle at 35% 35%, #ffb0a8, var(--berry)); box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.hud__right { display: flex; align-items: center; gap: 12px; }
.hud__streak {
  display: flex; align-items: baseline; gap: 4px; padding: 6px 14px; border-radius: 999px;
  background: rgba(90, 50, 20, .3);
  font-weight: 800; font-size: 13px;
  opacity: .7; transition: all .3s;
}
.hud__streak b { font-family: var(--num); font-size: 22px; }
.hud__flame::before { content: "🔥"; font-size: 18px; filter: grayscale(1); }
.hud__streak.is-hot { opacity: 1; background: linear-gradient(135deg, #ff6a3d, var(--orange)); box-shadow: 0 0 0 3px #fff3, 0 0 18px rgba(255, 120, 60, .6); }
.hud__streak.is-hot .hud__flame::before { filter: none; display: inline-block; animation: flame .5s ease-in-out infinite alternate; }
.hud__streak.is-bump { animation: bump .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes flame { from { transform: scale(1) rotate(-6deg); } to { transform: scale(1.2) rotate(6deg); } }
.hud__score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; padding: 6px 14px; border-radius: 14px; background: var(--cream); color: var(--ink); box-shadow: inset 0 2px 4px rgba(90, 50, 20, .25); }
.hud__score small { font-family: var(--num); font-size: 10px; letter-spacing: .2em; color: var(--muted); }
.hud__score b { font-family: var(--num); font-size: 26px; font-weight: 900; color: #e0731c; min-width: 4ch; text-align: right; }
.hud__score b.is-bump { animation: bump .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes bump { 40% { transform: scale(1.35); } }

/* =========================================================
   出題
   ========================================================= */
.quiz {
  width: 100%; max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(220px, 17vw, 280px);
  gap: clamp(14px, 1.6vw, 26px); align-items: stretch;
}
.quiz__main { display: flex; flex-direction: column; gap: clamp(12px, 1.6vh, 20px); min-width: 0; }

.q-card {
  position: relative; padding: clamp(18px, 2.2vw, 30px) clamp(20px, 2.4vw, 34px);
  min-height: clamp(150px, 24vh, 250px);
  display: flex; flex-direction: column;
}
.q-card::before { /* はっぱのワンポイント */
  content: ""; position: absolute; top: -14px; right: 26px; width: 44px; height: 28px;
  border-radius: 0 100% 0 100%; background: linear-gradient(135deg, var(--moss), var(--leaf-d));
  transform: rotate(-12deg); box-shadow: 0 3px 0 rgba(40, 90, 10, .3);
}
.q-card.is-in { animation: qIn .55s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes qIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } to { opacity: 1; transform: none; } }
.q-card__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.q-badge { font-family: var(--num); font-weight: 900; font-size: 22px; padding: 2px 14px; border-radius: 12px; color: #fff; background: linear-gradient(180deg, #9be05a, var(--leaf)); box-shadow: 0 3px 0 var(--leaf-d); text-shadow: 0 1px 0 var(--leaf-d); }
.q-stage { font-weight: 800; font-size: 14px; padding: 4px 12px; border-radius: 999px; background: #f3e6cc; color: var(--wood-d); }
.q-ask { font-weight: 800; font-size: 15px; color: #e0731c; }
.q-text { margin: auto 0; font-size: clamp(20px, 2vw, 32px); font-weight: 800; line-height: 1.6; letter-spacing: .02em; text-wrap: pretty; }

.choices { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(10px, 1.2vw, 16px); }
.choice {
  --c: var(--sky);
  position: relative; width: 100%; height: 100%;
  min-height: clamp(70px, 10vh, 104px);
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px 18px 12px 12px; border-radius: 20px;
  background: #fffdf6;
  border: 3px solid color-mix(in srgb, var(--c) 70%, #fff);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 75%, #5a3a1a), 0 12px 22px rgba(60, 90, 30, .2);
  font-weight: 800; font-size: clamp(16px, 1.45vw, 23px); line-height: 1.35; color: var(--ink);
  transition: transform .15s, box-shadow .15s, background .2s, opacity .3s, border-color .2s;
  animation: choiceIn .45s cubic-bezier(.2, 1.3, .4, 1) both;
}
.choices li:nth-child(1) .choice { animation-delay: .05s; }
.choices li:nth-child(2) .choice { animation-delay: .1s; }
.choices li:nth-child(3) .choice { animation-delay: .15s; }
.choices li:nth-child(4) .choice { animation-delay: .2s; }
@keyframes choiceIn { from { opacity: 0; transform: translateY(14px) scale(.95); } to { opacity: 1; transform: none; } }
.choice__key {
  flex: none; width: clamp(42px, 3.4vw, 56px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--num); font-weight: 900; font-size: clamp(20px, 1.8vw, 28px);
  color: #fff; background: var(--c); text-shadow: 0 2px 0 rgba(0, 0, 0, .18);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15), inset 0 3px 0 rgba(255, 255, 255, .45);
}
.choice__mark { margin-left: auto; font-size: 32px; font-weight: 900; opacity: 0; transform: scale(.3); transition: all .35s cubic-bezier(.2, 1.8, .4, 1); }
.choice:not(:disabled):hover { transform: translateY(-3px); background: color-mix(in srgb, var(--c) 14%, #fff); }
.choice:not(:disabled):active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 75%, #5a3a1a); }
.choice:disabled { cursor: default; }
.choice.is-dim { opacity: .45; filter: saturate(.4); }
.choice.is-picked { transform: translateY(2px); }
.choice.is-correct {
  border-color: var(--leaf); opacity: 1; filter: none;
  background: linear-gradient(180deg, #f1fbe4, #dcf3c2);
  box-shadow: 0 6px 0 var(--leaf-d), 0 0 0 5px rgba(108, 191, 58, .3), 0 0 30px rgba(108, 191, 58, .5);
  animation: correctGlow 1s ease-in-out 2;
}
.choice.is-correct .choice__mark { opacity: 1; transform: none; color: var(--leaf-d); }
.choice.is-correct .choice__mark::before { content: "◯"; }
.choice.is-wrong {
  border-color: var(--berry);
  background: linear-gradient(180deg, #fff0ee, #ffdcd8);
  box-shadow: 0 6px 0 #b8423c;
  animation: shake .5s;
}
.choice.is-wrong .choice__mark { opacity: 1; transform: none; color: var(--berry); }
.choice.is-wrong .choice__mark::before { content: "✕"; }
@keyframes correctGlow { 50% { box-shadow: 0 6px 0 var(--leaf-d), 0 0 0 10px rgba(108, 191, 58, .18), 0 0 46px rgba(108, 191, 58, .7); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- タイマー ---------- */
.quiz__side { position: relative; display: flex; flex-direction: column; }
.timer, .judge {
  padding: 20px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  flex: 1;
}
.timer__ringwrap { position: relative; width: clamp(140px, 13vw, 200px); aspect-ratio: 1; }
.timer__ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer__track { fill: #fff; stroke: #efe2c8; stroke-width: 16; }
.timer__bar { fill: none; stroke: url(#ringGrad); stroke-width: 16; stroke-linecap: round; stroke-dasharray: 552.92; stroke-dashoffset: 0; }
.timer__num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--num); font-weight: 900; font-size: clamp(56px, 5.2vw, 84px); padding-bottom: 14px; color: var(--ink); }
.timer__unit { position: absolute; left: 0; right: 0; bottom: 24%; text-align: center; font-weight: 800; font-size: 14px; color: var(--muted); }
.timer.is-warn .timer__bar { stroke: var(--berry); }
.timer.is-warn .timer__num { color: var(--berry); animation: warnPulse 1s ease-in-out infinite; }
@keyframes warnPulse { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } }

.levels { width: 100%; }
.levels__bar { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; height: 16px; }
.levels__bar i { border-radius: 4px; background: #efe2c8; transition: background .25s; }
.levels__bar i.on { background: var(--lc); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); }

.preview { text-align: center; line-height: 1.1; }
.preview__label { margin: 0 0 4px; font-size: 13px; font-weight: 800; color: var(--muted); }
.preview__pts { margin: 0; font-weight: 800; font-size: 18px; }
.preview__pts b { font-family: var(--num); font-size: clamp(40px, 3.6vw, 56px); font-weight: 900; color: #e0731c; }
.preview__mult { margin: 6px 0 0; display: inline-block; padding: 4px 14px; border-radius: 999px; font-family: var(--num); font-weight: 900; font-size: 18px; background: #f3e6cc; color: var(--wood-d); }
.preview__mult.is-hot { color: #fff; background: linear-gradient(135deg, #ff6a3d, var(--orange)); box-shadow: 0 4px 0 #c24e1c; }

/* ---------- 判定カード ---------- */
.judge { display: none; justify-content: center; text-align: center; }
.quiz__side.is-judging .timer { display: none; }
.quiz__side.is-judging .judge { display: flex; animation: judgeIn .5s .25s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes judgeIn { from { opacity: 0; transform: translateX(30px) scale(.95); } to { opacity: 1; transform: none; } }
.judge--ok { border-color: var(--moss); background: linear-gradient(180deg, #f2fbe6, var(--paper) 50%); }
.judge--ng { border-color: #c9d0ec; background: linear-gradient(180deg, #eef0fb, var(--paper) 50%); }
.judge__title { margin: 0; font-size: clamp(30px, 2.8vw, 42px); font-weight: 900; }
.judge--ok .judge__title { color: var(--leaf-d); }
.judge--ng .judge__title { color: #6a74b0; }
.judge__rows { margin: 0; width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; font-size: 14px; font-weight: 700; }
.judge__rows dt { color: var(--muted); text-align: left; }
.judge__rows dd { margin: 0; text-align: right; font-weight: 900; }
.judge__rows dd b { font-family: var(--num); font-size: 18px; }
.judge__rows dd.hot { color: #e0731c; }
.judge__rows .full { grid-column: 1 / -1; text-align: center; padding: 8px 10px; border-radius: 12px; background: #e6f6d4; color: var(--leaf-d); font-size: 16px; }
.judge__gain { margin: 0; font-family: var(--num); font-weight: 900; font-size: clamp(44px, 4vw, 64px); line-height: 1; color: #e0731c; text-shadow: 0 3px 0 #ffe0b8; }
.judge__gain small { font-family: var(--font); font-size: .4em; margin-left: 2px; }
.judge--ng .judge__gain { color: #a59a8c; text-shadow: none; }
.judge .btn { width: 100%; }
.judge__hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- 正解！／ざんねん… の大文字演出 ---------- */
.splash { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; pointer-events: none; }
.splash span { opacity: 0; font-weight: 900; font-size: clamp(80px, 12vw, 190px); letter-spacing: .04em; white-space: nowrap; }
.splash.is-ok span {
  color: #fff4a0;
  -webkit-text-stroke: clamp(4px, .5vw, 8px) #e0731c; paint-order: stroke fill;
  filter: drop-shadow(0 8px 0 #8b3e10) drop-shadow(0 0 30px rgba(255, 220, 120, .9));
  animation: splashOk 1.25s cubic-bezier(.2, 1.6, .4, 1) both;
}
.splash.is-ng span {
  color: #dfe5ff;
  -webkit-text-stroke: clamp(4px, .5vw, 8px) #5b66a8; paint-order: stroke fill;
  filter: drop-shadow(0 6px 0 #2e3570);
  animation: splashNg 1.35s ease both;
}
@keyframes splashOk {
  0% { opacity: 0; transform: scale(.2) rotate(-10deg); }
  30% { opacity: 1; transform: scale(1.12) rotate(2deg); }
  45% { transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.3); }
}
@keyframes splashNg {
  0% { opacity: 0; transform: translateY(-60px); }
  25% { opacity: 1; transform: translateY(0); }
  35% { transform: translateY(-8px); }
  45% { transform: translateY(0) rotate(-2deg); }
  80% { opacity: 1; transform: translateY(10px) rotate(-3deg); }
  100% { opacity: 0; transform: translateY(60px) rotate(-4deg); }
}

/* =========================================================
   キャラクター
   ========================================================= */
.cast { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.kid { position: absolute; bottom: var(--kid-bottom); margin: 0; height: var(--kid-h); width: calc(var(--kid-h) * 0.677); transition: height .6s cubic-bezier(.2, .8, .2, 1), width .6s cubic-bezier(.2, .8, .2, 1), left .6s, right .6s, bottom .6s; }
.kid--boy { left: var(--kid-x); }
.kid--girl { right: var(--kid-x); }
.kid__body { position: relative; z-index: 1; width: 100%; height: 100%; transform-origin: 50% 100%; transition: filter .5s; }
.kid__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom center; opacity: 0; transition: opacity .12s; user-select: none; -webkit-user-drag: none; }
.kid[data-pose="normal"] .kid__img--normal,
.kid[data-pose="banzai"] .kid__img--banzai,
.kid[data-pose="sad"] .kid__img--sad { opacity: 1; }
.kid__shadow { position: absolute; left: 20%; right: 20%; bottom: -1.5%; height: 5%; border-radius: 50%; background: radial-gradient(closest-side, rgba(40, 70, 20, .45), transparent); z-index: 0; transition: transform .3s; }

/* 通常：ゆらゆら */
.kid[data-pose="normal"] .kid__body { animation: idle 3.2s ease-in-out infinite; }
.kid--girl[data-pose="normal"] .kid__body { animation-delay: -1.6s; }
@keyframes idle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-1.6%) rotate(.8deg); } }

/* ばんざい：ぴょんぴょん＋おひさまの光 */
.kid[data-pose="banzai"] .kid__body { animation: jump .6s cubic-bezier(.3, .7, .4, 1) 4 both; }
.kid--girl[data-pose="banzai"] .kid__body { animation-delay: .12s; }
.kid[data-pose="banzai"] .kid__shadow { animation: shadowJump .6s cubic-bezier(.3, .7, .4, 1) 4 both; }
.kid--girl[data-pose="banzai"] .kid__shadow { animation-delay: .12s; }
@keyframes jump {
  0% { transform: translateY(0) scale(1.05, .95); }
  35% { transform: translateY(-10%) scale(.98, 1.03); }
  60% { transform: translateY(-10%) scale(1); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes shadowJump { 35%, 60% { transform: scale(.7); opacity: .5; } }
.kid::before {
  content: ""; position: absolute; left: -30%; right: -30%; top: 0; bottom: 8%; z-index: 0;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 236, 140, .55) 0 10deg, transparent 10deg 30deg),
    radial-gradient(closest-side, rgba(255, 240, 160, .9), rgba(255, 210, 90, .3) 60%, transparent);
  -webkit-mask: radial-gradient(closest-side, #000 40%, transparent);
          mask: radial-gradient(closest-side, #000 40%, transparent);
  opacity: 0; transform: scale(.5); transition: opacity .4s, transform .6s cubic-bezier(.2, 1.4, .4, 1);
}
.kid[data-pose="banzai"]::before { opacity: 1; transform: scale(1); animation: sunSpin 8s linear infinite; }
@keyframes sunSpin { to { transform: scale(1) rotate(360deg); } }

/* しょんぼり：沈み込み＋どよーん線 */
.kid[data-pose="sad"] .kid__body { animation: droop 1.1s cubic-bezier(.3, .6, .3, 1) both; filter: saturate(.7) brightness(.9); }
.kid--girl[data-pose="sad"] .kid__body { animation-name: droopR; }
@keyframes droop { 0% { transform: none; } 25% { transform: translateY(3%) scale(1.03, .95); } 100% { transform: translateY(3%) scale(.98, .96) rotate(-2deg); } }
@keyframes droopR { 0% { transform: none; } 25% { transform: translateY(3%) scale(1.03, .95); } 100% { transform: translateY(3%) scale(.98, .96) rotate(2deg); } }
.kid__gloom {
  position: absolute; z-index: 2; left: 22%; right: 22%; top: -2%; height: 34%;
  background: repeating-linear-gradient(90deg, transparent 0 9%, rgba(80, 95, 180, .7) 9% 12%, transparent 12% 20%);
  -webkit-mask: linear-gradient(to bottom, #000 10%, transparent);
          mask: linear-gradient(to bottom, #000 10%, transparent);
  opacity: 0; transform: translateY(-20%);
  transition: opacity .5s .3s, transform .8s .3s;
}
.kid[data-pose="sad"] .kid__gloom { opacity: 1; transform: none; }

/* 画面ごとのキャラクター配置 */
body[data-screen="screen-title"] { --kid-h: min(62vh, 29vw); --kid-x: 3vw; --kid-bottom: 3vh; }
body[data-screen="screen-quiz"] { --kid-h: min(40vh, 20vw); }
body[data-screen="screen-title"] #app,
body[data-screen="screen-stage"] #app { padding-inline: calc(var(--kid-h) * 0.677 + var(--kid-x)); }

/* =========================================================
   最終発表
   ========================================================= */
.final { width: min(820px, 100%); margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.final__title { margin: 0; font-size: clamp(34px, 4.2vw, 64px); font-weight: 900; }
.final__title span {
  display: inline-block; padding: 8px 40px; border-radius: 22px; color: #fffaf0;
  text-shadow: 0 4px 0 var(--wood-dd);
  background:
    repeating-linear-gradient(180deg, transparent 0 26px, rgba(90, 50, 20, .14) 26px 29px),
    linear-gradient(180deg, #e2aa6c, var(--wood) 55%, #b77b42);
  border: 5px solid var(--wood-d);
  box-shadow: 0 8px 0 var(--wood-dd), 0 20px 40px rgba(70, 40, 10, .35);
  animation: signIn .9s cubic-bezier(.2, 1.5, .4, 1) both;
}
.final__drum { padding: 10px 30px; border-radius: 999px; background: var(--paper); font-size: clamp(24px, 2.4vw, 34px); font-weight: 900; color: var(--wood-d); letter-spacing: .1em; animation: drum .12s linear infinite; }
@keyframes drum { 50% { transform: translateX(2px) translateY(-1px); } }
.final__body { display: none; width: 100%; flex-direction: column; align-items: center; gap: 14px; padding: clamp(18px, 2.4vw, 30px); }
.final.is-reveal .final__drum { display: none; }
.final.is-reveal .final__body { display: flex; animation: popIn .6s cubic-bezier(.2, 1.3, .4, 1) both; }
.final__label { margin: 0; color: var(--muted); font-weight: 800; font-size: 18px; }
.final__score { margin: -8px 0 -4px; line-height: 1; }
.final__score b {
  font-family: var(--num); font-weight: 900; font-size: clamp(84px, 9.5vw, 150px);
  color: #ff9d2e; -webkit-text-stroke: 6px #fff; paint-order: stroke fill;
  filter: drop-shadow(0 6px 0 #c2621a) drop-shadow(0 10px 20px rgba(194, 98, 26, .3));
}
.final__score small { font-size: clamp(26px, 2.6vw, 40px); font-weight: 900; margin-left: 6px; }
.final__rank {
  margin: 0; padding: 8px 28px; border-radius: 999px; font-size: clamp(20px, 2.1vw, 30px); font-weight: 900;
  color: #fff; text-shadow: 0 2px 0 var(--leaf-d);
  background: linear-gradient(180deg, #9be05a, var(--leaf)); box-shadow: 0 5px 0 var(--leaf-d);
  opacity: 0; transform: scale(.4);
}
.final.is-ranked .final__rank { animation: stagePop .7s cubic-bezier(.2, 1.8, .4, 1) both; }
.final__best { margin: 0; font-weight: 800; color: var(--muted); min-height: 1.4em; }
.final__best.is-new { color: #e0731c; animation: bump .6s cubic-bezier(.2, 1.8, .4, 1) 2; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; }
.stat { padding: 12px 10px; border-radius: 18px; background: #fff; border: 2px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.stat small { color: var(--muted); font-weight: 800; font-size: 13px; }
.stat b { font-family: var(--num); font-size: 36px; font-weight: 900; line-height: 1.1; color: var(--leaf-d); }
.stat span { font-size: 12px; color: var(--muted); font-weight: 700; }
.final.is-reveal .stats, .final.is-reveal .review, .final.is-reveal .final__actions { animation: screenIn .6s 1.9s both; }

.review { width: 100%; text-align: left; border-radius: 18px; background: #fff; border: 2px solid var(--line); }
.review summary { cursor: pointer; padding: 14px 18px; font-weight: 900; list-style: none; display: flex; justify-content: space-between; }
.review summary::-webkit-details-marker { display: none; }
.review summary::after { content: "▼"; font-size: 12px; color: var(--muted); transition: transform .2s; }
.review[open] summary::after { transform: rotate(180deg); }
.review__list { list-style: none; margin: 0; padding: 0 12px 12px; max-height: 38vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.review__list li { display: grid; grid-template-columns: 3.2em 1.6em minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: #faf4e6; font-size: 14px; }
.review__list .no { font-family: var(--num); font-weight: 900; color: var(--muted); }
.review__list .mk { font-weight: 900; text-align: center; }
.review__list li.ok .mk { color: var(--leaf-d); }
.review__list li.ng .mk { color: var(--berry); }
.review__list .tx { min-width: 0; }
.review__list .tx p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.review__list .tx small { color: var(--muted); font-weight: 700; }
.review__list .pt { font-family: var(--num); font-weight: 900; color: #e0731c; text-align: right; white-space: nowrap; }
.review__list li.ng .pt { color: var(--muted); }
.final__actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }

/* =========================================================
   カウントダウン
   ========================================================= */
.countdown { position: fixed; inset: 0; z-index: 35; display: none; place-items: center; background: rgba(255, 250, 230, .35); backdrop-filter: blur(3px); }
.countdown.is-on { display: grid; }
.countdown b {
  font-family: var(--num); font-weight: 900; font-size: clamp(140px, 22vw, 320px);
  color: var(--leaf); -webkit-text-stroke: 10px #fff; paint-order: stroke fill;
  filter: drop-shadow(0 10px 0 var(--leaf-d)) drop-shadow(0 20px 30px rgba(40, 90, 10, .35));
}
.countdown b.pop { animation: cdPop .9s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes cdPop { 0% { transform: scale(2.2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }

/* =========================================================
   レスポンシブ
   ========================================================= */
@media (max-width: 1100px) {
  :root { --kid-h: min(30vh, 22vw); }
  .quiz { grid-template-columns: minmax(0, 1fr); }
  .timer { flex-direction: row; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; }
  .timer__ringwrap { width: 110px; }
  .timer__num { font-size: 44px; padding-bottom: 10px; }
  .timer__unit { bottom: 20%; font-size: 11px; }
  .levels { order: 3; flex-basis: 100%; }
  .preview { flex: 1; }
  .judge { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .judge__rows { flex: 1 1 260px; }
  .judge .btn { flex-basis: 100%; }
}
@media (max-width: 900px) {
  :root { --kid-h: 22vh; --kid-x: 0px; --kid-bottom: 0px; --hud-h: 58px; }
  body[data-screen="screen-title"] { --kid-h: 24vh; --kid-x: 2vw; --kid-bottom: 0px; }
  body[data-screen="screen-quiz"] { --kid-h: 20vh; }
  #app, body[data-screen="screen-title"] #app, body[data-screen="screen-stage"] #app { padding: 18px 14px calc(var(--kid-h) + 12px); }
  body[data-screen="screen-title"] #app { padding-top: 46px; }
  body[data-screen="screen-quiz"] #app { padding-top: calc(var(--hud-h) + 14px); }
  .hud { padding: 0 10px; gap: 8px; }
  .hud__dots { display: none; }
  .hud__qno { font-size: 20px; }
  .hud__score b { font-size: 20px; }
  .hud__streak span:last-child { display: none; }
  .rules, .speed-demo, .stage-intro__choices { grid-template-columns: minmax(0, 1fr); }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .choice { min-height: 60px; }
  .stats { gap: 8px; }
  .stat b { font-size: 26px; }
  .btn--xl { padding: 0 40px; }
}

/* =========================================================
   スマホ横向き（高さが低い画面）専用レイアウト
   ・幅ではなく「横向き かつ 高さ520px以下」で判定するので、
     タブレット／PCには影響しません
   ・上の幅ベースの指定（〜900px / 〜1100px）より後ろに置いて上書きします
   ========================================================= */
@media (orientation: landscape) and (max-height: 520px) {
  :root {
    /* iPhone の切り欠き（ノッチ）側の余白。左右どちら向きでも同じだけ空ける */
    --safe-x: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    --kid-h: min(44vh, 15vw);
    --kid-x: calc(var(--safe-x) + 4px);
    --kid-bottom: 0px;
    --hud-h: 46px;
    --radius: 16px;
  }
  body[data-screen="screen-title"] { --kid-h: min(56vh, 17vw); --kid-x: calc(var(--safe-x) + 8px); --kid-bottom: 0px; }
  body[data-screen="screen-quiz"] { --kid-h: min(38vh, 13vw); }

  /* キャラクターは左右に置き、中央にコンテンツ */
  #app,
  body[data-screen="screen-title"] #app,
  body[data-screen="screen-stage"] #app {
    padding: 10px calc(var(--kid-h) * 0.677 + var(--kid-x) + 8px) calc(10px + env(safe-area-inset-bottom, 0px));
  }
  body[data-screen="screen-quiz"] #app { padding-top: calc(var(--hud-h) + 8px); }

  .card { border-width: 2px; box-shadow: 0 4px 0 #d9b98a, 0 10px 22px rgba(60, 90, 30, .22); }
  .btn { min-height: 42px; padding: 0 22px; font-size: 15px; }
  .btn--xl { min-height: 52px; padding: 0 40px; font-size: 22px; }
  .btn--xl::after { inset: -5px; border-width: 3px; }

  /* ---------- HUD ---------- */
  .hud {
    gap: 10px; border-bottom-width: 3px;
    padding: 0 calc(env(safe-area-inset-right, 0px) + 10px) 0 calc(env(safe-area-inset-left, 0px) + 10px);
  }
  .hud__progress { gap: 10px; }
  .hud__qno { font-size: 18px; }
  .hud__qno small { font-size: 12px; }
  .hud__dots { display: flex; flex-wrap: nowrap; gap: 3px; }
  .hud__dots li { width: 10px; height: 10px; }
  .hud__dots li.is-stage2 { margin-left: 5px; }
  .hud__right { gap: 8px; }
  .hud__streak { padding: 3px 10px; }
  .hud__streak b { font-size: 17px; }
  .hud__flame::before { font-size: 14px; }
  .hud__score { padding: 3px 10px; border-radius: 10px; }
  .hud__score small { font-size: 8px; }
  .hud__score b { font-size: 18px; }
  .icon-btn { width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }

  /* ---------- 出題：左に問題＋選択肢(2×2)、右に細いタイマー ---------- */
  .quiz { grid-template-columns: minmax(0, 1fr) clamp(130px, 19vw, 180px); gap: 10px; }
  .quiz__main { gap: 8px; }
  .q-card { padding: 10px 14px; min-height: 0; flex: 1; }
  .q-card::before { top: -9px; right: 18px; width: 30px; height: 19px; }
  .q-card__head { gap: 6px; margin-bottom: 4px; }
  .q-badge { font-size: 15px; padding: 1px 10px; border-radius: 8px; box-shadow: 0 2px 0 var(--leaf-d); }
  .q-stage { font-size: 11px; padding: 2px 8px; }
  .q-ask { font-size: 11px; }
  .q-text { font-size: clamp(14px, 2vw, 18px); line-height: 1.5; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .choice {
    min-height: 50px; padding: 6px 10px 6px 6px; gap: 8px; border-radius: 14px; border-width: 2px;
    font-size: clamp(12px, 1.7vw, 15px); line-height: 1.3;
  }
  .choice__key { width: 30px; font-size: 16px; }
  .choice__mark { font-size: 20px; }

  .timer, .judge { flex-direction: column; flex-wrap: nowrap; justify-content: center; padding: 10px; gap: 6px; }
  .timer__ringwrap { width: clamp(64px, 20vh, 92px); }
  .timer__num { font-size: clamp(26px, 8vh, 36px); padding-bottom: 6px; }
  .timer__unit { bottom: 16%; font-size: 9px; }
  .levels { order: 0; flex-basis: auto; }
  .levels__bar { height: 9px; gap: 2px; }
  .levels__bar i { border-radius: 2px; }
  .preview { flex: none; }
  .preview__label { margin-bottom: 2px; font-size: 10px; }
  .preview__pts { font-size: 13px; }
  .preview__pts b { font-size: clamp(24px, 4vw, 32px); }
  .preview__mult { margin-top: 4px; padding: 2px 10px; font-size: 12px; }

  .judge__title { font-size: clamp(18px, 3vw, 24px); }
  .judge__rows { flex: none; gap: 3px 6px; font-size: 11px; }
  .judge__rows dd b { font-size: 14px; }
  .judge__rows .full { padding: 4px 6px; border-radius: 8px; font-size: 12px; }
  /* 不正解時の「倍率リセット」は HUD の連チャン表示で分かるので省略 */
  .judge--ng .judge__rows dt, .judge--ng .judge__rows dd:not(.full) { display: none; }
  .judge__gain { font-size: clamp(26px, 4vw, 34px); }
  .judge .btn { flex-basis: auto; min-height: 40px; padding: 0 6px; font-size: clamp(12px, 1.8vw, 14px); white-space: nowrap; }
  .judge__hint { display: none; }

  .splash span { font-size: min(12vw, 30vh); }
  .splash.is-ok span, .splash.is-ng span { -webkit-text-stroke-width: 4px; }
  .countdown b { font-size: min(22vw, 62vh); -webkit-text-stroke: 7px #fff; }

  /* ---------- タイトル：左に看板＋スタート、右にルール ---------- */
  .title {
    max-width: none; display: grid; grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "eye rules" "h1 rules" "btn demo" "best demo";
    column-gap: clamp(12px, 2.5vw, 28px); row-gap: 8px; align-items: center; justify-items: center;
  }
  .title__eyebrow { grid-area: eye; align-self: end; padding: 3px 12px; font-size: 11px; }
  .title__h1 {
    grid-area: h1; align-self: start; margin: 22px 0 6px; padding: 10px 20px 9px; gap: 4px;
    border-width: 4px; border-radius: 18px;
    box-shadow: 0 6px 0 var(--wood-dd), 0 14px 26px rgba(70, 40, 10, .3), inset 0 2px 0 rgba(255, 255, 255, .35);
  }
  .title__h1::before, .title__h1::after { top: -24px; width: 5px; height: 24px; }
  .title__main { font-size: clamp(20px, 3.4vw, 32px); text-shadow: 0 3px 0 var(--wood-dd), 0 0 2px var(--wood-dd); }
  .title__sub { font-size: clamp(12px, 1.7vw, 16px); }
  .title__sub i { padding: 1px 10px; }
  .rules { grid-area: rules; align-self: end; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .rule { padding: 5px 10px; gap: 8px; border-radius: 12px; }
  .rule__icon { width: 30px; height: 30px; border-radius: 9px; font-size: 17px; }
  .rule p { gap: 0; }
  .rule b { font-size: 13px; }
  .rule small { font-size: 10.5px; }
  .speed-demo { grid-area: demo; align-self: start; grid-template-columns: minmax(0, 1fr); padding: 4px 12px; border-radius: 12px; }
  .speed-demo__row { flex-wrap: wrap; padding: 3px 0; font-size: 11px; border-bottom-width: 1px; }
  .speed-demo__row:last-child { border-bottom: 0; }
  .speed-demo__row b { font-size: 12px; }
  #btn-start { grid-area: btn; }
  .title__best { grid-area: best; align-self: start; padding: 2px 12px; font-size: 12px; }
  .title__best b { font-size: 16px; }

  /* ---------- ステージ紹介 ---------- */
  .stage-intro { width: min(640px, 100%); gap: 6px; padding: 12px 18px; }
  .stage-intro__label { font-size: 13px; letter-spacing: .4em; }
  .stage-intro__num { margin: -6px 0 -2px; font-size: clamp(48px, 15vh, 72px); text-shadow: 0 5px 0 var(--leaf-d), 0 10px 18px rgba(61, 138, 34, .3); }
  .stage-intro__title { font-size: clamp(18px, 3vw, 24px); }
  .stage-intro__desc { font-size: 13px; }
  .stage-intro__choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 2px 0; }
  .stage-intro__choices li { padding: 6px 10px; border-radius: 10px; border-left-width: 6px; font-size: 12.5px; }

  /* ---------- 最終発表：左に得点、右に成績・ふりかえり・ボタン ---------- */
  .final { width: min(760px, 100%); gap: 8px; }
  .final__title { font-size: clamp(22px, 3.6vw, 30px); }
  .final__title span { padding: 3px 24px; border-width: 4px; border-radius: 16px; box-shadow: 0 5px 0 var(--wood-dd), 0 12px 24px rgba(70, 40, 10, .3); }
  .final__drum { padding: 6px 22px; font-size: 20px; }
  .final.is-reveal .final__body {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas: "label stats" "score stats" "score review" "rank review" "best actions";
    gap: 4px 16px; padding: 10px 16px; align-items: center; justify-items: center;
  }
  .final__label { grid-area: label; align-self: end; font-size: 13px; }
  .final__score { grid-area: score; margin: 0; }
  .final__score b { font-size: clamp(44px, 8vw, 60px); -webkit-text-stroke: 4px #fff; }
  .final__score small { font-size: 18px; }
  .final__rank { grid-area: rank; padding: 4px 14px; font-size: clamp(12px, 1.7vw, 15px); box-shadow: 0 3px 0 var(--leaf-d); }
  .final__best { grid-area: best; min-height: 0; font-size: 12px; }
  .final__actions { grid-area: actions; flex-wrap: nowrap; gap: 8px; margin-top: 0; }
  .final__actions .btn { padding: 0 16px; white-space: nowrap; }
  .stats { grid-area: stats; align-self: end; gap: 6px; }
  .stat { padding: 5px 6px; border-radius: 12px; }
  .stat small { font-size: 10.5px; }
  .stat b { font-size: 22px; }
  .stat span { font-size: 10px; }
  .review { grid-area: review; align-self: start; border-radius: 12px; }
  .review summary { padding: 7px 12px; font-size: 13px; }
  .review__list { max-height: 34vh; padding: 0 8px 8px; gap: 4px; }
  .review__list li { grid-template-columns: 2.6em 1.2em minmax(0, 1fr) auto; gap: 6px; padding: 5px 8px; font-size: 11.5px; }
  /* ふりかえりを開いたら成績ボックスを畳んで、1画面に収める */
  .final__body:has(.review[open]) .stats { display: none; }
  .final__body:has(.review[open]) { grid-template-areas: "label review" "score review" "score review" "rank review" "best actions"; }
}
/* 幅が狭い横向き（iPhone SE など）：出題カードの見出しを1行に */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 760px) {
  .q-stage { display: none; }
}
/* さらに高さが低い時（ブラウザのツールバー表示中や小型機種）：タイトルを詰める */
@media (orientation: landscape) and (max-height: 360px) {
  .title { row-gap: 6px; }
  .rules { gap: 5px; }
  .rule { padding: 3px 8px; }
  .rule__icon { width: 24px; height: 24px; font-size: 14px; border-radius: 7px; }
  .rule small { display: none; }
  .speed-demo__row { padding: 2px 0; }
  .btn--xl { min-height: 46px; }
}
/* 対応ブラウザでは「アドレスバーを除いた実際の高さ」(svh) で計算する */
@supports (height: 1svh) {
  @media (orientation: landscape) and (max-height: 520px) {
    :root { --kid-h: min(44svh, 15vw); }
    body[data-screen="screen-title"] { --kid-h: min(56svh, 17vw); }
    body[data-screen="screen-quiz"] { --kid-h: min(38svh, 13vw); }
    .timer__ringwrap { width: clamp(64px, 20svh, 92px); }
    .timer__num { font-size: clamp(26px, 8svh, 36px); }
    .review__list { max-height: 34svh; }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .leaves { display: none; }
}
