:root {
  --bg: #14121f;
  --bg2: #1d1a2e;
  --card: #262238;
  --line: #3a3452;
  --text: #f4f1ff;
  --muted: #a39dbd;
  --accent: #ffd23f;
  --accent-ink: #1a1500;
  --good: #3ddc84;
  --bad: #ff5c6c;
  --A: #ff6b6b;
  --B: #4dabf7;
  --C: #ffd23f;
  --D: #51cf66;
  --radius: 18px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); }
body {
  background:
    radial-gradient(120% 60% at 50% -10%, #2c2450 0%, transparent 60%),
    var(--bg);
  min-height: 100dvh;
}
main {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  padding: calc(16px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 26px; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-family: var(--body); font-weight: 600; }
p { margin: 0; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }

/* ---------- Logo ---------- */
.logo { text-align: center; margin: 7vh 0 2vh; }
.logo .l1, .logo .l3 { font-family: var(--display); font-weight: 800; font-size: 54px; line-height: 0.95; display: block; }
.logo .l1 { color: var(--text); transform: rotate(-3deg); }
.logo .l2 { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--muted); display: block; margin: 6px 0; }
.logo .l3 { color: var(--accent); transform: rotate(2deg); }
.tagline { text-align: center; color: var(--muted); }

/* ---------- Buttons & inputs ---------- */
button {
  font: inherit; border: 0; cursor: pointer; color: inherit; background: none;
}
.btn {
  display: block; width: 100%; padding: 17px 18px; border-radius: 14px;
  font-family: var(--display); font-weight: 700; font-size: 19px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 0 #b8901a; transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b8901a; }
.btn.secondary { background: var(--card); color: var(--text); box-shadow: 0 4px 0 #120f1d; border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; font-size: 15px; padding: 10px; }
.btn:disabled { opacity: .4; pointer-events: none; }
input[type=text] {
  width: 100%; padding: 16px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--bg2); color: var(--text); font: 600 20px var(--body); outline: none;
}
input[type=text]:focus { border-color: var(--accent); }
input.code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-family: var(--display); font-size: 28px; }
.link { color: var(--muted); text-decoration: underline; font-size: 14px; padding: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* ---------- Colours ---------- */
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; position: relative;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.2);
}
.swatch.sel { border-color: #fff; transform: scale(1.1); }
.swatch:disabled { opacity: .18; }
.swatch:disabled::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Header ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.topbar b { color: var(--text); }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }

/* ---------- Lobby ---------- */
.roomcode { text-align: center; }
.roomcode .code { font-family: var(--display); font-weight: 800; font-size: 64px; letter-spacing: .12em; color: var(--accent); line-height: 1; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg2); border-radius: 12px; }
.players li .name { flex: 1; font-weight: 600; }
.players li.off { opacity: .45; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--text); text-transform: uppercase; letter-spacing: .05em; }
.badge.host { background: var(--accent); color: var(--accent-ink); }
.x { color: var(--muted); font-size: 20px; padding: 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 999px; background: var(--bg2); border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip:disabled { opacity: .6; }
.toggle { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; }
.toggle .sw { flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; margin-top: 2px; }
.toggle .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on .sw { background: var(--good); }
.toggle.on .sw::after { left: 21px; }
details.rules summary { cursor: pointer; font-weight: 600; }
details.rules ol { padding-left: 20px; margin: 10px 0 0; line-height: 1.5; color: var(--muted); }
details.rules b { color: var(--text); }

/* ---------- Question & answers ---------- */
.reader { border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; font-weight: 600; }
.question { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.2; }
.question.reading { font-size: 30px; }
.answers { display: grid; gap: 10px; }
.answer {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px; border-radius: 16px; background: var(--card); border: 2.5px solid var(--line);
  font-weight: 600; font-size: 18px; min-height: 64px; transition: transform .08s;
}
.answer:active { transform: scale(.98); }
.answer .letter {
  flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 22px; color: #15131f;
}
.answer.sel { border-color: #fff; background: #332d4a; }
.answer.dim { opacity: .35; }
.answer.correct { border-color: var(--good); background: rgba(61,220,132,.15); }
.answer:disabled { cursor: default; }
.L-A { background: var(--A); } .L-B { background: var(--B); } .L-C { background: var(--C); } .L-D { background: var(--D); }
.tc-A { color: var(--A); } .tc-B { color: var(--B); } .tc-C { color: var(--C); } .tc-D { color: var(--D); }
.waiting { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.waiting .pill { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Reveal (show your screen) ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); text-align: center; gap: 10px;
}
.reveal .who { font-family: var(--display); font-weight: 800; font-size: 30px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.reveal .big {
  font-family: var(--display); font-weight: 800; font-size: min(52vw, 260px); line-height: 1; color: #fff;
  text-shadow: 0 8px 0 rgba(0,0,0,.25);
}
.reveal .txt { font-family: var(--display); font-weight: 700; font-size: 30px; color: #fff; background: rgba(0,0,0,.22); padding: 10px 18px; border-radius: 14px; max-width: 100%; }
.reveal .hint { color: rgba(255,255,255,.85); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; font-size: 13px; }
.reveal .btn { max-width: 400px; margin-top: auto; background: rgba(0,0,0,.35); color: #fff; box-shadow: none; }

/* ---------- Results ---------- */
.result-head { text-align: center; }
.result-head .big { font-family: var(--display); font-weight: 800; font-size: 72px; line-height: 1; }
.table { display: flex; flex-direction: column; gap: 8px; }
.trow { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px; align-items: center; background: var(--bg2); border-radius: 12px; padding: 11px 14px; }
.trow .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.trow .pts { font-family: var(--display); font-weight: 800; font-size: 20px; min-width: 52px; text-align: right; }
.trow .pts.zero { color: var(--muted); }
.arrow { font-family: var(--display); font-weight: 800; font-size: 18px; white-space: nowrap; }
.tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.tag.good { background: rgba(61,220,132,.2); color: var(--good); }
.tag.stick { background: rgba(255,210,63,.2); color: var(--accent); }
.tag.swap { background: rgba(255,92,108,.18); color: var(--bad); }
.potline { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.5; }

.standings .trow { grid-template-columns: 28px 14px 1fr auto; }
.rank { font-family: var(--display); font-weight: 800; color: var(--muted); }
.winner { text-align: center; margin-top: 4vh; }
.winner .crown { font-size: 64px; }
.winner .wname { font-family: var(--display); font-weight: 800; font-size: 44px; }

/* ---------- Misc ---------- */
.conn { position: fixed; top: 0; left: 0; right: 0; z-index: 20; background: var(--bad); color: #fff; text-align: center; font-weight: 600; font-size: 14px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: #fff; color: #15131f; font-weight: 600; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 90vw; text-align: center; }
.footer-actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pop { animation: pop .35s cubic-bezier(.2,1.6,.4,1); }

/* ---------- Language pickers ---------- */
.langsel, .bigsel {
  font: 600 14px var(--body); color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 30px 7px 12px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.bigsel { width: 100%; border-radius: 12px; padding: 12px 34px 12px 14px; font-size: 16px; background-color: var(--bg2); }

/* ---------- Reading turn ---------- */
.readwait { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 44px; color: #fff; box-shadow: inset 0 -6px 0 rgba(0,0,0,.2); }

/* ---------- Tap twice to lock ---------- */
.answer-wrap { display: flex; flex-direction: column; gap: 6px; }
.tap-hint { align-self: center; background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; position: relative; }
.tap-hint::before { content: ''; position: absolute; top: -6px; left: 50%; margin-left: -6px;
  border: 6px solid transparent; border-top: 0; border-bottom-color: var(--text); }
.answer .atext { display: flex; flex-direction: column; gap: 2px; }
.answer.wasfirst { box-shadow: 0 0 0 3px rgba(255,210,63,.55), 0 0 18px rgba(255,210,63,.25); border-color: var(--accent); }
.answer.wasfirst.dim { opacity: .55; }
.firstlabel { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Reveal: answer text is the hero ---------- */
.reveal .rletter { font-family: var(--display); font-weight: 800; font-size: 34px; color: #fff; width: 64px; height: 64px;
  border-radius: 16px; display: grid; place-items: center; background: rgba(0,0,0,.25); }
.reveal .rtext { font-family: var(--display); font-weight: 800; line-height: 1.02; color: #fff; text-shadow: 0 6px 0 rgba(0,0,0,.22);
  max-width: 100%; overflow-wrap: anywhere; }
.reveal .who { font-size: 28px; line-height: 1.15; }

/* ---------- In-game menu ---------- */
.menu-btn { font-size: 18px; line-height: 1; padding: 4px 12px; color: var(--text); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; min-width: 210px; display: flex; flex-direction: column; box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.menu button { text-align: left; padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.menu button:active { background: var(--bg2); }
