/* Kana quiz page. Builds on /assets/site.css tokens. Same rules apply here:
   one accent (nihon), square corners, hairlines, no CSS shadows, no pills.
   Glow and fog live inside the WebGL scene only. */

.kana-page { --hud-pad: clamp(12px, 1.6vw, 22px); --line: rgba(250, 247, 242, 0.18); --line-strong: rgba(250, 247, 242, 0.3); --panel: rgba(14, 14, 15, 0.72); --mast: 62px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- stage ---------- */

.stage {
  position: relative;
  height: calc(100svh - var(--mast));
  min-height: 600px;
  padding: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 10%, #17141f 0%, var(--sumi) 62%);
  isolation: isolate;
}

.scene { position: absolute; inset: 0; }
.scene canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }

.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(140% 100% at 50% 45%, transparent 55%, rgba(8, 8, 9, 0.55) 100%);
}

.hud { position: absolute; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums lining-nums; }
.hud > * { pointer-events: auto; }
.hud [hidden] { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}
/* A second hairline inset 3px, like a bordered book plate. */
.panel::before {
  content: ""; position: absolute; inset: 3px; border: 1px solid rgba(250, 247, 242, 0.07); pointer-events: none;
}

.panel-eyebrow, .label, .card-eyebrow, .res-sub, dt {
  font-family: var(--tight); font-weight: 700; font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
}
.panel-eyebrow { color: var(--nihon-on-dark); margin: 0 0 12px; }

/* ---------- status ---------- */

.status {
  position: absolute; top: var(--hud-pad); left: var(--hud-pad);
  display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; min-height: 58px;
}
.seal {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  background: var(--nihon); color: var(--bone);
  font-family: var(--serif); font-weight: 700; font-size: 21px; line-height: 1;
  transform: rotate(-3deg);
}
.status-text { display: grid; gap: 2px; }
.status .label { color: var(--gray-cool); font-size: 10px; }
.status .value { font-family: var(--serif); font-weight: 700; font-size: 17px; line-height: 1.2; letter-spacing: 0.01em; }

/* ---------- toolbar ---------- */

.toolbar { position: absolute; top: var(--hud-pad); right: var(--hud-pad); display: flex; gap: 6px; }
.tool {
  position: relative; width: 42px; height: 42px; display: grid; place-items: center; padding: 0;
  background: var(--panel); border: 1px solid var(--line); color: var(--bone); cursor: pointer;
  border-radius: 0; transition: border-color .15s, background-color .15s;
}
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: square; }
.tool:hover, .tool:focus-visible { border-color: var(--line-strong); background: rgba(30, 28, 32, 0.85); outline: none; }
.tool:focus-visible { border-color: var(--bone); }
.tool[aria-pressed="true"].is-accent, .tool[aria-expanded="true"] { border-color: var(--nihon); background: rgba(188, 0, 45, 0.22); }
#tool-view .ico-3d, #tool-view .t-3d { display: none; }
#tool-view[aria-pressed="true"] .ico-3d, #tool-view[aria-pressed="true"] .t-3d { display: block; }
#tool-view[aria-pressed="true"] .ico-chart, #tool-view[aria-pressed="true"] .t-chart { display: none; }
#tool-view[aria-pressed="true"] { border-color: var(--nihon); background: rgba(188, 0, 45, 0.22); }
#tool-sound .ico-off { display: none; }
#tool-sound[aria-pressed="false"] .ico-on { display: none; }
#tool-sound[aria-pressed="false"] .ico-off { display: block; }

.tip {
  position: absolute; top: calc(100% + 8px); right: 0; width: 230px; padding: 10px 12px 11px;
  background: rgba(14, 14, 15, 0.94); border: 1px solid var(--line-strong);
  text-align: left; pointer-events: none; opacity: 0; transform: translateY(-3px);
  transition: opacity .14s, transform .14s; z-index: 5;
}
.tip b { display: block; font-family: var(--tight); font-weight: 700; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--bone); margin-bottom: 4px; }
.tip span { display: block; font-size: 12.5px; line-height: 1.45; color: var(--gray-cool); }
@media (hover: hover) { .tool:hover .tip { opacity: 1; transform: none; } }
.tool:focus-visible .tip { opacity: 1; transform: none; }
.hud:has(.settings:not([hidden])) .tip { display: none; }

