/* 日本列島わけっこゲーム style.css — 構造とクラス名は docs/design.md を参照 */

:root {
  --c-sea: #cdebf7;
  --c-sea-deep: #a6d8ee;
  --c-sea-wave: rgba(255, 255, 255, 0.55);
  --c-land: #fff4dc;
  --c-land-edge: #b89b6a;
  --c-pref-line: #dcc9a4;

  --c-side-a: #ff8fab;
  --c-side-a-deep: #e8608a;
  --c-side-a-soft: #ffe3eb;
  --c-side-b: #7bc96f;
  --c-side-b-deep: #4fa443;
  --c-side-b-soft: #e3f5df;

  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-bg: #fff8ea;
  --c-shu: #e8513b;
  --c-shu-deep: #b83a28;
  --c-ai: #2f4b7c;
  --c-ai-deep: #1e3256;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-line: #eadcc0;

  --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;
  --shadow-card: 0 4px 0 rgba(59, 47, 47, 0.12), 0 10px 24px rgba(59, 47, 47, 0.08);
  --btn-depth: 6px;

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

  --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-bg);
  background-image: radial-gradient(circle at 10px 10px, rgba(232, 81, 59, 0.06) 2px, transparent 2.5px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  position: relative;
  max-width: 520px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

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

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  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;
}

.fade-in { animation: fade-in var(--dur-mid) ease both; }
.fade-out { animation: fade-out var(--dur-mid) ease both; }

/* ---------- ロゴ ---------- */

.logo {
  margin: 0;
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.logo__sub {
  display: block;
  font-size: clamp(20px, 6vw, 28px);
  color: var(--c-ai);
}

.logo__main {
  display: inline-flex;
  gap: 2px;
  margin: 4px 0;
  font-size: clamp(44px, 15vw, 72px);
}

.logo__char {
  display: inline-block;
  padding: 0 2px;
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow:
    0 3px 0 var(--c-ink),
    2px 0 0 var(--c-ink), -2px 0 0 var(--c-ink),
    0 2px 0 var(--c-ink), 0 -2px 0 var(--c-ink),
    2px 2px 0 var(--c-ink), -2px 2px 0 var(--c-ink),
    2px -2px 0 var(--c-ink), -2px -2px 0 var(--c-ink);
}

.logo__char--a { color: var(--c-side-a); transform: rotate(-6deg); }
.logo__char--b { color: var(--c-side-b); transform: rotate(5deg) translateY(-2px); }

.logo__main .logo__char:nth-child(1) { animation: logo-bob 2.4s ease-in-out infinite; }
.logo__main .logo__char:nth-child(2) { animation: logo-bob 2.4s ease-in-out 0.15s infinite; }
.logo__main .logo__char:nth-child(3) { animation: logo-bob 2.4s ease-in-out 0.3s infinite; }
.logo__main .logo__char:nth-child(4) { animation: logo-bob 2.4s ease-in-out 0.45s infinite; }

.logo__cut {
  position: relative;
  display: inline-block;
  width: 4px;
  margin: 0 4px;
  align-self: stretch;
  background: repeating-linear-gradient(to bottom, var(--c-ai) 0 8px, transparent 8px 14px);
  border-radius: 2px;
  transform: rotate(14deg);
}

.logo__tail {
  display: block;
  font-size: clamp(22px, 7vw, 32px);
  color: var(--c-shu);
}

.logo--small .logo__sub { font-size: 12px; }
.logo--small .logo__main { font-size: 22px; margin: 0; }
.logo--small .logo__char { text-shadow: none; }
.logo--small .logo__tail { display: none; }

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

.btn {
  --btn-bg: var(--c-shu);
  --btn-edge: var(--c-shu-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;
  user-select: none;
  box-shadow: 0 var(--btn-depth) 0 var(--btn-edge), 0 var(--btn-depth) 0 3px var(--c-ink);
  transform: translateY(0);
  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 {
  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--secondary { --btn-bg: var(--c-ai); --btn-edge: var(--c-ai-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; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-paper);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--c-ink); }

/* ---------- 共通カード ---------- */

.card {
  background: var(--c-paper);
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

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

/* ---------- タイトル画面 ---------- */

.screen--title {
  justify-content: center;
  align-items: center;
  gap: 24px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 110%, var(--c-sea) 0 40%, transparent 41%);
}

.title__map {
  width: min(70vw, 280px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--c-ink);
  background-color: var(--c-sea);
  background-image: var(--pattern-seigaiha);
  background-size: 40px 20px;
  box-shadow: var(--shadow-card);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.title__map canvas { width: 100%; height: 100%; }

.title__lead {
  margin: 0;
  font-size: 15px;
  color: var(--c-ink-sub);
}

.title__actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(100%, 320px);
}

.title__best {
  font-size: 14px;
  color: var(--c-ink-sub);
}

.title__best .num { font-size: 20px; color: var(--c-shu); }

/* ---------- チュートリアル ---------- */

.screen--tutorial {
  justify-content: center;
  gap: 20px;
}

.tutorial__title {
  margin: 0;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
}

.tutorial__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  counter-reset: step;
}

.tutorial__step {
  display: flex;
  align-items: center;
  gap: 14px;
  counter-increment: step;
  animation: pop-in 0.45s var(--ease-pop) both;
}

.tutorial__step:nth-child(2) { animation-delay: 0.1s; }
.tutorial__step:nth-child(3) { animation-delay: 0.2s; }
.tutorial__step:nth-child(4) { animation-delay: 0.3s; }

.tutorial__step::before {
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 3px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-gold);
  font-family: var(--font-num);
  font-weight: 900;
  font-size: 20px;
}

.tutorial__text { font-size: 16px; font-weight: 700; }
.tutorial__text small { display: block; font-weight: 400; color: var(--c-ink-sub); font-size: 13px; }

.tutorial__demo {
  position: relative;
  height: 160px;
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-m);
  background-color: var(--c-sea);
  background-image: var(--pattern-seigaiha);
  background-size: 40px 20px;
  overflow: hidden;
}

