/* Duco Quiz Night - gold theme on charcoal. Fonts: Montserrat (headings), Source Sans 3 (body). */
:root {
  --charcoal: #0A0A0A;
  --surface: #161616;
  --surface-2: #222222;
  --line: #2E2E2E;
  --gold: #FBB216;
  --gold-dark: #D39103;
  --gold-darkest: #B07B10;
  --maroon: #720823;
  --maroon-mid: #9B223E;
  --white: #FFFFFF;
  --text: #FFFFFF;
  --muted: #C6C6C6;
  --muted-2: #8A8A8A;
  --font-head: "Montserrat", Verdana, sans-serif;
  --font-body: "Source Sans 3", "Source Sans Pro", Verdana, sans-serif;
  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.35);
  --space-xs: 4px; --space-sm: 8px; --space-md: 16px; --space-lg: 24px;
  --space-xl: 32px; --space-2xl: 48px; --space-3xl: 64px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--charcoal); color: var(--text);
  font-family: var(--font-body); font-size: 1.125rem; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .head { font-family: var(--font-head); font-weight: 700; line-height: 1.05; margin: 0; }
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
p { margin: 0 0 var(--space-md); }
a { color: var(--gold); }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.small { font-size: 0.875rem; }
.eyebrow {
  font-family: var(--font-head); font-weight: 600; font-size: 0.75rem;
  letter-spacing: 1.6px; text-transform: uppercase; color: var(--gold);
}
.label { font-family: var(--font-head); font-weight: 600; font-size: 0.875rem; line-height: 1.1; }

/* Layout shells */
.page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: var(--space-md); }
.page-center { justify-content: center; align-items: center; text-align: center; }
.wrap { width: 100%; max-width: 1480px; margin: 0 auto; }
.narrow { width: 100%; max-width: 560px; margin: 0 auto; }
.brand {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-md); padding: var(--space-sm) 0 var(--space-md);
}
.brand img { height: 28px; width: auto; }
.brand .code { font-family: var(--font-head); font-weight: 600; color: var(--muted); letter-spacing: 1px; }
.pattern {
  background-image: url("../brand/pattern-gold-flow.png");
  background-size: cover; background-position: center; background-repeat: no-repeat;
}

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: var(--space-lg);
}
.card-tinted { background: var(--surface-2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm);
  border: none; border-radius: var(--radius-sm); padding: 14px 32px;
  font-family: var(--font-head); font-weight: 700; font-size: 1rem; line-height: 1.1;
  background: var(--gold); color: var(--charcoal); min-height: 48px;
  transition: background 120ms ease, transform 80ms ease;
}
.btn:hover { background: var(--gold-dark); }
.btn:active { background: var(--gold-darkest); transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-dark { background: var(--surface-2); color: var(--white); }
.btn-dark:hover { background: #333333; }
.btn-dark:active { background: #3D3D3D; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-lg { font-size: 1.25rem; padding: 18px 40px; min-height: 60px; }
.btn-block { width: 100%; }

/* Inputs */
.input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--white); padding: 14px 16px;
  font: inherit; font-size: 1.25rem; min-height: 56px;
}
.input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.field-error { color: #FF8A9B; margin-top: var(--space-sm); min-height: 1.5em; }

/* Option buttons (A-H) */
.options { display: grid; gap: var(--space-sm); margin: 0; padding: 0; list-style: none; }
.option {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: var(--space-md);
  width: 100%; min-height: 72px; text-align: left; padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-sm);
  border: 2px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--white); font-size: 1.125rem; line-height: 1.3;
  transition: border-color 120ms ease, background 120ms ease, opacity 200ms ease, transform 80ms ease;
}
.option .letter {
  width: 56px; height: 56px; border-radius: var(--radius-sm); display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.5rem;
  background: var(--surface-2); color: var(--gold);
}
.option:not(:disabled):hover { border-color: var(--muted-2); }
.option:not(:disabled):active { transform: scale(0.99); }
.option:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.option:disabled { cursor: default; }
.option.is-selected { border-color: var(--gold); background: #1F1A0E; }
.option.is-selected .letter { background: var(--gold); color: var(--charcoal); }
.option.is-dim { opacity: 0.38; }
.option.is-correct { border-color: var(--gold); background: var(--gold); color: var(--charcoal); opacity: 1; }
.option.is-correct .letter { background: var(--charcoal); color: var(--gold); }
.option.is-wrong { border-color: var(--maroon-mid); background: #1A0A0F; opacity: 1; }
.option.is-wrong .letter { background: var(--maroon); color: var(--white); }
.option.pulse { animation: pulse-gold 700ms ease-in-out 3; }
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 178, 22, 0); }
  50% { box-shadow: 0 0 0 10px rgba(251, 178, 22, 0.35); }
}
.options.cols-2 { grid-template-columns: 1fr 1fr; }

