:root {
  --bg: #14112b;
  --bg2: #1f1a42;
  --card: #2a2356;
  --line: #3d3478;
  --text: #f4f1ff;
  --muted: #a9a2d6;
  --primary: #ffcc33;
  --primary-ink: #2a1f00;
  --accent: #5ee6ff;
  --good: #3ddc84;
  --bad: #ff5c7a;
  --radius: 16px;
}
* { box-sizing: border-box; }
/* custom robot pictures may not be square */
img[src^="/robot/"] { object-fit: cover; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #3a2d86 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: .4em 0; line-height: 1.15; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.err { color: var(--bad); min-height: 1.2em; font-size: .9em; }

.screen { display: none; }
.screen.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.logo {
  font-weight: 700; font-size: clamp(42px, 13vw, 64px); text-align: center; letter-spacing: 2px;
  margin: 8vh 0 4vh;
  background: linear-gradient(90deg, var(--primary), #ff7ac8, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 204, 51, .25));
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
label { font-weight: 600; font-size: .95em; }
input, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  background: var(--line); color: var(--text); transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.good { background: var(--good); color: #062; }
.btn.big { width: 100%; padding: 16px; font-size: 1.1em; }
.btn.link { background: none; color: var(--muted); text-decoration: underline; padding: 8px; }
.btn.small { padding: 6px 10px; font-size: .85em; border-radius: 9px; }

/* top bar */
#topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
  background: rgba(20, 17, 43, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
#topbar img { width: 40px; height: 40px; border-radius: 50%; }
#topbar .tb-mid { flex: 1; min-width: 0; }
#tb-team { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tb-me { font-size: .8em; color: var(--muted); }
#tb-score { font-weight: 700; font-size: 1.3em; color: var(--primary); }

/* teams */
.team-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 20px; }
.team {
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
}
.team img { width: 52px; height: 52px; border-radius: 50%; flex: none; }
.team .t-mid { flex: 1; min-width: 0; }
.team .t-name { font-weight: 700; }
.team .t-members { font-size: .85em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.robot-card { text-align: center; margin: 10px 0 16px; }
.robot-card img, .robot-big img {
  width: min(60vw, 220px); aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .45), 0 0 0 6px var(--line);
}
.robot-card img.spin { animation: roll .45s ease; }
@keyframes roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(.6); } 100% { transform: rotate(360deg) scale(1); } }
.robot-name { font-weight: 700; font-size: 1.25em; margin: 12px 0 8px; }
.robot-big { text-align: center; margin-top: 4vh; }
.robot-big img { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 12px 0; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: .9em; }
.chip.off { opacity: .45; }
.pulse { animation: pulse 1.6s ease-in-out infinite; text-align: center; }
@keyframes pulse { 50% { opacity: .45; } }

/* countdown */
#scr-countdown { text-align: center; padding-top: 10vh; }
.cat { display: inline-block; background: var(--accent); color: #022; font-weight: 700; border-radius: 99px; padding: 4px 14px; margin: 10px 0; }
.cd-num { font-size: min(40vw, 200px); font-weight: 700; color: var(--primary); line-height: 1; margin-top: 4vh; }
.cd-num.pop { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: scale(1.8); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .7; } }

/* question */
.q-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 600; }
.timer { font-size: 1.6em; color: var(--primary); font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); animation: pulse .6s infinite; }
.bar { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin: 8px 0 14px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); width: 100%; transition: width .2s linear; }
.q-body { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.q-text { font-size: 1.35em; font-weight: 600; }
.q-body img { width: 100%; border-radius: 12px; margin-top: 10px; max-height: 45vh; object-fit: contain; background: #0003; }
.audio-btn { margin-top: 12px; width: 100%; }
.eq { display: inline-flex; gap: 3px; height: 18px; align-items: flex-end; vertical-align: middle; margin-right: 6px; }
.eq i { width: 4px; background: currentColor; animation: eq .8s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .2s; } .eq i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }
.prop-form { display: flex; gap: 8px; margin-bottom: 12px; }
.prop-form input { flex: 1; min-width: 0; }
.paused { text-align: center; background: var(--line); border-radius: 12px; padding: 8px; margin-bottom: 10px; font-weight: 700; }
.prop-list { display: flex; flex-direction: column; gap: 8px; }
.prop {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid var(--line);
  border-radius: 14px; padding: 10px 10px 10px 14px; animation: fadein .25s ease;
}
.prop.lead { border-color: var(--primary); background: linear-gradient(90deg, #3a2f12, var(--card)); }
.prop-text { flex: 1; min-width: 0; font-weight: 600; word-break: break-word; }
.prop-text small { display: block; font-weight: 400; color: var(--muted); font-size: .78em; }
.vote { font: inherit; font-weight: 700; border: 2px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 12px; padding: 8px 12px; min-width: 64px; cursor: pointer; }
.vote.on { background: var(--accent); color: #022; border-color: var(--accent); }
.vote:disabled { opacity: .6; }

/* reveal */
.answer-card {
  margin: 14px 0; text-align: center; border-radius: 22px; padding: 22px 16px;
  background: linear-gradient(135deg, #ffcc33, #ff7ac8); color: #2a0a2a;
  box-shadow: 0 12px 40px rgba(255, 122, 200, .35);
}
.answer-card.go { animation: reveal .8s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes reveal { 0% { transform: scale(.3) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.answer-card .lbl { font-size: .9em; opacity: .8; }
.answer-card .ans { font-size: clamp(28px, 9vw, 44px); font-weight: 700; word-break: break-word; }
.rv-team { text-align: center; font-size: 1.1em; margin: 10px 0 18px; padding: 12px; border-radius: 14px; background: var(--card); }
.rv-team.good { border: 2px solid var(--good); }
.rv-team.bad { border: 2px solid var(--bad); }
.rv-team.go { animation: fadein .4s ease .6s both; }
.rv-team .big { font-size: 1.6em; display: block; }

.board { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 12px; position: relative;
}
.row.me { border: 2px solid var(--accent); }
.row .rank { width: 26px; font-weight: 700; color: var(--muted); text-align: center; }
.row img { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.row .nm { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sc { font-weight: 700; font-size: 1.2em; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.row .gain { color: var(--good); font-weight: 700; opacity: 0; }
.row.gained .gain { animation: gain 1.6s ease forwards; }
.row.gained { animation: glow 1.4s ease; }
@keyframes gain { 0% { opacity: 0; transform: translateY(8px); } 20% { opacity: 1; transform: none; } 100% { opacity: 1; } }
@keyframes glow { 30% { box-shadow: 0 0 0 3px var(--good); } }

/* final */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 20px 0; }
.pod { flex: 1; max-width: 160px; text-align: center; animation: rise .8s cubic-bezier(.2, 1.2, .4, 1) both; }
.pod img { width: 70%; border-radius: 50%; box-shadow: 0 0 0 4px var(--line); }
.pod .pn { font-weight: 700; font-size: .9em; margin: 6px 0; word-break: break-word; }
.pod .block { border-radius: 12px 12px 0 0; font-weight: 700; font-size: 1.4em; padding-top: 8px; color: #2a1f00; }
.pod.p1 .block { height: 130px; background: #ffd34d; }
.pod.p2 .block { height: 95px; background: #d7dbe6; }
.pod.p3 .block { height: 70px; background: #e0a066; }
.pod.p1 { order: 2; animation-delay: .9s; } .pod.p2 { order: 1; animation-delay: .5s; } .pod.p3 { order: 3; animation-delay: .2s; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 50; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal .card { width: 100%; max-width: 380px; }
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: #000c; color: #fff; padding: 10px 16px; border-radius: 12px; transition: transform .25s; z-index: 30; max-width: 90vw; text-align: center;
}
#toast.show { transform: translateX(-50%); }

.good { color: var(--good); }
.bad { color: var(--bad); }
.q-answer { text-align: center; font-size: .95em; background: var(--bg2); border: 1px dashed var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; }
.q-answer:empty { display: none; }
.q-answer small { color: var(--muted); }
.row.lost .gain { color: var(--bad); animation: gain 1.6s ease forwards; }
.row.lost { animation: glowbad 1.4s ease; }
@keyframes glowbad { 30% { box-shadow: 0 0 0 3px var(--bad); } }
.spectator { text-align: center; background: var(--card); border: 2px dashed var(--accent); border-radius: 14px; padding: 14px; margin-bottom: 12px; font-size: 1.05em; }