.tutorial__demo canvas { width: 100%; height: 100%; display: block; }

.tutorial__finger {
  position: absolute;
  left: 20%;
  top: 20%;
  font-size: 36px;
  animation: finger-swipe 2.2s ease-in-out infinite;
  pointer-events: none;
}

/* ---------- プレイ画面 ---------- */

.screen--play {
  padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom));
  gap: 10px;
  overflow: hidden;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud__round {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 14px;
}

.hud__round .num { font-size: 22px; }

.hud__pips {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hud__pip {
  width: 10px;
  height: 10px;
  border: 2px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-paper);
}

.hud__pip.is-done { background: var(--c-side-b); }
.hud__pip.is-current { background: var(--c-gold); transform: scale(1.3); }

.hud__score {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 14px;
  border: 2px solid var(--c-ink);
  border-radius: 999px;
  background: var(--c-paper);
  font-size: 12px;
  font-weight: 700;
}

.hud__score .num { font-size: 22px; color: var(--c-shu); }

.odai {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--c-paper);
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  animation: pop-in 0.45s var(--ease-pop) both;
}

.odai::before {
  content: "お題";
  position: absolute;
  top: -12px;
  left: 14px;
  padding: 0 10px;
  border: 2px solid var(--c-ink);
  border-radius: 999px;
  background: var(--c-shu);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
}

.odai__icon {
  flex: none;
  font-size: 34px;
  line-height: 1;
}

.odai__text {
  margin: 0;
  font-size: clamp(17px, 5vw, 21px);
  font-weight: 800;
  line-height: 1.3;
}

.odai__em {
  color: var(--c-shu);
  background: linear-gradient(transparent 62%, rgba(255, 200, 61, 0.6) 62%);
}

.odai__unit {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-ink-sub);
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-l);
  background-color: var(--c-sea);
  background-image: var(--pattern-seigaiha);
  background-size: 40px 20px;
  overflow: hidden;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.35);
  touch-action: none;
}