/* ---------- settings ---------- */

.settings { position: absolute; top: calc(var(--hud-pad) + 52px); right: var(--hud-pad); width: 290px; padding: 16px 18px 14px; z-index: 6; }
.switch { display: grid; grid-template-columns: 18px 1fr; gap: 12px; align-items: start; padding: 9px 0; border-top: 1px solid rgba(250, 247, 242, 0.08); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .box { width: 16px; height: 16px; margin-top: 3px; border: 1px solid var(--line-strong); position: relative; }
.switch input:checked + .box { border-color: var(--nihon); background: var(--nihon); }
.switch input:checked + .box::after { content: ""; position: absolute; left: 4.5px; top: 1px; width: 4px; height: 8px; border: solid var(--bone); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.switch input:focus-visible + .box { outline: 1px solid var(--bone); outline-offset: 2px; }
.switch input:disabled ~ .txt { opacity: 0.45; }
.switch .txt { font-size: 14px; line-height: 1.35; }
.switch small { display: block; font-size: 12px; color: var(--gray-cool); margin-top: 2px; }

.btn-quiet {
  background: none; border: 0; padding: 8px 0 0; color: var(--gray-cool); cursor: pointer;
  font-family: var(--tight); font-weight: 700; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
}
.btn-quiet:hover, .btn-quiet:focus-visible { color: var(--bone); outline: none; }
kbd { font-family: var(--tight); font-size: 10px; letter-spacing: 0.1em; border: 1px solid var(--line-strong); padding: 1px 5px; margin-left: 6px; color: var(--bone); }

/* ---------- stats ---------- */

.stats {
  position: absolute; top: calc(var(--hud-pad) + 54px); right: var(--hud-pad); width: 244px; padding: 14px 16px 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px;
}
.stat { display: grid; gap: 3px; }
.stat .label { color: var(--gray-cool); font-size: 10px; }
.stat .num { font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-streak .num { color: var(--nihon-on-dark); }
.stat-progress { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: baseline; }
.stat-progress .num { font-size: 15px; font-family: var(--tight); letter-spacing: 0.06em; }
.bar { grid-column: 1 / -1; height: 3px; background: rgba(250, 247, 242, 0.1); margin-top: 6px; position: relative; }
.bar > span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--nihon); transition: width .35s ease; }
.ticks { grid-column: 1 / -1; display: flex; gap: 3px; min-height: 8px; }
.ticks i { width: 8px; height: 8px; border: 1px solid rgba(250, 247, 242, 0.35); }
.ticks i.ok { background: var(--bone); border-color: var(--bone); }
.ticks i.no { background: var(--nihon); border-color: var(--nihon); }

/* ---------- setup ---------- */

.setup {
  position: absolute; left: var(--hud-pad); top: calc(var(--hud-pad) + 72px); bottom: var(--hud-pad);
  width: min(420px, calc(100% - 2 * var(--hud-pad))); padding: 22px 22px 18px;
  display: flex; flex-direction: column; overflow: auto; overscroll-behavior: contain;
}
.setup-title { font-size: clamp(24px, 2.4vw, 30px); margin: 0 0 18px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); margin-bottom: 14px; }
.seg button, .presets button, .tabs button {
  border: 0; border-radius: 0; background: none; color: var(--gray-cool); cursor: pointer;
  font-family: var(--tight); font-weight: 700; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 11px 6px; transition: color .15s, background-color .15s;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button span { font-family: var(--serif); font-size: 15px; letter-spacing: 0; text-transform: none; margin-right: 4px; color: var(--bone); }
.seg button[aria-checked="true"] { background: var(--bone); color: var(--ink); }
.seg button[aria-checked="true"] span { color: var(--nihon); }
.seg button:hover:not([aria-checked="true"]), .presets button:hover, .tabs button:hover { color: var(--bone); }
.seg button:focus-visible, .presets button:focus-visible, .tabs button:focus-visible, .row-chip:focus-visible { outline: 1px solid var(--bone); outline-offset: -3px; }

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 18px; }
.presets button { border: 1px solid var(--line); padding: 9px 4px; font-size: 10px; letter-spacing: 0.12em; }
.presets button.on { border-color: var(--nihon); color: var(--bone); background: rgba(188, 0, 45, 0.18); }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { padding: 10px 4px 11px; text-align: left; position: relative; display: flex; justify-content: space-between; gap: 6px; }
.tabs button .n { color: var(--gray-warm); letter-spacing: 0.06em; }
.tabs button[aria-selected="true"] { color: var(--bone); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--nihon); }
.tabs button .n.some { color: var(--nihon-on-dark); }

.rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; align-content: start; margin-bottom: 14px; flex: 0 1 auto; min-height: 96px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.rows.yoon { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-chip {
  display: grid; grid-template-columns: 14px 1fr; align-items: center; gap: 10px; text-align: left;
  border: 1px solid var(--line); background: rgba(250, 247, 242, 0.02); color: var(--bone); border-radius: 0; cursor: pointer;
  padding: 9px 10px; min-height: 44px; transition: border-color .15s, background-color .15s;
}
.row-chip .box { width: 12px; height: 12px; border: 1px solid var(--line-strong); }
.row-chip .kana { font-family: var(--serif); font-size: 16px; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 1.2; }
.row-chip .rl { display: block; font-family: var(--tight); font-weight: 700; font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gray-cool); margin-bottom: 2px; }
.row-chip[aria-pressed="true"] { border-color: rgba(232, 72, 104, 0.7); background: rgba(188, 0, 45, 0.14); }
.row-chip[aria-pressed="true"] .box { background: var(--nihon); border-color: var(--nihon); }
.row-chip:hover { border-color: var(--line-strong); }

.btn-primary, .btn-line, .cta-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 0; cursor: pointer; text-decoration: none;
  font-family: var(--tight); font-weight: 700; font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase;
  min-height: 50px; padding: 0 22px; transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--nihon); color: var(--bone); border: 1px solid var(--nihon); }
.btn-primary:hover { background: #a10027; }
.btn-primary:focus-visible, .btn-line:focus-visible, .cta-link:focus-visible { outline: 1px solid var(--bone); outline-offset: 3px; }
.btn-primary:disabled { background: transparent; border-color: var(--line); color: var(--gray-warm); cursor: default; }
.btn-line { background: none; color: var(--bone); border: 1px solid var(--line-strong); }
.btn-line:hover { border-color: var(--bone); }
#start { margin-top: auto; width: 100%; flex: none; }
#start-count { color: rgba(250, 247, 242, 0.7); letter-spacing: 0.12em; }
.setup-hint { margin: 12px 0 0; font-size: 12.5px; color: var(--gray-cool); text-align: center; max-width: none; }

/* ---------- prompt card ---------- */

.prompt { position: absolute; left: var(--hud-pad); top: 50%; transform: translateY(-46%); width: 290px; }
.card {
  position: relative; background: var(--bone); color: var(--ink); padding: 18px 22px 18px;
  border-top: 3px solid var(--nihon);
}
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 1px; background: var(--bone); border-bottom: 1px solid var(--nihon); }
.card-eyebrow { display: flex; justify-content: space-between; color: var(--nihon); margin: 6px 0 0; font-size: 10.5px; }
.card-eyebrow #pr-count { color: var(--gray-warm); letter-spacing: 0.12em; }
.char {
  font-family: var(--serif); font-weight: 700; font-size: 150px; line-height: 1; text-align: center;
  padding: 26px 0 30px; white-space: nowrap; letter-spacing: -0.02em;
}
.char.long { font-size: 112px; padding: 46px 0 48px; }
.card-seal {
  position: absolute; right: 18px; top: 46px; width: 46px; height: 46px; display: grid; place-items: center;
  background: var(--nihon); color: var(--bone); font-family: var(--serif); font-weight: 700; font-size: 27px;
  transform: rotate(-8deg) scale(1.6); opacity: 0; pointer-events: none;
}
.card.stamped .card-seal { animation: stamp .5s cubic-bezier(.2, .9, .3, 1.2) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: rotate(-14deg) scale(1.9); } 45% { opacity: 1; transform: rotate(-8deg) scale(0.94); } 100% { opacity: 0.92; transform: rotate(-8deg) scale(1); } }
.card.miss .char { color: var(--nihon); }
.card.shake .char { animation: shake .42s ease; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.answer { display: block; border-top: 1px solid var(--hairline-light); padding-top: 12px; }
#answer {
  width: 100%; border: 0; border-bottom: 1.5px solid var(--ink); background: transparent; color: var(--ink); border-radius: 0;
  font-family: var(--tight); font-weight: 700; font-size: 26px; letter-spacing: 0.2em; text-transform: lowercase; text-align: center;
  padding: 6px 0 8px; outline: none;
}
#answer::placeholder { color: rgba(26, 26, 26, 0.26); letter-spacing: 0.24em; font-size: 14px; text-transform: uppercase; }
#answer:focus { border-bottom-color: var(--nihon); }
.card.miss #answer { border-bottom-color: var(--nihon); }
.card-hint { margin: 10px 0 0; text-align: center; font-family: var(--tight); font-weight: 700; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gray-warm); max-width: none; }

