/* rad lib */

:root {
  --paper: #f5efe4;
  --card: #fffaf1;
  --ink: #1f1b16;
  --muted: #6f665a;
  --rule: #ddd3c2;
  --hover: #ece3d3;

  --ry: #c2410c;
  --ry-bg: #fde2d2;
  --ryon: #5b3cc4;
  --ryon-bg: #e6defb;
  --laine: #b5176b;
  --laine-bg: #fbdcea;
  --ryond: #0d7468;
  --ryond-bg: #d3f0eb;

  --good: #2f7d32;
  --good-bg: #d8edd3;
  --bad: #c0262d;
  --bad-bg: #f8d6d3;
  --miss: #94610a;
  --miss-bg: #f8e8c2;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --display: "Fraunces", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --measure: 40rem;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130f;
    --card: #1f1b16;
    --ink: #efe7d9;
    --muted: #a39885;
    --rule: #3a332a;
    --hover: #2a251e;

    --ry: #ff9a66;
    --ry-bg: #45230f;
    --ryon: #b3a0ff;
    --ryon-bg: #2c2350;
    --laine: #ff8cc6;
    --laine-bg: #4a1531;
    --ryond: #6fdccb;
    --ryond-bg: #123c37;

    --good: #86cc89;
    --good-bg: #1d3820;
    --bad: #ff8f87;
    --bad-bg: #4a1d1b;
    --miss: #f0bd55;
    --miss-bg: #41300c;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

a { color: inherit; text-underline-offset: 0.15em; }

button { font: inherit; color: inherit; }

/* ---- footer ---- */

.site-footer { max-width: var(--measure); margin: 0 auto; padding: 0 1.5rem 2rem; text-align: center; color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: 0; }

/* ---- header ---- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
}

.header-left { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }

.site-nav { display: flex; gap: 0.85rem; font-size: 0.95rem; }
.site-nav a { color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; }
.site-nav a:hover { color: var(--ink); border-bottom-color: currentColor; }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ryon); }

/* The Ryon Rising badge: pops in, spins a prism border, and cycles an RGB glow. */
@property --rr-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.rr-badge {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid transparent;
  border-radius: 11px;
  background:
    linear-gradient(#140f2e, #140f2e) padding-box,
    conic-gradient(from var(--rr-a), #ff3f8e, #ffb347, #fff36b, #5dff9e, #41e2ff, #9a6bff, #ff3f8e) border-box;
  box-shadow: 0 0 10px 1px rgb(255 63 142 / 0.75), 0 0 22px 3px rgb(65 226 255 / 0.4);
  animation:
    rr-pop 700ms cubic-bezier(0.2, 1.6, 0.4, 1) 250ms backwards,
    rr-spin 3s linear infinite,
    rr-hue 4s linear infinite;
  transition: transform 150ms, box-shadow 150ms;
}
.rr-badge:hover, .rr-badge:focus-visible {
  transform: scale(1.12) rotate(-6deg);
  box-shadow: 0 0 14px 3px rgb(255 63 142 / 0.9), 0 0 32px 8px rgb(65 226 255 / 0.55);
}
.rr-badge:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.rr-badge svg { display: block; filter: drop-shadow(0 0 3px rgb(127 240 255 / 0.9)); }
.rr-spark { transform-box: fill-box; transform-origin: center; animation: rr-twinkle 1.6s ease-in-out infinite; }
@keyframes rr-pop {
  0% { transform: scale(0) rotate(-35deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: none; }
}
@keyframes rr-spin { to { --rr-a: 360deg; } }
@keyframes rr-hue { to { filter: hue-rotate(360deg); } }
@keyframes rr-twinkle { 0%, 100% { transform: scale(0.4); opacity: 0.4; } 50% { transform: scale(1.15); opacity: 1; } }

.header-actions { display: flex; gap: 0.5rem; }

/* The big "Try Ryon Rising" banner on the rad lib page: same prism border and RGB glow as the badge. */
.rr-promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 2rem;
  padding: 1.1rem 1.4rem;
  border: 3px solid transparent;
  border-radius: 18px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgb(255 63 142 / 0.28), transparent 55%) padding-box,
    radial-gradient(120% 140% at 100% 100%, rgb(65 226 255 / 0.25), transparent 55%) padding-box,
    linear-gradient(#140f2e, #140f2e) padding-box,
    conic-gradient(from var(--rr-a), #ff3f8e, #ffb347, #fff36b, #5dff9e, #41e2ff, #9a6bff, #ff3f8e) border-box;
  box-shadow: 0 0 18px 2px rgb(255 63 142 / 0.55), 0 0 42px 6px rgb(65 226 255 / 0.3);
  color: #f4f0ff;
  text-decoration: none;
  animation:
    rr-pop 700ms cubic-bezier(0.2, 1.6, 0.4, 1) 150ms backwards,
    rr-spin 3s linear infinite,
    rr-glow 4s linear infinite;
  transition: transform 150ms;
}
.rr-promo:hover, .rr-promo:focus-visible { transform: translateY(-2px) scale(1.01); }
.rr-promo:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.rr-promo-text { display: grid; gap: 0.2rem; min-width: 0; }
.rr-promo strong {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.9rem, 7vw, 2.9rem);
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ff3f8e, #ffb347, #fff36b, #5dff9e, #41e2ff, #9a6bff, #ff3f8e) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgb(255 63 142 / 0.45));
  animation: rr-shine 3s linear infinite;
}
.rr-promo small { font-size: 0.9rem; color: #d9d2f5; }
.rr-promo-go {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff3f8e, #41e2ff);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 0 16px rgb(255 63 142 / 0.7);
  transition: transform 150ms;
}
.rr-promo:hover .rr-promo-go { transform: translateX(4px); }
/* Giving Thanks to Ryon (November 2026): the holiday event's banner, above the Ryon Rising one while it runs. */
.gt-promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.25rem;
  padding: 1rem 1.3rem;
  border: 2px solid #c8742a;
  border-radius: 18px;
  background:
    radial-gradient(4px 2.5px at 14% 20%, #e8923a, transparent),
    radial-gradient(4px 2.5px at 38% 82%, #c8263c, transparent),
    radial-gradient(4px 2.5px at 62% 16%, #ffd23a, transparent),
    radial-gradient(90% 140% at 100% 50%, rgb(232 114 31 / 0.45), transparent 60%),
    linear-gradient(120deg, #2a1206, #4a1e0c 60%, #5a2a10);
  box-shadow: 0 0 22px 2px rgb(232 114 31 / 0.35);
  color: #fbeedd;
  text-decoration: none;
  transition: transform 150ms;
}
.gt-promo:hover, .gt-promo:focus-visible { transform: translateY(-2px); }
.gt-promo:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.gt-promo-text { display: grid; gap: 0.25rem; min-width: 0; }
.gt-promo strong {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.5rem, 5.5vw, 2.2rem);
  line-height: 1.05;
  background: linear-gradient(90deg, #ffd9a8, #ffb347, #e8721f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gt-promo small { font-size: 0.88rem; color: #ecd8c4; }
.gt-promo .gt-promo-tag { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #ffb347; }
.gt-promo-art { flex: none; width: 4.5rem; height: 4.5rem; filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.4)); transition: transform 150ms; }
.gt-promo:hover .gt-promo-art { transform: rotate(-6deg) scale(1.06); }
@media (max-width: 420px) { .gt-promo-art { width: 3.2rem; height: 3.2rem; } }
@media (prefers-reduced-motion: reduce) { .gt-promo, .gt-promo-art { transition: none; } }
/* December's: the same banner in red and green, with snow */
.xmas-promo {
  border-color: #2f9a5a;
  background:
    radial-gradient(3px 3px at 12% 24%, #fff, transparent),
    radial-gradient(2px 2px at 30% 78%, #fff, transparent),
    radial-gradient(3px 3px at 56% 18%, #fff, transparent),
    radial-gradient(2px 2px at 74% 70%, #fff, transparent),
    radial-gradient(90% 140% at 100% 50%, rgb(200 38 60 / 0.45), transparent 60%),
    linear-gradient(120deg, #0b2a1a, #12402a 60%, #4a0f1a);
  box-shadow: 0 0 22px 2px rgb(47 154 90 / 0.35);
  color: #f1f6ee;
}
.xmas-promo strong { background-image: linear-gradient(90deg, #ffffff, #ffd9d9, #ff6b7f); }
.xmas-promo small { color: #dcebdc; }
.xmas-promo .gt-promo-tag { color: #8fe0a8; }
/* The Extended Ryon Universe banner under it, and the page it links to: a night sky, quieter than the gacha. */
.eru-promo, .eru {
  background:
    radial-gradient(1px 1px at 18% 30%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 42% 72%, #cfd8ff, transparent),
    radial-gradient(1px 1px at 63% 22%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 81% 58%, #ffe9c7, transparent),
    radial-gradient(1px 1px at 92% 18%, #cfd8ff, transparent),
    linear-gradient(120deg, #0d1233, #24184f 60%, #3a1c5c);
  color: #f1edff;
}
.eru-promo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: -1rem 0 2rem;
  padding: 0.8rem 1.4rem;
  border: 1px solid #4b3f86;
  border-radius: 14px;
  text-decoration: none;
  transition: transform 150ms;
}
.eru-promo:hover, .eru-promo:focus-visible { transform: translateY(-1px); }
.eru-promo:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.eru-promo-text { display: grid; gap: 0.1rem; min-width: 0; }
.eru-promo strong { font-family: var(--display); font-weight: 800; font-size: 1.25rem; line-height: 1.15; }
.eru-promo small { font-size: 0.85rem; color: #c8c0ea; }
.eru {
  display: grid;
  place-content: center;
  gap: 0.5rem;
  min-height: 22rem;
  padding: 2rem 1.25rem;
  border-radius: 18px;
  text-align: center;
}
.eru h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 8vw, 3rem); line-height: 1.05; }
.eru p { margin: 0; color: #c8c0ea; font-size: 1.15rem; }

@keyframes rr-shine { to { background-position: 200% 0; } }
@keyframes rr-glow {
  0%, 100% { box-shadow: 0 0 18px 2px rgb(255 63 142 / 0.55), 0 0 42px 6px rgb(65 226 255 / 0.3); }
  33% { box-shadow: 0 0 18px 2px rgb(93 255 158 / 0.55), 0 0 42px 6px rgb(154 107 255 / 0.35); }
  66% { box-shadow: 0 0 18px 2px rgb(65 226 255 / 0.55), 0 0 42px 6px rgb(255 179 71 / 0.35); }
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
}
.icon-btn svg { fill: currentColor; }
#sound-btn .waves, #sound-btn .mute-x { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
#sound-btn .mute-x { display: none; }
#sound-btn[aria-pressed="false"] .waves { display: none; }
#sound-btn[aria-pressed="false"] .mute-x { display: block; }
#sound-btn[aria-pressed="false"] { color: var(--muted); }
.icon-btn:hover { background: var(--hover); }

/* ---- layout ---- */

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.masthead { text-align: center; margin-bottom: 1.25rem; }

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.75rem, 10vw, 4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.dateline {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dot { margin: 0 0.4em; }

/* ---- rules strip + chips ---- */

.rules {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.1rem;
  margin: 0 0 1.5rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.chip {
  display: inline-block;
  padding: 0.05em 0.5em;
  border-radius: 999px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.95em;
  line-height: 1.4;
}
.chip-ry { background: var(--ry-bg); color: var(--ry); }
.chip-ryon { background: var(--ryon-bg); color: var(--ryon); }
.chip-laine { background: var(--laine-bg); color: var(--laine); }
.chip-ryond { background: var(--ryond-bg); color: var(--ryond); }

/* ---- the passage ---- */

.passage {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: 0 1px 0 var(--rule), 0 10px 30px -18px rgb(0 0 0 / 0.25);
}

.passage p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  /* Tall enough for the small original word shown above changed ones */
  line-height: 2.4;
}

.passage-status {
  margin: 2rem 0;
  text-align: center;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
}

/* ---- start card ---- */

.start {
  padding: 2rem 1.5rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  text-align: center;
}
.start-line {
  margin: 0 0 1.25rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.5;
}
.btn-go {
  min-width: 9rem;
  padding: 0.85rem 2rem;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
}
.start .fine { margin: 1.25rem auto 0; max-width: 26rem; }

/* ---- the clock + tally, stuck to the top while you scroll ---- */

.hud {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -0.5rem 0.75rem;
  padding: 0.6rem 0.5rem 0;
  background: var(--paper);
}
.hud-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}
.time { margin: 0; color: var(--muted); font-size: 0.9rem; }
.time strong {
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.time-track {
  height: 4px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: var(--rule);
  overflow: hidden;
}
.time-bar {
  height: 100%;
  background: var(--ryon);
  transform-origin: left;
  transition: transform 250ms linear;
}
.hud.is-urgent .time strong { color: var(--bad); }
.hud.is-urgent .time-bar { background: var(--bad); }

.word {
  display: inline;
  padding: 0.1em 0.12em;
  margin: 0 -0.12em;
  border: 0;
  border-radius: 5px;
  background: none;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms;
}
button.word:hover { background: var(--hover); }
button.word:focus-visible { outline: 2px solid var(--ryon); outline-offset: 1px; }

/* Changed words: the tint sits on the replacement only, not the small original above it. */
.word .base {
  padding: 0.06em 0.16em;
  margin: 0 -0.04em;
  border-radius: 5px;
  font-weight: 600;
}
button.word:has(.base):hover { background: none; }
button.word:has(.base):hover .base { filter: brightness(0.96); }
button.word.is-ry .base { background: var(--ry-bg); color: var(--ry); }
button.word.is-ryon .base { background: var(--ryon-bg); color: var(--ryon); }
button.word.is-laine .base { background: var(--laine-bg); color: var(--laine); }
button.word.is-ryond .base { background: var(--ryond-bg); color: var(--ryond); }
button.word[aria-expanded="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---- the picker ---- */

.picker {
  position: absolute;
  z-index: 10;
  display: flex;
  gap: 0.3rem;
  padding: 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 12px 30px -10px rgb(0 0 0 / 0.35);
}
.pick {
  padding: 0.3rem 0.7rem;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}
.pick:hover { filter: brightness(0.95); }
.pick:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.pick-keep { font-weight: 400; color: var(--muted); }
.pick-ry { background: var(--ry-bg); color: var(--ry); }
.pick-ryon { background: var(--ryon-bg); color: var(--ryon); }
.pick-laine { background: var(--laine-bg); color: var(--laine); }
.pick-ryond { background: var(--ryond-bg); color: var(--ryond); }
.pick[aria-checked="true"] { box-shadow: inset 0 0 0 2px currentColor; }

ruby { ruby-position: over; }
rt {
  font-family: var(--sans);
  font-size: 0.5em;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--muted);
  user-select: none;
}
rt.struck { text-decoration: line-through; }

/* reveal */
.word.is-found .base, .word.is-free .base { background: var(--good-bg); color: var(--good); }
.word.is-free .base { opacity: 0.8; }
.word.is-wrong .base { background: var(--bad-bg); color: var(--bad); }
.word.is-wrong.is-keep .base { font-weight: 400; }
.word.is-missed .base {
  background: var(--miss-bg);
  color: var(--miss);
  box-shadow: inset 0 -2px 0 currentColor;
}

/* ---- controls ---- */

.controls {
  display: flex;
  justify-content: flex-end;
}
.results .buttons { flex-wrap: wrap; justify-content: center; }
.controls { margin-top: 1.25rem; }

.tally { margin: 0; color: var(--muted); font-size: 0.9rem; }
.tally strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.hint {
  display: inline-grid;
  place-items: center;
  width: 1.1em;
  height: 1.1em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.8em;
  cursor: help;
}

.buttons { display: flex; gap: 0.5rem; }

.btn {
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { opacity: 0.88; }
.btn-ghost { background: transparent; border-color: var(--rule); }
.btn-ghost:hover { background: var(--hover); }
.btn-wide { width: 100%; }

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

.results { margin-top: 2rem; }

.score { text-align: center; }
.score-line {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  line-height: 1;
}
.score-big { font-size: 3.5rem; }
.score-total { margin-left: 0.4rem; font-size: 1.25rem; color: var(--muted); }
.flavor {
  margin: 0.6rem 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
}
.score-detail { margin: 0.35rem 0 0; color: var(--muted); }
.score-detail.fine { font-size: 0.85rem; }
.crowd {
  display: inline-block;
  margin: 0.75rem 0 0;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--ryon-bg);
  color: var(--ryon);
  font-size: 0.9rem;
  font-weight: 600;
}

.key {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin: 1rem 0 2rem;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.swatch {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.35em;
  border-radius: 3px;
  vertical-align: -0.05em;
}
.swatch.found { background: var(--good); }
.swatch.wrong { background: var(--bad); }
.swatch.missed { background: var(--miss); }

.results h2 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
}

.rad-version {
  margin: 0;
  padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 3px solid var(--ryon);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.6;
}

.rad-version .rv-ry { color: var(--ry); font-weight: 600; }
.rad-version .rv-ryon { color: var(--ryon); font-weight: 600; }
.rad-version .rv-laine { color: var(--laine); font-weight: 600; }
.rad-version .rv-ryond { color: var(--ryond); font-weight: 600; }

.source {
  margin: 0.75rem 0 1.5rem 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.next {
  margin: 1.5rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.next strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- dialogs ---- */

.sheet {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 60px -20px rgb(0 0 0 / 0.45);
}
.sheet::backdrop { background: rgb(20 16 10 / 0.45); }
.sheet h2 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.75rem;
}
.sheet p { margin: 0 0 0.9rem; }

.sheet-close {
  float: right;
  width: 2rem;
  height: 2rem;
  margin: -0.5rem -0.5rem 0 0;
  border: 0;
  border-radius: 999px;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:hover { background: var(--hover); }

.help-rules { margin: 0 0 1rem; padding-left: 1.1rem; }
.help-rules li { margin-bottom: 0.45rem; }
.eg { display: block; color: var(--muted); font-size: 0.85rem; font-style: italic; }

.example {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--paper);
  font-family: var(--serif);
  font-size: 1.1rem;
}
.example p { margin: 0; }
.example-before { color: var(--muted); }
.example-before::after { content: " ↓"; }

.fine { color: var(--muted); font-size: 0.85rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  row-gap: 1rem;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.stats div { text-align: center; }
.stats dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stats dt { color: var(--muted); font-size: 0.8rem; }
.stats div { display: flex; flex-direction: column-reverse; }

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms, transform 150ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 404 ---- */

.lost { text-align: center; padding-top: 3rem; }
.lost h1 { font-family: var(--display); font-weight: 800; font-size: 3rem; margin: 0 0 0.5rem; }
.lost p { color: var(--muted); }

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

.dash { max-width: 48rem; margin: 0 auto; }
main:has(.dash) { max-width: 52rem; }
.dash h2 {
  margin: 2rem 0 0.5rem;
  font-family: var(--display);
  font-size: 1.25rem;
}
.dash h3 { margin: 1.25rem 0 0.5rem; font-size: 1rem; }
.dash h2 + .fine { margin: -0.25rem 0 0.5rem; }
.dash .stats { margin-top: 0.5rem; }

.key-form { max-width: 22rem; margin: 2rem auto; }
.key-form label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.key-row { display: flex; gap: 0.5rem; }
.key-row input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
}
.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data th, .data td { padding: 0.45rem 0.7rem; text-align: left; white-space: nowrap; }
.data th { color: var(--muted); font-weight: 600; font-size: 0.8rem; border-bottom: 1px solid var(--rule); }
.data td { border-bottom: 1px solid var(--rule); }
.data tr:last-child td { border-bottom: 0; }
.data .n { text-align: right; font-variant-numeric: tabular-nums; }
.data .empty { color: var(--muted); text-align: center; }
.data tr.pickable { cursor: pointer; }
.data tr.pickable:hover, .data tr.pickable:focus-visible { background: var(--hover); outline: none; }
.data tr.is-picked { background: var(--ryon-bg); }

.day-detail { scroll-margin-top: 1rem; }
.histogram {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.35rem;
  height: 9rem;
  padding: 0.75rem 0.75rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--card);
}
.histogram .bar { display: flex; flex-direction: column; min-width: 0; }
.histogram .track { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.histogram .fill { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--ryon); }
.histogram .count { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.histogram .label { padding: 0.2rem 0; font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.dash-foot { margin-top: 2rem; }
.link-btn { padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; cursor: pointer; font-size: inherit; }

/* ---- small screens ---- */

@media (max-width: 540px) {
  .site-header { padding: 0.85rem 1rem; }
  .wordmark { display: none; }
  /* With the game's buttons in the header, the links get their own row. */
  .site-header:has(.header-actions) { flex-wrap: wrap; row-gap: 0.6rem; }
  .site-header:has(.header-actions) .header-left { display: contents; }
  .site-header:has(.header-actions) .site-nav { order: 3; width: 100%; }
  .site-nav a { white-space: nowrap; }
  main { padding: 1.5rem 1rem 3rem; }
  .passage { padding: 1.1rem 1rem 1rem; }
  .passage p { font-size: 1.15rem; line-height: 2.35; }
  .controls { justify-content: center; }
  .stats { grid-template-columns: repeat(3, 1fr); row-gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .rr-badge, .rr-spark, .rr-promo, .rr-promo strong { animation: none; }
}