.map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.map-wrap.is-dragging { box-shadow: inset 0 0 0 6px rgba(47, 75, 124, 0.25); }
.map-wrap.is-locked .map-canvas { cursor: default; }

.map-badge {
  position: absolute;
  top: 10px;
  padding: 2px 10px;
  border: 2px solid var(--c-ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.map-badge--a { left: 10px; background: var(--c-side-a); }
.map-badge--b { right: 10px; background: var(--c-side-b); }
.map-wrap.is-dragging .map-badge,
.map-wrap.is-split .map-badge { opacity: 1; }

.map-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(59, 47, 47, 0.85);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  animation: pop-in 0.3s var(--ease-pop) both;
}

.hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
}

.hint__text {
  margin: 0;
  font-size: 13px;
  color: var(--c-ink-sub);
  font-weight: 700;
}

.hint__text::before { content: "☝️ "; }

.hint__actions { display: flex; gap: 8px; flex: none; }

/* ---------- 1問の結果オーバーレイ ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px calc(16px + var(--safe-bottom));
  background: rgba(59, 47, 47, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
}

.overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--dur-mid) ease, visibility 0s;
}

.result {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 18px 18px;
  text-align: center;
  background: var(--c-paper);
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-l);
  box-shadow: 0 8px 0 rgba(59, 47, 47, 0.2);
}

.overlay.is-open .result { animation: sheet-up 0.45s var(--ease-pop) both; }

.result__label {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--c-ink-sub);
}

.result__ratio {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 4px 0 8px;
  font-family: var(--font-num);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.result__side {
  font-size: clamp(44px, 14vw, 64px);
}

.result__side--a { color: var(--c-side-a-deep); }
.result__side--b { color: var(--c-side-b-deep); }

.result__colon {
  font-size: clamp(32px, 10vw, 48px);
  color: var(--c-ink);
  transform: translateY(-4px);
}

.ratio-bar {
  display: flex;
  height: 18px;
  margin: 0 0 12px;
  border: 2px solid var(--c-ink);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.ratio-bar__a { background: var(--c-side-a); transition: flex-basis 0.8s var(--ease-pop); }
.ratio-bar__b { background: var(--c-side-b); transition: flex-basis 0.8s var(--ease-pop); }

.ratio-bar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--c-ink);
  transform: translateX(-1px);
}

.result__points {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
}

.result__points .num {
  font-size: 48px;
  color: var(--c-shu);
  line-height: 1;
}

.result__points.is-counting .num { animation: count-bounce 0.12s ease-out; }
.result__points.is-done .num { animation: score-bounce 0.6s var(--ease-pop); }

.result__bonus {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  border: 2px solid var(--c-ink);
  border-radius: 999px;
  background: var(--c-gold);
  font-size: 13px;
  font-weight: 800;
  animation: stamp 0.5s var(--ease-pop) 0.4s both;
}

.result__verdict {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 900;
}

.result__verdict--perfect { color: var(--c-shu); }
.result__verdict--great { color: var(--c-side-b-deep); }
.result__verdict--good { color: var(--c-ai); }
.result__verdict--miss { color: var(--c-ink-sub); }

.trivia {
  position: relative;
  margin: 0 0 16px;
  padding: 12px 14px 12px 14px;
  text-align: left;
  border: 2px dashed var(--c-land-edge);
  border-radius: var(--radius-s);
  background: var(--c-land);
  font-size: 14px;
}

.trivia__title {
  display: block;
  margin-bottom: 2px;
  font-weight: 800;
  color: var(--c-shu);
  font-size: 13px;
}

.trivia__title::before { content: "💡 "; }

/* ---------- 最終結果画面 ---------- */

.screen--final {
  gap: 16px;
  text-align: center;
}

.final__head { margin: 8px 0 0; font-size: 18px; font-weight: 800; color: var(--c-ink-sub); }

.final__total {
  position: relative;
  margin: 0;
  font-family: var(--font-num);
  font-weight: 900;
  line-height: 1;
}

