:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2c313c;
  --text: #e8e9ec;
  --muted: #8b90a0;
  --accent: #b88cff;
  --good: #4fd18b;
  --warn: #f0b84a;
  --bad: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* `hidden` must win over any class that sets display (.row is flex): it hid nothing on the rename form. */
[hidden] { display: none !important; }
/* Scene backgrounds: the splash on the name and pack-picker screens, each pack's own inside it (set by
   setScene in app.ts). A dark gradient keeps the game readable; only the active image is downloaded. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(15, 17, 21, 0.72), rgba(15, 17, 21, 0.86) 60%, rgba(15, 17, 21, 0.94)),
    var(--scene, none) center / cover no-repeat;
}
body[data-scene="splash"] { --scene: url("/img/splash.webp"); }
body[data-scene="mtg"] { --scene: url("/img/mtg.webp"); }
body[data-scene="pokemon"] { --scene: url("/img/pokemon.webp"); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
header, main, footer { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px; }
header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 20px; }
#day-label { text-align: right; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.04em; color: var(--accent); }
h1 a.home { color: inherit; text-decoration: none; }
h2 { margin: 0 0 8px; font-size: 1.15rem; }
.tagline { margin: 0 0 14px; font-size: 1.05rem; color: var(--muted); font-style: italic; }
main { flex: 1; padding-top: 16px; padding-bottom: 32px; }
footer { color: var(--muted); font-size: 0.72rem; padding-bottom: 20px; }
footer a { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.card {
  background: rgba(24, 27, 34, 0.93); /* --panel, slightly see-through over the scene */
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}
.prompt-text { font-size: 1.35rem; font-weight: 600; line-height: 1.35; margin: 6px 0 4px; }

input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }
button, a.button {
  display: inline-block;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #15101f;
  cursor: pointer;
}
button.secondary, a.button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

.timer { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin: 12px 0 4px; }
.timer > div { height: 100%; background: var(--accent); transition: width 0.25s linear; }
.timer.low > div { background: var(--bad); }
.timer-row { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); }

.feedback { list-style: none; padding: 0; margin: 12px 0 0; font-size: 0.92rem; }
.feedback li { padding: 4px 0; }
.feedback .wrong { color: var(--warn); }
.feedback .unknown { color: var(--bad); }
.feedback .ambiguous { color: var(--text); }
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
button.choice { padding: 6px 10px; font-size: 0.88rem; font-weight: 500; text-align: left; }

