/* サンタさんがお待ちです style.css — 構造とクラス名は docs/design.md を参照
   シリーズ共通: ポップ・太い墨枠・押すと沈むボタン・丸ゴシック（外部フォントなし） */

:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-bg: #fff8ea;
  --c-line: #eadcc0;

  --c-red: #e8413b;
  --c-red-deep: #b8302c;
  --c-green: #3fa66a;
  --c-green-deep: #2b7a4b;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-night: #1b2960;
  --c-night-deep: #0b1438;
  --c-night-soft: #34488a;
  --c-dawn: #ffb59a;
  --c-snow: #f4f8fd;
  --c-snow-shade: #d6e3f2;
  --c-ice: #9fdcf0;
  --c-ice-deep: #5fb3d6;
  --c-deer: #b87a4b;
  --c-deer-deep: #8a5532;
  --c-wood: #c98a52;
  --c-wood-deep: #8f5a2e;

  --c-time-ok: #4cc26e;
  --c-time-warn: #ffc83d;
  --c-time-bad: #ff5a4a;

  --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: 10px;
  --radius-m: 18px;
  --radius-l: 28px;
  --btn-depth: 6px;

  --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);

  --app-w: min(100vw, 480px);
  --hud-h: 56px;
  --foot-h: 104px;   /* ワン！ボタンの段 */

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

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font-base);
  color: var(--c-ink);
  background-color: var(--c-night-deep);
  overflow: hidden;
  position: fixed;
  inset: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; }
canvas { display: block; }