.final__total .num {
  font-size: clamp(72px, 24vw, 112px);
  color: var(--c-shu);
  text-shadow: 0 4px 0 rgba(59, 47, 47, 0.15);
}

.final__max { font-size: 20px; color: var(--c-ink-sub); }

.final__total.is-done .num { animation: score-bounce 0.7s var(--ease-pop); }

.new-record {
  display: inline-block;
  align-self: center;
  padding: 4px 18px;
  border: 3px solid var(--c-ink);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--c-side-a), var(--c-gold), var(--c-side-b), var(--c-gold), var(--c-side-a));
  background-size: 200% 100%;
  font-size: 18px;
  font-weight: 900;
  animation: stamp 0.6s var(--ease-pop) 0.6s both, shimmer 2s linear 1.2s infinite;
}

.new-record[hidden] { display: none; }

.final__best { margin: 0; font-size: 13px; color: var(--c-ink-sub); }

.rank {
  align-self: center;
  position: relative;
  padding: 10px 24px 12px;
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-s);
  background: var(--c-paper);
  box-shadow: var(--shadow-card);
  animation: pop-in 0.5s var(--ease-pop) 0.3s both;
}

.rank__label { display: block; font-size: 12px; font-weight: 700; color: var(--c-ink-sub); }
.rank__name { display: block; font-size: 26px; font-weight: 900; color: var(--c-ai); }

.rank::before,
.rank::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 3px solid var(--c-ink);
  border-radius: 50%;
  background: var(--c-shu);
  transform: translateY(-50%);
}

.rank::before { left: -9px; }
.rank::after { right: -9px; }

.breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
}

.breakdown__item {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 2px dotted var(--c-line);
  animation: pop-in 0.4s var(--ease-pop) both;
}

.breakdown__item:nth-child(1) { animation-delay: 0.05s; }
.breakdown__item:nth-child(2) { animation-delay: 0.12s; }
.breakdown__item:nth-child(3) { animation-delay: 0.19s; }
.breakdown__item:nth-child(4) { animation-delay: 0.26s; }
.breakdown__item:nth-child(5) { animation-delay: 0.33s; }

.breakdown__item:last-child { border-bottom: 0; }

.breakdown__no {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--c-ink);
  border-radius: 50%;
  font-family: var(--font-num);
  font-weight: 900;
  font-size: 13px;
  background: var(--c-land);
}

.breakdown__odai { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown__ratio { font-family: var(--font-num); font-size: 13px; color: var(--c-ink-sub); font-variant-numeric: tabular-nums; }
.breakdown__pts { font-family: var(--font-num); font-weight: 900; font-size: 18px; color: var(--c-shu); min-width: 3ch; text-align: right; }
.breakdown__item.is-perfect .breakdown__pts::after { content: "★"; color: var(--c-gold-deep); margin-left: 2px; }

.final__actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.share-done {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-side-b-deep);
  animation: pop-in 0.3s var(--ease-pop) both;
}

.history__title { margin: 0 0 8px; font-size: 15px; font-weight: 800; text-align: left; }

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.history__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-s);
  background: var(--c-land);
  font-size: 13px;
}

.history__item.is-best { outline: 2px solid var(--c-gold-deep); }
.history__date { color: var(--c-ink-sub); }
.history__score { font-family: var(--font-num); font-weight: 900; font-size: 16px; }
.history__rank { font-size: 12px; color: var(--c-ai); font-weight: 700; }
.history__empty { font-size: 13px; color: var(--c-ink-sub); }

