/* Default Settings Gaala — tokenit design systemistä. Tumma teema ensisijainen. */
:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #141414;
  --surface-raised: #1f1f1f;
  --border: #2e2e2e;
  --ink: #ffffff;
  --ink-muted: #b5b5b8;
  --gold-light: #f3e09c;
  --gold: #d2af57;
  --gold-dark: #bea260;
  --gold-text: #d2af57;
  --on-gold: #000000;
  --red: #801b1d;
  --on-red: #ffffff;
  --charcoal: #55565a;
  --focus: #f3e09c;
  --danger-text: #e06a6c;
  --glow-gold: 0 0 32px rgba(243, 224, 156, 0.18);

  --font-sans: Jost, "Futura PT", Futura, "Century Gothic", system-ui, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-3: 16px; --space-4: 24px; --space-5: 48px; --space-6: 96px;
  --radius-0: 0; --radius-sm: 2px; --radius-pill: 999px;
  --gold-gradient: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #ffffff; --surface: #f8f5ec; --surface-raised: #efe8d6; --border: #ddd3bb;
    --ink: #000000; --ink-muted: #55565a; --gold-text: #7a6430; --focus: #7a6430; --danger-text: #801b1d;
    --glow-gold: 0 8px 24px rgba(122, 100, 48, 0.16);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff; --surface: #f8f5ec; --surface-raised: #efe8d6; --border: #ddd3bb;
  --ink: #000000; --ink-muted: #55565a; --gold-text: #7a6430; --focus: #7a6430; --danger-text: #801b1d;
  --glow-gold: 0 8px 24px rgba(122, 100, 48, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--gold-text); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.wrap { max-width: 1040px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Type */
.eyebrow { font-size: 12px; line-height: 1.4; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-text); margin: 0; }
.display { font-size: clamp(44px, 9vw, 72px); line-height: 0.95; font-weight: 500; letter-spacing: 0.02em; margin: 0; text-wrap: balance; }
.h1 { font-size: clamp(32px, 6vw, 48px); line-height: 1.05; font-weight: 500; letter-spacing: 0.02em; margin: 0; text-wrap: balance; }
.h2 { font-size: clamp(24px, 4vw, 32px); line-height: 1.15; font-weight: 500; margin: 0; text-wrap: balance; }
.h3 { font-size: 20px; line-height: 1.25; font-weight: 500; margin: 0; }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; line-height: 1.5; }
.lead { font-size: 18px; color: var(--ink-muted); max-width: 60ch; margin: 0; }

/* Header */
.topbar { border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-block: var(--space-3); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; font-size: 13px; text-decoration: none; color: var(--ink); }
.brand-mark { display: flex; height: 22px; }
.brand-mark i { display: block; height: 100%; }
.brand-mark i:nth-child(1) { width: 9px; background: var(--gold-dark); }
.brand-mark i:nth-child(2) { width: 3px; background: var(--gold-light); }
.brand-mark i:nth-child(3) { width: 9px; background: var(--red); }
.brand-mark i:nth-child(4) { width: 6px; background: var(--gold); }
.whoami { display: flex; align-items: center; gap: var(--space-3); font-size: 14px; }

/* Phase stepper */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin: 0; padding: 0; list-style: none; }
.stepper li { padding: 12px 0 0; border-top: 2px solid var(--border); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); }
.stepper li b { display: block; font-weight: 500; font-size: 13px; letter-spacing: 0.04em; text-transform: none; color: inherit; }
.stepper li.done { border-top-color: var(--gold-dark); }
.stepper li.now { border-top-color: var(--gold-light); color: var(--ink); }
.stepper li.now b { color: var(--gold-text); }

/* Hero */
.hero { padding-block: var(--space-5) var(--space-4); display: grid; gap: var(--space-4); }
.hero-head { display: grid; gap: var(--space-2); }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); align-items: center; }
.meter { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 14px; height: 14px; border: 1.5px solid var(--gold-dark); display: block; }
.pips i.on { background: var(--gold); border-color: var(--gold); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-4); font: 500 14px/1 var(--font-sans); letter-spacing: 0.16em; text-transform: uppercase; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: filter .15s, background .15s; white-space: nowrap; }
.btn--primary { background: var(--gold-gradient); color: var(--on-gold); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--secondary { background: transparent; color: var(--ink); border-color: var(--gold-dark); }
.btn--secondary:hover { background: var(--surface-raised); }
.btn--red { background: var(--red); color: var(--on-red); }
.btn--ghost { background: transparent; color: var(--ink-muted); min-height: 36px; padding: 0 var(--space-2); letter-spacing: 0.12em; font-size: 12px; }
.btn--ghost:hover { color: var(--ink); }
.btn--sm { min-height: 36px; padding: 0 var(--space-3); font-size: 12px; }
.btn:disabled { background: var(--charcoal); color: #ffffff; border-color: transparent; cursor: not-allowed; filter: none; }
.btn--voted { background: var(--gold-gradient); color: var(--on-gold); border-color: transparent; }

/* Forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); }
.input { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.input:focus { border-color: var(--gold-dark); outline: none; box-shadow: 0 0 0 2px var(--focus); }
.form-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: var(--space-3); align-items: end; }
@media (max-width: 720px) { .form-row { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); padding: var(--space-4); display: grid; gap: var(--space-3); }

/* Section */
.section { padding-block: var(--space-4); display: grid; gap: var(--space-4); }
.cat-head { padding-bottom: var(--space-3); border-bottom: 1px solid var(--gold-dark); display: grid; gap: var(--space-2); }
.cat-head .row { display: flex; justify-content: space-between; align-items: end; gap: var(--space-3); flex-wrap: wrap; }

/* Lists of things to vote on */
.list { display: grid; gap: 2px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); }
.item > div { min-width: 0; }
.item .title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-weight: 500; font-size: 18px; }
.item p { margin: 2px 0 0; color: var(--ink-muted); font-size: 14px; overflow-wrap: anywhere; }
.item.is-voted { border-color: var(--gold-dark); }
.tag { display: inline-block; padding: 3px 8px; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 500; border: 1px solid var(--border); color: var(--ink-muted); }
.tag--gold { border-color: var(--gold-dark); color: var(--gold-text); }
.tag--red { background: var(--red); border-color: var(--red); color: var(--on-red); }

