/* Motormath: one stylesheet for the student page (a phone, upright) and the teacher page (the board, wide). */

:root {
  --paper: #f5f2ea;
  --card: #ffffff;
  --ink: #1d2026;
  --muted: #5f6672;
  --line: #e2dccd;
  --road: #2f343d;
  --road-line: #5b6270;
  --yellow: #ffd60a;
  --red: #e5383b;
  --red-deep: #a4161a;
  --green: #1f8a3f;
  --blue: #3a66f0;
  --orange: #c2410c;
  --purple: #8b46d6;
  --radius: 16px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body { -webkit-text-size-adjust: 100%; line-height: 1.35; }
h1, h2, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---- shared pieces ------------------------------------------------------------------------------------------ */

.logo { font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 900; font-style: italic; letter-spacing: -0.02em; text-align: center; }
.logo span { color: var(--red); }
.logo::after {
  content: ""; display: block; width: 168px; height: 12px; margin: 8px auto 0;
  background: conic-gradient(var(--ink) 90deg, transparent 90deg 180deg, var(--ink) 180deg 270deg, transparent 270deg) 0 0 / 12px 12px;
}
.logo.small { font-size: clamp(1.8rem, 6vw, 2.6rem); }

.lead { font-size: 1.1rem; text-align: center; color: var(--muted); text-wrap: balance; }
.status { text-align: center; color: var(--muted); font-weight: 600; }
.error { color: var(--red-deep); font-weight: 700; text-align: center; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 3px 0 var(--line); }

.big { font-size: 1.25rem; font-weight: 800; padding: 15px 22px; border: 0; border-radius: 14px; }
.go { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-deep); }
.go:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--red-deep); }
.go:disabled { background: #c9c4b8; box-shadow: 0 5px 0 #aaa497; }
.ghost { background: transparent; border: 2px solid var(--line); border-radius: 12px; padding: 10px 16px; font-weight: 700; color: var(--muted); }
.ghost:hover { border-color: var(--muted); color: var(--ink); }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 800; }
.secs { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.clock { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.clock > div { height: 100%; width: 100%; background: var(--green); border-radius: 99px; }
.clock > div.low { background: var(--red); }

.question { font-size: 1.3rem; font-weight: 700; line-height: 1.35; text-wrap: pretty; }
.how { color: var(--muted); font-weight: 600; text-align: center; text-wrap: balance; }
.nitro-tag { align-self: center; background: var(--ink); color: var(--yellow); font-weight: 800; padding: 5px 14px; border-radius: 99px; text-align: center; }
.paused { text-align: center; font-weight: 800; color: var(--red-deep); }

.choices { display: grid; gap: 12px; }
.choice {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px;
  border: 0; border-radius: 14px; color: #fff; font-size: 1.25rem; font-weight: 800; text-align: left;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28); overflow: hidden;
}
.choice.c0 { background: var(--blue); }
.choice.c1 { background: var(--orange); }
.choice.c2 { background: var(--green); }
.choice.c3 { background: var(--purple); }
.choice .tag { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, 0.26); }
button.choice:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28); }
button.choice:disabled:not(.picked) { opacity: 0.4; }
button.choice.picked { outline: 4px solid var(--ink); outline-offset: 2px; }

.coin { display: inline-block; width: 1em; height: 1em; margin-right: 0.3em; border-radius: 50%; background: var(--yellow); box-shadow: inset 0 0 0 2px #b08900; vertical-align: -0.12em; }

.offline { position: fixed; z-index: 20; top: 0; left: 0; right: 0; padding: 8px; background: var(--red-deep); color: #fff; font-weight: 700; text-align: center; }

svg.car { display: block; width: 100%; height: auto; }
svg.sign { display: block; width: 62%; height: 62%; }

/* ---- the student page --------------------------------------------------------------------------------------- */

.student .screen {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 480px; min-height: 100dvh; margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}
#s-join { padding-top: 9vh; }
#s-join form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
#s-join label { font-weight: 800; }
#s-join input {
  width: 100%; padding: 12px 14px; margin-bottom: 8px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--paper); font-size: 1.3rem; font-weight: 700;
}
#s-join input:focus { border-color: var(--ink); outline: none; }
#s-join .code-input { font-size: 2.2rem; font-weight: 900; letter-spacing: 0.35em; text-align: center; text-transform: uppercase; padding-left: calc(14px + 0.35em); }

.preview { position: relative; padding: 18px 16px 12px; border-radius: var(--radius); background: var(--road); }
.preview::after { content: ""; position: absolute; left: 16px; right: 16px; bottom: 7px; border-bottom: 3px dashed var(--road-line); }
.preview svg { position: relative; z-index: 1; width: min(100%, 320px); margin: 0 auto; }
.preview.small svg { width: min(70%, 220px); }
.cash { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 99px; background: var(--card); font-weight: 800; box-shadow: 0 2px 0 var(--line); }