/* ---------- 紙吹雪 ---------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.confetti__piece {
  position: absolute;
  top: -20px;
  left: var(--x, 50%);
  width: 10px;
  height: 14px;
  background: var(--c-side-a);
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall var(--dur, 1.8s) cubic-bezier(0.25, 0.6, 0.5, 1) var(--delay, 0s) forwards;
}

.confetti__piece:nth-child(4n + 1) { background: var(--c-side-a); }
.confetti__piece:nth-child(4n + 2) { background: var(--c-side-b); width: 8px; height: 8px; border-radius: 50%; }
.confetti__piece:nth-child(4n + 3) { background: var(--c-gold); }
.confetti__piece:nth-child(4n + 4) { background: var(--c-shu); width: 6px; height: 16px; }

.is-perfect-flash {
  animation: perfect-flash 0.6s ease-out;
}

.perfect-stamp {
  position: absolute;
  top: 18%;
  left: 50%;
  z-index: 30;
  padding: 6px 22px;
  border: 4px solid var(--c-shu);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.92);
  color: var(--c-shu);
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.1em;
  pointer-events: none;
  transform: translateX(-50%) rotate(-8deg);
  animation: stamp-center 0.55s var(--ease-pop) both;
}

/* ---------- パターン ---------- */

:root {
  --pattern-seigaiha:
    radial-gradient(circle at 50% 100%, transparent 0 7px, var(--c-sea-wave) 7px 8.5px, transparent 8.5px 12px, var(--c-sea-wave) 12px 13.5px, transparent 13.5px 20px),
    radial-gradient(circle at 0 50%, transparent 0 7px, var(--c-sea-wave) 7px 8.5px, transparent 8.5px 12px, var(--c-sea-wave) 12px 13.5px, transparent 13.5px 20px),
    radial-gradient(circle at 100% 50%, transparent 0 7px, var(--c-sea-wave) 7px 8.5px, transparent 8.5px 12px, var(--c-sea-wave) 12px 13.5px, transparent 13.5px 20px);
}

/* ---------- ユーティリティ ---------- */

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.spacer { flex: 1; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pop-in { animation: pop-in 0.45s var(--ease-pop) both; }
.bounce { animation: score-bounce 0.6s var(--ease-pop); }
.shake { animation: shake 0.4s ease; }

/* ---------- keyframes ---------- */

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

@keyframes fade-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-12px); }
}

@keyframes pop-in {
  0% { opacity: 0; transform: scale(0.6); }
  60% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(60px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes count-bounce {
  0% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

@keyframes score-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35) rotate(-3deg); }
  55% { transform: scale(0.92) rotate(1deg); }
  75% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes stamp {
  0% { opacity: 0; transform: scale(2.2) rotate(-12deg); }
  70% { opacity: 1; transform: scale(0.94) rotate(-4deg); }
  100% { opacity: 1; transform: scale(1) rotate(-4deg); }
}

@keyframes stamp-center {
  0% { opacity: 0; transform: translateX(-50%) scale(2.4) rotate(-14deg); }
  70% { opacity: 1; transform: translateX(-50%) scale(0.94) rotate(-8deg); }
  100% { opacity: 1; transform: translateX(-50%) scale(1) rotate(-8deg); }
}

@keyframes shimmer {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  100% { opacity: 0.9; transform: translate3d(var(--drift, 30px), 110vh, 0) rotate(var(--spin, 720deg)); }
}

@keyframes perfect-flash {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 200, 61, 0.9); }
  40% { box-shadow: inset 0 0 0 14px rgba(255, 200, 61, 0.9); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 200, 61, 0); }
}

@keyframes logo-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -4px; }
}

@keyframes finger-swipe {
  0% { opacity: 0; transform: translate(0, 0); }
  15% { opacity: 1; transform: translate(0, 0); }
  70% { opacity: 1; transform: translate(140px, 70px); }
  100% { opacity: 0; transform: translate(140px, 70px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------- PC ---------- */

@media (min-width: 768px) {
  .app {
    height: min(100dvh, 920px);
    margin-top: max(0px, calc((100dvh - 920px) / 2));
    border: 3px solid var(--c-ink);
    border-radius: var(--radius-l);
    background: var(--c-bg);
    box-shadow: 0 12px 40px rgba(59, 47, 47, 0.15);
  }
}

/* ---------- reduced motion ---------- */

@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;
    scroll-behavior: auto !important;
  }

  .screen { transform: none; }
  .confetti { display: none; }
  .tutorial__finger { opacity: 1; }
}