.num {
  font-family: var(--font-num);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* PC ではそのまま中央に縦長 */
.app {
  position: relative;
  width: var(--app-w);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(120% 40% at 50% 100%, rgba(255, 181, 154, 0.45), transparent 70%),
    linear-gradient(180deg, var(--c-night-deep), var(--c-night) 45%, var(--c-night-soft) 80%, #6a5f9a);
}

/* ---------- 画面切替 ---------- */

.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;
}

/* ← ゲーム一覧（bound-bingo と同じ） */
.screen > a.back-to-games {
  position: absolute; top: calc(12px + var(--safe-top)); left: calc(12px + var(--safe-left)); z-index: 6;
  display: inline-flex; align-items: center; padding: 6px 12px 7px;
  font: 800 13px/1 var(--font-base); color: var(--c-ink); text-decoration: none;
  background: var(--c-paper); border: 3px solid var(--c-ink); border-radius: 999px; box-shadow: 0 3px 0 var(--c-ink);
}
.screen > a.back-to-games:active { transform: translateY(3px); box-shadow: none; }

/* ---------- ボタン ---------- */

.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:focus-visible, .icon-btn:focus-visible, .stage-tile:focus-visible {
  outline: 4px solid var(--c-gold);
  outline-offset: 4px;
}
.btn:disabled {
  filter: grayscale(0.8) opacity(0.6);
  cursor: not-allowed;
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn--block { display: flex; width: 100%; }
.btn--green { --btn-bg: var(--c-green); --btn-edge: var(--c-green-deep); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--ice { --btn-bg: var(--c-ice); --btn-edge: var(--c-ice-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: 42px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 3px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-paper);
  font-size: 18px;
  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); }

/* ---------- 星 ---------- */

.star {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: var(--c-line);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.star.is-on { background: var(--c-gold); }

/* ---------- タイトル ---------- */

.screen--title { align-items: center; justify-content: center; gap: 14px; text-align: center; }

/* 夜明け前の空にちらつく雪（CSS だけ） */
.title__snow {
  position: absolute; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.9) 1.6px, transparent 2px),
    radial-gradient(circle, rgba(255,255,255,0.6) 1.2px, transparent 1.6px);
  background-size: 46px 52px, 31px 37px;
  background-position: 0 0, 13px 9px;
  animation: snow-fall 9s linear infinite;
}
@keyframes snow-fall { to { background-position: 0 520px, 13px 379px; } }

.logo { position: relative; margin: 0; font-weight: 900; line-height: 1.1; }
.logo__sub {
  display: inline-block;
  padding: 2px 14px;
  border: 3px solid var(--c-ink);
  border-radius: 999px;
  background: var(--c-green);
  color: #fff;
  font-size: clamp(14px, 4vmin, 19px);
  transform: rotate(-3deg);
}
.logo__main {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  font-size: clamp(36px, 11vmin, 62px);
}
.logo__line { display: flex; justify-content: center; width: 100%; }
.logo__char {
  display: inline-block;
  color: var(--c-paper);
  -webkit-text-stroke: 3px var(--c-ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--c-ink);
  animation: hop-herd 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.09s);
}
.logo__char--red { color: var(--c-red); }
.logo__char--gold { color: var(--c-gold); }
.logo__char--deer { color: #e0a36c; }

/* 群れが1頭ずつぴょんと跳ねて、少し右へ寄る */
@keyframes hop-herd {
  0%, 60%, 100% { transform: translate(0, 0); }
  70% { transform: translate(1px, -10px) rotate(-4deg); }
  80% { transform: translate(2px, 1px) scale(1.04, 0.94); }
  90% { transform: translate(0, 0); }
}

.title__scene {
  position: relative;
  width: min(72vw, 300px);
  height: auto;
  aspect-ratio: 4 / 3;
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-l);
  background: var(--c-snow);
  box-shadow: 0 6px 0 var(--c-ink);
}
.title__actions { position: relative; display: flex; flex-direction: column; gap: 12px; width: min(80vw, 320px); }
.title__note { position: relative; margin: 0; color: #c8d0ef; font-size: 13px; }

/* ---------- ルール（初回は自動で出す） ---------- */

.screen--rules { gap: 12px; }
.rules__head { display: flex; align-items: center; gap: 10px; }
.rules__title { flex: 1; margin: 0; color: var(--c-paper); font-size: 22px; font-weight: 900; text-align: center; }
.rules__head::after { content: ""; width: 44px; flex: none; }

.rules__list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: koma; }
.rule {
  position: relative;
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 10px;
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-m);
  background: var(--c-paper);
  box-shadow: 0 5px 0 var(--c-ink);
  animation: card-in var(--dur-mid) var(--ease-pop) both;
  animation-delay: calc(var(--i, 0) * 0.1s);
  counter-increment: koma;
}
.rule::before {
  content: counter(koma);
  position: absolute; top: -12px; left: -8px;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-gold);
  font: 900 15px/1 var(--font-num);
}
.rule__pic {
  width: 88px; height: 88px;
  border: 3px solid var(--c-ink);
  border-radius: 14px;
  background: var(--c-snow);
}
.rule__text { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.45; }
.rule__text b { color: var(--c-red); }
.rule__sub { display: block; margin-top: 2px; color: var(--c-ink-sub); font-size: 12px; font-weight: 700; }
.rule--danger { background: #fff1ee; }
.rules__foot { margin-top: auto; padding-top: 6px; }

/* ---------- ステージ選択（8マス = 4x2） ---------- */

.screen--stages { gap: 14px; }
.stages__head { display: flex; align-items: center; gap: 10px; }
.stages__title { flex: 1; margin: 0; color: var(--c-paper); font-size: 22px; font-weight: 900; }
.stages__total {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-paper);
  font-weight: 900;
}
.stages__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0; padding: 0; list-style: none;
}
@media (min-width: 420px) and (min-height: 760px) { .stages__grid { gap: 14px; } }

.stage-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-height: 104px;
  padding: 26px 8px 8px;
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-m);
  background:
    radial-gradient(circle at 20% 110%, var(--c-snow-shade) 0 30%, transparent 31%),
    var(--c-paper);
  text-align: center;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--c-ink);
  animation: card-in var(--dur-mid) var(--ease-pop) both;
  animation-delay: calc(var(--i, 0) * 0.05s);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.stage-tile:active { transform: translateY(5px); box-shadow: 0 0 0 var(--c-ink); }
