/* フリッカー・ジャブ style.css — 構造とクラス名は docs/design.md
   シリーズ共通: ポップ・太い墨枠・押すと沈むボタン・丸ゴシック（外部フォントなし） */

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

  --c-red: #ec3d3a;
  --c-red-deep: #b5242a;
  --c-red-light: #ffd6d0;
  --c-blue: #3f8be8;
  --c-blue-deep: #2560b0;
  --c-blue-light: #a9d4ff;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-mint: #5ad6a8;
  --c-mint-deep: #2fa57a;
  --c-purple: #6b4fb0;
  --c-night: #2c2357;

  --c-done: #2fa57a;        /* 入力済み文字 */
  --c-next: #ec3d3a;        /* 次に打つ文字 */
  --c-pending: #3b2f2f;     /* まだの文字 */

  --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: 48px;
  /* キーボード 1段の高さ: 56px〜72px を画面高で伸縮（4段） */
  --key-h: clamp(56px, 8.4dvh, 72px);
  --key-gap: 6px;

  --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);
  background-image: radial-gradient(circle at 50% 0%, rgba(255,240,190,.18) 0 30%, transparent 31%);
  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; }

.app {
  position: relative;
  width: var(--app-w);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, #4a3a8e, var(--c-night));
  box-shadow: 0 0 0 3px 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;
}

/* ← ゲーム一覧（santa-fly-high と同じ） */
.screen--title > a.back-to-games { position: absolute !important; 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--title > a.back-to-games[hidden] { display: none; }
.screen--title > a.back-to-games:active { transform: translateY(3px); box-shadow: none; }
.screen--title:has(> a.back-to-games:not([hidden])) { padding-top: calc(52px + var(--safe-top)); justify-content: safe center; }

/* ---------- ボタン ---------- */
.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 { outline: 4px solid var(--c-gold); outline-offset: 4px; }
.btn:disabled { filter: grayscale(0.8) opacity(0.6); cursor: not-allowed; }
.btn--block { display: flex; width: 100%; }
.btn--blue { --btn-bg: var(--c-blue); --btn-edge: var(--c-blue-deep); --btn-fg: #fff; }
.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: 42px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }
.btn--small::after { top: 4px; height: 4px; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  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); }
.icon-btn::before, .icon-btn::after { content: ""; position: absolute; }
/* ポーズ（二本線） */
.icon-btn--pause::before { width: 6px; height: 14px; left: 10px; top: 10px; border-radius: 2px; background: var(--c-ink); box-shadow: 8px 0 0 var(--c-ink); }
/* スピーカー（.is-muted で斜線） */
.icon-btn--sound::before { width: 16px; height: 14px; left: 9px; top: 10px; background: var(--c-ink); clip-path: polygon(0 30%, 35% 30%, 75% 0, 75% 100%, 35% 70%, 0 70%); }
.icon-btn--sound.is-muted::after { width: 4px; height: 26px; left: 15px; top: 4px; border-radius: 2px; background: var(--c-red); transform: rotate(45deg); box-shadow: 0 0 0 2px var(--c-paper); }
.icon-btn--help::before { content: "?"; position: static; font: 900 18px/1 var(--font-num); }

/* ---------- 星 ---------- */
.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; }
.screen__bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.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-gold);
  color: var(--c-ink);
  font-size: clamp(13px, 3.8vmin, 17px);
  transform: rotate(-3deg);
}
.logo__main { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 8px; font-size: clamp(40px, 12.5vmin, 66px); }
.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: jab-hop 2.2s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.08s);
}
.logo__char--red { color: var(--c-red); }
.logo__char--gold { color: var(--c-gold); }
/* 1文字ずつジャブを受けて後ろにのけぞる */
@keyframes jab-hop {
  0%, 60%, 100% { transform: none; }
  66% { transform: translate(4px, -4px) scale(0.86) rotate(6deg); }
  74% { transform: translate(-2px, 0) scale(1.08); }
  82% { transform: none; }
}

.title__art {
  position: relative;
  width: min(74vw, 300px);
  aspect-ratio: 4 / 3;
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-l);
  background: var(--c-blue-light);
  box-shadow: 0 6px 0 var(--c-ink);
  overflow: hidden;
}
.title__art canvas { width: 100%; height: 100%; }
.title__best {
  position: relative;
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper);
  font-size: 14px; font-weight: 800;
}
.title__best b { font: 900 20px/1 var(--font-num); color: var(--c-red-deep); }
.title__best[hidden] { display: none; }
.title__actions { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(80vw, 320px); }
.title__sub { display: flex; justify-content: center; gap: 12px; }