/* ---------- reveal ---------- */

.reveal { position: absolute; right: var(--hud-pad); top: calc(var(--hud-pad) + 236px); width: 300px; padding: 18px 20px 14px; }
.reveal.enter { animation: slide-in .32s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.rules-mark { margin: -4px 0 14px; }
.rules-mark::before, .rules-mark::after { content: ""; display: block; width: 52px; background: var(--nihon); }
.rules-mark::before { height: 1px; }
.rules-mark::after { height: 3px; margin-top: 3px; }
.rv-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 2px; }
.rv-char { font-family: var(--serif); font-weight: 700; font-size: 44px; line-height: 1; color: var(--bone); }
.rv-romaji { font-family: var(--serif); font-weight: 700; font-size: 44px; line-height: 1; color: var(--nihon-on-dark); letter-spacing: 0.02em; }
.rv-alt { font-family: var(--tight); font-weight: 700; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gray-cool); margin: 8px 0 12px; min-height: 1px; }
.rv-diag { font-size: 13.5px; line-height: 1.5; color: var(--bone); margin: 0 0 12px; padding: 2px 0 2px 11px; border-left: 2px solid var(--nihon); }
.rv-mnemonic { font-family: var(--serif); font-size: 16px; line-height: 1.5; margin: 0 0 10px; }
.rv-note, .rv-example { font-size: 13px; line-height: 1.5; color: var(--gray-cool); margin: 0 0 8px; }
.rv-example b { font-family: var(--serif); color: var(--bone); font-weight: 700; margin-right: 6px; }
.rv-note:empty, .rv-example:empty, .rv-mnemonic:empty, .rv-alt:empty { display: none; }
.rv-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid rgba(250, 247, 242, 0.1); padding-top: 10px; margin: 6px 0 0; font-size: 12px; color: var(--gray-cool); max-width: none; }
.rv-foot .btn-quiet { padding: 0; color: var(--bone); }

/* ---------- results ---------- */

