:root {
  --bg: #0a1230;
  --bg-2: #101c45;
  --surface: #16255a;
  --line: #2a3b78;
  --text: #eef2ff;
  --muted: #a3afd6;
  --primary: #4f7cff;
  --accent: #f2c14e;
  --good: #22c08a;
  --a0: #8b5cf6;
  --a1: #2f80ed;
  --a2: #e8a317;
  --a3: #13a37a;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-2), var(--bg)) fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; }
p { line-height: 1.5; }
[hidden] { display: none !important; }

.logo { font-weight: 900; letter-spacing: .02em; font-style: italic; }
.logo b { color: var(--accent); }
.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
.wide { max-width: 1100px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.big-input { font-size: 1.6rem; text-align: center; letter-spacing: .15em; font-weight: 700; }

button, .btn {
  font: inherit; font-weight: 700; color: #fff; background: var(--primary);
  border: 0; border-radius: 10px; padding: 12px 18px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-small { padding: 7px 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.msg { color: var(--accent); min-height: 1.5em; margin: 8px 0 0; }

/* Answer colors and shapes, shared by phones and the big screen */
.a0 { background: var(--a0); } .a1 { background: var(--a1); } .a2 { background: var(--a2); } .a3 { background: var(--a3); }
.shape { font-size: 1.4em; line-height: 1; }

/* Player phone */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answers button {
  min-height: 34vh; border-radius: var(--radius); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; font-size: 1.05rem; padding: 12px; word-break: break-word;
}
.answers.two button { min-height: 60vh; }
.big-num { font-size: 3rem; font-weight: 900; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.result-good { color: var(--good); }

/* Big screen */
.host { padding: 20px 24px; }
.host-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pin-box { display: flex; gap: 28px; align-items: center; justify-content: center; flex-wrap: wrap; }
.pin { font-size: clamp(3rem, 9vw, 6rem); font-weight: 900; letter-spacing: .08em; color: var(--accent); }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: 200px; height: 200px; }
.qr svg { width: 100%; height: 100%; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.chip.off { opacity: .5; }
.chip button { background: transparent; color: var(--muted); padding: 2px 8px; font-size: 1rem; }
.q-text { font-size: clamp(1.6rem, 4vw, 3rem); text-align: center; margin: 10px 0 24px; }
.timer { width: 84px; height: 84px; border-radius: 50%; border: 5px solid var(--accent); display: grid; place-items: center; font-size: 2rem; font-weight: 900; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile { border-radius: var(--radius); padding: 22px; font-size: clamp(1.1rem, 2.4vw, 1.8rem); font-weight: 700; display: flex; align-items: center; gap: 14px; min-height: 90px; }
.tile.dim { opacity: .35; }
.tile.right { outline: 4px solid var(--accent); }
.bars { display: flex; gap: 18px; align-items: flex-end; justify-content: center; height: 260px; margin: 10px 0 20px; }
.bar { width: 90px; border-radius: 10px 10px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 6px; font-weight: 800; min-height: 34px; transition: height .6s ease-out; }
.board { list-style: none; margin: 0 auto; padding: 0; max-width: 760px; }
.board li { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; margin-bottom: 10px; font-size: 1.3rem; font-weight: 700; }
.board .rank { width: 2em; color: var(--muted); }
.board .gain { color: var(--good); font-size: 1rem; }
.board li.first { border-color: var(--accent); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 20px 0 30px; }
.step { width: 180px; text-align: center; }
.step .block { background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 0 0; display: grid; place-items: center; font-size: 2.4rem; font-weight: 900; }
.step.p1 .block { height: 200px; border-color: var(--accent); color: var(--accent); }
.step.p2 .block { height: 150px; }
.step.p3 .block { height: 110px; }
.step .name { font-size: 1.3rem; font-weight: 800; margin-bottom: 8px; word-break: break-word; }

/* Admin */
.quiz-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--line); }
.quiz-row:first-child { border-top: 0; }
.q-edit { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg); }
.q-edit .ans { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.q-edit .ans input[type=radio] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.q-edit .ans .swatch { width: 12px; align-self: stretch; border-radius: 4px; flex: none; }

@media (max-width: 600px) {
  .tiles { grid-template-columns: 1fr; }
  .bar { width: 56px; }
  .step { width: 30%; }
}

/* Phase 2: big-screen extras */
.usage { position: relative; width: 190px; height: 30px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; font-size: .8rem; font-weight: 700; display: grid; place-items: center; }
.usage span { position: relative; }
.usage-fill { position: absolute; inset: 0 auto 0 0; transition: width .6s; }
.u-green .usage-fill { background: #1c7a5a; }
.u-yellow .usage-fill { background: #a77c12; }
.u-red .usage-fill, .banner.u-red { background: #b4232f; }
.banner { margin: 0 0 14px; padding: 10px 16px; border-radius: 10px; font-weight: 700; text-align: center; color: #fff; }
.q-mid { display: grid; grid-template-columns: 1fr minmax(0, 2.4fr) 1fr; align-items: center; gap: 16px; margin-bottom: 20px; min-height: 120px; }
.q-mid .side { display: flex; flex-direction: column; align-items: center; }
.q-img { max-width: 100%; max-height: 34vh; border-radius: 12px; justify-self: center; display: block; }
.ring { width: 110px; height: 110px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.ring text { transform: rotate(90deg); transform-origin: 50px 50px; fill: var(--text); font-size: 30px; font-weight: 900; text-anchor: middle; dominant-baseline: middle; }
.bars { height: 240px; margin: 0; }
.bar-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar { height: 0; }
.bar-label { margin-top: 6px; font-weight: 800; color: var(--muted); }
.race { position: relative; max-width: 1000px; margin: 10px auto 0; }
.bar.dim { opacity: .45; }
.lane { position: absolute; left: 0; right: 0; height: 48px; transition: top .6s cubic-bezier(.3, 1.3, .5, 1); }
.track { position: relative; height: 100%; margin-right: 250px; border-bottom: 1px dashed var(--line); }
.finish-line { position: absolute; top: -8px; bottom: -8px; right: 244px; width: 10px; border-radius: 2px;
  background: repeating-conic-gradient(var(--text) 0 25%, var(--bg) 0 50%) 0 0 / 10px 10px; opacity: .8; }
.runner { position: absolute; top: 4px; height: 40px; display: flex; align-items: center; gap: 10px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 16px 0 6px; font-weight: 800;
  transition: left 2.4s cubic-bezier(.4, 0, .2, 1); box-shadow: -18px 0 18px -14px var(--primary); }
.runner .pos { width: 30px; height: 30px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: .9rem; color: var(--muted); }
.runner .nm { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.runner .sc { color: var(--muted); }
.runner.leader { border-color: var(--accent); }
.runner.leader .pos { background: var(--accent); color: var(--bg); }
.runner.leader .nm::before { content: '👑 '; }
.runner.settle { animation: settle .45s ease-out; }
@keyframes settle { 40% { transform: translateY(-6px); } 70% { transform: translateY(2px); } }
.overtake { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none;
  font-size: clamp(2rem, 6vw, 4rem); font-weight: 900; font-style: italic; color: var(--accent); text-shadow: 0 4px 24px rgba(0, 0, 0, .5); }
.overtake.show { animation: overtake 1.4s ease-out forwards; }
@keyframes overtake { 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }
.hidden-step { opacity: 0; transform: translateY(30px); }
.step, #rest { transition: opacity .6s, transform .6s cubic-bezier(.3, 1.4, .5, 1); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.roster { margin-top: 24px; color: var(--muted); }
.roster summary { cursor: pointer; }
.pop-in { animation: pop .4s ease-out; }
@keyframes pop { 0% { transform: scale(.8); opacity: 0; } 70% { transform: scale(1.05); } }

@media (max-width: 700px) {
  .q-mid { grid-template-columns: 1fr 1fr; }
  .q-mid > :nth-child(2) { grid-column: 1 / -1; order: 3; }
  .track { margin-right: 150px; }
  .finish-line { right: 144px; }
  .runner .nm { max-width: 70px; }
  .usage { width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