/* Finale radio */
.vote { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.vote:hover { background: var(--surface-raised); }
.vote input { appearance: none; width: 22px; height: 22px; margin: 0; border: 1.5px solid var(--gold-dark); border-radius: 50%; display: grid; place-items: center; flex: none; cursor: pointer; }
.vote input::after { content: ""; width: 11px; height: 11px; border-radius: 50%; background: var(--gold); transform: scale(0); transition: transform .12s; }
.vote input:checked::after { transform: scale(1); }
.vote:has(input:checked) { border-color: var(--gold-dark); box-shadow: var(--glow-gold); }
.vote .txt { min-width: 0; }
.vote .txt b { font-weight: 500; font-size: 18px; display: block; }
.vote .txt span { color: var(--ink-muted); font-size: 14px; }

/* Empty */
.empty { padding: var(--space-4); border: 1px dashed var(--border); color: var(--ink-muted); text-align: left; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.login-main { display: grid; align-content: center; gap: var(--space-5); padding-block: var(--space-5); }
.login-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--space-5); align-items: start; }
@media (max-width: 820px) { .login-grid { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: var(--space-4); border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; padding: 0 0 10px; cursor: pointer; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold-light); }
.band { display: flex; height: 10px; }
.band i { display: block; height: 100%; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--surface-raised); color: var(--ink); border: 1px solid var(--gold-dark); padding: 12px 18px; font-size: 14px; max-width: calc(100% - 32px); z-index: 50; }
.toast.err { border-color: var(--red); }

/* Admin */
.admin { margin-top: var(--space-5); border-top: 1px solid var(--gold-dark); padding-block: var(--space-5); display: grid; gap: var(--space-4); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-muted); font-weight: 500; background: var(--surface); }
td.num { font-variant-numeric: tabular-nums; text-align: right; width: 1%; white-space: nowrap; }
td.act { width: 1%; white-space: nowrap; text-align: right; }
.bar { height: 6px; background: var(--surface-raised); min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--gold); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.phase-btns { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.footer { padding-block: var(--space-5); color: var(--ink-muted); font-size: 13px; display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-muted); text-decoration: underline; cursor: pointer; font-size: 13px; }

/* Gala show */
.show { position: fixed; inset: 0; background: #000; color: #fff; z-index: 100; display: grid; grid-template-rows: auto 1fr auto; padding: calc(24px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); overflow: auto; }
.show .eyebrow { color: #d2af57; }
.show-stage { display: grid; align-content: center; justify-items: center; gap: var(--space-4); text-align: center; }
.show-noms { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }
.show-noms span { padding: 10px 18px; border: 1px solid #2e2e2e; font-size: 20px; }
.show-winner { font-size: clamp(48px, 10vw, 120px); line-height: .95; font-weight: 500; background: linear-gradient(135deg, #f3e09c, #bea260); -webkit-background-clip: text; background-clip: text; color: transparent; animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
.show-bar { display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.show select { background: #141414; color: #fff; border: 1px solid #2e2e2e; min-height: 44px; padding: 0 12px; }
.rays { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 0%, rgba(243,224,156,.16), transparent 60%); }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .show-winner { animation: none; } * { transition: none !important; } }

.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; letter-spacing: 0.08em; color: var(--gold-text); white-space: nowrap; }
.code-input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.12em; text-transform: uppercase; font-size: 18px; }
textarea.input { resize: vertical; min-height: 64px; }

/* Ehdokaskortit (vaihe 2) */
.nom-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.nom-card { display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.nom-card.is-voted { border-color: var(--gold-dark); box-shadow: var(--glow-gold); }
.nom-mono { position: relative; aspect-ratio: 16 / 9; max-width: 100%; display: grid; place-items: center; background: var(--surface-raised); border-bottom: 1px solid var(--border); overflow: hidden; }
.nom-mono > span:first-child { font-size: 72px; line-height: 1; font-weight: 500; color: var(--gold-text); }
.nom-card.is-voted .nom-mono { background: var(--gold-gradient); }
.nom-card.is-voted .nom-mono > span:first-child { color: var(--on-gold); }
.nom-tag { position: absolute; top: var(--space-2); left: var(--space-2); background: var(--bg); }
.nom-body { padding: var(--space-3) var(--space-3) var(--space-2); display: grid; gap: 4px; align-content: start; min-width: 0; }
.nom-body p { margin: 0; color: var(--ink-muted); font-size: 14px; overflow-wrap: anywhere; }
.nom-card > .btn { margin: var(--space-2) var(--space-3) var(--space-3); }
