/* Quick Vote. Themes: light (default), dark, sepia, contrast; "system" follows prefers-color-scheme. */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1b1f2a;
  --muted: #5a6275;
  --border: #d5d9e3;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --accent-soft: #e6ecfb;
  --danger: #b3261e;
  --success: #1e7a3c;
  --success-soft: #e4f4e9;
  --bar: #2f5bd3;
  --focus: #f0a500;
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12151c; --surface: #1c212b; --text: #e8eaf0; --muted: #a3abbd; --border: #333a48;
  --accent: #7c9bff; --accent-text: #0d1220; --accent-soft: #24304d; --danger: #ff8a80;
  --success: #6fd38e; --success-soft: #1d3326; --bar: #7c9bff; --focus: #ffcc4d;
  color-scheme: dark;
}
:root[data-theme="sepia"] {
  --bg: #f3ead8; --surface: #fbf5e9; --text: #3b2f22; --muted: #6e5d49; --border: #dccdb2;
  --accent: #8a4b16; --accent-text: #fff8ee; --accent-soft: #efdcc2; --danger: #a12d1f;
  --success: #3d6b26; --success-soft: #e3ead0; --bar: #8a4b16; --focus: #c26a00;
  color-scheme: light;
}
:root[data-theme="contrast"] {
  --bg: #000000; --surface: #000000; --text: #ffffff; --muted: #ffffff; --border: #ffffff;
  --accent: #ffff00; --accent-text: #000000; --accent-soft: #333300; --danger: #ff6b6b;
  --success: #00ff7f; --success-soft: #002b16; --bar: #ffff00; --focus: #00ffff;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #12151c; --surface: #1c212b; --text: #e8eaf0; --muted: #a3abbd; --border: #333a48;
    --accent: #7c9bff; --accent-text: #0d1220; --accent-soft: #24304d; --danger: #ff8a80;
    --success: #6fd38e; --success-soft: #1d3326; --bar: #7c9bff; --focus: #ffcc4d;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .5rem; overflow-wrap: anywhere; }
h2, .h3 { font-size: 1.2rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header { padding: .75rem 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.brand-mark { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 6px; background: var(--accent); color: var(--accent-text); }
.container { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; flex: 1; }
.container-wide { max-width: 1040px; }

.landing-hero { padding: 1.5rem 0 .5rem; }
.landing-hero h1 { font-size: 2rem; }
.landing h2 { margin-top: 1.25rem; }
.video-card .h3 { margin-bottom: .4rem; }
.video { display: block; background: #000; border-radius: var(--radius); height: auto; }
.video-tall { width: auto; max-width: 100%; max-height: 85vh; aspect-ratio: 9 / 16; margin: 0 auto; }
.video-wide { display: none; width: 100%; aspect-ratio: 16 / 9; }
.features { margin: 0 0 1rem; padding-left: 1.25rem; }
.features li { margin-bottom: .45rem; }
@media (min-width: 760px) {
  .video-tall.has-wide { display: none; }
  .video-wide { display: block; }
}
.site-footer { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; justify-content: space-between; align-items: center; padding: 1rem 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: .95rem; }
.lang-switch { display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
.lang-switch a { padding: .4rem .2rem; min-height: 44px; display: inline-flex; align-items: center; }
.lang-switch a[aria-current] { font-weight: 700; color: var(--text); text-decoration: none; }
.theme-switch select { margin-left: .4rem; }
.app-version { font-size: .85rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.notice-card { border-color: var(--accent); background: var(--accent-soft); }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); margin-bottom: .25rem; }
.lead { font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); }
small.muted { display: block; font-size: .85rem; }
.error { color: var(--danger); font-weight: 600; }
.success { color: var(--success); background: var(--success-soft); padding: .75rem 1rem; border-radius: 8px; font-weight: 600; }
.notice { display: flex; gap: .6rem; align-items: center; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.danger { color: var(--danger); border-color: var(--danger); }
.button.small { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.button.wide { width: 100%; margin-top: .75rem; }
.link-button { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .75rem 0; }
form.inline { display: inline; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; min-height: 44px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 1rem; margin-bottom: .75rem; }
.stack label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.stack label input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
label.check { flex-direction: row !important; align-items: center; font-weight: 400 !important; gap: .6rem !important; }
label.check input { width: 1.3rem; height: 1.3rem; min-height: 0; flex-shrink: 0; }

.pin-row { display: flex; gap: .6rem; margin-top: .35rem; }
.pin-input { font-size: 1.8rem; letter-spacing: .3em; text-align: center; width: 100%; max-width: 260px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); align-items: center; }
.tabs a { padding: .6rem .9rem; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.admin-nav form { margin-left: auto; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: .6rem; }
.choice {
  display: flex; gap: .8rem; align-items: flex-start; padding: .8rem 1rem; margin-bottom: .5rem;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; min-height: 52px;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 1.4rem; height: 1.4rem; margin-top: .1rem; flex-shrink: 0; accent-color: var(--accent); }
.choice-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.choice-label { font-weight: 600; }
.choice-detail { color: var(--muted); font-size: .92rem; }
.hp { position: absolute; left: -9999px; }

.results { list-style: none; padding: 0; margin: 0 0 .5rem; }
.result { margin-bottom: .8rem; }
.result-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.result-label { min-width: 0; overflow-wrap: anywhere; }
.result-count { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.result.is-winner .result-label { font-weight: 700; }
.bar { height: 10px; border-radius: 6px; background: var(--accent-soft); overflow: hidden; margin-top: .25rem; }
.bar span { display: block; height: 100%; width: 0; background: var(--bar); transition: width .4s ease; }

.winner { text-align: center; padding: 1rem; border-radius: var(--radius); background: var(--accent-soft); margin: 1rem 0; }
.winner-name { font-size: 1.8rem; font-weight: 800; margin: 0; overflow-wrap: anywhere; }

.share { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center; margin: 1rem 0; }
.qr { background: #fff; border-radius: 8px; padding: 4px; width: 180px; height: 180px; }
.share-facts { flex: 1; min-width: 220px; margin: 0; }
.share-facts dt { color: var(--muted); font-size: .9rem; }
.share-facts dd { margin: 0 0 .75rem; }
.pin-big { font-size: 2rem; font-weight: 800; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; min-width: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid var(--border); }
.status-open { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.status-closed { color: var(--muted); }
.poll-list { list-style: none; padding: 0; margin: 0; }
.poll-list li { padding: .7rem 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: baseline; }
.poll-list li a { font-weight: 600; overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.stats div { border: 1px solid var(--border); border-radius: 10px; padding: .75rem; }
.stats dt { color: var(--muted); font-size: .9rem; }
.stats dd { margin: 0; font-size: 1.6rem; font-weight: 800; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }

.spinner { width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .bar span { transition: none; } }

/* TV screen */
body.is-screen .container { max-width: 1400px; }
.screen { text-align: center; padding: 2vh 0; }
.screen-title { font-size: clamp(1.8rem, 4vw, 3.5rem); }
.screen-join { display: flex; flex-wrap: wrap; gap: 4vw; align-items: center; justify-content: center; margin-top: 3vh; }
.qr-big { width: min(70vw, 52vh); height: auto; aspect-ratio: 1; }
.screen-facts { text-align: left; font-size: clamp(1.1rem, 2.2vw, 2rem); }
.screen-step { margin: 0 0 .4em; }
.pin-huge { font-size: clamp(3rem, 9vw, 8rem); font-weight: 900; letter-spacing: .08em; margin: .1em 0; font-variant-numeric: tabular-nums; }
.screen-count { font-size: clamp(1.2rem, 2.5vw, 2.2rem); color: var(--muted); }
.winner-big .winner-name { font-size: clamp(2.5rem, 7vw, 6rem); }
.screen-results { max-width: 900px; margin: 3vh auto; text-align: left; font-size: clamp(1rem, 2vw, 1.6rem); }

@media (max-width: 480px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 1rem; }
  .pin-row { flex-direction: column; }
  .pin-input { max-width: none; }
}

[hidden] { display: none !important; }
fieldset.settings, fieldset.deadline { border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; }
fieldset.settings legend, fieldset.deadline legend { padding: 0 .35rem; }
.stack fieldset label:not(.check) { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.deadline-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.deadline-amount { width: 6rem; }
.pin-gap { margin-left: .35em; }