.results {
  position: absolute; left: var(--hud-pad); top: calc(var(--hud-pad) + 72px); bottom: var(--hud-pad);
  width: min(430px, calc(100% - 2 * var(--hud-pad))); padding: 22px 22px 18px; overflow: auto; overscroll-behavior: contain;
}
/* the panel scrolls, so its inset hairline is an outline that stays put */
.results::before { display: none; }
.results { outline: 1px solid rgba(250, 247, 242, 0.07); outline-offset: -4px; }
.res-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.res-big { display: grid; }
.res-big .num { font-family: var(--serif); font-weight: 700; font-size: 60px; line-height: 0.9; letter-spacing: -0.02em; }
.res-big .label { color: var(--gray-cool); margin-top: 10px; font-size: 10px; }
.res-facts { display: grid; gap: 6px; margin: 0; }
.res-facts div { display: flex; justify-content: space-between; gap: 18px; }
dt { color: var(--gray-cool); font-size: 10px; align-self: center; }
dd { margin: 0; font-family: var(--tight); font-weight: 700; font-size: 15px; letter-spacing: 0.04em; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 0 0; font-size: 12px; color: var(--gray-cool); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 7px; vertical-align: -1px; }
.lg-clean { background: var(--bone); }
.lg-shaky { background: #8c8174; }
.lg-missed { background: var(--nihon); }
.res-sub { color: var(--nihon-on-dark); margin: 14px 0 8px; }
.missed { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
.missed li { border: 1px solid var(--line); padding: 5px 2px 4px; text-align: center; }
.missed li.missed-out { border-color: rgba(232, 72, 104, 0.6); }
.missed .k { display: block; font-family: var(--serif); font-weight: 700; font-size: 21px; line-height: 1.2; }
.missed .r { display: block; font-family: var(--tight); font-weight: 700; font-size: 10px; letter-spacing: 0.1em; color: var(--gray-cool); }
.missed .none { grid-column: 1 / -1; border: 0; text-align: left; padding: 0; color: var(--gray-cool); font-size: 14px; }
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-actions .btn-primary, .res-actions .btn-line { padding: 0 10px; font-size: 11px; letter-spacing: 0.16em; }
.res-cta { margin-top: 14px; padding: 16px; background: var(--bone); color: var(--ink); }
.res-cta p { font-size: 13.5px; line-height: 1.45; color: var(--gray-warm); margin: 0 0 12px; }
.cta-link { width: 100%; background: var(--ink); color: var(--bone); border: 1px solid var(--ink); }
.cta-link:hover { background: var(--nihon); border-color: var(--nihon); }
.small-link { display: block; text-align: center; margin-top: 12px; font-size: 13px; color: var(--gray-warm); }
.small-link:hover { color: var(--nihon); }

/* ---------- study next ---------- */

.study { padding-top: 2px; }
.study .res-sub { margin-top: 16px; }
.study-head { font-family: var(--serif); font-weight: 700; font-size: 19px; line-height: 1.38; margin: 0 0 12px; max-width: none; text-wrap: pretty; }
.verdicts { display: grid; gap: 0; border-top: 1px solid var(--line); margin-bottom: 14px; }
.verdict {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 46px; align-items: baseline; column-gap: 12px;
  padding: 8px 0 9px; border-bottom: 1px solid var(--line); position: relative;
}
.v-label, .v-word { font-family: var(--tight); font-weight: 700; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; }
.v-label { color: var(--bone); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verdict.sub .v-label { color: var(--gray-cool); padding-left: 12px; }
.v-word { color: var(--gray-cool); }
.v-mastered .v-word { color: var(--bone); }
.v-drill .v-word { color: var(--nihon-on-dark); }
.v-n { font-family: var(--tight); font-weight: 700; font-size: 12px; letter-spacing: 0.06em; text-align: right; font-variant-numeric: tabular-nums; color: var(--gray-cool); }
.v-bar { position: absolute; left: 0; bottom: -1px; width: 100%; height: 1px; }
.v-bar i { display: block; height: 100%; background: var(--bone); opacity: 0.7; }
.v-drill .v-bar i { background: var(--nihon); opacity: 1; }
.verdict.sub .v-bar i { opacity: 0.35; }

.study-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.st-item { border: 1px solid var(--line); background: rgba(250, 247, 242, 0.02); position: relative; transition: border-color .2s, background-color .2s; }
.st-item:hover, .st-item:focus-within { border-color: var(--line-strong); }
.st-item.on { border-color: var(--nihon); background: rgba(188, 0, 45, 0.1); }
.st-main {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; width: 100%;
  padding: 12px; background: none; border: 0; color: inherit; text-align: left; cursor: pointer; font: inherit;
}
.st-main:focus-visible { outline: 1px solid var(--bone); outline-offset: -4px; }
.st-glyphs { display: flex; gap: 4px; width: 104px; margin-bottom: 42px; /* room for Drill this */ }
.sg { display: grid; justify-items: center; width: 50px; padding: 5px 0 4px; background: #e9e2d6; color: var(--ink); }
.sg + .sg { background: transparent; color: var(--bone); outline: 1px solid var(--line-strong); outline-offset: -1px; }
.sg-k { font-family: var(--serif); font-weight: 700; font-size: 34px; line-height: 1.12; white-space: nowrap; }
.sg-r { font-family: var(--tight); font-weight: 700; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gray-warm); }
.sg + .sg .sg-r { color: var(--gray-cool); }
.st-row .st-glyphs, .st-rule .st-glyphs { flex-wrap: wrap; }
.st-row .st-glyphs { gap: 3px; }
.sg.sm, .sg.sm + .sg.sm { width: 32px; padding: 3px 0 2px; background: transparent; color: var(--bone); outline: 1px solid var(--line); outline-offset: -1px; }
.sg.sm .sg-k { font-size: 19px; }
.sg.sm .sg-r { font-size: 8px; letter-spacing: 0.08em; color: var(--gray-cool); }
.sg.sm.miss, .sg.sm + .sg.sm.miss { background: var(--nihon); outline-color: var(--nihon); }
.sg.sm.miss .sg-r, .sg.sm + .sg.sm.miss .sg-r { color: rgba(250, 247, 242, 0.75); }
.st-body { display: grid; gap: 3px; min-width: 0; }
.st-kicker { display: flex; gap: 8px; font-family: var(--tight); font-weight: 700; font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gray-cool); }
.st-kicker b { color: var(--nihon-on-dark); font-weight: 700; }
.st-title { font-family: var(--serif); font-weight: 700; font-size: 16px; line-height: 1.3; color: var(--bone); }
.st-tip { font-size: 13px; line-height: 1.48; color: var(--gray-cool); }
.st-recur { font-size: 12.5px; line-height: 1.4; color: var(--nihon-on-dark); margin-top: 2px; }
/* sits in the free space under the glyphs, the same width as the pair */
.st-drill {
  position: absolute; left: 12px; bottom: 12px; width: 104px; padding: 8px 0; background: none; color: var(--bone); cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 0;
  font-family: var(--tight); font-weight: 700; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
}
.st-drill:hover { border-color: var(--nihon); background: var(--nihon); }
.st-drill:focus-visible { outline: 1px solid var(--bone); outline-offset: 2px; }
.study-all { width: 100%; margin-bottom: 4px; }
.study.empty .study-list, .study.empty .study-all { display: none; }

/* ---------- phases ---------- */

.stage[data-phase="boot"] .hud > :not(.status):not(.toolbar) { display: none; }
.stage:not([data-phase="play"]):not([data-phase="reveal"]) .stats { display: none; }
.stage[data-phase="results"] .stats { display: none; }

/* ---------- 2D fallback board ---------- */

.board2d {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 90px 24px 24px;
}
.b2-grid {
  display: grid; grid-template-columns: repeat(16, var(--cell)); grid-auto-rows: var(--cell); gap: var(--gap);
  padding: calc(var(--cell) * 0.35); background: #141316; border: 1px solid var(--line); position: relative;
  --cell: 40px; --gap: 4px;
}
.b2-grid::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(250, 247, 242, 0.08); pointer-events: none; }
.b2-label { display: grid; place-items: center; font-family: var(--tight); font-weight: 700; font-size: calc(var(--cell) * 0.24); letter-spacing: 0.14em; color: rgba(250, 247, 242, 0.42); text-transform: uppercase; transition: opacity .3s; }
.board2d.playing .b2-label { opacity: 0; }
.b2-tile {
  position: relative; display: grid; place-items: center; background: #e9e2d6; color: var(--ink);
  font-family: var(--serif); font-weight: 700; font-size: calc(var(--cell) * 0.5); line-height: 1; white-space: nowrap;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), background-color .3s, color .3s, opacity .3s;
  border: 1px solid rgba(26, 26, 26, 0.2); cursor: default; padding: 0;
}
.b2-tile.long { font-size: calc(var(--cell) * 0.34); letter-spacing: -0.04em; }
.b2-tile.off { background: #2a2725; color: rgba(250, 247, 242, 0.24); border-color: transparent; }
.b2-tile.facedown { color: transparent; }
.b2-tile.facedown::after { content: ""; width: 26%; height: 26%; border: 1px solid rgba(26, 26, 26, 0.18); border-radius: 50%; position: absolute; }
.b2-tile.target { transform: scale(1.18); z-index: 2; outline: 2px solid var(--nihon); outline-offset: 2px; color: var(--ink); }
.b2-tile.target::after { display: none; }
.b2-tile.sealed::before { content: ""; position: absolute; right: 8%; bottom: 8%; width: 24%; height: 24%; background: var(--nihon); transform: rotate(-8deg); }
.b2-tile.shaky { background: #8c8174; color: var(--bone); }
.b2-tile.missed { background: var(--nihon); color: var(--bone); }
.b2-tile.strong { background: #f6f1e8; }
.b2-tile.weak { background: #dfc9c6; }
.b2-tile.shake { animation: shake .42s ease; }
.b2-tile.dim { opacity: 0.28; }
.b2-tile.hl { transform: scale(1.12); z-index: 2; outline: 2px solid var(--bone); outline-offset: 2px; }
.b2-tile.off.hl { background: #e9e2d6; color: var(--ink); }
.b2-tile.pulse { animation: pulse .6s ease both; }
@keyframes pulse { 0% { filter: brightness(1); } 40% { filter: brightness(1.18); } 100% { filter: brightness(1); } }
.b2-plate { grid-column: 8 / span 5; grid-row: 7 / span 6; display: grid; place-items: center; align-content: center; gap: 8px; color: rgba(250, 247, 242, 0.5); }
.b2-plate .disc { width: calc(var(--cell) * 1.6); height: calc(var(--cell) * 1.6); border-radius: 50%; background: var(--nihon); opacity: 0.85; }
.b2-plate .nm { font-family: var(--serif); font-size: calc(var(--cell) * 0.42); color: rgba(250, 247, 242, 0.6); letter-spacing: 0.2em; }

/* ---------- SEO block ---------- */

.seo { padding-block: clamp(56px, 8vw, 104px); border-top: 1px solid var(--hairline-dark); }
.seo-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.seo h1 { font-size: clamp(32px, 4.4vw, 52px); }
.seo a { color: var(--bone); text-decoration-color: var(--nihon); text-underline-offset: 3px; }
.noscript { position: absolute; inset: auto 0 40% 0; text-align: center; margin: 0 auto; color: var(--gray-cool); }

/* ---------- desktop: give the reveal and the prompt room ---------- */

@media (min-width: 1500px) {
  .prompt { width: 320px; }
  .char { font-size: 170px; }
}

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  .kana-page { --mast: 56px; --hud-pad: 10px; }
  .masthead .wrap { min-height: 56px; }
  .stage { height: calc(100svh - var(--mast)); min-height: 560px; }

  /* While a round runs the stage takes over the visual viewport so the input
     and the character stay above the on-screen keyboard. */
  .kana-page.immersive { overflow: hidden; }
  .kana-page.immersive .stage {
    position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vv-h, 100svh); min-height: 0; z-index: 30;
  }

  .status { padding: 6px 10px 6px 6px; min-height: 44px; gap: 9px; max-width: calc(100% - 232px); }
  .seal { width: 28px; height: 28px; font-size: 16px; }
  .status .label { font-size: 9px; letter-spacing: 0.2em; }
  .status .value { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toolbar { gap: 4px; }
  .tool { width: 40px; height: 40px; }
  .tool svg { width: 18px; height: 18px; }
  .tip { display: none; }
  .settings { top: 58px; right: 10px; left: 10px; width: auto; }

  .stats {
    top: 60px; left: var(--hud-pad); right: var(--hud-pad); width: auto; padding: 8px 12px;
    grid-template-columns: auto auto 1fr; gap: 4px 16px; align-items: center;
  }
  .stats .stat { grid-auto-flow: column; align-items: baseline; gap: 8px; justify-content: start; }
  .stat .num { font-size: 18px; }
  .stat-progress { grid-column: auto; grid-template-columns: auto auto; justify-content: end; }
  .stat-progress .num { font-size: 12px; }
  .bar { position: absolute; left: 0; right: 0; bottom: -1px; margin: 0; height: 2px; }
  .ticks { display: none; }

  .setup {
    top: auto; bottom: var(--hud-pad); max-height: 56%; padding: 14px 14px 12px;
    width: auto; right: var(--hud-pad);
  }
  .setup .panel-eyebrow { margin-bottom: 10px; }
  .setup-title { display: none; }
  .seg { margin-bottom: 10px; }
  .seg button { padding: 10px 4px; }
  .row-chip { min-height: 46px; padding: 6px 9px; }
  .presets { grid-template-columns: repeat(2, 1fr); margin-bottom: 12px; }
  .rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rows.yoon { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #start { margin-top: 4px; }
  .setup-hint { display: none; }

  .prompt { left: var(--hud-pad); right: var(--hud-pad); top: auto; bottom: var(--hud-pad); transform: none; width: auto; }
  .card { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto auto; column-gap: 14px; padding: 10px 14px 12px; }
  .card-eyebrow { grid-column: 1 / -1; margin: 2px 0 4px; }
  .char, .char.long { grid-row: 2 / span 2; font-size: 76px; padding: 4px 0 2px; align-self: center; }
  .char.long { font-size: 52px; }
  .card-seal { top: 34px; right: 12px; width: 34px; height: 34px; font-size: 19px; }
  .answer { border-top: 0; padding-top: 6px; align-self: end; }
  #answer { font-size: 22px; text-align: left; padding: 4px 0 6px; }
  .card-hint { text-align: left; margin-top: 6px; font-size: 9px; }

  .reveal { left: var(--hud-pad); right: var(--hud-pad); width: auto; top: auto; bottom: calc(var(--hud-pad) + var(--prompt-h, 150px) + 8px); padding: 12px 14px 10px; max-height: calc(100% - var(--prompt-h, 150px) - 120px); overflow: auto; }
  .rules-mark { display: none; }
  .reveal .panel-eyebrow { margin-bottom: 6px; }
  .rv-char, .rv-romaji { font-size: 32px; }
  .rv-alt { margin: 4px 0 6px; }
  .rv-mnemonic { font-size: 14.5px; margin-bottom: 6px; }
  .rv-note { display: none; }
  .rv-foot span { display: none; }

  .status .label { white-space: nowrap; }
  .results { top: auto; bottom: var(--hud-pad); right: var(--hud-pad); width: auto; max-height: 68%; padding: 14px 14px 12px; }
  .res-top { padding-bottom: 10px; }
  .res-big .num { font-size: 46px; }
  .res-big .label { margin-top: 6px; }
  .legend { font-size: 11px; padding-top: 8px; }
  .res-sub { margin: 10px 0 6px; }
  .missed { margin-bottom: 10px; }
  .res-cta { margin-top: 10px; padding: 12px; }
  .res-cta p { display: none; }
  .study-head { font-size: 17px; }
  .st-main { gap: 11px; padding: 10px; }
  .sg { width: 44px; }
  .sg-k { font-size: 29px; }
  .st-glyphs { width: 92px; margin-bottom: 44px; }
  .st-row .st-glyphs { gap: 2px; }
  .sg.sm, .sg.sm + .sg.sm { width: 29px; }
  .sg.sm .sg-k { font-size: 17px; }
  .st-drill { left: 10px; bottom: 10px; width: 92px; padding: 10px 0; }
  .small-link { margin-top: 8px; }

  .seo-grid { grid-template-columns: minmax(0, 1fr); }
  .board2d { padding: 108px 10px 180px; align-items: start; }
}

@media (max-width: 760px) and (max-height: 520px) {
  /* keyboard open on a short screen: drop the stats strip */
  .kana-page.immersive .stats { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card.shake .char, .b2-tile.shake { animation: none; }
  .reveal.enter { animation: none; }
}
.stage.reduce-motion .card.shake .char, .stage.reduce-motion .b2-tile.shake { animation: none; }

.stage:fullscreen { height: 100vh; min-height: 0; }
