:root {
  color-scheme: dark;
  --background: #110d14;
  --panel: #201725;
  --line: #493347;
  --ink: #fff6e9;
  --muted: #d0b8cb;
  --gold: #ffcf86;
  --accent: #e38bbb;
  font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(ellipse at top right, #3a1b35, var(--background) 62%);
  min-height: 100vh;
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  gap: 1rem;
}
.masthead a { font-weight: 750; color: var(--gold); text-decoration: none; }
.masthead span { color: var(--muted); font-size: .88rem; }
main { max-width: 1500px; margin: auto; padding: clamp(1rem, 4vw, 4rem); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: clamp(1.25rem, 3vw, 2.8rem); min-width: 0; }
.host-grid, .stage { display: grid; gap: 1rem; align-items: start; }
.host-grid { grid-template-columns: 1fr 1.12fr; }
.stage { grid-template-columns: minmax(0, 2.2fr) minmax(235px, 1fr); }
.history { grid-column: 1 / -1; }
h1, h2 { margin: 0 0 .8rem; line-height: 1.06; overflow-wrap: anywhere; }
h1 { font-family: Georgia, serif; font-size: clamp(2.2rem, 5vw, 4.3rem); font-weight: 500; letter-spacing: -.03em; }
h2 { font-size: clamp(1.2rem, 2vw, 1.8rem); }
p { line-height: 1.5; }
p:empty { display: none; }
a { color: var(--gold); }
form, label, #choices { display: grid; gap: .65rem; }
form { gap: 1.1rem; }
label { font-weight: 650; }
label small, .muted { color: var(--muted); font-weight: 400; }
input, select, textarea, button, .button { font: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; padding: .75rem .85rem; color: var(--ink); background: var(--background); border: 1px solid var(--line); border-radius: 8px;
}
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--gold); width: 1rem; height: 1rem; }
.checkbox, .option { display: flex; align-items: center; gap: .65rem; }
.option { padding: .95rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; overflow-wrap: anywhere; }
.option:has(input:checked) { border-color: var(--gold); background: #372533; }
button, .button {
  min-height: 44px; border: 1px solid var(--gold); border-radius: 8px; padding: .65rem 1rem;
  background: var(--gold); color: #261523; cursor: pointer; font-weight: 750; text-decoration: none; text-align: center;
}
button:disabled { opacity: .42; cursor: default; }
.secondary { color: var(--gold); background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.two, .actions, .chart-label { display: flex; gap: .65rem; }
.two > * { flex: 1; }
.actions { flex-wrap: wrap; align-items: center; }
.links { border-top: 1px solid var(--line); margin-top: 1.35rem; padding-top: 1.15rem; gap: 1rem; }
.status, .eyebrow { color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .11em; font-size: .75rem; }
.status { color: var(--gold); margin-top: 0; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }
.phone { max-width: 530px; margin: 0 auto; }
.landing { padding-top: 3rem; }
.join-card { display: grid; gap: 1rem; text-align: center; justify-items: center; }
.join-card img { display: block; width: min(100%, 280px); border-radius: 10px; }
.join-card a { overflow-wrap: anywhere; }
.room-code { color: var(--gold); font: 800 clamp(1.4rem, 3vw, 2.6rem) ui-monospace, monospace; letter-spacing: .12em; }
.stage-main h1 { font-size: clamp(2.5rem, 6vw, 6rem); }
.stage-main .chart-label { font-size: clamp(1rem, 2vw, 1.6rem); }
.stage-main:has(.chart-row:nth-child(9)) .chart { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart { display: grid; gap: .65rem; }
.chart-label { justify-content: space-between; overflow-wrap: anywhere; }
.chart-label strong { color: var(--gold); white-space: nowrap; font-variant-numeric: tabular-nums; }
progress { width: 100%; height: .65rem; appearance: none; border: 0; border-radius: 20px; background: var(--line); accent-color: var(--gold); }
progress::-webkit-progress-bar { background: var(--line); border-radius: 20px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 20px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 20px; }
details { border-top: 1px solid var(--line); padding: 1rem 0; }
details[open] summary { margin-bottom: 1rem; }
summary { cursor: pointer; }
.message, .connection { color: var(--gold); }
@media (max-width: 760px) {
  .host-grid, .stage, .stage-main:has(.chart-row:nth-child(9)) .chart { grid-template-columns: 1fr; }
}
.roster-card { grid-column: 1 / -1; }
.roster-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
#roster-picker { min-width: 0; margin: 0; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; }
#roster-picker legend { padding: 0 .35rem; color: var(--muted); }
@media (max-width: 520px) { .roster-grid { grid-template-columns: 1fr; } }

/* Admin dashboard */
.admin-dashboard { max-width: 1240px; padding-top: clamp(1.4rem, 3.5vw, 3rem); }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.dashboard-header h1 { margin: 0; font-size: clamp(2.1rem, 5vw, 3.65rem); }
.dashboard-header nav { display: flex; flex-wrap: wrap; gap: .4rem 1.15rem; }
.dashboard-header nav a { padding-block: .55rem; font-size: .88rem; text-underline-offset: .3em; }
.admin-dashboard .host-grid { grid-template-areas: "rounds rounds" "live setup" "roster roster" "guests guests" "judging judging" "audience audience" "history history"; }
.admin-dashboard .card { padding: clamp(1rem, 2.3vw, 1.65rem); }
.admin-dashboard h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.rounds-card { grid-area: rounds; }
.setup-card { grid-area: setup; }
.live-card { grid-area: live; }
.roster-card { grid-area: roster; }
.admin-dashboard .history { grid-area: history; }
.round-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: clamp(.68rem, 2.1vw, .92rem); }
.round-table th, .round-table td { text-align: left; padding: .65rem .35rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.round-table thead th { color: var(--muted); font-weight: 550; }
.round-table td { color: var(--muted); }
.round-table .current-round { color: var(--gold); font-weight: 750; background: #372633; }
.live-card .status { display: inline-block; border: 1px solid var(--line); border-radius: 50px; padding: .4rem .7rem; }
.live-card .status:empty { display: none; }
.live-card[data-phase="open"] .status { background: #193730; border-color: #365a4a; color: #c0ecd8; }
.live-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; margin-bottom: 1rem; }
.live-heading h3 { margin: .4rem 0; font-family: Georgia, serif; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 500; }
.live-heading p { margin: 0; color: var(--muted); }
.live-tally { display: grid; flex: none; text-align: right; color: var(--muted); font-size: .8rem; }
.live-tally strong { color: var(--gold); font-size: clamp(1.8rem, 3.8vw, 3rem); line-height: 1; font-variant-numeric: tabular-nums; }
.live-card .chart { margin-top: 1.25rem; }

/* Voter dashboard */
.voter-dashboard { max-width: 600px; padding: clamp(.9rem, 4vw, 2.25rem); }
.voter-title { padding: 1.35rem 0 1.6rem; text-align: center; }
.voter-title h1 { color: #f6deb9; font-size: clamp(2.6rem, 10vw, 4.4rem); line-height: .96; margin: 0; }
.voting-card {
  color-scheme: light;
  background: #fff8ef;
  border-color: #eed9be;
  color: #30182b;
  box-shadow: 0 18px 50px #0d071255;
  padding: clamp(1rem, 4.5vw, 1.8rem);
}
.voting-card h2 { font-family: Georgia, serif; font-size: clamp(1.75rem, 5.2vw, 2.35rem); font-weight: 500; margin-bottom: 1rem; }
.voting-card .ballot-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .35rem .75rem; margin-bottom: .85rem; }
.voting-card .status, .voting-card .eyebrow { margin: 0; color: #62455b; letter-spacing: .045em; }
.voting-card .status { border-radius: 50px; padding: .25rem .55rem; background: #f3e5d8; text-transform: none; }
.voting-card [data-phase="open"] .status { background: #ddeddf; color: #25513c; }
.voting-card input:not([type=radio]) { background: #fffdf8; border-color: #cbb7c5; color: #30182b; }
.voting-card input[type=radio] { accent-color: #713459; flex: none; }
.ballot-choices { min-width: 0; margin: 0; padding: 0; border: 0; }
.ballot-choices legend { margin-bottom: .65rem; color: #62455b; font-size: .87rem; }
.voting-card .option { min-height: 54px; border-color: #ddcbd5; background: #fffcf9; }
.voting-card .option:has(input:checked) { background: #f4e5ee; border-color: #83416c; }
.voting-card button { background: #5b274a; color: #fff8ef; border-color: #5b274a; }
.voting-card .message { color: #842f50; }
.vote-receipt { display: grid; gap: .25rem; margin-top: 1.25rem; padding: .9rem; border: 1px solid #bed7c1; border-radius: 10px; background: #e7f2e6; color: #225239; }
.ballot-results { margin-top: 1.4rem; }
.ballot-results h3 { margin-bottom: .85rem; }
.voting-card .chart-label strong { color: #713459; }
.voting-card progress, .voting-card progress::-webkit-progress-bar { background: #eadbe3; }
.voting-card progress::-webkit-progress-value { background: #884773; }
.voting-card progress::-moz-progress-bar { background: #884773; }
@media (max-width: 760px) {
  .admin-dashboard .host-grid { grid-template-areas: "rounds" "live" "setup" "roster" "guests" "judging" "audience" "history"; }
}

.guest-access { grid-area: guests; margin: 0; }
.guest-access summary { font-size: 1.2rem; font-weight: 750; }
#email-form + #verification-form { margin-top: 1rem; }
.public-title { margin-bottom: clamp(1rem, 3vw, 2.2rem); }
.public-title h1 { color: #f6deb9; font-size: clamp(2.35rem, 6vw, 5.2rem); }
.public-stage .stage-main h2 { font: 500 clamp(2rem, 5vw, 4.25rem)/1.08 Georgia, serif; }
.public-stage .count { font-size: clamp(1.1rem, 2.2vw, 1.6rem); }
.public-stage .status { display: inline-block; padding: .35rem .65rem; border: 1px solid var(--line); border-radius: 30px; }
.public-stage [data-phase="open"] .status { background: #193730; color: #c0ecd8; }
.public-contestants { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; list-style: none; margin: 1rem 0 0; padding: 0; }
.public-contestants li { padding: .55rem .7rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
@media (max-width: 520px) { .public-contestants { grid-template-columns: 1fr; } }

.judging-card { grid-area: judging; margin: 0; }
.judging-card summary { font-size: 1.2rem; font-weight: 750; }
.judging-qr img { display: block; max-width: 100%; height: auto; margin-bottom: .75rem; }
.judge-codes { padding: 0; list-style: none; }
.judge-codes li { display: flex; flex-wrap: wrap; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.judge-codes code { color: var(--gold); }
#score-fields { display: grid; gap: .75rem; }

.audience-card { grid-area: audience; margin: 0; }
.audience-card > summary { font-size: 1.2rem; font-weight: 750; }
#audience-admin-results { margin-top: 1rem; }
#audience-history:not(:empty) { border-top: 1px solid var(--line); margin-top: 1rem; }
