/* Burn Vote — castle candlelight meets spreadsheet */
:root {
  --bg: #140f1a;
  --bg2: #1a1322;
  --surface: #211a2b;
  --surface2: #2c2338;
  --ink: #f3ead8;
  --muted: #b9aec4;
  --faint: #8a7f96;
  --line: #3b3049;
  --gold: #e7b24c;
  --gold-ink: #1a1206;
  --red: #e0505f;
  --red-bg: rgba(224, 80, 95, .14);
  --teal: #4cc2b3;
  --teal-bg: rgba(76, 194, 179, .14);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5eedf;
  --bg2: #efe5d1;
  --surface: #fffaf0;
  --surface2: #f1e6d0;
  --ink: #1d1524;
  --muted: #554a5e;
  --faint: #776c80;
  --line: #d7c9b0;
  --gold: #8f5f0c;
  --gold-ink: #fffaf0;
  --red: #a8233a;
  --red-bg: rgba(168, 35, 58, .1);
  --teal: #1b6f66;
  --teal-bg: rgba(27, 111, 102, .1);
  --shadow: 0 8px 24px rgba(60, 40, 20, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 50% -200px, rgba(231, 178, 76, .12), transparent 70%),
    radial-gradient(800px 400px at 100% 100%, rgba(224, 80, 95, .06), transparent 70%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--gold); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0 0 .4em; letter-spacing: .01em; }
h1 { font-size: clamp(2.4rem, 8vw, 4.4rem); }
h2 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.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; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--gold-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 14px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 1.35rem; margin-right: auto; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.nav-links { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-links a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .92rem; font-weight: 500; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); background: var(--surface2); }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--surface2); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: grid; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; font-size: 1rem; }
}

main { max-width: 1100px; margin: 0 auto; padding: 18px 14px 60px; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 24px 14px 40px; text-align: center; }
.site-footer p { max-width: 720px; margin: 0 auto .5em; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem var(--body); padding: 12px 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface2); color: var(--ink);
  text-decoration: none; min-height: 46px; transition: transform .12s ease, background .2s, border-color .2s;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn-gold:hover { filter: brightness(1.08); }
