/* Did You Know Anime: one narrow column, flat tiles, one typeface. Colors follow Wordle's and mean
   state only: green = right, grey = wrong or out, gold = the Legend rung. Palette in docs/GAME.md. */
:root {
  --fg: #121213;
  --bg: #ffffff;
  --line: #d3d6da;
  --strong: #878a8c;
  --soft: #f4f4f5;
  --muted: #6b6f73;
  --go: #6aaa64;
  --miss: #787c7e;
  --gold: #c9b458;
  --on: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #f8f8f8;
    --bg: #121213;
    --line: #3a3a3c;
    --strong: #565758;
    --soft: #1e1e20;
    --muted: #8e9196;
    --go: #538d4e;
    --miss: #3a3a3c;
    --gold: #b59f3b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.5 "Libre Franklin", system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- header ---- */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 50px;
  padding: 0 6px;
  border-bottom: 1px solid var(--line);
}
.top .title {
  justify-self: center;
  font-weight: 800;
  font-size: clamp(17px, 4.8vw, 22px);
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.top .side { display: flex; }
.top .side.end { justify-content: flex-end; }
.icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px;
  background: none;
}
.icon:hover { background: var(--soft); }
.icon svg { width: 22px; height: 22px; }
@media (min-width: 600px) {
  .top { height: 60px; padding: 0 12px; }
}

main { width: 100%; max-width: 500px; margin: 0 auto; padding: 16px 16px 40px; flex: 1; }

/* ---- shared bits ---- */
.kicker { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; margin: 0 0 12px; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 800; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 700; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 24px;
  border: 0; border-radius: 24px;
  background: var(--fg); color: var(--bg);
  font-weight: 700; font-size: 16px;
  text-decoration: none;
}
.btn.go { background: var(--go); color: var(--on); }
.btn.ghost { background: none; color: var(--fg); box-shadow: inset 0 0 0 1px var(--strong); }
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn svg { flex: none; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--muted); font-size: 15px; }

/* ---- ladder tiles: the one thing people remember ---- */
.rungs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 0 0 18px; }
.rung {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border: 2px solid var(--line);
  font-weight: 800; font-size: 20px;
  color: var(--muted);
  user-select: none;
}
.rung.legend { border-color: var(--gold); color: var(--gold); }
.rung.now { border-color: var(--strong); color: var(--fg); animation: pop 0.1s ease-in-out; }
.rung.ok { background: var(--go); border-color: var(--go); color: var(--on); }
.rung.ok.legend { background: var(--gold); border-color: var(--gold); color: var(--on); }
.rung.out { background: var(--miss); border-color: var(--miss); color: var(--on); }
.rung.flip { animation: flip 0.5s ease-in-out; }