.parts h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 8px; }
.parts h2:first-child { margin-top: 0; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.option { border: 3px solid transparent; border-radius: 12px; background: #f0ece2; padding: 4px; }
.option.on { border-color: var(--ink); background: #fff; }
.cars .option { width: calc(25% - 6px); min-width: 72px; }
.swatches .option { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.swatches .option.on { border-color: #fff; box-shadow: 0 0 0 3px var(--ink); }
.number-row { display: flex; align-items: center; gap: 12px; }
.number-row output { min-width: 2.2ch; font-size: 1.8rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
.round { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 1.5rem; font-weight: 800; line-height: 1; }
.number-row .ghost { margin-left: auto; }

.student .question { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 3px 0 var(--line); }
#s-question.nitro .question { box-shadow: 0 0 0 4px var(--yellow), 0 0 0 7px var(--ink); }
.number-form { display: flex; flex-direction: column; gap: 12px; }
.number-form input {
  width: 100%; padding: 14px; border: 3px solid var(--ink); border-radius: 14px; background: var(--card);
  font-size: 2rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums;
}
.locked { padding: 14px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 800; text-align: center; }

#s-reveal { align-items: center; text-align: center; padding-top: 6vh; }
#s-reveal > * { width: 100%; }
.badge { width: 104px !important; height: 104px; display: grid; place-items: center; border-radius: 50%; color: #fff; font-size: 3.6rem; font-weight: 900; line-height: 1; }
.right .badge { background: var(--green); }
.wrong .badge { background: var(--red); }
.silent .badge { background: var(--muted); }
#s-reveal h2 { font-size: 2rem; font-weight: 900; }
.place { font-size: 1.5rem; font-weight: 900; text-align: center; }
.streak { display: flex; justify-content: center; gap: 8px; }
.streak i { width: 20px; height: 20px; border-radius: 50%; background: var(--line); }
.streak i.on { background: var(--yellow); box-shadow: inset 0 0 0 2px var(--ink); }

#s-podium { text-align: center; padding-top: 5vh; }
#s-podium h2 { font-size: 1.8rem; font-weight: 900; }
.payout { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.payout strong { font-size: 1.7rem; font-weight: 900; }
.payout small { color: var(--muted); font-weight: 600; }

#s-wait { justify-content: center; align-items: center; text-align: center; }
.count { font-size: 9rem; font-weight: 900; font-style: italic; line-height: 1; }
.count.words { font-size: 3.4rem; }

/* ---- the teacher page --------------------------------------------------------------------------------------- */

.teacher { height: 100vh; overflow: hidden; }
.teacher .screen { display: flex; flex-direction: column; gap: 1.6vh; height: 100vh; padding: 2.2vh 2.4vw; }
.teacher .controls { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex: none; }
.teacher .controls .tally { margin-right: auto; font-size: 1.3rem; font-weight: 800; }
.teacher .controls .paused { margin-right: auto; font-size: 1.3rem; }

#t-setup { max-width: 760px; margin: 0 auto; overflow: auto; padding-top: 6vh; }
.setup { display: flex; flex-direction: column; gap: 18px; }
.setup fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.setup legend { font-weight: 800; padding: 0; margin-bottom: 8px; }
.pill input { position: absolute; opacity: 0; }
.pill span { display: block; padding: 10px 18px; border: 2px solid var(--line); border-radius: 99px; font-weight: 700; cursor: pointer; }
.pill input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

.join-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0.4em 1.2em; flex: none;
  padding: 1.6vh 2vw; border-radius: 20px; background: var(--ink); color: #fff; font-size: clamp(1.3rem, 2.6vw, 2.6rem); font-weight: 700;
}
.join-banner strong { color: var(--yellow); font-weight: 900; }
.join-banner .code { font-size: 1.9em; letter-spacing: 0.14em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; flex: 1; min-height: 0; overflow: auto; padding: 4px; }
.grid.many { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.entry { position: relative; padding: 10px 10px 8px; border-radius: 14px; background: var(--card); box-shadow: 0 3px 0 var(--line); text-align: center; }
.entry .who { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out { border: 0; border-radius: 50%; width: 26px; height: 26px; background: #efeadf; color: var(--muted); font-weight: 800; line-height: 1; }
.out:hover { background: var(--red); color: #fff; }
.entry .out { position: absolute; top: 6px; right: 6px; opacity: 0; }
.entry:hover .out, .entry .out:focus-visible { opacity: 1; }
#t-lobby .lead { flex: 1; font-size: 1.5rem; }
#t-lobby .grid:empty { display: none; }

.q-panel { display: flex; flex-direction: column; gap: 1.2vh; flex: none; padding: 1.8vh 1.6vw; }
.q-panel .bar { font-size: clamp(1rem, 1.4vw, 1.5rem); }
.teacher .question { font-size: clamp(1.4rem, 2.3vw, 2.7rem); line-height: 1.25; }
.choices.host { grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1vw; }
.choices.host .choice { font-size: clamp(1.1rem, 1.8vw, 2.1rem); padding: 1.1vh 1vw; box-shadow: none; }
.choices.host .choice .tag { position: relative; }
.choices.host .words { min-width: 0; }
.choices.host .words { position: relative; display: flex; flex-direction: column; }
.choices.host .words small { font-size: 0.6em; font-weight: 600; opacity: 0.95; }
.choices.host .n { position: relative; margin-left: auto; font-variant-numeric: tabular-nums; }
.choices.host .votes { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.24); transition: width 0.8s ease-out; }
.choices.host .faded { filter: saturate(0.35) brightness(0.92); }
.choices.host .correct { outline: 5px solid var(--ink); outline-offset: -5px; }
.typed { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4em 1.6em; font-size: clamp(1.1rem, 1.7vw, 2rem); font-weight: 700; }
.typed .hint { color: var(--muted); }
.typed .answer { font-weight: 900; font-size: 1.3em; color: var(--green); }
.typed .slip { color: var(--red-deep); }
.teacher .how { text-align: left; font-size: clamp(1rem, 1.5vw, 1.7rem); }
.teacher .nitro-tag { align-self: flex-start; font-size: clamp(0.9rem, 1.2vw, 1.3rem); }

.track-panel { display: flex; gap: 1.2vw; flex: 1; min-height: 0; }
.track {
  --car-w: 60px;
  position: relative; flex: 1; min-width: 0; display: grid; grid-template-rows: repeat(var(--lanes, 1), 1fr);
  padding: 6px 0; border-radius: 18px; background: var(--road); overflow: hidden;
}
.track::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 20px;
  background: conic-gradient(#fff 90deg, #1d2026 90deg 180deg, #fff 180deg 270deg, #1d2026 270deg) 0 0 / 20px 20px;
}
.lane { position: relative; border-bottom: 2px dashed var(--road-line); }
.lane:last-child { border-bottom: 0; }
.lane .road { position: absolute; top: 0; bottom: 0; left: 10px; right: calc(var(--car-w) + 28px); }
.runner { position: absolute; left: 0; bottom: -3px; width: var(--car-w); transition: left 1.8s cubic-bezier(0.3, 0.1, 0.2, 1); }
.runner .tag {
  position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%); z-index: 2;
  padding: 1px 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.94); color: var(--ink);
  font-size: clamp(0.75rem, 1.05vw, 1.15rem); font-weight: 800; white-space: nowrap;
}
.runner.far .tag { left: auto; right: calc(100% + 6px); }

.side { flex: none; width: clamp(180px, 17vw, 300px); display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.side h2 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.top5 { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; counter-reset: place; }
.top5 li { counter-increment: place; display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; background: var(--card); font-weight: 800; font-size: clamp(0.9rem, 1.25vw, 1.4rem); box-shadow: 0 2px 0 var(--line); }
.top5 li::before { content: counter(place); width: 1.2em; color: var(--muted); }
.top5 .mini { flex: none; width: 2.6em; }
.top5 .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#people { margin-top: auto; min-height: 0; display: flex; flex-direction: column; }
#people summary { cursor: pointer; font-weight: 700; color: var(--muted); }
#people ul { list-style: none; margin: 6px 0 0; padding: 0; max-height: 26vh; overflow: auto; }
#people li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; font-weight: 600; }
#people li.off { color: var(--muted); }

.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(29, 32, 38, 0.86); color: var(--yellow); font-size: 34vh; font-weight: 900; font-style: italic; }

#t-podium { align-items: center; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 2vw; flex: 1; min-height: 0; width: 100%; }
.step { display: flex; flex-direction: column; align-items: center; gap: 0.8vh; width: 24vw; }
.step .pic { width: 78%; }
.step .who { font-size: clamp(1.2rem, 2.2vw, 2.4rem); font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .block { display: grid; place-items: start center; width: 100%; padding-top: 1vh; border-radius: 16px 16px 0 0; background: var(--ink); color: var(--yellow); font-size: clamp(2rem, 5vw, 5rem); font-weight: 900; font-style: italic; }
.step.p1 .block { height: 30vh; }
.step.p2 .block { height: 21vh; }
.step.p3 .block { height: 14vh; }
.pod-rest { display: flex; gap: 2.4vw; margin: 0; padding: 0 0 0 1.4em; font-size: clamp(1.1rem, 1.7vw, 1.9rem); font-weight: 800; }
.pod-rest li { padding-right: 1vw; }
.pod-rest:empty { display: none; }
#t-podium .controls { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .runner, .choices.host .votes { transition: none; }
}