.tier-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
}
.tier-gem { border-color: #6fd3ff; color: #6fd3ff; }
.tier-forgotten { border-color: #b88cff; color: #b88cff; }
.tier-deep { border-color: #5b9dff; color: #5b9dff; }
.tier-niche { border-color: var(--good); color: var(--good); }
.tier-playable { border-color: var(--warn); color: var(--warn); }
.tier-miss { color: var(--muted); }
.answer-name { font-size: 1.25rem; font-weight: 700; margin: 4px 0; }
.points { font-size: 2rem; font-weight: 800; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
td { padding: 7px 4px; border-top: 1px solid var(--border); vertical-align: top; }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.me td { color: var(--accent); font-weight: 700; }
table.examples td { padding: 4px; font-size: 0.88rem; }
details { border-top: 1px solid var(--border); padding: 8px 0; }
details:first-child { border-top: 0; }
summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }
details table { margin-top: 6px; }
.total-of { font-size: 1rem; }
.total { font-size: 2.6rem; font-weight: 800; margin: 0; }
.grid { font-size: 1.6rem; letter-spacing: 2px; }
.legend { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; font-size: 0.9rem; }

.banner {
  background: #2a2140;
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

/* Difficulty selector (packs with Normal / Hard / Insane) and the one-time recovery code. */
.difficulty { gap: 0.5rem; flex-wrap: wrap; }
.difficulty .button { flex: 1 1 0; text-align: center; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; user-select: all; }

/* "Report a problem" under each reveal: quiet text link, small form. */
.report { margin-top: 12px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 400; text-decoration: underline; cursor: pointer; }
.report select, .report textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }

/* ---------- Descent (src/client/descent): canvas for the shaft, DOM for anything with text ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.descent { position: relative; height: min(62vh, 540px); min-height: 320px; margin-bottom: 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #07060a; }
.descent-stage { position: absolute; inset: 0; transition: opacity 0.22s ease; will-change: transform; }
.descent-stage.dim { opacity: 0; }
.descent canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.descent-labels { position: absolute; inset: 0; pointer-events: none; }
/* Text on the shaft always sits on a dark pill, so it reads at any depth, the darkest strata included. */
.relic, .xs { position: absolute; left: 0; top: 0; will-change: transform; transition: opacity 0.4s ease; }
.relic { display: flex; align-items: center; gap: 6px; }
.relic.left { flex-direction: row-reverse; }
.relic.gone { opacity: 0; }
.relic-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--relic); box-shadow: 0 0 8px 2px var(--relic); }
.relic-label { min-width: 0; font-size: 0.72rem; line-height: 1.3; padding: 1px 7px; border-radius: 999px; background: rgba(10, 9, 12, 0.8); color: #f4efe6; border: 1px solid var(--relic); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.relic.new .relic-dot { animation: relic-in 0.7s ease-out; }
@keyframes relic-in { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.6); opacity: 1; } 100% { transform: scale(1); } }
.descent-hud { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.descent.revealed .descent-hud { top: auto; bottom: 10px; } /* names fill the top in the cross-section */
.descent-secs { display: inline-block; margin-top: 5px; font-size: 0.8rem; font-variant-numeric: tabular-nums; padding: 2px 9px; border-radius: 999px; background: rgba(10, 9, 12, 0.78); color: #f3d9a4; pointer-events: none; }
.descent-secs:empty { display: none; }
.descent-secs.low { color: #ffb0a0; }
/* A brass-cased mechanical counter: dark drums shaded at top and bottom. */
.odo { display: inline-flex; align-items: center; gap: 2px; padding: 4px 6px; border-radius: 6px; border: 1px solid #a07c44;
  background: linear-gradient(180deg, #6a5230, #3a2c18 45%, #24190c); box-shadow: inset 0 1px 0 rgba(255, 220, 150, 0.35), 0 4px 12px rgba(0, 0, 0, 0.45);
  font: 700 1.5rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #f6e7c8; }
.odo-digit { position: relative; display: inline-block; height: 1em; width: 0.74em; overflow: hidden; text-align: center; border-radius: 2px;
  background: linear-gradient(180deg, #050403, #1e1912 30%, #1e1912 70%, #050403); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6); }
.odo-digit::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.75)); pointer-events: none; }
.odo-digit.lead { color: #6c6458; }
.odo-strip { display: block; will-change: transform; }
.odo-strip > span { display: block; height: 1em; }
.odo-unit { font: 600 0.6em/1 system-ui, sans-serif; margin: 0 2px 0 4px; color: #f0d9a8; }
/* The depth scale on the left edge: ticks are drawn on the canvas, the meters are these labels. */
.descent-scale { position: absolute; inset: 0; pointer-events: none; }
.descent-scale span { position: absolute; left: 0; top: 0; font: 600 0.66rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #efe2c8; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; will-change: transform; }
/* End-of-run cross-section labels. */
.xs { opacity: 0; pointer-events: none; }
.xs.show { opacity: 1; }
.xs span { display: block; font-size: 0.66rem; line-height: 1.25; padding: 1px 6px; border-radius: 6px; background: rgba(10, 9, 12, 0.78); color: #ece2d0; }
.xs-name span { writing-mode: vertical-rl; transform: rotate(180deg); max-height: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 1px; }
.xs-depth span { padding: 0 2px; font-size: 0.62rem; font-variant-numeric: tabular-nums; }
.xs.me span { color: #1a1206; background: #f3c86a; font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .relic.new .relic-dot { animation: none; }
}
.descent.reduced .relic.new .relic-dot { animation: none; }