.stage-tile:focus-visible { outline: 4px solid var(--c-gold); outline-offset: 4px; }
/* 番号は赤い札（小屋の屋根の色） */
.stage-tile__num {
  position: absolute; top: -3px; left: 50%;
  display: grid; place-items: center;
  min-width: 40px; height: 28px; padding: 0 8px;
  border: 3px solid var(--c-ink);
  border-radius: 0 0 12px 12px;
  background: var(--c-red); color: #fff;
  font-size: 17px; line-height: 1;
  transform: translateX(-50%);
}
.stage-tile__name { font-size: 14px; font-weight: 900; line-height: 1.25; }
.stage-tile__meta { color: var(--c-ink-sub); font-size: 11px; font-weight: 800; }
.stage-tile__meta .num { font-size: 12px; }
.stage-tile__stars { display: flex; gap: 2px; margin-top: auto; }
.stage-tile.is-cleared .stage-tile__num { background: var(--c-green); }
.stage-tile.is-perfect { background: radial-gradient(circle at 50% 0%, #fff4c9, var(--c-paper) 70%); }
.stage-tile.is-new::after {
  content: "NEW";
  position: absolute; top: 6px; right: -6px;
  padding: 0 6px;
  border: 2px solid var(--c-ink); border-radius: 999px;
  background: var(--c-gold);
  font: 900 10px/16px var(--font-num);
  transform: rotate(8deg);
  animation: chip-pulse 0.9s ease-in-out infinite;
}
.stage-tile.is-locked { background: #c9cde0; cursor: not-allowed; box-shadow: 0 5px 0 #6b7194; }
.stage-tile.is-locked:active { transform: none; box-shadow: 0 5px 0 #6b7194; }
.stage-tile.is-locked .stage-tile__num { background: #8a90ad; }
.stage-tile.is-locked .stage-tile__name { color: #6b7194; }
.stage-tile.is-locked .stage-tile__stars,
.stage-tile.is-locked .stage-tile__meta { display: none; }
.stage-tile__lock {
  position: relative;
  width: 26px; height: 22px; margin-top: auto;
  border: 3px solid var(--c-ink); border-radius: 6px;
  background: var(--c-gold);
}
.stage-tile__lock::before {
  content: "";
  position: absolute; left: 3px; top: -15px;
  width: 14px; height: 14px;
  border: 3px solid var(--c-ink); border-bottom: 0;
  border-radius: 10px 10px 0 0;
}
.stage-tile:not(.is-locked) .stage-tile__lock { display: none; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------- プレイ ---------- */

.screen--play { padding: 0; overflow: hidden; gap: 0; }

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: calc(var(--hud-h) + var(--safe-top));
  padding: calc(8px + var(--safe-top)) calc(10px + var(--safe-right)) 4px calc(10px + var(--safe-left));
}
.hud__chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 11px;
  border: 3px solid var(--c-ink);
  border-radius: 999px;
  background: var(--c-paper);
  box-shadow: 0 3px 0 var(--c-ink);
  font-weight: 900;
  white-space: nowrap;
}
.hud__stage { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; }
.hud__stage-num {
  flex: none;
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--c-red); color: #fff;
  font-size: 13px;
}
.hud__stage-name { overflow: hidden; text-overflow: ellipsis; }
.hud__time { min-width: 76px; justify-content: center; }
.hud__time-icon {
  position: relative; flex: none;
  width: 18px; height: 18px;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
}
.hud__time-icon::after {
  content: "";
  position: absolute; left: 50%; top: 1px;
  width: 3px; height: 6px; margin-left: -1.5px;
  border-radius: 2px; background: var(--c-ink);
  transform-origin: 50% 100%;
  animation: tick 4s steps(8) infinite;
}
@keyframes tick { to { transform: rotate(360deg); } }
.hud__time-val { font-size: 19px; }
.hud__time.is-hurry { background: var(--c-time-bad); color: #fff; animation: chip-pulse 0.6s ease-in-out infinite; }
.hud__time.is-hurry .hud__time-icon { border-color: #fff; background: transparent; }
.hud__time.is-hurry .hud__time-icon::after { background: #fff; }

/* 小屋に入った数 n/N（鈴アイコン） */
.hud__count { padding-left: 6px; }
.hud__count-icon {
  flex: none;
  width: 22px; height: 22px;
  border: 2.5px solid var(--c-ink); border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c9 0 18%, transparent 20%), radial-gradient(circle at 50% 78%, var(--c-ink) 0 14%, transparent 16%), var(--c-gold);
}
.hud__count-val { font-size: 19px; }
.hud__count-total { font-size: 13px; color: var(--c-ink-sub); }
.hud__count.is-bump { animation: bump 0.35s var(--ease-pop); }
.hud__count.is-full { background: var(--c-gold); }
.play__pause { flex: none; }

@keyframes chip-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* 牧場（canvas）。JS が 12x16 に合う最大の s を決めて style の width/height を px で入れる */
.field {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 8px 0;
}
.field__canvas {
  width: 100%;
  height: 100%;
  border: 4px solid var(--c-ink);
  border-radius: 16px;
  background: var(--c-snow);
  box-shadow: 0 5px 0 var(--c-ink);
  touch-action: none;
}
.field__hint {
  position: absolute; left: 50%; top: 14px;
  margin: 0; padding: 4px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: rgba(255, 253, 247, 0.95);
  font-size: 13px; font-weight: 900; white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  animation: hint-fade 3.2s ease both;
}
.field__hint[hidden] { display: none; }
@keyframes hint-fade { 0% { opacity: 0; } 10%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* 下の段: ワン！ボタン（親指の位置） */
.play__foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: calc(var(--foot-h) + var(--safe-bottom));
  padding: 6px 16px calc(10px + var(--safe-bottom));
}
.play__foot-note { color: #c8d0ef; font-size: 11px; font-weight: 800; line-height: 1.3; width: 64px; }
.play__foot-note--right { text-align: right; }

.bark-btn {
  --cool: 0;  /* クールダウンの残り 1..0（JS が更新。0 で使える） */
  --size: 84px;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size); height: var(--size);
  padding: 0;
  border: 4px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-gold);
  color: var(--c-ink);
  font: 900 22px/1 var(--font-base);
  letter-spacing: -0.02em;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--c-gold-deep), 0 7px 0 4px var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter var(--dur-fast);
  touch-action: none;
}
.bark-btn::after {
  content: "";
  position: absolute; inset: -12px;
  border-radius: 50%;
  border: 6px solid rgba(255, 200, 61, 0.0);
  pointer-events: none;
}
.bark-btn__label { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bark-btn__key { font-size: 10px; font-weight: 800; color: var(--c-gold-deep); }
.bark-btn:active, .bark-btn.is-pressed {
  transform: translateY(7px);
  box-shadow: 0 0 0 var(--c-gold-deep), 0 0 0 4px var(--c-ink);
}
.bark-btn:focus-visible { outline: 4px solid var(--c-paper); outline-offset: 14px; }
/* 待ち中: 灰色で中身がゲージ。is-cooling は JS が付け外し */
.bark-btn.is-cooling {
  background: conic-gradient(var(--c-gold) calc((1 - var(--cool)) * 360deg), #d8d3c4 0);
  box-shadow: 0 7px 0 #a9a290, 0 7px 0 4px var(--c-ink);
  cursor: default;
}
.bark-btn.is-cooling .bark-btn__label { opacity: 0.55; }
/* 使えるようになった瞬間 */
.bark-btn.is-ready { animation: ready-pop 0.4s var(--ease-pop); }
.bark-btn.is-ready::after { animation: ready-ring 0.6s ease-out; }
@keyframes ready-pop { 0% { transform: scale(0.9); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes ready-ring { from { border-color: rgba(255, 200, 61, 0.9); transform: scale(0.85); } to { border-color: rgba(255, 200, 61, 0); transform: scale(1.25); } }

/* トースト「あと2頭！」「にげちゃう！」など */
.toast {
  position: absolute;
  left: 50%;
  top: 34%;
  z-index: 8;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 8px 18px;
  border: 3px solid var(--c-ink);
  border-radius: 999px;
  background: var(--c-paper);
  box-shadow: 0 4px 0 var(--c-ink);
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  animation: toast 1.4s ease both;
}
.toast--warn { background: var(--c-gold); }
.toast--bad { background: var(--c-time-bad); color: #fff; }
.toast--good { background: var(--c-green); color: #fff; }
.toast[hidden] { display: none; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  25% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -14px); }
}

/* カウントダウン「よーい」「ドン！」 */
.countdown {
  position: absolute; inset: 0; z-index: 9;
  display: grid; place-items: center;
  pointer-events: none;
}
.countdown[hidden] { display: none; }
.countdown__text {
  font: 900 56px/1 var(--font-base);
  color: var(--c-gold);
  -webkit-text-stroke: 4px var(--c-ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--c-ink);
  animation: pop-in 0.35s var(--ease-pop) both;
}
@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }

/* 逃げた瞬間の画面フラッシュ（結果の前に 0.8 秒） */
.escape-flash {
  position: absolute; inset: 0; z-index: 9;
  display: grid; place-items: center;
  background: rgba(255, 90, 74, 0.25);
  pointer-events: none;
  animation: fade-in 0.2s ease both;
}
.escape-flash[hidden] { display: none; }
.escape-flash__text {
  padding: 6px 20px;
  border: 4px solid var(--c-ink); border-radius: 999px;
  background: var(--c-time-bad); color: #fff;
  font-size: 26px; font-weight: 900;
  box-shadow: 0 5px 0 var(--c-ink);
  animation: shake 0.5s ease both;
}
@keyframes shake { 0%, 100% { transform: translateX(0) rotate(0); } 20% { transform: translateX(-8px) rotate(-3deg); } 40% { transform: translateX(7px) rotate(2deg); } 60% { transform: translateX(-5px) rotate(-1deg); } 80% { transform: translateX(3px); } }

/* ---------- オーバーレイ・シート ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
  background: rgba(11, 20, 56, 0.62);
  animation: fade-in var(--dur-mid) ease both;
}
.overlay[hidden] { display: none; }

.sheet {
  position: relative;
  width: min(92vw, 360px);
  padding: 20px 18px 18px;
  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;
  animation: sheet-in 0.45s var(--ease-pop) both;
}
.sheet__title { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.sheet__text { margin: 0 0 10px; color: var(--c-ink-sub); font-size: 14px; }
.sheet__actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.sheet__row { display: flex; gap: 10px; }
.sheet__row > .btn { flex: 1; padding-left: 10px; padding-right: 10px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(30px) scale(0.92); } to { opacity: 1; transform: none; } }

.sheet--pause .sheet__title::before {
  content: "";
  display: inline-block;
  width: 14px; height: 18px; margin-right: 8px;
  border-left: 5px solid var(--c-ink); border-right: 5px solid var(--c-ink);
  vertical-align: -2px;
}

/* ---------- 結果 ---------- */

.overlay--result { background: radial-gradient(circle at 50% 30%, rgba(255, 181, 154, 0.35), rgba(11, 20, 56, 0.8) 70%); }
.sheet--result { padding-top: 34px; }
.result__badge {
  position: absolute; top: -50px; left: 50%;
  width: 84px; height: 84px;
  margin-left: -42px;
  border: 3px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-dawn);
  box-shadow: 0 4px 0 var(--c-ink);
}
.result__badge img, .result__badge canvas { width: 100%; height: 100%; }
.result__stage { margin: 0; color: var(--c-ink-sub); font-size: 13px; font-weight: 800; }
.result__title {
  margin: 0;
  font-size: 30px; font-weight: 900; line-height: 1.2;
  color: var(--c-green);
  -webkit-text-stroke: 2px var(--c-ink);
  paint-order: stroke fill;
}
.sheet--result.is-over .result__title { color: var(--c-time-bad); }
.result__time { margin: 2px 0 0; font-size: 44px; line-height: 1.1; }
.result__time-unit { margin-left: 2px; font-size: 16px; }
.result__new {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--c-red); color: #fff;
  font-size: 12px; vertical-align: 6px;
  animation: chip-pulse 0.8s ease-in-out infinite;
}
.result__new[hidden] { display: none; }
.result__stars { display: flex; justify-content: center; gap: 8px; margin: 8px 0 4px; }
.result-star {
  width: 48px; height: 48px;
  background: var(--c-line);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.result-star:nth-child(2) { transform: translateY(-10px); }
.result-star.is-on { background: var(--c-gold); animation: star-pop 0.5s var(--ease-pop) both; animation-delay: calc(0.4s + var(--i, 0) * 0.35s); }
.result-star.is-on:nth-child(2) { animation-name: star-pop-mid; }
@keyframes star-pop { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes star-pop-mid { 0% { transform: translateY(-10px) scale(0) rotate(-40deg); } 70% { transform: translateY(-10px) scale(1.25) rotate(8deg); } 100% { transform: translateY(-10px) scale(1); } }

.result__next {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 12px;
  border-radius: 999px;
  background: #fff1c9;
  font-size: 13px; font-weight: 800;
}
.result__next[hidden] { display: none; }
.result__next b { color: var(--c-red); }

/* ゲームオーバー: 理由と n/N の小屋ゲージ */
.result__reason { margin: 6px 0 4px; font-size: 15px; font-weight: 900; }
.result__reason[hidden] { display: none; }
.result__herd {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 3px;
  margin: 4px auto 6px; padding: 6px 8px; max-width: 280px;
  border: 2px solid var(--c-line); border-radius: 12px; background: var(--c-bg);
}
.result__herd[hidden] { display: none; }
.result__herd i {   /* 1 頭 = 1 つの鈴。入った子は .is-in */
  width: 18px; height: 18px;
  border: 2px solid var(--c-ink); border-radius: 50%;
  background: #d8d3c4;
}
.result__herd i.is-in { background: var(--c-gold); }
.result__herd i.is-escaped { background: var(--c-time-bad); }
.result__count { margin: 0 0 6px; font-size: 13px; font-weight: 800; color: var(--c-ink-sub); }
.result__count b { color: var(--c-red); font-size: 16px; }

/* 紙吹雪（クリア時、JS が .confetti > i を十数個置く） */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; left: calc(var(--x, 50) * 1%);
  width: 8px; height: 12px;
  border: 1.5px solid var(--c-ink);
  background: var(--c, var(--c-gold));
  animation: confetti 2.4s linear both;
  animation-delay: calc(var(--d, 0) * 1s);
}
@keyframes confetti { to { transform: translateY(110dvh) rotate(720deg); } }

/* ---------- 横向き ---------- */

.rotate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--c-night-deep);
  color: var(--c-paper);
  text-align: center;
}
.rotate__phone {
  width: 56px; height: 92px;
  border: 4px solid var(--c-paper);
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--c-ink);
  animation: turn 2s ease-in-out infinite;
}
.rotate__text { margin: 0; font-size: 20px; font-weight: 900; }
@keyframes turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }

/* 横向きスマホ（高さ < 500 かつ横長）だけ。PC はそのまま中央に縦長 */
@media (orientation: landscape) and (max-height: 499px) and (pointer: coarse) {
  .rotate { display: flex; }
}

/* ---------- 小さい画面（360x640 など） ---------- */

@media (max-height: 700px) {
  :root { --hud-h: 50px; --foot-h: 88px; }
  .screen { padding-top: calc(10px + var(--safe-top)); padding-bottom: calc(10px + var(--safe-bottom)); }
  .screen--title { gap: 10px; }
  .title__scene { width: min(56vw, 210px); }
  .logo__main { font-size: clamp(30px, 9.5vmin, 46px); }
  .btn { min-height: 50px; font-size: 18px; }
  .btn--small { min-height: 40px; font-size: 14px; }
  .rules__list { gap: 10px; }
  .rule { grid-template-columns: 68px 1fr; padding: 8px 10px 8px 8px; }
  .rule__pic { width: 68px; height: 68px; }
  .rule__text { font-size: 14px; }
  .rule__sub { font-size: 11px; }
  .stages__grid { gap: 10px; }
  .stage-tile { min-height: 88px; padding-top: 24px; }
  .hud__chip { height: 36px; }
  .bark-btn { --size: 70px; font-size: 19px; }
  .sheet { padding: 16px 14px 14px; }
  .sheet--result { padding-top: 30px; }
  .result__badge { width: 68px; height: 68px; margin-left: -34px; top: -40px; }
  .result__time { font-size: 36px; }
  .result-star { width: 38px; height: 38px; }
  .sheet__actions { gap: 8px; margin-top: 10px; }
}
@media (max-width: 370px) {
  .hud__stage-name { display: none; }
  .hud__stage { flex: none; padding: 0 6px; }
  .hud { justify-content: space-between; }
  .play__foot-note { display: none; }
}

/* ---------- 動きをへらす ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
  .title__snow { animation: none !important; }
  .toast, .field__hint { animation: none !important; }
  .hud__time.is-hurry { outline: 3px solid var(--c-paper); outline-offset: 1px; }
  .bark-btn.is-ready { outline: 4px solid var(--c-paper); outline-offset: 10px; }
}