@keyframes pop { 0% { transform: scale(0.8); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } 60% { transform: translateY(2px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- splash: one screen, one button, like a Wordle start page ---- */
.splash { text-align: center; padding: 28px 0 0; }
.splash .rungs { max-width: 280px; margin: 0 auto 28px; }
.splash .rung { font-size: 16px; }
.splash h1 { font-size: 36px; margin: 0 0 10px; }
.splash .lede { font-size: 20px; line-height: 1.35; color: var(--fg); max-width: 340px; margin: 0 auto 28px; }
.splash .btn { max-width: 220px; margin: 0 auto; }
.splash .date { font-size: 15px; margin: 22px 0 4px; }
.splash .date b { font-weight: 700; }
.splash .fine { font-size: 14px; color: var(--muted); margin: 0; }
.also {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 36px 0 0; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; text-align: left;
}
.also:hover { border-color: var(--strong); }
.also b { display: block; font-weight: 700; }
.also span { font-size: 14px; color: var(--muted); }
.also .arrow { font-size: 20px; color: var(--muted); }

/* ---- question ---- */
.timer { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 0 0 8px; }
.timer i { display: block; height: 100%; width: 100%; background: var(--fg); transform-origin: left; }
.timer.low i { background: var(--miss); }
.qmeta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.qmeta b { color: var(--fg); font-weight: 700; font-variant-numeric: tabular-nums; }
.question { font-size: 22px; line-height: 1.3; font-weight: 700; margin: 0 0 20px; min-height: 2.6em; letter-spacing: -0.01em; }
.opts { display: grid; gap: 8px; }
.opt {
  min-height: 56px;
  padding: 10px 16px;
  border: 2px solid var(--line); border-radius: 6px;
  background: none;
  font-weight: 600; font-size: 17px;
  line-height: 1.25;
  transition: border-color 0.1s, opacity 0.2s;
}
.opt:hover:not(:disabled) { border-color: var(--strong); }
.opt:active:not(:disabled) { transform: scale(0.98); }
.opt:disabled { cursor: default; color: var(--fg); }
.opts.done .opt:not(.right):not(.wrong) { opacity: 0.45; }
.opt.right { background: var(--go); border-color: var(--go); color: var(--on); animation: bounce 0.4s ease-out; }
.opt.wrong { background: var(--miss); border-color: var(--miss); color: var(--on); animation: shake 0.6s; }
.reveal { margin: 20px 0 0; }
.reveal > * { animation: rise 0.2s ease-out; }
.reveal .pct { font-weight: 700; margin: 0 0 4px; }
.reveal .why { color: var(--muted); }
.reveal .btn { margin-top: 18px; }

/* ---- results ---- */
.result .rank { font-size: 44px; font-weight: 800; line-height: 1.05; margin: 4px 0 6px; letter-spacing: -0.03em; }
.result .rank.legend { color: var(--gold); }
.result .sub { font-size: 17px; color: var(--muted); margin: 0 0 20px; }
.result section { padding: 20px 0; border-top: 1px solid var(--line); }
.result section:first-of-type { border-top: 0; padding-top: 0; }
.result h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.stats b { display: block; font-size: 32px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats span { display: block; font-size: 12px; line-height: 1.3; color: var(--muted); }

.dist { display: grid; gap: 4px; }
.dist .row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; font-size: 13px; }
.dist .bar { min-width: 26px; padding: 1px 7px; background: var(--miss); color: var(--on); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.dist .row.me .bar { background: var(--go); }
.dist .row.me .label { font-weight: 700; }

.fell { padding: 14px 16px; background: var(--soft); border-radius: 8px; }
.fell p:last-child { margin: 0; }

.next { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.next .clock { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -0.01em; }
.next .btn { width: auto; flex: 1; max-width: 200px; }

.namebox { display: flex; gap: 8px; }
.namebox input { flex: 1; min-width: 0; }
.namebox .btn { width: auto; min-height: 48px; }
.field {
  height: 48px; padding: 0 14px;
  border: 2px solid var(--line); border-radius: 6px;
  background: var(--bg);
  font-size: 16px;
}
.field:focus { border-color: var(--strong); outline: none; }
.err { color: var(--fg); font-weight: 700; font-size: 14px; margin: 8px 0 0; }

/* ---- clues ---- */
.clues { list-style: none; padding: 0; margin: 0 0 16px; counter-reset: clue; }
.clues li {
  counter-increment: clue;
  display: grid; grid-template-columns: 28px 1fr; gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  min-height: 48px;
}
.clues li:first-child { border-top: 1px solid var(--line); }
.clues li::before { content: counter(clue); font-weight: 700; color: var(--muted); }
.clues li.hidden { color: var(--muted); }
.clues li.spare { color: var(--muted); }
.clues li .no { display: block; font-size: 13px; color: var(--muted); text-decoration: line-through; }
.squares { letter-spacing: 2px; }
.guess { position: relative; }
.guess .field { width: 100%; }
.suggest { list-style: none; margin: 4px 0 0; padding: 0; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
.suggest li { padding: 11px 14px; cursor: pointer; border-top: 1px solid var(--line); }
.suggest li:first-child { border-top: 0; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--soft); }
.suggest small { color: var(--muted); }
.guess-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.guess-row .btn + .btn { margin-top: 0; }
.answer { font-size: 32px; font-weight: 800; line-height: 1.15; margin: 4px 0 10px; letter-spacing: -0.02em; }

/* ---- modals ---- */
dialog {
  width: min(500px, 100vw - 24px);
  max-height: min(720px, 100dvh - 24px);
  padding: 0;
  border: 0; border-radius: 8px;
  background: var(--bg); color: var(--fg);
  box-shadow: 0 4px 23px rgba(0, 0, 0, 0.2);
}
dialog[open] { animation: rise 0.2s ease-out; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
@media (prefers-color-scheme: dark) { dialog { box-shadow: 0 0 0 1px var(--line); } }
.dlg { padding: 20px 20px 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin: -6px -8px 10px 0; }
.dlg-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.dlg h3 { font-size: 16px; font-weight: 700; margin: 18px 0 6px; }
.dlg ul { padding-left: 20px; margin: 0 0 8px; }
.dlg li { margin: 4px 0; }
.dlg-body > .btn { margin-top: 16px; }
.dlg-body > .btn + .btn { margin-top: 10px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 8px; padding: 3px; margin: 0 0 10px; }
.seg button { border: 0; background: none; border-radius: 6px; min-height: 38px; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
select.field { width: 100%; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

.board { list-style: none; padding: 0; margin: 12px 0 0; }
.board li { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.board li .pos { color: var(--muted); }
.board li .pts { font-weight: 700; }
.board li.me { background: var(--soft); border-radius: 6px; border-bottom-color: transparent; }
.board li.gap { display: block; text-align: center; color: var(--muted); padding: 2px; border: 0; }
.board .empty { color: var(--muted); padding: 20px 0; text-align: center; display: block; border: 0; }
.league-tools { display: flex; gap: 8px; margin: 12px 0 0; }
.league-tools .btn { min-height: 44px; font-size: 15px; }
.league-tools .btn + .btn { margin-top: 0; }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  font-weight: 700; font-size: 14px; padding: 12px 16px; border-radius: 4px;
  z-index: 10; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  animation: rise 0.15s ease-out;
}

/* ---- reading pages (facts, about) ---- */
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 18px; }
.crumbs a { color: inherit; }
.lede { font-size: 18px; color: var(--muted); }
.facts { list-style: none; padding: 0; margin: 24px 0; }
.facts li { padding: 18px 0; border-top: 1px solid var(--line); }
.facts h2 { font-size: 18px; margin: 0 0 6px; }
.facts p { margin: 0; }
.series { list-style: none; padding: 0; margin: 20px 0; }
.series a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; }
.series b { font-weight: 700; font-size: 17px; }
.series span { color: var(--muted); font-size: 14px; }
.series .n { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.aff { padding: 16px; background: var(--soft); border-radius: 8px; margin: 24px 0; }
.aff a { display: block; font-weight: 700; padding: 6px 0; }
.aff p { margin: 8px 0 0; }
.prose h2 { margin-top: 24px; }
.cta { padding: 24px 20px; border: 1px solid var(--line); border-radius: 8px; margin: 28px 0; text-align: center; }
.cta .btn { max-width: 240px; margin: 0 auto; }
.news { margin: 24px 0; }
.ad-slot { margin: 24px 0; min-height: 100px; }

footer { width: 100%; max-width: 500px; margin: 0 auto; padding: 16px 16px 24px; font-size: 12px; color: var(--muted); text-align: center; }
footer nav { display: flex; justify-content: center; gap: 18px; margin: 0 0 6px; }
footer p { margin: 0; }

@media (max-width: 360px) {
  .question { font-size: 20px; }
  .splash h1 { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
