/* Flick design system.
   The world it borrows from: switch plates, breaker panels and bench instruments.
   Surfaces are powder-coated faceplates, labels are engraved mono caps, buttons have
   key travel, and the one bright thing is the filament: amber means "on".
   Lights-off (dark) is the lobby and the night theme; lights-on is the game. */

:root {
  --ink: #15161b;
  --ink-2: #3b3d46;
  --ink-3: #6a6d77;
  --plate: #e7e9e2;
  --plate-2: #dcdfd5;
  --paper: #f7f8f3;
  --line: #c8cbc1;
  --line-2: #b4b8ad;
  --filament: #ffb020;
  --filament-deep: #b97700;
  --glow: rgb(255 176 32 / .38);
  --cobalt: #2d5be3;
  --live: #ef432b;
  --ok: #138f68;
  --no: #d23f2e;
  --on-filament: #15161b;
  --seg-off: rgb(21 22 27 / .08);
  --shadow: 0 1px 0 rgb(255 255 255 / .7) inset, 0 1px 2px rgb(21 22 27 / .06);

  --k-a: #ffb020; --k-b: #2d5be3; --k-c: #e2523f; --k-d: #129a6e; --k-e: #8650de; --k-f: #0a8597;

  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 6px;
  --r-lg: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --snap: cubic-bezier(.5, 1.6, .4, .8);
  color-scheme: light;
}
/* lights off */
:root[data-theme="dark"], .lights-off {
  --ink: #eef0ea;
  --ink-2: #c3c6bd;
  --ink-3: #8b8e97;
  --plate: #121318;
  --plate-2: #0c0d11;
  --paper: #1b1c23;
  --line: #2c2e37;
  --line-2: #3b3e49;
  --seg-off: rgb(238 240 234 / .07);
  --shadow: 0 1px 0 rgb(255 255 255 / .04) inset;
  --cobalt: #7f9cff;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eef0ea; --ink-2: #c3c6bd; --ink-3: #8b8e97; --plate: #121318; --plate-2: #0c0d11; --paper: #1b1c23;
    --line: #2c2e37; --line-2: #3b3e49; --seg-off: rgb(238 240 234 / .07); --shadow: 0 1px 0 rgb(255 255 255 / .04) inset;
    --cobalt: #7f9cff; color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--plate); color: var(--ink);
  font: 400 16px/1.5 var(--body); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--display); font-stretch: 112%; font-weight: 800; line-height: 1.05; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: 24px; }