/* Timer */
.timer-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.timer-bar > span { display: block; height: 100%; background: var(--gold); width: 100%; transform-origin: left; }
.timer-bar.is-urgent > span { background: var(--maroon-mid); }
.timer-ring { position: relative; width: 140px; height: 140px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 10; }
.timer-ring .track { stroke: var(--surface-2); }
.timer-ring .prog { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 250ms linear; }
.timer-ring .num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 3rem;
}

/* Leaderboard */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-xs); }
.board li {
  display: grid; grid-template-columns: 2.5em 1fr auto auto; align-items: center; gap: var(--space-md);
  padding: 10px var(--space-md); border-radius: var(--radius-sm); background: var(--surface);
}
.board li.is-me { outline: 2px solid var(--gold); }
.board .rank { font-family: var(--font-head); font-weight: 700; color: var(--gold); }
.board .nick { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.board .gain { color: var(--muted); font-size: 0.875rem; min-width: 3em; text-align: right; }
.board .gain.is-plus { color: var(--gold); }
.board .total { font-family: var(--font-head); font-weight: 700; min-width: 3em; text-align: right; }
.board li:nth-child(1) .rank { font-size: 1.25em; }

/* Distribution bars */
.dist { display: grid; gap: var(--space-sm); }
.dist .row { display: grid; grid-template-columns: 2em 1fr 3em; align-items: center; gap: var(--space-sm); }
.dist .row .letter { font-family: var(--font-head); font-weight: 700; color: var(--muted); }
.dist .row.is-correct .letter { color: var(--gold); }
.dist .bar { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dist .bar > span { display: block; height: 100%; background: var(--muted-2); transition: width 600ms ease; }
.dist .row.is-correct .bar > span { background: var(--gold); }
.dist .n { text-align: right; color: var(--muted); font-size: 0.875rem; }

/* Result banner (phone) */
.result { text-align: center; padding: var(--space-lg) var(--space-md); }
.result .big { font-family: var(--font-head); font-weight: 700; font-size: 2.5rem; line-height: 1.05; }
.result .big.is-good { color: var(--gold); }
.result .big.is-bad { color: var(--muted); }
.stat { font-family: var(--font-head); font-weight: 700; font-size: 4rem; line-height: 1.05; color: var(--gold); }

/* Toast + connectivity */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--surface-2); color: var(--white); padding: 12px 20px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-card); max-width: 90vw; z-index: 50;
}
.toast.is-error { border-left: 0; background: var(--maroon); }
.netbar {
  position: fixed; top: 0; left: 0; right: 0; padding: 6px 12px; text-align: center;
  background: var(--gold-dark); color: var(--charcoal); font-family: var(--font-head);
  font-weight: 600; font-size: 0.875rem; z-index: 60;
}

/* Question presentation */
.q-meta { display: flex; gap: var(--space-md); align-items: baseline; flex-wrap: wrap; }
.q-text { font-family: var(--font-head); font-weight: 600; font-size: 1.5rem; line-height: 1.15; margin: var(--space-md) 0 var(--space-lg); }
.q-image { border-radius: var(--radius-md); overflow: hidden; margin: 0 auto var(--space-lg); max-height: 40vh; width: auto; }
.q-image img { max-height: 40vh; width: auto; margin: 0 auto; }

