/* サンタクロースは悩ましい style.css — 構造とクラス名は docs/design.md を参照 */

:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-cream: #fff1d6;
  --c-line: #eadcc0;
  --c-red: #e8413b;
  --c-red-deep: #b8302c;
  --c-green: #3fa66a;
  --c-green-deep: #2a7a4b;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-sky: #4f9be0;
  --c-sky-deep: #2f6fb8;
  --c-sky-pale: #bfe3ff;
  --c-wall: #3a2f63;
  --c-wall-deep: #251d45;
  --c-night-deep: #0b1438;
  --c-gift: #ff6fa3;
  --c-yes: #3fa66a;
  --c-no: #e8413b;

  --font-base: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "SF Pro Rounded",
    ui-rounded, system-ui, sans-serif;

  --radius-s: 12px;
  --radius-m: 18px;
  --radius-l: 28px;
  --btn-depth: 6px;
  --play-w: min(100vw, 480px);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --dur-fast: 0.15s;
  --dur-mid: 0.35s;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* プレイ画面の寸法（人数 --n は .screen--play に JS から style="--n:5"） */
  --kid-size: 58px;
  --card-w: 64px;
  --card-h: 104px;
  --cell: 36px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-base);
  color: var(--c-ink);
  background: var(--c-wall-deep);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
canvas.sprite { display: block; pointer-events: none; }
.num { font-family: var(--font-num); font-weight: 900; font-variant-numeric: tabular-nums; }

.app {
  position: relative;
  width: var(--play-w);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--c-wall);
}
@media (min-width: 520px) {
  .app { border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink); }
}

/* ---------- 画面切替 ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(12px);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
  overflow-y: auto;
}
.screen.is-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s;
}
.screen__bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.screen > :not(.screen__bg):not(.sheet):not(.modal) { position: relative; z-index: 1; }

/* ---------- ボタン（押すと沈む） ---------- */
.btn {
  --btn-bg: var(--c-red);
  --btn-edge: var(--c-red-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 28px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 20px; font-weight: 800; letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 var(--btn-depth) 0 var(--btn-edge), 0 var(--btn-depth) 0 3px var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter var(--dur-fast);
}
.btn::after {
  content: ""; position: absolute; top: 5px; left: 18%; right: 18%; height: 6px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.35); pointer-events: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active, .btn.is-pressed {
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn:disabled { filter: grayscale(0.8) opacity(0.6); cursor: not-allowed; transform: none; }
.btn--block { display: flex; width: 100%; }
.btn--green { --btn-bg: var(--c-green); --btn-edge: var(--c-green-deep); }
.btn--sky { --btn-bg: var(--c-sky); --btn-edge: var(--c-sky-deep); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--ghost { --btn-bg: var(--c-paper); --btn-edge: var(--c-line); --btn-fg: var(--c-ink); }
.btn--small { min-height: 40px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }
.btn__sub { display: block; font-size: 12px; font-weight: 700; opacity: 0.9; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
  font-size: 20px; font-weight: 900; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
.icon-btn--small { width: 36px; height: 36px; font-size: 16px; box-shadow: 0 3px 0 var(--c-ink); }
.icon-btn[aria-pressed="true"] { background: #d8d0c4; }
.btn:focus-visible, .icon-btn:focus-visible, .kid:focus-visible, .pcard:focus-visible,
.memo__cell:focus-visible, .qbtn:focus-visible, .stage-btn:focus-visible {
  outline: 4px solid var(--c-gold); outline-offset: 3px;
}

/* ---------- パネル（モーダル・結果の白い板） ---------- */
.panel {
  width: min(100%, 360px);
  padding: 20px 18px 22px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-l);
  background: var(--c-paper);
  box-shadow: 0 8px 0 var(--c-ink);
  text-align: center;
}
.panel__title { margin: 0 0 12px; font-size: 22px; font-weight: 900; }
.panel__actions { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.panel__row { display: flex; gap: 10px; justify-content: center; }

.modal {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(11, 20, 56, 0.66);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
}
.modal.is-open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--dur-mid) ease, visibility 0s; }
.modal.is-open .panel { animation: pop-in var(--dur-mid) var(--ease-pop) both; }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- タイトル ---------- */
.screen--title { align-items: center; justify-content: space-between; text-align: center; }
.title__top { display: flex; width: 100%; justify-content: flex-end; gap: 8px; }
.logo { margin: 4px 0 0; line-height: 1.05; }
.logo__sub {
  display: inline-block; margin-bottom: 8px; padding: 2px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-gold);
  font-size: 14px; font-weight: 900;
}
.logo__main { display: block; }
.logo__row { display: block; }
.logo__char {
  display: inline-block;
  font-size: 46px; font-weight: 900;
  color: var(--c-paper);
  -webkit-text-stroke: 8px var(--c-ink); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--c-ink);
  animation: rise 2.4s ease-in-out calc(var(--i, 0) * 0.08s) infinite;
}
.logo__char--red { color: var(--c-red); }
.logo__char--gold { color: var(--c-gold); }
.logo__char--small { font-size: 30px; }
@keyframes rise { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(-6px) rotate(-4deg); } }
.title__scene { position: relative; width: 300px; height: 220px; }
.title__santa { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); }
.title__kid { position: absolute; bottom: 8px; }
.title__kid:nth-of-type(2) { left: 0; }
.title__kid:nth-of-type(3) { right: 0; }
.title__actions { display: grid; gap: 12px; width: min(100%, 320px); }
.title__stars { margin: 0; color: var(--c-paper); font-size: 14px; font-weight: 800; }