h3 { font-size: 18px; font-stretch: 105%; font-weight: 750; }
p { margin: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--filament); color: #15161b; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* engraved label: what an instrument panel prints next to a knob */
.label {
  font: 500 10.5px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.mono { font-family: var(--mono); font-feature-settings: "zero"; }
.num { font-family: var(--display); font-stretch: 125%; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }

/* ---------- wordmark: the dot over the i is the indicator lamp ---------- */
.wordmark {
  display: inline-flex; align-items: baseline; gap: 0; font: 900 26px/1 var(--display); font-stretch: 125%;
  letter-spacing: -.035em; color: var(--ink); text-decoration: none; user-select: none; position: relative;
}
.wordmark .i { position: relative; display: inline-block; }
.wordmark .lamp {
  position: absolute; left: 50%; top: -.06em; width: .3em; height: .3em; margin-left: -.15em; border-radius: 50%;
  background: var(--filament); box-shadow: 0 0 0 .05em rgb(255 176 32 / .25), 0 0 .5em var(--glow);
  transition: background .12s, box-shadow .2s;
}
.wordmark.off .lamp, .wordmark[aria-pressed="false"] .lamp { background: var(--line-2); box-shadow: none; }
button.wordmark { background: none; border: 0; padding: 4px 2px; cursor: pointer; }
.wordmark.big { font-size: clamp(64px, 14vw, 132px); }

/* ---------- buttons: keys with travel ---------- */
.btn {
  --bg: var(--ink); --fg: var(--paper); --edge: #000;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border: 0; border-radius: var(--r);
  background: var(--bg); color: var(--fg); font: 700 15px/1 var(--body); text-decoration: none; cursor: pointer;
  box-shadow: 0 3px 0 var(--edge); transform: translateY(0); transition: transform .06s, box-shadow .06s, filter .15s;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] .btn:not(.primary):not(.ghost):not(.danger), .lights-off .btn:not(.primary):not(.ghost):not(.danger) { --bg: #eef0ea; --fg: #15161b; --edge: #8b8e97; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.primary):not(.ghost):not(.danger) { --bg: #eef0ea; --fg: #15161b; --edge: #8b8e97; } }
.btn:hover { filter: brightness(1.08); }
.btn:active, .btn.pressed { transform: translateY(3px); box-shadow: 0 0 0 var(--edge); }
.btn.primary { --bg: var(--filament); --fg: #15161b; --edge: var(--filament-deep); }
.btn.ghost { --bg: transparent; --fg: var(--ink); --edge: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn.ghost:active { transform: translateY(1px); }
.btn.danger { --bg: var(--no); --fg: #fff; --edge: #8e2418; }
.btn.small { min-height: 32px; padding: 0 11px; font-size: 13.5px; box-shadow: 0 2px 0 var(--edge); }
.btn.small.ghost { box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn.big { min-height: 56px; padding: 0 26px; font-size: 18px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn .kbd { font: 500 11px var(--mono); opacity: .6; border: 1px solid currentColor; border-radius: 3px; padding: 2px 4px; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: var(--r); cursor: pointer; color: var(--ink-2); line-height: 0; }
.icon-btn:hover { background: var(--plate-2); color: var(--ink); }
.linkish { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- the switch: Flick's signature control ---------- */
.switch {
  --w: 54px; --h: 30px; position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: var(--w); height: var(--h); flex: none; border-radius: calc(var(--h) / 2); background: var(--plate-2);
  box-shadow: inset 0 0 0 1.5px var(--line-2), inset 0 2px 4px rgb(0 0 0 / .08); position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: calc(var(--h) - 6px); height: calc(var(--h) - 6px); border-radius: 50%;
  background: var(--paper); box-shadow: 0 1px 2px rgb(0 0 0 / .25), inset 0 -2px 0 rgb(0 0 0 / .08); transition: transform .22s var(--snap);
}
.switch input:checked + .track { background: var(--filament); box-shadow: inset 0 0 0 1.5px var(--filament-deep), 0 0 14px var(--glow); }
.switch input:checked + .track::after { transform: translateX(calc(var(--w) - var(--h))); background: #fffdf6; }
.switch input:focus-visible + .track { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.switch .txt { font-weight: 600; }
.switch .txt small { display: block; font-weight: 400; color: var(--ink-3); font-size: 13.5px; line-height: 1.35; }

/* The big one: a wall switch you flick to start a game. */
.mains {
  --h: 220px; width: calc(var(--h) * .58); height: var(--h); border-radius: 18px; position: relative; cursor: pointer;
  background: linear-gradient(#f4f5ef, #d9dcd2); border: 0; padding: 0;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .25), 0 18px 40px rgb(0 0 0 / .45), inset 0 1px 0 #fff;
}
.mains::before, .mains::after { /* the two screws */
  content: ""; position: absolute; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #9a9d94); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2);
}
.mains::before { top: 12px; } .mains::after { bottom: 12px; }
.mains .rocker {
  position: absolute; left: 22%; right: 22%; top: 22%; bottom: 22%; border-radius: 10px;
  background: linear-gradient(#2a2b31 0 50%, #1c1d22 50%); box-shadow: 0 6px 0 #0c0c0f, inset 0 1px 0 rgb(255 255 255 / .12);
  transform-origin: 50% 50%; transition: transform .14s var(--ease), box-shadow .14s;
  display: grid; place-items: center;
}
.mains .rocker::after { content: "OFF"; font: 600 12px var(--mono); letter-spacing: .12em; color: #6a6d77; margin-top: 52%; }
.mains .lamp { position: absolute; top: 10%; right: 12%; width: 9px; height: 9px; border-radius: 50%; background: #9a9d94; }
.mains.on .rocker { transform: perspective(300px) rotateX(-14deg); box-shadow: 0 -4px 0 #0c0c0f, inset 0 -1px 0 rgb(255 255 255 / .12); }
.mains.on .rocker::after { content: "ON"; color: var(--filament); margin-top: -52%; }
.mains.on .lamp { background: var(--filament); box-shadow: 0 0 12px var(--filament); }
.mains:focus-visible { outline: 4px solid var(--filament); outline-offset: 6px; }

/* ---------- surfaces ---------- */
.plate { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.plate.pad { padding: 20px; }
.plate-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.plate-body { padding: 18px; }
.rule { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- form fields: recessed ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.field > small { color: var(--ink-3); font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: var(--r);
  background: var(--plate); box-shadow: inset 0 2px 3px rgb(0 0 0 / .05); transition: border-color .12s, box-shadow .12s;
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.4; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 2px 3px rgb(0 0 0 / .05), 0 0 0 3px var(--glow); }
.input.pin { font: 600 clamp(30px, 9vw, 44px)/1 var(--mono); letter-spacing: .2em; text-align: center; padding: 16px 8px; font-feature-settings: "zero"; }
.input.huge { font-size: 22px; font-weight: 700; text-align: center; padding: 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* segmented rocker group */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--plate-2); border-radius: calc(var(--r) + 3px); box-shadow: inset 0 0 0 1px var(--line); flex-wrap: wrap; }
.seg button, .seg label { border: 0; background: none; padding: 7px 12px; border-radius: var(--r); font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-2); position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg [aria-pressed="true"], .seg label:has(input:checked) { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .15), inset 0 0 0 1px var(--line); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--cobalt); }

/* ---------- tags, chips, badges ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; background: var(--plate-2); font: 500 11.5px/1.3 var(--mono); letter-spacing: .02em; color: var(--ink-2); white-space: nowrap; }
.tag.live { background: var(--live); color: #fff; }
.tag.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.4s steps(2) infinite; }
.tag.on { background: var(--filament); color: #15161b; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-weight: 600; font-size: 14.5px; }
.chip.pop { animation: pop .35s var(--snap); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.on { background: var(--ok); }
/* team badge: the team's SI unit symbol on its colour */
.badge {
  --c: var(--ink); display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 8px;
  background: var(--c); color: #fff; font: 800 15px/1 var(--display); font-stretch: 112%; letter-spacing: -.02em;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / .2);
}
.badge.lg { width: 64px; height: 64px; border-radius: 14px; font-size: 28px; }
.badge.xl { width: 120px; height: 120px; border-radius: 24px; font-size: 54px; box-shadow: inset 0 -6px 0 rgb(0 0 0 / .2); }

/* ---------- level meter: a team's score as lit segments ---------- */
.meter { --c: var(--filament); --n: 30; position: relative; height: 26px; border-radius: 3px; }
.meter, .meter > i {
  background: repeating-linear-gradient(90deg, var(--seg) 0 calc(100% / var(--n) - 3px), transparent calc(100% / var(--n) - 3px) calc(100% / var(--n)));
}
.meter { --seg: var(--seg-off); }
.meter > i { --seg: var(--c); position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--v, 0%)) 0 0); transition: clip-path .9s var(--ease); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--c) 45%, transparent)); }

/* ---------- answer keys ---------- */
.keys { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.key {
  --c: var(--k-a); position: relative; display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  min-height: 76px; padding: 14px 16px; border: 0; border-radius: var(--r-lg); cursor: pointer;
  background: var(--c); color: #fff; font: 700 18px/1.25 var(--body);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 60%, #000); transition: transform .07s, box-shadow .07s, opacity .2s, filter .2s;
  -webkit-tap-highlight-color: transparent;
}
.key:nth-child(1) { --c: var(--k-a); color: #15161b; } .key:nth-child(2) { --c: var(--k-b); } .key:nth-child(3) { --c: var(--k-c); }
.key:nth-child(4) { --c: var(--k-d); } .key:nth-child(5) { --c: var(--k-e); } .key:nth-child(6) { --c: var(--k-f); }
.key .cap {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 7px;
  background: rgb(255 255 255 / .22); font: 700 17px/1 var(--mono); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .15);
}
.key:active, .key.chosen { transform: translateY(5px); box-shadow: 0 0 0 color-mix(in srgb, var(--c) 60%, #000); }
.key.dim { opacity: .28; filter: saturate(.4); }
.key.right { outline: 4px solid var(--ink); outline-offset: 3px; }
.key.right::after { content: "✓"; position: absolute; right: 14px; top: 50%; translate: 0 -50%; font: 800 24px var(--display); }
.key[disabled] { cursor: default; }
/* true / false: a rocker switch, ON and OFF */
.keys.tf { grid-template-columns: 1fr; }
.keys.tf .key { justify-content: center; min-height: 120px; font-size: 26px; font-family: var(--display); font-stretch: 115%; font-weight: 800; }
.keys.tf .key:nth-child(1) { --c: var(--k-a); }
.keys.tf .key:nth-child(2) { --c: #26272e; color: #eef0ea; }
.keys.tf .key .cap { width: auto; padding: 0 10px; font-size: 14px; letter-spacing: .1em; }

/* ---------- timer: a filament that burns down ---------- */
.fuse { position: relative; height: 10px; border-radius: 5px; background: var(--seg-off); overflow: hidden; }
.fuse > i { position: absolute; inset: 0; transform-origin: left; background: var(--filament); box-shadow: 0 0 16px var(--filament); border-radius: inherit; }
.fuse.low > i { animation: flicker .9s steps(1) infinite; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font: 500 10.5px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: color-mix(in srgb, var(--plate) 60%, transparent); }
.table-wrap { overflow-x: auto; }

/* ---------- toast & dialog ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; translate: -50% 0; z-index: 90; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: #15161b; color: #eef0ea; padding: 12px 16px; border-radius: var(--r); box-shadow: 0 10px 30px rgb(0 0 0 / .3); font-weight: 600; font-size: 15px; animation: toast-in .25s var(--ease); pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--filament); flex: none; }
.toast.err::before { background: var(--no); }
dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); color: var(--ink); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); box-shadow: 0 30px 80px rgb(0 0 0 / .35); }
dialog::backdrop { background: rgb(12 13 17 / .55); }
dialog[open] { animation: dlg-in .22s var(--ease); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 1; }
.dlg-body { padding: 20px; display: grid; gap: 16px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--paper); }

/* empty state */
.empty { padding: 36px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; color: var(--ink-2); }
.empty .wordmark { font-size: 40px; opacity: .3; }

/* ---------- motion ---------- */
@keyframes blink { 50% { opacity: .2; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes dlg-in { from { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes flicker { 0%, 100% { opacity: 1; } 30% { opacity: .35; } 34% { opacity: 1; } 62% { opacity: .55; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes surge { 0% { box-shadow: 0 0 0 0 var(--glow); } 100% { box-shadow: 0 0 0 26px transparent; } }
.rise { animation: rise .45s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
