/* Light like the original; dark when the computer is set to dark. */
:root {
  --bg: #f6f6f4; --surface: #fdfdfc; --ink: #1d2a30; --muted: #6c7276; --line: #dfdedb;
  --gold: #c8902a; --tag: #ebeae6;
  --st-a: #eef1f3; --st-b: #a3abb1; --st-c: #5e676e; --st-edge: #48505a; --ghost: #b8bbbd;
  --shadow: 0 12px 26px rgba(29, 42, 48, .07), 0 1px 2px rgba(29, 42, 48, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181b; --surface: #1d2226; --ink: #ecebe6; --muted: #9da3a7; --line: #30373c;
    --gold: #e0a94a; --tag: #262c31;
    --st-a: #dfe4e8; --st-b: #8f989f; --st-c: #555e65; --st-edge: #20262a; --ghost: #4a5258;
    --shadow: 0 12px 26px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 17px/1.55 Newsreader, Georgia, serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
b, .btn, .eyebrow, .tag, .icon-btn, .bar, .gold { font-family: Geist, system-ui, sans-serif; }
.gold { color: var(--gold); font-weight: 600; }

.btn {
  display: inline-block; border: 0; border-radius: 7px; padding: 12px 22px; min-width: 216px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15.5px; transition: transform .12s, opacity .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px dashed #9da2a5; }
.btn.sm { min-width: 0; padding: 9px 16px; font-size: 14px; }

.eyebrow { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0; }
.eyebrow.center { text-align: center; }

/* ---------- home ---------- */
.home { max-width: 560px; margin: 0 auto; padding: 44px 16px 40px; text-align: center; }
.logo { font-size: inherit; font-weight: inherit; display: flex; align-items: center; justify-content: center; margin: 0 auto 30px; max-width: 520px; }
.logo-card {
  flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  font: 700 clamp(30px, 8vw, 46px)/1 Geist, sans-serif; letter-spacing: -.02em; padding: 18px clamp(16px, 4vw, 34px) 20px; position: relative; z-index: 1;
}
.logo-chain { flex: 1 1 auto; min-width: 0; height: auto; margin: 0 -6px; }
.lede { font-size: 19px; margin: 0 auto 10px; max-width: 480px; }
.lede b { font-size: 1.05em; }
.kicker { font: 500 13px Geist, sans-serif; color: var(--muted); margin: 0 0 24px; }
.actions { display: grid; justify-items: center; gap: 10px; }
.how { text-align: left; border-top: 1px solid var(--line); margin-top: 38px; padding-top: 22px; }
.rules { padding-left: 20px; margin: 12px 0 18px; font-size: 15.5px; }
.rules li { margin-bottom: 8px; }
.mode { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 15px; margin-bottom: 10px; }
.mode-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode-h b { font-size: 15.5px; font-weight: 600; }
.tag { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; background: var(--tag); color: var(--muted); border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.mode p { margin: 2px 0 8px; font-size: 15px; color: var(--muted); }
.ex { font-size: 15px; }
.ex b { font-weight: 600; }
.ex i { font-style: normal; color: var(--muted); margin: 0 3px; }
.fine { font-style: italic; color: var(--muted); font-size: 14.5px; margin: 12px 0 0; }
.site { margin-top: 28px; font: 500 13px Geist, sans-serif; letter-spacing: .04em; color: var(--muted); }

/* ---------- game ---------- */
.game { max-width: 660px; margin: 0 auto; padding: 14px 16px 40px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 26px; font-size: 13.5px; color: var(--muted); }
.bar b { color: var(--ink); }
.bar-l, .bar-r { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--ink);
  display: grid; place-items: center; font-weight: 600; font-size: 14px; padding: 0; flex: none;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.brief { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; max-width: 380px; margin: 8px auto 22px; padding: 9px 16px 10px; text-align: center; font-size: 14.5px; line-height: 1.45; }
.brief p { margin: 0; }
.brief .ex { margin-top: 3px; font-size: 14px; }
.brief .ex span { color: var(--muted); font-family: Newsreader, serif; margin-right: 4px; }
.brief .note { margin-top: 3px; font-size: 13.5px; font-style: italic; color: var(--muted); }

/* stage: SVG chains under HTML cards, both positioned in stage units */
.stage-wrap { position: relative; container-type: inline-size; }
.stage { display: block; width: 100%; height: auto; overflow: visible; }
#cards { position: absolute; inset: 0; pointer-events: none; }
.plate {
  position: absolute; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: 5px; box-shadow: var(--shadow); pointer-events: auto; overflow: hidden;
}
.plate-word { font: 700 30px/1 Geist, sans-serif; letter-spacing: -.02em; white-space: nowrap; padding: 0 8px; }
.plate.answer { border: 1.5px solid var(--ink); }
.plate.answer.done { border: 1px solid var(--line); }
.plate.answer input {
  width: 100%; height: 100%; border: 0; background: transparent; outline: none; text-align: center;
  font: 600 18px Geist, sans-serif; color: var(--ink); padding: 0 8px;
}
.plate.answer input::placeholder { color: var(--muted); font: italic 400 16px Newsreader, serif; }
.plate.gold .plate-word { color: var(--gold); }
.reading { position: absolute; font: 500 11px Geist, sans-serif; color: var(--muted); transform: translate(-50%, 0); white-space: nowrap; }
.st-a { stop-color: var(--st-a); } .st-b { stop-color: var(--st-b); } .st-c { stop-color: var(--st-c); }
.ghost-line { stroke: var(--ghost); stroke-width: 1.3; stroke-dasharray: 1.5 5; stroke-linecap: round; fill: none; }
.link { fill: none; stroke: url(#steel); }
.link-edge { fill: none; stroke: var(--st-edge); opacity: .55; }
.link-g { opacity: 0; animation: link-in .22s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.link-gold .link { stroke: url(#goldg); }
.link-gold .link-edge { stroke: #6e4a0f; }
.glow { fill: #f3c25c; opacity: 0; animation: glow 1.2s ease-out forwards; }
@keyframes link-in { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
@keyframes glow { 30% { opacity: .45; } to { opacity: 0; } }
.anchor { fill: url(#steel); stroke: var(--st-edge); stroke-width: 1; }

.guess { display: flex; justify-content: center; gap: 8px; margin: 22px 0 6px; }
.input-home input {
  width: 190px; text-align: center; font-size: 16px; padding: 9px 12px; border-radius: 6px;
  border: 1.5px solid var(--line); background: var(--surface); outline: none; font-family: Geist, sans-serif;
}
.input-home input:focus { border-color: var(--ink); }
.input-home input::placeholder { color: var(--muted); font-family: Newsreader, serif; font-style: italic; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.verdict { text-align: center; margin-top: 22px; animation: fade .35s ease-out; }
.verdict .said { color: var(--muted); margin: 0 0 8px; }
.verdict .said b { color: var(--ink); font-weight: 600; }
.verdict .pts { margin: 0; font-size: 18px; }
.verdict .pts b { font-size: 26px; font-weight: 700; margin-right: 2px; }
.verdict .rank { margin: 0; font-size: 14px; color: var(--muted); }
.verdict .rank b { color: var(--ink); font-weight: 600; }
.verdict .ours { margin: 2px 0 16px; font-size: 14.5px; font-style: italic; color: var(--muted); }
.verdict .ours b { font-style: normal; color: var(--ink); font-weight: 600; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.watermark { text-align: center; font: 600 12px Geist, sans-serif; letter-spacing: .03em; color: var(--muted); opacity: .8; margin-top: 26px; }

/* ---------- final ---------- */
.final { text-align: center; padding-top: 18px; animation: fade .4s ease-out; }
.final .when { font: 500 12.5px Geist, sans-serif; color: var(--muted); margin: 0; }
.final .total { margin: 2px 0 0; font: 700 64px/1 Geist, sans-serif; letter-spacing: -.03em; }
.final .total small { font: 500 13px Geist, sans-serif; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.final .verdict-line { margin: 8px 0 22px; }
.recap { list-style: none; padding: 0; margin: 0 auto 22px; max-width: 540px; text-align: left; border-top: 1px solid var(--line); }
.recap li { display: grid; grid-template-columns: 1fr 120px 48px; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.recap .cl { font: 600 14px Geist, sans-serif; }
.recap .yo { font-style: italic; color: var(--muted); font-size: 14px; line-height: 1.3; }
.recap .best { font-size: 13.5px; color: var(--muted); line-height: 1.3; }
.recap .best b { color: var(--ink); font-weight: 600; }
.recap svg { width: 120px; height: 34px; overflow: visible; }
.recap .pt { font: 700 16px Geist, sans-serif; text-align: right; }
.final .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.final .actions .btn { min-width: 0; padding: 10px 18px; font-size: 14.5px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; padding: 16px; z-index: 20; }
.dialog { position: relative; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: 12px; padding: 20px 22px; font-size: 15.5px; animation: fade .2s ease-out; }
.dialog h3 { margin: 0 0 10px; font: 700 18px Geist, sans-serif; }
.dialog ul { padding-left: 20px; margin: 8px 0 12px; } .dialog li { margin-bottom: 6px; }
.close { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 24px; line-height: 1; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin: 8px 0 4px; }
.tiles b { display: block; font-size: 26px; font-weight: 700; }
.tiles span { font: 500 11.5px Geist, sans-serif; color: var(--muted); }
.toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; z-index: 30;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font: 600 14px Geist, sans-serif; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .lede { font-size: 17.5px; }
  .bar { margin-bottom: 18px; font-size: 12.5px; }
  .bar-l, .bar-r { gap: 6px; }
  .recap li { grid-template-columns: 1fr 84px 40px; gap: 8px; }
  .recap svg { width: 84px; }
  .final .total { font-size: 52px; }
}
/* site home logo: pinned top-left above 1000px, so keep the game bar clear of it; in flow above the game below that */
@media (min-width: 1001px) { .game { max-width: min(660px, calc(100% - 2 * var(--site-logo-space))); } }
@media (max-width: 1000px) { .home { padding-top: 22px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