/* TV question layout (host) */
.tv { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; width: 100%; max-width: 1600px; margin: 0 auto; gap: clamp(8px, 1.6vh, 24px); }
.q-meta-center { justify-content: center; }
.q-text-tv { font-size: clamp(1.5rem, 5.2vh, 4.25rem) !important; line-height: 1.1; margin: 0 !important; max-width: 28ch; font-weight: 700; }
.q-text-tv.is-long { font-size: clamp(1.375rem, 4vh, 3.25rem) !important; max-width: 36ch; }
.tv.is-compact .q-text-tv { font-size: clamp(1.25rem, 3vh, 2.25rem) !important; max-width: 44ch; }
.q-image-tv { margin: 0; }
.q-image-tv img { max-height: 28vh; }
.tv.is-compact .q-image-tv img { max-height: 16vh; }
.options-tv { width: 100%; text-align: left; gap: clamp(6px, 1.2vh, 14px); }
.projector .options-tv .option { min-height: clamp(56px, 9vh, 104px); font-size: clamp(1.125rem, 2.6vh, 2rem); grid-template-columns: clamp(48px, 7vh, 76px) 1fr; }
.projector .options-tv .option .letter { width: clamp(48px, 7vh, 76px); height: clamp(48px, 7vh, 76px); font-size: clamp(1.25rem, 3vh, 2.25rem); }
.projector .options-tv.cols-3 { grid-template-columns: repeat(3, 1fr); }
.projector .options-tv.cols-3 .option { min-height: clamp(52px, 7.5vh, 88px); font-size: clamp(1rem, 2.2vh, 1.625rem); }
.projector .options-tv.is-compact .option { min-height: clamp(44px, 6vh, 60px); font-size: clamp(1rem, 1.9vh, 1.25rem); grid-template-columns: 48px 1fr; }
.projector .options-tv.is-compact .option .letter { width: 48px; height: 48px; font-size: 1.375rem; }
.tv-foot { width: 100%; display: flex; justify-content: center; }
.tv-pill { display: inline-flex; align-items: center; gap: 20px; background: var(--surface); border-radius: var(--radius-lg); padding: 10px 24px; box-shadow: var(--shadow-card); font-size: clamp(0.9rem, 1.8vh, 1.25rem); }
.tv-pill-num { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.25rem, 3vh, 2rem); color: var(--gold); }
.timer-ring-tv { width: clamp(72px, 12vh, 110px); height: clamp(72px, 12vh, 110px); }
.timer-ring-tv .num { font-size: clamp(1.5rem, 4vh, 2.5rem); }
.tv-answered { font-family: var(--font-head); font-weight: 600; font-size: clamp(1rem, 2.2vh, 1.5rem); }
.tv-results { width: 100%; display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--space-xl); text-align: left; }
.tv.is-compact .board li { padding: 6px 14px; font-size: clamp(0.9rem, 1.8vh, 1.25rem); }
.tv.is-compact .dist .bar { height: 10px; }
@media (max-width: 1100px) { .tv-results { grid-template-columns: 1fr; } }
.tv-reveal { flex: 1; display: grid; grid-template-columns: 1fr 28%; gap: var(--space-xl); align-items: stretch; width: 100%; }
.tv-reveal .tv-left { max-width: none; }
.tv-side { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-card); text-align: left; overflow: hidden; align-self: center; }
.tv-side .eyebrow { font-size: clamp(0.7rem, 1.4vh, 0.9rem); }
.dist-side .row { grid-template-columns: 1.5em 1fr 2.5em; gap: 6px; }
.dist-side .bar { height: clamp(8px, 1.3vh, 12px); }
.dist-side .row .letter, .dist-side .n { font-size: clamp(0.8rem, 1.6vh, 1rem); }
.projector .board-side li { padding: clamp(3px, 0.7vh, 8px) 12px; font-size: clamp(0.85rem, 1.9vh, 1.2rem); grid-template-columns: 2em 1fr auto auto; gap: 8px; }
.projector .board-side .gain { font-size: 0.8em; }