.btn-red { background: var(--red); color: #fff; border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface2); border: 1px solid var(--line); color: var(--muted); }
.pill.red { color: var(--red); background: var(--red-bg); border-color: transparent; }
.pill.teal { color: var(--teal); background: var(--teal-bg); border-color: transparent; }
.pill.gold { color: var(--gold); border-color: transparent; background: color-mix(in srgb, var(--gold) 14%, transparent); }
.eyebrow { font: 600 .78rem var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: .6em; }
.kicker { font-family: var(--display); font-style: italic; font-size: 1.3rem; color: var(--muted); }

.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented label { flex: 1 1 140px; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented .opt { display: block; height: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); }
.segmented .opt strong { display: block; font-size: 1rem; }
.segmented .opt span { display: block; color: var(--muted); font-size: .84rem; line-height: 1.35; margin-top: 2px; }
.segmented input:checked + .opt { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--surface2)); }
.segmented input:focus-visible + .opt { outline: 3px solid var(--gold); outline-offset: 2px; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 700; margin-bottom: 8px; padding: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 28px 0 10px; }
.hero h1 span { color: var(--gold); }
.hero .lede { max-width: 640px; margin: 0 auto 20px; font-size: 1.08rem; color: var(--muted); }
.hero-quote { max-width: 620px; margin: 0 auto 24px; font-family: var(--display); font-size: 1.3rem; font-style: italic; border-left: 3px solid var(--gold); padding: 4px 0 4px 14px; text-align: left; }
.hero-quote cite { display: block; font-family: var(--body); font-style: normal; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.candles { display: flex; justify-content: center; gap: 18px; margin: 4px 0 14px; }
.candle { width: 10px; height: 34px; background: linear-gradient(#efe3c8, #c9b791); border-radius: 3px; position: relative; }
.candle::before { content: ""; position: absolute; left: 50%; top: -16px; width: 10px; height: 16px; margin-left: -5px; background: radial-gradient(circle at 50% 70%, #fff6c9, #f2b544 55%, transparent 70%); border-radius: 50% 50% 45% 45%; animation: flicker 2.4s infinite ease-in-out; }
.candle:nth-child(2)::before { animation-delay: -.8s; }
.candle:nth-child(3)::before { animation-delay: -1.5s; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-2deg); opacity: 1; } 50% { transform: scale(.88, 1.08) rotate(3deg); opacity: .85; } }

.setup { max-width: 860px; margin: 0 auto; }
.setup .card h2 { margin-bottom: 4px; }
.stats-strip { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* ---------- game layout ---------- */
.game { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 940px) { .game { grid-template-columns: minmax(0, 1fr) 340px; } }
.phase-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.phase-bar .day { font-family: var(--display); font-size: 1.7rem; font-weight: 700; }
.phase-steps { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.phase-steps li { font-size: .75rem; padding: 3px 8px; border-radius: 999px; color: var(--faint); border: 1px solid var(--line); }
.phase-steps li.on { color: var(--gold-ink); background: var(--gold); border-color: var(--gold); font-weight: 700; }
.phase-steps li.done { color: var(--muted); }
.hud { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.stage { min-height: 360px; }
.stage-title { font-family: var(--display); font-size: 1.9rem; margin-bottom: 4px; }
.narration { font-size: 1.05rem; }
.narration .q { font-family: var(--display); font-size: 1.25rem; font-style: italic; }

.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.guest {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px 8px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line);
  text-align: center; font: inherit; color: inherit; min-width: 0;
}
button.guest { cursor: pointer; }
button.guest:hover { border-color: var(--gold); }
.guest.selected { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.guest.dead { opacity: .55; filter: grayscale(.7); }
.guest .face { font-size: 2rem; line-height: 1; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.guest.you .face { border-color: var(--gold); }
.guest .gname { font-weight: 700; font-size: .86rem; line-height: 1.2; overflow-wrap: anywhere; }
.guest .gjob { font-size: .7rem; color: var(--muted); line-height: 1.2; }
.guest .meter { width: 100%; height: 6px; background: var(--surface); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.guest .meter i { display: block; height: 100%; background: var(--red); border-radius: 4px; transition: width .6s ease; }
.guest .pct { font-family: var(--mono); font-size: .78rem; color: var(--red); font-weight: 700; }
.guest .tag { position: absolute; top: 4px; right: 4px; font-size: .9rem; }
.guest .fate { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.guest .fate.T { color: var(--red); }
.guest .fate.F { color: var(--teal); }
.guest .votes { position: absolute; top: -6px; left: -6px; min-width: 24px; height: 24px; border-radius: 12px; background: var(--red); color: #fff; font: 700 .8rem var(--mono); display: grid; place-items: center; padding: 0 6px; }

.side .card { padding: 14px; }
.side .card + .card { margin-top: 14px; }
.slist { list-style: none; padding: 0; margin: 0; }
.srow { display: grid; grid-template-columns: 26px minmax(0, 1fr) 70px 48px; gap: 6px; align-items: center; padding: 4px 0; font-size: .88rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.srow:last-child { border-bottom: 0; }
.srow.dead { opacity: .6; }
.srow .sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .sbar { height: 6px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.srow .sbar i { display: block; height: 100%; background: var(--red); border-radius: 4px; transition: width .6s ease; }
.srow > :last-child { text-align: right; }
.fate.T { color: var(--red); }
.fate.F { color: var(--teal); }
.side h3 { font-size: 1.2rem; margin-bottom: 8px; }
.ledger { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow: auto; font-size: .86rem; }
.ledger li { padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; align-items: baseline; }
.ledger li:last-child { border-bottom: 0; }
.ledger .lr { margin-left: auto; font-family: var(--mono); font-size: .78rem; white-space: nowrap; }
.ledger .lr.up { color: var(--red); }
.ledger .lr.down { color: var(--teal); }
.ledger .d { font-family: var(--mono); color: var(--faint); font-size: .75rem; flex: none; }

.speech { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; animation: rise .35s ease both; }
.speech .face { font-size: 1.5rem; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); flex: none; border: 1px solid var(--line); }
.speech .bubble { background: var(--surface2); padding: 8px 12px; border-radius: 4px 12px 12px 12px; border: 1px solid var(--line); }
.speech .bubble b { display: block; font-size: .8rem; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.reveal { text-align: center; padding: 22px 10px; border-radius: var(--radius); margin: 12px 0; animation: rise .5s ease both; }
.reveal.T { background: var(--red-bg); border: 1px solid var(--red); }
.reveal.F { background: var(--teal-bg); border: 1px solid var(--teal); }
.reveal .big { font-family: var(--display); font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 700; }
.reveal.T .big { color: var(--red); }
.reveal.F .big { color: var(--teal); }
.reveal .face { font-size: 3.4rem; }

.actions { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 12px 0; }
.action { text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); cursor: pointer; color: inherit; font: inherit; }
.action:hover:not(:disabled) { border-color: var(--gold); }
.action:disabled { opacity: .45; cursor: not-allowed; }
.action.selected { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.action strong { display: block; }
.action span { font-size: .82rem; color: var(--muted); }
.tokens { display: inline-flex; gap: 4px; vertical-align: middle; }
.tokens i { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); display: inline-block; }
.tokens i.used { background: var(--line); }
.log-box { background: var(--bg2); border-radius: 12px; padding: 12px; margin-top: 12px; border: 1px solid var(--line); }

/* ---------- missions ---------- */
.mission { text-align: center; }
.simon { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 16px auto; }
.simon button { aspect-ratio: 1; font-size: 2rem; border-radius: 14px; border: 2px solid var(--line); background: var(--surface2); cursor: pointer; color: inherit; transition: transform .1s, background .15s; }
.simon button.lit { background: var(--gold); transform: scale(1.06); box-shadow: 0 0 24px var(--gold); }
.simon button.bad { background: var(--red); }
.chests { display: flex; gap: 12px; justify-content: center; margin: 18px 0; flex-wrap: wrap; }
.chest { width: 96px; height: 96px; font-size: 3rem; border-radius: 14px; border: 2px solid var(--line); background: var(--surface2); cursor: pointer; color: inherit; }
.chest.picked { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold); }
.chest.opened { opacity: .5; }
.lantern-field { position: relative; height: 280px; border-radius: 14px; background: radial-gradient(circle at 50% 120%, #2c2338, #0d0912); overflow: hidden; margin: 14px 0; touch-action: manipulation; border: 1px solid var(--line); }
.lantern { position: absolute; width: 58px; height: 58px; border-radius: 50%; border: 0; font-size: 2rem; cursor: pointer; background: radial-gradient(circle, rgba(242, 181, 68, .9), rgba(242, 181, 68, 0) 70%); animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }
.trivia-opts { display: grid; gap: 8px; max-width: 520px; margin: 12px auto; }
.trivia-opts button { text-align: left; }
.trivia-opts button.right { border-color: var(--teal); background: var(--teal-bg); }
.trivia-opts button.wrong { border-color: var(--red); background: var(--red-bg); }
.progress { height: 8px; background: var(--surface2); border-radius: 6px; overflow: hidden; max-width: 420px; margin: 8px auto; }
.progress i { display: block; height: 100%; background: var(--gold); transition: width .2s linear; }

/* ---------- results ---------- */
.result-hero { text-align: center; padding: 10px 0; }
.result-hero .face { font-size: 4rem; }
.result-title { font-family: var(--display); font-size: clamp(2rem, 7vw, 3.2rem); color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 16px 0; }
.stat { background: var(--surface2); border-radius: 12px; padding: 12px; text-align: center; border: 1px solid var(--line); }
.stat b { display: block; font-family: var(--mono); font-size: 1.5rem; }
.stat span { font-size: .8rem; color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ach { padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); font-size: .85rem; }
.ach.locked { opacity: .45; }
.ach strong { display: block; }
canvas.card-canvas { width: 100%; max-width: 540px; height: auto; border-radius: 12px; display: block; margin: 12px auto; border: 1px solid var(--line); }

/* ---------- tables / detective ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table.votes-table { border-collapse: collapse; width: 100%; font-size: .85rem; min-width: 420px; }
.votes-table th, .votes-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.votes-table th { background: var(--surface2); font-weight: 700; position: sticky; top: 0; }
.votes-table td.T { color: var(--red); font-weight: 700; }
.votes-table td.F { color: var(--teal); }
.votes-table tr.dead td:first-child { text-decoration: line-through; color: var(--faint); }

/* ---------- odds lab ---------- */
.dots { display: grid; grid-template-columns: repeat(20, 1fr); gap: 4px; max-width: 520px; margin: 12px auto; }
.dots i { aspect-ratio: 1; border-radius: 50%; background: var(--line); transition: background .4s, opacity .4s, transform .4s; }
.dots i.T { background: var(--red); }
.dots i.F { background: var(--teal); }
.dots i.out { opacity: .15; transform: scale(.7); }
.range-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; margin: 10px 0; }
.range-row label { font-weight: 600; font-size: .92rem; }
.range-row output { font-family: var(--mono); font-weight: 700; color: var(--gold); }
.range-row input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--gold); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 15px var(--body); }
.chart .axis { stroke: var(--line); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .bar { fill: var(--gold); }
.chart .bar:hover { fill: var(--red); }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2; }
.chart .line2 { fill: none; stroke: var(--teal); stroke-width: 2; stroke-dasharray: 5 4; }
.hero-number { font-family: var(--mono); font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 700; color: var(--gold); line-height: 1; }
.tooltip { position: fixed; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .8rem; padding: 5px 8px; border-radius: 6px; z-index: 50; opacity: 0; transition: opacity .1s; }
.tooltip.show { opacity: 1; }

/* ---------- quiz ---------- */
.quiz-q { font-family: var(--display); font-size: 1.6rem; margin-bottom: 14px; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opts button { text-align: left; justify-content: flex-start; }
.type-card { text-align: center; }
.type-card .face { font-size: 4rem; }
.trait-list { text-align: left; max-width: 520px; margin: 0 auto; }

/* ---------- prose ---------- */
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.4em; }
.prose li { margin-bottom: .4em; }
.formula { font-family: var(--mono); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 420px) {
  .board { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .guest .face { width: 44px; height: 44px; font-size: 1.7rem; }
  .card { padding: 14px; }
  .chest { width: 84px; height: 84px; }
}