/* ---------- ステージ選択 ---------- */
.screen--stages { gap: 14px; }
.stages__head { display: flex; align-items: center; gap: 10px; }
.stages__title {
  margin: 0; flex: 1; text-align: center;
  color: var(--c-paper); font-size: 24px; font-weight: 900;
  -webkit-text-stroke: 6px var(--c-ink); paint-order: stroke fill;
}
.stage-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.stage-btn {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-paper); text-align: left;
  box-shadow: 0 6px 0 var(--c-ink);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.stage-btn:active { transform: translateY(6px); box-shadow: 0 0 0 var(--c-ink); }
.stage-btn__no {
  display: grid; place-items: center; width: 56px; height: 56px;
  border: 3px solid var(--c-ink); border-radius: 50%; background: var(--c-red); color: #fff;
  font-size: 26px;
}
.stage-btn__name { display: block; font-size: 18px; font-weight: 900; }
.stage-btn__desc { display: block; color: var(--c-ink-sub); font-size: 12px; font-weight: 700; }
.stage-btn__kids { display: flex; margin-top: 4px; }
.stage-btn__kids .sprite { margin-right: -8px; }
.stage-btn.is-locked { background: #d8d0c4; cursor: not-allowed; box-shadow: 0 6px 0 var(--c-ink); transform: none; }
.stage-btn.is-locked .stage-btn__no { background: #a99f90; }
.stage-btn.is-locked .stage-btn__no::before { content: "🔒"; font-size: 22px; }
.stage-btn.is-locked .stage-btn__no > * { display: none; }

.stars { display: inline-flex; gap: 2px; }
.star { position: relative; display: inline-block; width: 24px; height: 24px; }
.star::before, .star::after {
  content: ""; position: absolute;
  clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 61%, 80% 100%, 50% 78%, 20% 100%, 30% 61%, 0 38%, 38% 35%);
}
.star::before { inset: 0; background: var(--c-ink); }
.star::after { inset: 18%; background: #d8d0c4; }
.star.is-on::after { background: var(--c-gold); }
.stars--big .star { width: 52px; height: 52px; }
.stars--big .star.is-on { animation: star-pop 0.5s var(--ease-pop) calc(var(--i, 0) * 0.25s + 0.2s) both; }
@keyframes star-pop { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }

/* ---------- ルール ---------- */
.rules { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; text-align: left; }
.rules__item {
  display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 12px;
  padding: 8px 10px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: #fff;
}
.rules__pic {
  display: grid; place-items: center; width: 64px; height: 64px;
  border: 2px solid var(--c-ink); border-radius: var(--radius-s); background: var(--c-cream);
}
.rules__text { margin: 0; font-size: 14px; font-weight: 700; }
.rules__text b { color: var(--c-red); }
.rules__stage { margin: 12px 0 0; padding: 8px 12px; border: 3px dashed var(--c-ink); border-radius: var(--radius-m); background: #fff6d8; font-size: 13px; font-weight: 800; text-align: left; }

/* ---------- プレイ ---------- */
.screen--play {
  padding: calc(8px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
  gap: 8px; overflow: hidden;
}
.hud { display: flex; align-items: center; gap: 8px; }
.hud__stage {
  padding: 4px 12px;
  border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-paper);
  font-size: 14px; font-weight: 900;
}
.hud__spacer { flex: 1; }
/* 残り質問数: 吹き出し型のカウンタ */
.qcount {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 8px;
  border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-gold);
  font-size: 13px; font-weight: 900;
}
.qcount__icon {
  display: grid; place-items: center; width: 24px; height: 24px;
  border: 2px solid var(--c-ink); border-radius: 50%; background: var(--c-paper); font-size: 14px;
}
.qcount__num { font-size: 22px; line-height: 1; }
.qcount.is-low { background: #ffb3a8; animation: wiggle 0.5s ease 2; }
.qcount.is-zero { background: #d8d0c4; }
.qcount.is-tick .qcount__num { animation: tick 0.35s var(--ease-pop); }
@keyframes tick { from { transform: scale(1.6); } to { transform: none; } }
@keyframes wiggle { 0%, 100% { transform: none; } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

.play__hint { margin: 0; color: var(--c-paper); font-size: 13px; font-weight: 800; text-align: center; text-shadow: 0 2px 0 var(--c-ink); }

/* 子どもの列。吹き出しは顔の上にかぶせる */
.kids {
  display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 4px;
  padding-top: 34px;
}
.kid {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 0 4px; border: 0; background: none; cursor: pointer;
}
.kid__face {
  display: grid; place-items: center;
  width: calc(var(--kid-size) + 8px); height: calc(var(--kid-size) + 8px);
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-cream); overflow: hidden;
  box-shadow: 0 4px 0 var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background var(--dur-fast);
}
.kid:active .kid__face { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
.kid.is-selected .kid__face { background: var(--c-gold); transform: translateY(-4px); box-shadow: 0 8px 0 var(--c-ink); }
.kid__name {
  margin-top: 6px; padding: 0 8px;
  border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-paper);
  font-size: 12px; font-weight: 900; white-space: nowrap;
}
/* くばるときの受け皿（割り当てたカードのミニ表示） */
.kid__slot {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-top: 4px;
  border: 3px dashed rgba(255, 253, 247, 0.6); border-radius: var(--radius-s);
}
.kid__slot.is-filled { border: 3px solid var(--c-ink); background: var(--c-paper); animation: pop-in 0.25s var(--ease-pop); }
.kid.is-drop .kid__slot { border-color: var(--c-gold); background: rgba(255, 200, 61, 0.25); }

/* 吹き出し */
.bubble {
  position: absolute; left: 50%; bottom: calc(100% - 4px); z-index: 3;
  min-width: 46px; padding: 3px 8px;
  border: 3px solid var(--c-ink); border-radius: 14px; background: var(--c-paper);
  font-size: 14px; font-weight: 900; line-height: 1.2; text-align: center; white-space: nowrap;
  transform: translateX(-50%);
  animation: bubble-in 0.3s var(--ease-pop) both;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  width: 10px; height: 10px; margin: -6px 0 0 -6px;
  background: inherit; border: solid var(--c-ink); border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.bubble--yes { background: #c9f2d3; color: var(--c-green-deep); }
.bubble--no { background: #ffd6d2; color: var(--c-red-deep); }
.bubble--think { background: var(--c-paper); color: var(--c-ink-sub); }
.bubble--wide { max-width: 140px; white-space: normal; font-size: 12px; }
.kids > .kid:first-child .bubble--wide { left: 0; transform: none; }
.kids > .kid:last-child .bubble--wide { left: auto; right: 0; transform: none; }
.bubble.is-out { animation: bubble-out 0.2s ease both; }
@keyframes bubble-in { from { transform: translateX(-50%) scale(0.3); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes bubble-out { to { opacity: 0; } }

/* メモ表（行=子ども、列=プレゼント） */
.memo {
  padding: 6px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-paper);
  box-shadow: 0 5px 0 var(--c-ink);
}
.memo__bar { display: flex; align-items: center; gap: 8px; margin: 0 2px 4px; font-size: 12px; font-weight: 900; }
.memo__bar .hud__spacer { flex: 1; }
.memo__auto { color: var(--c-green-deep); }
.memo__table { width: 100%; font-size: 0; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.memo__corner { width: 40px; }
.memo__head, .memo__kid { padding: 0; }
.memo__head .sprite, .memo__kid .sprite { margin: 0 auto; }
.memo__head { height: 34px; }
.memo__cell {
  display: grid; place-items: center;
  width: 100%; height: var(--cell); padding: 0;
  border: 2px solid var(--c-line); border-radius: 10px; background: #fff;
  font-family: var(--font-num); font-size: 22px; font-weight: 900; line-height: 1;
  cursor: pointer;
}
.memo__cell:active { transform: scale(0.92); }
.memo__cell[data-mark="o"]::before { content: "○"; }
.memo__cell[data-mark="x"]::before { content: "×"; }
.memo__cell[data-mark="o"] { background: #fff6d8; border-color: var(--c-gold); }
.memo__cell[data-mark="x"] { background: #f3eee4; }
/* オートメモ（赤ペン・手動で消せない） */
.memo__cell.is-auto { color: var(--c-red); border-style: dashed; cursor: default; }
.memo__cell.is-auto[data-mark="x"] { background: #fff0ee; border-color: #f3b8b2; }
.memo__cell.is-auto[data-mark="o"] { background: #fff0ee; border-color: var(--c-red); }
.memo__cell.is-new { animation: pop-in 0.3s var(--ease-pop); }
.memo tr.is-hl .memo__cell, .memo .memo__cell.is-hl { box-shadow: 0 0 0 2px var(--c-gold); }

/* プレゼントカード */
.hand { display: grid; grid-template-columns: repeat(var(--m, var(--n, 5)), 1fr); gap: 6px; justify-items: center; perspective: 700px; }
.pcard {
  position: relative;
  width: 100%; max-width: 76px; height: var(--card-h); padding: 0;
  border: 0; background: none; cursor: pointer;
  --deal-x: 0px;
}
.pcard__inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease-pop);
}
.pcard__front, .pcard__back {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  border: 3px solid var(--c-ink); border-radius: var(--radius-s);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 4px 0 var(--c-ink);
}
.pcard__front { padding: 14px 2px 3px; background: var(--pc-bg, var(--c-paper)); }
/* 色は背景で見せる: style="--pc-bg:#fbd9d7;--pc:#e8413b"（Sprites.mix(色,'#fff',0.78) が目安） */
.pcard__badge { position: absolute; width: 16px; height: 16px; }
.pcard__badge--kind { top: 2px; left: 2px; }
.pcard__badge--size { top: 2px; right: 2px; }
.pcard__badge--sound { top: 2px; left: 50%; margin-left: -8px; }
.pcard__color {
  margin-top: 1px; padding: 0 5px;
  border: 2px solid var(--c-ink); border-radius: 999px; background: var(--pc, #fff); color: #fff;
  font-size: 9px; font-weight: 900; line-height: 1.3;
  text-shadow: 0 0 2px var(--c-ink);
}
.pcard__back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, var(--c-gold) 0 9px, transparent 10px),
    repeating-linear-gradient(45deg, var(--c-red) 0 8px, var(--c-red-deep) 8px 16px);
}
.pcard__icon { flex: 1; display: grid; place-items: center; }
.pcard__name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.2em; font-size: 9px; font-weight: 900; line-height: 1.1; text-align: center; letter-spacing: -0.03em;
}
.pcard__attrs { display: flex; gap: 1px; margin-top: 2px; }
.pcard__attrs .sprite { width: 16px; height: 16px; }
.pcard:active .pcard__inner { transform: translateY(3px); }
.pcard.is-selected .pcard__inner { transform: translateY(-10px); }
.pcard.is-selected .pcard__front { background: #fff6d8; box-shadow: 0 0 0 3px var(--c-gold), 0 8px 0 var(--c-ink); }
.pcard.is-used { opacity: 0.35; filter: grayscale(0.6); pointer-events: none; }
.pcard.is-hl .pcard__front { box-shadow: 0 0 0 3px var(--c-gold), 0 4px 0 var(--c-ink); }
/* 裏向き → .is-flipped を外すと表に */
.pcard.is-down .pcard__inner { transform: rotateY(180deg); }
/* 配る: 山（中央下）から各位置へ。--i で順番、--deal-x は JS で中央からのずれ（省略可） */
.pcard.is-deal { animation: deal 0.5s var(--ease-pop) calc(var(--i, 0) * 0.08s) both; }
@keyframes deal {
  from { transform: translate(var(--deal-x), 140px) rotate(-20deg) scale(0.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}
/* めくる: .is-down を付けた状態から .is-flip を付ける */
.pcard.is-flip .pcard__inner { animation: flip 0.6s var(--ease-pop) calc(var(--i, 0) * 0.35s) both; }
@keyframes flip { from { transform: rotateY(180deg); } 50% { transform: rotateY(90deg) scale(1.12); } to { transform: rotateY(0deg); } }
/* 子どもへ飛ぶ（くばる）: JS で --fly-x/--fly-y を入れて .is-fly */
.pcard.is-fly { animation: fly 0.45s ease-in both; }
@keyframes fly { to { transform: translate(var(--fly-x, 0), var(--fly-y, -200px)) scale(0.5) rotate(12deg); opacity: 0; } }

.play__actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: auto; }

/* 質問メニュー（ボトムシート） */
.sheet { position: absolute; inset: 0; z-index: 15; visibility: hidden; pointer-events: none; transition: visibility 0s linear var(--dur-mid); }
.sheet.is-open { visibility: visible; pointer-events: auto; transition: visibility 0s; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(11, 20, 56, 0.5); opacity: 0; transition: opacity var(--dur-mid); border: 0; padding: 0; width: 100%; }
.sheet.is-open .sheet__backdrop { opacity: 1; }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 72%; overflow-y: auto;
  padding: 10px 14px calc(16px + var(--safe-bottom));
  border: 3px solid var(--c-ink); border-bottom: 0; border-radius: var(--radius-l) var(--radius-l) 0 0;
  background: var(--c-paper);
  transform: translateY(105%);
  transition: transform var(--dur-mid) var(--ease-pop);
}
.sheet.is-open .sheet__panel { transform: none; }
.sheet__grip { width: 48px; height: 6px; margin: 0 auto 8px; border-radius: 3px; background: var(--c-line); }
.sheet__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet__head .kid__face { --kid-size: 40px; box-shadow: none; }
.sheet__title { margin: 0; flex: 1; font-size: 17px; font-weight: 900; line-height: 1.3; }
.sheet__title small { display: block; color: var(--c-ink-sub); font-size: 12px; }
.sheet__group { margin: 0 0 12px; }
.sheet__label { margin: 0 0 6px; font-size: 12px; font-weight: 900; color: var(--c-ink-sub); }
.qgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.qgrid--4 { grid-template-columns: repeat(4, 1fr); }
.qgrid--4 .qbtn { flex-direction: column; gap: 0; padding: 4px 2px; }
.qgrid--cards { grid-template-columns: repeat(var(--m, var(--n, 5)), 1fr); }
.qbtn {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px; padding: 4px 8px;
  border: 3px solid var(--c-ink); border-radius: 14px; background: #fff;
  font-size: 14px; font-weight: 900; white-space: nowrap;
  box-shadow: 0 4px 0 var(--c-ink);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.qbtn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
.qbtn--card { flex-direction: column; gap: 0; min-height: 60px; padding: 2px; font-size: 10px; }
.qbtn.is-asked { background: #efe6d2; color: var(--c-ink-sub); box-shadow: 0 2px 0 var(--c-ink); }
.qbtn.is-asked::after { content: "済"; margin-left: 2px; font-size: 10px; }
.qbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.sheet__note { margin: 4px 0 10px; color: var(--c-ink-sub); font-size: 12px; font-weight: 700; text-align: center; }

/* ---------- 正解発表 ---------- */
.screen--reveal { align-items: center; gap: 12px; }
.reveal__title {
  margin: 4px 0 0; color: var(--c-paper); font-size: 26px; font-weight: 900;
  -webkit-text-stroke: 7px var(--c-ink); paint-order: stroke fill;
}
.reveal__santa { margin: -4px 0; }
.reveal__list { display: grid; gap: 8px; width: min(100%, 360px); margin: 0; padding: 0; list-style: none; }
.reveal__row {
  display: grid; grid-template-columns: 52px 1fr 64px 40px; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m); background: var(--c-paper);
  box-shadow: 0 4px 0 var(--c-ink);
}
.reveal__row .pcard { --card-h: 72px; max-width: 60px; pointer-events: none; }
.reveal__kid { display: flex; flex-direction: column; align-items: center; font-size: 11px; font-weight: 900; }
.reveal__want { font-size: 12px; font-weight: 800; line-height: 1.3; }
.reveal__want b { display: block; font-size: 14px; }
.reveal__mark {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 3px solid var(--c-ink); border-radius: 50%;
  font-size: 22px; font-weight: 900; color: #fff;
  opacity: 0;
}
.reveal__mark.is-ok { background: var(--c-green); animation: stamp 0.4s var(--ease-pop) calc(var(--i, 0) * 0.35s + 0.45s) both; }
.reveal__mark.is-ok::before { content: "○"; }
.reveal__mark.is-ng { background: var(--c-red); animation: stamp 0.4s var(--ease-pop) calc(var(--i, 0) * 0.35s + 0.45s) both; }
.reveal__mark.is-ng::before { content: "×"; }
@keyframes stamp { from { transform: scale(2.2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.reveal__score { margin: 0; color: var(--c-paper); font-size: 18px; font-weight: 900; text-shadow: 0 3px 0 var(--c-ink); }

/* ---------- 結果 ---------- */
.screen--result { align-items: center; justify-content: center; }
.result__panel { width: min(100%, 360px); padding: 18px 16px 20px; }
.result__label { margin: 0; font-size: 14px; font-weight: 900; color: var(--c-ink-sub); }
.result__head { margin: 0 0 4px; font-size: 28px; font-weight: 900; }
.result__head--clear { color: var(--c-red); }
.result__stars { justify-content: center; margin: 4px 0 10px; }
.result__santa { margin: 0 auto; }
.result__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.result__stat { padding: 6px; border: 3px solid var(--c-ink); border-radius: var(--radius-m); background: #fff; }
.result__stat-label { display: block; font-size: 11px; font-weight: 900; color: var(--c-ink-sub); }
.result__stat-value { font-size: 24px; line-height: 1.1; }
.result__new { display: inline-block; margin-left: 4px; padding: 0 6px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-gold); font-size: 11px; font-weight: 900; animation: wiggle 0.6s ease 0.8s 3; }
.result__answer { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.result__pair { display: flex; flex-direction: column; align-items: center; padding: 4px; border: 2px solid var(--c-line); border-radius: var(--radius-s); background: #fff; font-size: 10px; font-weight: 900; }
.result__history {
  margin: 6px 0 0; padding: 8px;
  border: 3px dashed var(--c-ink); border-radius: var(--radius-m); background: #fff6d8;
  font-size: 15px; line-height: 1.4; letter-spacing: 0.06em; word-break: break-all;
}
.result__actions { display: grid; gap: 10px; margin-top: 14px; }

/* ---------- トースト・横向き ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 40;
  padding: 8px 18px;
  border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-paper);
  font-size: 14px; font-weight: 900;
  transform: translateX(-50%);
  animation: pop-in 0.3s var(--ease-pop);
}
.rotate {
  position: fixed; inset: 0; z-index: 100;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--c-wall-deep); color: var(--c-paper);
  font-size: 20px; font-weight: 900;
}
.rotate__phone {
  width: 48px; height: 80px;
  border: 4px solid var(--c-paper); border-radius: 10px;
  animation: turn 1.6s ease-in-out infinite;
}
@keyframes turn { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0deg); } }
@media (orientation: landscape) and (max-height: 500px) { .rotate { display: flex; } }
.rotate.is-show { display: flex; }

/* ---------- 小さい画面（高さ 700 未満） ---------- */
@media (max-height: 740px) {
  :root { --kid-size: 46px; --card-h: 92px; --cell: 30px; }
  .kids { padding-top: 30px; }
  .bubble { font-size: 12px; }
}
@media (max-width: 360px) {
  :root { --kid-size: 46px; }
  .pcard__name { font-size: 9px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-iteration-count: 1 !important; }
  .logo__char, .rotate__phone, .qcount.is-low, .result__new { animation: none !important; }
  .pcard.is-deal { animation: fade 0.2s ease both; animation-delay: 0s; }
  .pcard.is-fly { animation: fade-out 0.2s ease both; }
  /* めくりは回転せず即表に（順番のずれだけ残す） */
  .pcard.is-flip .pcard__inner { animation: none; transform: none; transition: none; }
  .pcard__inner, .sheet__panel { transition-duration: 0.01s; }
  .bubble { animation: fade 0.15s ease both; transform: translateX(-50%); }
  .reveal__mark.is-ok, .reveal__mark.is-ng { animation: fade 0.2s ease calc(var(--i, 0) * 0.2s) both; }
  .stars--big .star.is-on { animation: fade 0.2s ease both; }
  .screen { transform: none !important; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
