/* TokenCraze — one stylesheet for every screen.
   Layout: a one-column app shell; the host "stage" is a projection panel that can go full screen;
   on phones the answer pads fill the width. One committed dark look (classroom projector). */

@font-face { font-family: "Bricolage Grotesque"; font-weight: 600; font-display: swap; src: url("/fonts/bricolage-grotesque/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-display: swap; src: url("/fonts/bricolage-grotesque/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-hyperlegible/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("/fonts/atkinson-hyperlegible/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 600; font-display: swap; src: url("/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2") format("woff2"); }

:root {
  --ink: #0d2127; --panel: #14303a; --panel-2: #1b3d48; --line: #2a5260; --paper: #f4efe4; --muted: #9db5b7;
  --accent: #ffd166; --good: #5ad893; --bad: #ff7d6e;
  --a0: #e0533a; --a1: #2c7fd6; --a2: #d29a10; --a3: #20975a;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--ink); color: var(--paper); margin: 0; }
body { font-family: var(--f-body); font-size: 16px; line-height: 1.5; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.app { max-width: 1180px; margin: 0 auto; padding-inline: 16px; padding-block: 12px 64px; }

/* top bar */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 6px 14px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.01em; color: var(--paper); text-decoration: none; }
.brand svg { flex: none; }
.tagline { display: block; font-family: var(--f-body); font-weight: 400; font-size: .78rem; color: var(--muted); letter-spacing: 0; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; background: var(--panel); padding: 4px; border-radius: 999px; }
.nav a, .nav button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 700; text-decoration: none; font-size: .95rem; }
.nav a[aria-current="page"] { background: var(--paper); color: var(--ink); }
.nav form { margin: 0; }

/* type + common */
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.6rem; } h3 { font-size: 1.15rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.eyebrow { font-family: var(--f-mono); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.trace { font-family: var(--f-mono); font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.trace b { color: var(--accent); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; background: var(--panel-2); border: 1px solid var(--line); color: var(--paper); text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #1d1600; border-color: var(--accent); }
.btn.big { font-size: 1.15rem; padding: 14px 26px; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: .88rem; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.inline { display: inline; margin: 0; }
label.lbl, .lbl { font-size: .85rem; font-weight: 700; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input:not([type]), select, textarea {
  background: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; min-height: 90px; font-family: var(--f-mono); font-size: .88rem; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: transparent; cursor: pointer; font-size: .9rem; color: var(--paper); text-decoration: none; }
.chip[aria-current="true"], .chip:has(input:checked) { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.pill { font-family: var(--f-mono); font-size: .75rem; border-radius: 999px; padding: 3px 10px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.live { background: var(--good); color: #06240f; border-color: var(--good); }
.pill.warn { background: var(--bad); color: #2a0702; border-color: var(--bad); }
.flash { border-left: 3px solid var(--good); padding: 10px 14px; background: var(--panel); border-radius: 0 10px 10px 0; margin-bottom: 18px; }
.flash.error, .errors { border-left-color: var(--bad); }
.errors { border-left: 3px solid var(--bad); padding: 10px 14px; background: var(--panel); border-radius: 0 10px 10px 0; }
.errors ul { margin: 6px 0 0; padding-left: 1.2em; }
.empty { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
details > summary { cursor: pointer; font-weight: 700; }
code, .mono { font-family: var(--f-mono); font-size: .9em; }
.secret { font-family: var(--f-mono); font-size: 2rem; letter-spacing: .12em; background: var(--ink); border: 1px dashed var(--accent); border-radius: 12px; padding: 14px 20px; display: inline-block; user-select: all; overflow-wrap: anywhere; }

/* tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td.num, th.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }

/* answer tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; display: flex; align-items: center; gap: 14px; border: 0; border-radius: 14px; padding: 18px; min-height: 86px; text-align: left; color: #fff; font-weight: 700; font-size: 1.1rem; cursor: pointer; overflow: hidden; min-width: 0; }
.tile .txt { min-width: 0; overflow-wrap: anywhere; }
.tile.t0 { background: var(--a0); } .tile.t1 { background: var(--a1); } .tile.t2 { background: var(--a2); color: #1c1400; } .tile.t3 { background: var(--a3); }
.tile .key { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: 1.2rem; background: rgba(0,0,0,.22); }
.tile.dim { opacity: .32; }
.tile .count { margin-left: auto; font-family: var(--f-mono); font-size: 1.2rem; flex: none; }
.tile .barfill { position: absolute; left: 0; bottom: 0; height: 6px; background: rgba(255,255,255,.75); }
.tile .tick { flex: none; font-size: 1.4rem; }
div.tile { cursor: default; }
button.tile:active { transform: scale(.98); }

/* timer */
.tline { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.tbar { height: 100%; background: var(--accent); transform-origin: left; transition: transform .2s linear; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .tnum { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: 2rem; }
.ring .track { stroke: var(--panel-2); } .ring .tring { stroke: var(--accent); transition: stroke-dashoffset .2s linear; }

/* host stage */
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 3vw, 36px); display: flex; flex-direction: column; gap: 22px; min-height: 440px; }
.stage:fullscreen { border-radius: 0; border: 0; padding: 4vw; font-size: 1.35rem; justify-content: center; overflow: auto; }
.stage:fullscreen .qtext { font-size: clamp(2rem, 4vw, 3.6rem); }
.stage:fullscreen .tile { min-height: 16vh; font-size: 1.6rem; }
.qtext { font-size: clamp(1.5rem, 3.2vw, 2.6rem); font-weight: 800; }
.qhead { display: flex; gap: 20px; align-items: center; justify-content: space-between; }
.qhead .qtext { min-width: 0; flex: 1; }
.lobby { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 6px; font-size: 1.15rem; }
.bignum { font-family: var(--f-display); font-weight: 800; font-size: 4.5rem; line-height: 1; }
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; font-weight: 700; max-width: 100%; }
.pchip small { font-weight: 400; color: var(--muted); }
.pchip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 0 6px; font-size: 1.1rem; }
.pchip button:hover { color: var(--bad); }
.names-hidden .pchip small { display: none; }
.foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; }
.board { display: flex; flex-direction: column; gap: 8px; max-width: 720px; width: 100%; margin: 0 auto; }
.brow { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; background: var(--panel-2); border-radius: 12px; padding: 12px 16px; font-size: 1.2rem; font-weight: 700; }
.brow .rk { font-family: var(--f-display); font-weight: 800; font-size: 1.4rem; color: var(--accent); }
.brow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .delta { font-family: var(--f-mono); color: var(--good); font-size: .95rem; }
.brow .sc { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; max-width: 720px; margin: 0 auto; width: 100%; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-width: 0; }
.pod .nm { font-weight: 800; font-size: 1.15rem; max-width: 100%; overflow-wrap: anywhere; }
.pod .blk { width: 100%; border-radius: 12px 12px 0 0; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: 2.2rem; color: var(--accent); }
.pod.p1 .blk { height: 160px; } .pod.p2 .blk { height: 110px; } .pod.p3 .blk { height: 80px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel-2); border-radius: 12px; padding: 14px; }
.stat .v { font-family: var(--f-display); font-weight: 800; font-size: 1.8rem; }
.stat .k { font-size: .85rem; color: var(--muted); }
.stat.wide { grid-column: 1 / -1; }

/* student phone */
.phone { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.status { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 16px; }
.status .huge { font-family: var(--f-display); font-weight: 800; font-size: 2.4rem; line-height: 1.1; }
.status.ok .huge { color: var(--good); }
.status.no .huge { color: var(--bad); }
.gain { font-family: var(--f-mono); font-size: 1.3rem; color: var(--good); }
.loop { font-family: var(--f-mono); color: var(--muted); font-size: .9rem; }
.loop span { opacity: .35; transition: opacity .3s; }
.loop span.on { opacity: 1; color: var(--accent); }
.me-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.me-bar b { color: var(--paper); }
.phone .tile { min-height: 120px; flex-direction: column; align-items: flex-start; justify-content: space-between; font-size: 1rem; }
.signin { max-width: 420px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 18px; }
.signin input.code { font-family: var(--f-mono); font-size: 1.5rem; letter-spacing: .15em; text-align: center; }
.conn { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); background: var(--bad); color: #2a0702; font-weight: 700; padding: 6px 14px; border-radius: 999px; font-size: .88rem; z-index: 5; }

/* question bank */
.qlist { display: flex; flex-direction: column; gap: 8px; }
.qrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.qrow .qq { font-weight: 700; }
.qrow .meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.qrow .ans { color: var(--good); }
.optedit { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.optedit .key { font-family: var(--f-display); font-weight: 800; }

/* rankings */
.rank { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.rank .pos { font-family: var(--f-display); font-weight: 800; font-size: 1.6rem; color: var(--accent); text-align: center; }
.rank .hd { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.rank .nm { font-weight: 800; font-size: 1.1rem; }
.rank .pc { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.meter { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.bad i { background: var(--bad); }
.rank .sub { font-size: .85rem; color: var(--muted); margin-top: 6px; }

@media (max-width: 720px) {
  .lobby { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .phone .tiles { grid-template-columns: 1fr 1fr; }
  .qhead { flex-direction: column-reverse; align-items: flex-start; }
  .bignum { font-size: 3.2rem; }
  .qrow { grid-template-columns: auto minmax(0, 1fr); }
  .qrow > :last-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