.tv-standings { justify-content: flex-start; gap: clamp(8px, 1.5vh, 20px); }
.standings-title { font-size: clamp(1.75rem, 5vh, 3.5rem) !important; }
.podium-tv { width: 100%; max-width: 1100px; gap: clamp(8px, 1.5vw, 24px); }
.podium-tv .step { padding: clamp(10px, 1.6vh, 24px); }
.podium-tv .step.p1 { padding-top: clamp(24px, 5vh, 56px); }
.podium-tv .place { font-size: clamp(1.75rem, 4.5vh, 3rem); }
.podium-tv .name { font-size: clamp(1.1rem, 2.4vh, 1.75rem); }
.board-cols { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; text-align: left; }
.projector .board-cols li { padding: clamp(3px, 0.6vh, 8px) 12px; font-size: clamp(0.85rem, 1.8vh, 1.15rem); gap: 8px; grid-template-columns: 2em 1fr 0 auto; }

/* Modal + rounds manager */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; font-size: 1rem; text-align: left; }
.rounds-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rounds-item { display: grid; grid-template-columns: 2em 24px 1fr auto; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.rounds-item.is-off { opacity: 0.55; }
.rounds-item input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--gold); cursor: pointer; }
.rounds-pos { font-family: var(--font-head); font-weight: 700; color: var(--gold); text-align: right; }
.rounds-name { cursor: pointer; }
.rounds-arrows { display: flex; gap: 4px; }
.rounds-arrows .btn { padding: 6px 10px; min-height: 36px; font-size: 0.8rem; }
.projector .modal { font-size: 1rem; }
.projector .modal h3 { font-size: 1.5rem; }

/* Projector (host) scale */
.projector { font-size: 1.5rem; }
.projector .page { height: 100vh; height: 100dvh; }
.projector #main { overflow: auto; min-height: 0; }
.projector .q-text { font-size: 2.25rem; margin: 12px 0 20px; }
.projector .options { grid-template-columns: 1fr 1fr; }
.projector .option { min-height: 76px; font-size: 1.375rem; grid-template-columns: 60px 1fr; }
.projector .option .letter { width: 60px; height: 60px; font-size: 1.625rem; }
.projector .board li { padding: 8px 16px; font-size: 1.25rem; }
.projector .card { padding: 16px 20px; }
.projector .split { gap: var(--space-xl); }
.projector h1 { font-size: 4rem; }
.projector h2 { font-size: 3rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2xl); align-items: start; }
.qr-box { background: var(--white); border-radius: var(--radius-lg); padding: 16px; display: inline-block; }
.qr-box svg, .qr-box img { width: min(28vw, 42vh); height: auto; display: block; }
.lobby-title { font-size: 2.5rem !important; margin: 0 0 16px; }
.players-grid { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.chip {
  padding: 8px 14px; border-radius: 4px; background: var(--surface-2); font-size: 1.125rem;
  animation: chip-in 300ms ease;
}
@keyframes chip-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.hostbar {
  display: flex; gap: var(--space-md); align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: var(--space-md) 0; border-top: 1px solid var(--line); margin-top: auto;
}
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); align-items: end; }
.podium .step { text-align: center; background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-lg); box-shadow: var(--shadow-card); }
.podium .step.p1 { background: var(--gold); color: var(--charcoal); padding-top: var(--space-3xl); }
.podium .step.p1 .place { color: var(--charcoal); }
.podium .place { font-family: var(--font-head); font-weight: 700; font-size: 3rem; color: var(--gold); }
.podium .name { font-family: var(--font-head); font-weight: 700; font-size: 1.5rem; overflow-wrap: anywhere; }

/* Tables (results) */
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-family: var(--font-head); font-weight: 600; font-size: 0.875rem; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .projector { font-size: 1.25rem; }
  .projector .q-text { font-size: 2.25rem; }
  .split { gap: var(--space-xl); }
}
@media (max-width: 767px) {
  .split { grid-template-columns: 1fr; }
  .podium { grid-template-columns: 1fr; }
  .options.cols-2 { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
  .stat { font-size: 3rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