/* ---------- モーダル共通（ルール・ポーズ） ---------- */
.modal {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: rgba(30, 20, 60, 0.6);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
  overflow-y: auto;
}
.modal.is-open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--dur-mid) ease, visibility 0s; }
.card {
  position: relative;
  width: min(100%, 380px);
  margin-top: 20px;
  padding: 22px 18px 18px;
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-l);
  background: var(--c-paper);
  box-shadow: 0 7px 0 var(--c-ink);
}
.modal.is-open .card { animation: card-in var(--dur-mid) var(--ease-pop) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(20px) scale(0.92); } to { opacity: 1; transform: none; } }
.card__title {
  margin: -40px auto 12px;
  width: fit-content;
  padding: 4px 22px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-red);
  color: #fff;
  font-size: 20px; font-weight: 900;
  box-shadow: 0 4px 0 var(--c-ink);
}

/* ルール（初回は自動で出す） */
.rules__list { display: grid; gap: 10px; margin: 0 0 14px; padding: 0; list-style: none; counter-reset: rule; }
.rule {
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  border: 3px solid var(--c-ink);
  border-radius: var(--radius-m);
  background: var(--c-cream);
  counter-increment: rule;
  animation: card-in var(--dur-mid) var(--ease-pop) both;
  animation-delay: calc(var(--i, 0) * 0.1s);
}
.rule::before {
  content: counter(rule);
  position: absolute; top: -10px; left: -8px;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-gold);
  font: 900 14px/1 var(--font-num);
}
.rule__pic { width: 84px; height: 84px; border: 3px solid var(--c-ink); border-radius: 14px; background: var(--c-blue-light); }
.rule__text { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.45; }
.rule__text b { color: var(--c-red-deep); }
.rule__sub { display: block; margin-top: 2px; color: var(--c-ink-sub); font-size: 12px; font-weight: 700; }
/* フリック方向図（ルール用、静的な十字） */
.flick-diagram {
  display: grid;
  grid-template-columns: repeat(3, 26px);
  grid-template-rows: repeat(3, 26px);
  gap: 1px;
  width: fit-content;
  margin: 2px auto;
}
.flick-diagram > span {
  display: grid; place-items: center;
  border: 2px solid var(--c-ink); border-radius: 7px;
  background: var(--c-paper);
  font-size: 14px; font-weight: 900; line-height: 1;
}
.flick-diagram > .is-center { background: var(--c-red); color: #fff; }
.flick-diagram > .is-empty { visibility: hidden; }

/* ポーズ */
.pause { display: flex; flex-direction: column; gap: 12px; text-align: center; }
.pause__note { margin: 0; color: var(--c-ink-sub); font-size: 13px; font-weight: 700; }

/* ---------- プレイ ----------
   上から HUD / ステージ(伸縮) / お題 / キーボード。flex 縦積みで重ならない */
.screen--play {
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  overflow: hidden;
  touch-action: none;
  gap: 0;
  background: var(--c-night);
}

.hud {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  height: var(--hud-h);
  padding: 0 8px;
  background: var(--c-night);
  border-bottom: 3px solid var(--c-ink);
  z-index: 3;
}
.hud__chip {
  display: inline-flex; align-items: baseline; gap: 4px;
  height: 34px; padding: 0 10px;
  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;
  line-height: 28px;
}
.hud__chip small { font-size: 10px; font-weight: 800; color: var(--c-ink-sub); }
.hud__round { background: var(--c-red); color: #fff; }
.hud__round small { color: #ffe1dc; }
.hud__round .num { font-size: 18px; }
.hud__time { min-width: 62px; justify-content: center; }
.hud__time .num { font-size: 20px; }
.hud__time.is-low { background: var(--c-red-light); animation: tick 1s steps(1) infinite; }
.hud__time.is-low .num { color: var(--c-red-deep); }
@keyframes tick { 50% { transform: scale(1.08); } }
.hud__score { flex: 1; min-width: 0; justify-content: flex-end; overflow: hidden; }
.hud__score .num { font-size: 20px; }
.hud__score.is-up .num { animation: bump 0.25s var(--ease-pop); display: inline-block; }
@keyframes bump { from { transform: scale(1.35); color: var(--c-red); } }
.hud__btns { display: flex; gap: 6px; flex: none; }

/* ステージ: canvas を中に敷く。高さは残りぜんぶ（最低 120px） */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 120px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--c-purple) 0 44%, #7cc4ff 44%);
}
.stage__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.is-shaking .stage__canvas { transform: translate(var(--sx, 0px), var(--sy, 0px)); }
/* コンボ（ステージ右上に重ねる） */
.combo {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  padding: 2px 10px 4px;
  border: 3px solid var(--c-ink); border-radius: 14px;
  background: var(--c-gold);
  box-shadow: 0 3px 0 var(--c-ink);
  line-height: 1;
  transform-origin: 50% 0;
}
.combo .num { font-size: 22px; }
.combo small { font-size: 10px; font-weight: 900; }
.combo__mult { font: 900 11px/1 var(--font-num); color: var(--c-red-deep); }
.combo[hidden] { display: none; }
.combo.is-up { animation: combo-up 0.3s var(--ease-pop); }
@keyframes combo-up { from { transform: scale(1.4) rotate(-6deg); } }
.combo.is-break { animation: combo-break 0.4s ease; background: var(--c-line); }
@keyframes combo-break { 30% { transform: translateY(6px) rotate(8deg); } 100% { transform: none; } }

/* お題パネル */
.word {
  flex: none;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 78px;
  padding: 6px 12px 8px;
  border-top: 3px solid var(--c-ink);
  border-bottom: 3px solid var(--c-ink);
  background: var(--c-paper);
  z-index: 2;
}
.word__label {
  display: inline-block;
  padding: 0 10px;
  border: 2px solid var(--c-ink); border-radius: 999px;
  background: var(--c-cream);
  font-size: 12px; font-weight: 800; line-height: 18px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.word__kana {
  display: flex; justify-content: center; gap: 2px;
  margin-top: 4px;
  font-size: clamp(30px, 9.5vw, 40px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.word__kana > span {
  position: relative;
  display: inline-block;
  min-width: 0.9em;
  text-align: center;
  transition: color var(--dur-fast), transform var(--dur-fast);
}
.word__kana > .is-pending { color: var(--c-pending); opacity: 0.45; }
.word__kana > .is-done { color: var(--c-done); }
.word__kana > .is-done.is-just { animation: char-done 0.25s var(--ease-pop); }
@keyframes char-done { from { transform: translateY(-6px) scale(1.3); } }
.word__kana > .is-next { color: var(--c-next); }
.word__kana > .is-next::after {
  content: "";
  position: absolute; left: 12%; right: 12%; bottom: -4px;
  height: 4px; border-radius: 2px;
  background: var(--c-next);
  animation: caret 0.9s ease-in-out infinite;
}
@keyframes caret { 50% { opacity: 0.25; } }
/* 変換途中（清音まで打って゛゜小待ち） */
.word__kana > .is-partial { color: var(--c-gold-deep); }
.word__kana > .is-partial::after { background: var(--c-gold-deep); }
/* 長い単語は縮める（JS が data-len を入れる） */
.word[data-len="7"] .word__kana { font-size: clamp(26px, 8.2vw, 36px); }
.word[data-len="8"] .word__kana, .word[data-len="9"] .word__kana { font-size: clamp(22px, 7.2vw, 32px); }
/* ミス: 赤く震える */
.word.is-miss { background: var(--c-red-light); }
.word.is-miss .word__kana { animation: miss-shake 0.32s linear; }
.word.is-miss .is-next { color: var(--c-red-deep); }
@keyframes miss-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px) rotate(-2deg); }
  40% { transform: translateX(7px) rotate(2deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
/* 打ち切り（KO）の一瞬 */
.word.is-clear .word__kana > span { color: var(--c-done); animation: char-done 0.3s var(--ease-pop) both; animation-delay: calc(var(--i, 0) * 0.03s); }

/* ---------- フリックキーボード ---------- */
.fk {
  flex: none;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, var(--key-h));
  gap: var(--key-gap);
  padding: 8px 10px 10px;
  background: linear-gradient(180deg, #4a3a8e, var(--c-night));
  touch-action: none;
}
.fk__key {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 56px;
  min-height: 56px;
  padding: 0 0 4px;
  border: 3px solid var(--c-ink);
  border-radius: 14px;
  background: var(--c-paper);
  box-shadow: 0 5px 0 var(--c-line), 0 5px 0 3px var(--c-ink);
  margin-bottom: 5px;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.06s ease, box-shadow 0.06s ease, background var(--dur-fast);
}
/* 小さく各方向の字を添える（JS が data-l/u/r/d を入れる） */
.fk__sub { font-size: 10px; font-weight: 800; color: var(--c-ink-sub); letter-spacing: 0.15em; margin-top: 3px; }
.fk__key.is-down, .fk__key:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 var(--c-line), 0 0 0 3px var(--c-ink);
  background: var(--c-cream);
}
.fk__key--mod { background: var(--c-blue-light); font-size: 19px; }
.fk__key--mod { box-shadow: 0 5px 0 #6aa5e0, 0 5px 0 3px var(--c-ink); }
.fk__key--mod.is-down { box-shadow: 0 0 0 #6aa5e0, 0 0 0 3px var(--c-ink); }
.fk__key--blank { visibility: hidden; pointer-events: none; }
/* 最初の1文字のヒント: 押すべきキーを光らせる */
.fk__key.is-hint { background: var(--c-gold); animation: hint-glow 1s ease-in-out infinite; }
@keyframes hint-glow { 50% { box-shadow: 0 5px 0 var(--c-gold-deep), 0 5px 0 3px var(--c-ink), 0 0 0 9px rgba(255,200,61,.55); } }
/* ヒントの方向矢印（data-dir="left|up|right|down"） */
.fk__key.is-hint[data-dir]::after {
  content: "";
  position: absolute; width: 0; height: 0;
  border: 8px solid transparent;
}
.fk__key.is-hint[data-dir="up"]::after { top: -2px; border-bottom-color: var(--c-red); border-top: 0; }
.fk__key.is-hint[data-dir="down"]::after { bottom: 0; border-top-color: var(--c-red); border-bottom: 0; }
.fk__key.is-hint[data-dir="left"]::after { left: 0; border-right-color: var(--c-red); border-left: 0; }
.fk__key.is-hint[data-dir="right"]::after { right: 0; border-left-color: var(--c-red); border-right: 0; }

/* フリックガイド: 押したキーの中心に十字。JS が left/top(px, キー中心)と --cell を入れる */
.fk-guide {
  --cell: 60px;
  position: absolute;
  z-index: 30;
  width: calc(var(--cell) * 3);
  height: calc(var(--cell) * 3);
  margin: calc(var(--cell) * -1.5) 0 0 calc(var(--cell) * -1.5);
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  grid-template-rows: repeat(3, var(--cell));
  pointer-events: none;
  filter: drop-shadow(0 4px 0 var(--c-ink));
}
.fk-guide[hidden] { display: none; }
.fk-guide__cell {
  display: grid; place-items: center;
  margin: -1.5px;
  border: 3px solid var(--c-ink);
  background: var(--c-paper);
  font-size: calc(var(--cell) * 0.46);
  font-weight: 900;
  line-height: 1;
  transition: background 0.05s, color 0.05s, transform 0.08s;
}
.fk-guide__cell--c { grid-area: 2 / 2; border-radius: 12px; background: var(--c-cream); z-index: 1; }
.fk-guide__cell--u { grid-area: 1 / 2; border-radius: 14px 14px 4px 4px; }
.fk-guide__cell--l { grid-area: 2 / 1; border-radius: 14px 4px 4px 14px; }
.fk-guide__cell--r { grid-area: 2 / 3; border-radius: 4px 14px 14px 4px; }
.fk-guide__cell--d { grid-area: 3 / 2; border-radius: 4px 4px 14px 14px; }
.fk-guide__cell:empty { visibility: hidden; }
.fk-guide__cell.is-sel {
  background: var(--c-red);
  color: #fff;
  transform: scale(1.12);
  z-index: 2;
}
.fk-guide__cell--c.is-sel { background: var(--c-red); }

/* ---------- ラウンド間カード ---------- */
.round-card {
  position: absolute; inset: 0; z-index: 15;
  display: grid; place-items: center; align-content: center; gap: 10px;
  background: rgba(30, 20, 60, 0.55);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.round-card.is-open { opacity: 1; visibility: visible; transition: opacity 0.2s ease, visibility 0s; }
.round-card__plate {
  padding: 10px 34px 14px;
  border: 5px solid var(--c-ink);
  border-radius: var(--radius-l);
  background: var(--c-red);
  color: #fff;
  box-shadow: 0 8px 0 var(--c-ink);
  text-align: center;
  transform: rotate(-4deg);
}
.round-card.is-open .round-card__plate { animation: slam 0.45s var(--ease-pop) both; }
@keyframes slam { from { transform: translateX(-120%) rotate(-14deg); } 70% { transform: translateX(4%) rotate(-2deg); } to { transform: rotate(-4deg); } }
.round-card__label { display: block; font: 900 18px/1 var(--font-num); letter-spacing: 0.2em; }
.round-card__num {
  display: block;
  font: 900 64px/1 var(--font-num);
  color: var(--c-gold);
  -webkit-text-stroke: 3px var(--c-ink);
  paint-order: stroke fill;
}
.round-card__note {
  padding: 4px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper);
  font-size: 14px; font-weight: 800;
}
.round-card__sub { font: 800 13px/1.4 var(--font-base); color: #fff; text-shadow: 0 2px 0 var(--c-ink); }

/* ---------- 結果 ---------- */
.screen--result { align-items: center; gap: 12px; text-align: center; justify-content: safe center; }
.verdict {
  position: relative;
  margin: 0;
  padding: 6px 22px 10px;
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-m);
  background: var(--c-gold);
  box-shadow: 0 6px 0 var(--c-ink);
  font-size: clamp(30px, 10vw, 42px);
  font-weight: 900;
  line-height: 1.15;
  transform: rotate(-3deg);
  animation: verdict-in 0.6s var(--ease-pop) both;
}
.verdict--ko { background: var(--c-red); color: #fff; }
.verdict--decision { background: var(--c-blue); color: #fff; }
@keyframes verdict-in { from { transform: scale(2.2) rotate(-12deg); opacity: 0; } }
.result-card {
  width: min(100%, 380px);
  padding: 14px 16px 16px;
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-l);
  background: var(--c-paper);
  box-shadow: 0 7px 0 var(--c-ink);
}
.result__title { display: inline-block; padding: 1px 12px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-cream); font-size: 13px; font-weight: 900; }
.result__score { margin: 4px 0 0; font: 900 clamp(44px, 14vw, 58px)/1 var(--font-num); color: var(--c-red-deep); }
.result__score small { font: 800 16px var(--font-base); color: var(--c-ink); }
.result__stars { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.result__stars .star { width: 34px; height: 34px; }
.result__stars .star.is-on { animation: star-pop 0.4s var(--ease-pop) both; animation-delay: calc(0.5s + var(--i, 0) * 0.15s); }
@keyframes star-pop { from { transform: scale(0) rotate(-90deg); } }
.result__new { display: inline-block; padding: 0 10px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-gold); font: 900 13px/22px var(--font-num); animation: tick 0.8s steps(1) infinite; }
.result__new[hidden] { display: none; }
.result__next { margin: 2px 0 8px; font-size: 13px; font-weight: 800; color: var(--c-ink-sub); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
.stats > div { padding: 4px 8px; border: 2px solid var(--c-ink); border-radius: 12px; background: var(--c-cream); }
.stats dt { font-size: 11px; font-weight: 800; color: var(--c-ink-sub); }
.stats dd { margin: 0; font: 900 20px/1.2 var(--font-num); }
.result__best { margin: 8px 0 0; font-size: 13px; font-weight: 800; }
.result__actions { display: flex; flex-direction: column; gap: 12px; width: min(100%, 320px); }
.result__share-note { min-height: 1.4em; margin: 0; font-size: 12px; font-weight: 800; color: #fff; }

/* ---------- 横向き警告 ---------- */
.rotate {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--c-night);
  color: #fff;
  font-size: 18px; font-weight: 900;
  text-align: center;
}
.rotate__phone {
  width: 46px; height: 76px;
  border: 4px solid var(--c-ink);
  border-radius: 10px;
  background: var(--c-paper);
  box-shadow: 0 0 0 3px #fff;
  animation: rotate-hint 2s ease-in-out infinite;
}
@keyframes rotate-hint { 0%, 20% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate { display: flex; }
}
.rotate.is-forced { display: flex; }

/* ---------- 低い画面 ---------- */
@media (max-height: 700px) {
  :root { --hud-h: 44px; --key-gap: 5px; }
  .word { min-height: 66px; padding: 4px 10px 6px; }
  .word__kana { font-size: clamp(26px, 8.4vw, 34px); margin-top: 2px; }
  .fk { padding: 6px 8px 8px; }
}
@media (max-height: 600px) {
  :root { --key-h: 56px; }
  .word__label { font-size: 11px; line-height: 16px; }
}

/* ---------- 動きを減らす ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stage.is-shaking .stage__canvas { transform: none; }
  .word.is-miss .word__kana { animation: none; }
  .fk-guide__cell.is-sel { transform: none; }
}
