:root {
  --bg: #1b1033;
  --bg2: #34206e;
  --ink: #fff;
  --muted: #b9add9;
  --panel: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.16);
  --yellow: #ffd23f;
  --red: #ff4d6d;
  --green: #2ec27e;
  --pink: #ff5fa2;
  --card-ink: #1b1033;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; }

body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1, h2, p { margin: 0; }
.grow { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Buttons */
button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: 18px;
  padding: 16px 18px;
  font-weight: 800;
  cursor: pointer;
  background: var(--panel);
  transition: transform 0.06s ease, filter 0.15s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.35; }
.primary { background: var(--yellow); color: var(--card-ink); font-size: 20px; box-shadow: 0 6px 0 #c99a00; }
.primary:active { box-shadow: 0 2px 0 #c99a00; transform: translateY(4px); }
.ghost { background: transparent; border: 2px solid var(--line); }
.link { background: none; padding: 8px; color: var(--muted); font-weight: 600; text-decoration: underline; }
.block { display: block; width: 100%; }

/* Home */
.logo {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  color: var(--yellow);
  text-shadow: 0 6px 0 var(--pink), 0 12px 0 rgba(0, 0, 0, 0.25);
  transform: rotate(-4deg);
  margin: 6vh 0 18px;
}
.lang { display: flex; gap: 8px; background: var(--panel); padding: 6px; border-radius: 20px; }
.lang button { flex: 1; padding: 12px; border-radius: 14px; background: transparent; }
.lang button.on { background: #fff; color: var(--card-ink); }

/* Setup */
.field { background: var(--panel); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.field > label { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { flex: 1; min-width: 60px; padding: 12px 6px; border-radius: 14px; }
.chips button.on { background: #fff; color: var(--card-ink); }
.team-row { display: flex; gap: 8px; align-items: center; }
.team-row .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.team-row input {
  flex: 1; min-width: 0; font: inherit; font-weight: 700; color: var(--ink);
  background: rgba(0, 0, 0, 0.25); border: 2px solid transparent; border-radius: 14px; padding: 12px 14px;
  user-select: text; -webkit-user-select: text;
}
.team-row input:focus { outline: none; border-color: var(--yellow); }
.team-row .x { padding: 10px 14px; border-radius: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar h2 { font-size: 22px; }
.topbar button { padding: 10px 14px; border-radius: 14px; }

/* Scoreboard */
.scores { display: flex; flex-direction: column; gap: 8px; }
.score { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 16px; padding: 12px 14px; font-weight: 800; }
.score.now { outline: 3px solid var(--yellow); }
.score .dot { width: 14px; height: 14px; border-radius: 50%; }
.score .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .pts { font-size: 22px; font-variant-numeric: tabular-nums; }
.bigname { font-size: 40px; font-weight: 900; line-height: 1.05; word-break: break-word; }

/* Play */
.hud { display: flex; align-items: center; gap: 12px; }
.hud .time { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: center; }
.hud .time.low { color: var(--red); animation: pulse 1s infinite; }
.hud .bar { flex: 1; height: 12px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.hud .bar i { display: block; height: 100%; background: var(--yellow); border-radius: 99px; transform-origin: left; }
.hud .turnpts { font-weight: 900; font-size: 22px; background: var(--panel); border-radius: 12px; padding: 6px 12px; font-variant-numeric: tabular-nums; }
.hud .pause { padding: 8px 12px; border-radius: 12px; }
@keyframes pulse { 50% { transform: scale(1.15); } }

.card {
  flex: 1;
  background: #fff;
  color: var(--card-ink);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  animation: pop 0.18s ease-out;
}
@keyframes pop { from { transform: scale(0.94) rotate(-1.5deg); opacity: 0.4; } }
.card .target {
  background: linear-gradient(135deg, #6a3df0, var(--pink));
  color: #fff;
  padding: 26px 16px;
  text-align: center;
  font-weight: 900;
  font-size: 38px;
  line-height: 1.05;
  text-transform: uppercase;
  word-break: break-word;
}
.card .target.long { font-size: 28px; }
.card ul { list-style: none; margin: 0; padding: 6px 0; flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; }
.card li { text-align: center; font-size: 26px; font-weight: 800; padding: 4px 12px; text-transform: uppercase; color: #3a2a63; }
.card li + li { border-top: 2px dashed #e6e0f5; }

.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.actions button { padding: 20px 4px; font-size: 19px; border-radius: 20px; color: #fff; }
.actions small { display: block; font-size: 13px; font-weight: 700; opacity: 0.85; }
.b-taboo { background: var(--red); box-shadow: 0 6px 0 #b8203f; }
.b-pass { background: #f59f00; box-shadow: 0 6px 0 #b37400; }
.b-ok { background: var(--green); box-shadow: 0 6px 0 #1b8a57; }
.actions button:active { transform: translateY(4px); box-shadow: none; }

.overlay { position: fixed; inset: 0; background: #170d2e; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 24px; z-index: 5; }
.overlay > * { max-width: 420px; width: 100%; margin: 0 auto; }

/* Summary */
.log { display: flex; flex-direction: column; gap: 6px; }
.log button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px 14px; border-radius: 14px; font-weight: 700; }
.log .tag { margin-left: auto; font-size: 13px; padding: 4px 10px; border-radius: 99px; color: #fff; font-weight: 800; white-space: nowrap; }
.tag.c { background: var(--green); } .tag.t { background: var(--red); } .tag.p { background: #f59f00; } .tag.x { background: #6b5f8c; }
.turntotal { font-size: 64px; font-weight: 900; color: var(--yellow); line-height: 1; }

/* Rules */
.rules { background: var(--panel); border-radius: 20px; padding: 6px 16px; }
.rules li { margin: 12px 0; }

.crown { font-size: 72px; line-height: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #fff; color: var(--card-ink); font-weight: 800; padding: 12px 18px; border-radius: 16px;
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 9; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 640px) {
  .card .target { padding: 16px; font-size: 30px; }
  .card li { font-size: 21px; }
  .actions button { padding: 14px 4px; }
}

/* ---------- hub: home, lobby, game shell ---------- */
.hublogo { font-size: 58px; letter-spacing: -2px; margin: 3vh 0 14px; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row > .input { flex: 1; min-width: 0; }
.input {
  font: inherit; font-weight: 700; color: var(--ink); width: 100%;
  background: rgba(0, 0, 0, 0.25); border: 2px solid transparent; border-radius: 14px; padding: 12px 14px;
  user-select: text; -webkit-user-select: text;
}
.input:focus { outline: none; border-color: var(--yellow); }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-size: 22px; text-align: center; }
textarea.input { resize: none; }
button.small { padding: 10px 12px; border-radius: 12px; font-size: 14px; }

.gamecard {
  display: flex; flex-direction: column; gap: 2px; text-align: left; text-decoration: none; color: var(--ink);
  background: rgba(0, 0, 0, 0.22); border: 2px solid transparent; border-radius: 16px; padding: 12px 14px; width: 100%;
}
.gamecard b { font-size: 19px; }
.gamecard span { color: var(--muted); font-size: 14px; font-weight: 600; }
.gamecard.on { border-color: var(--yellow); background: rgba(255, 210, 63, 0.12); }

.codebox { display: flex; gap: 14px; align-items: center; background: var(--panel); border-radius: 20px; padding: 14px; }
.codebox .qr { width: 132px; flex: none; background: #fff; border-radius: 12px; padding: 4px; line-height: 0; }
.codebox .qr svg { width: 100%; height: auto; display: block; }
.codeside { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.code { font-size: 44px; font-weight: 900; letter-spacing: 6px; color: var(--yellow); line-height: 1; }

.prow { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: 700; }
.prow.off { opacity: 0.45; }
.prow .x { margin-left: auto; padding: 6px 10px; border-radius: 10px; font-size: 13px; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.team { border-left: 4px solid var(--team, var(--line)); padding: 4px 0 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.team-name { font-weight: 900; color: var(--team, var(--muted)); }

.rules-box { margin-top: 4px; color: var(--muted); font-size: 15px; }
.rules-box summary { font-weight: 800; cursor: pointer; padding: 6px 0; }
.rules-box ol { margin: 4px 0; padding-left: 22px; }
.rules-box li { margin: 6px 0; }

.banner { background: var(--red); color: #fff; font-weight: 800; text-align: center; border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.gamebar { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.menu-btn { padding: 6px 12px; border-radius: 12px; }
.game { flex: 1; display: flex; flex-direction: column; gap: 14px; min-height: 0; }

/* shared pieces for game modules */
.tm { font-weight: 900; font-variant-numeric: tabular-nums; }
.tm.low { color: var(--red); }
.bar { display: block; flex: 1; height: 12px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--yellow); border-radius: 99px; transform-origin: left; }
.panel { background: var(--panel); border-radius: 20px; padding: 14px; }
.flag { padding: 6px 10px; border-radius: 10px; font-size: 14px; background: transparent; color: var(--muted); }
.big { font-size: 34px; font-weight: 900; line-height: 1.1; }

/* the host's start button stays reachable while the lobby scrolls */
.cta { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 2; display: flex; flex-direction: column; gap: 6px; background: linear-gradient(transparent, var(--bg) 35%); padding-top: 18px; }
.cta button:disabled { opacity: 1; filter: saturate(0.3) brightness(0.6); }

/* ---------- voice strip (public/voice.js): sits in the lobby's top bar and in the game bar ---------- */
.topbar, .gamebar { flex-wrap: wrap; gap: 8px; }
.voice { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; min-width: 0; }
.voice:empty { display: none; }
.voice.active { order: 9; flex: 1 0 100%; margin: 0; align-items: flex-start; } /* someone is in voice: a row of its own under the bar */
.voice button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 12px; border-radius: 12px; font-size: 14px; white-space: nowrap; }
.voice svg { flex: none; }
.vjoin { background: var(--panel); }
.vmic.live { background: var(--green); color: #06281a; }
.vmic.off { background: var(--red); color: #fff; }
.vleave { background: transparent; border: 2px solid var(--line); color: var(--muted); }
.vchips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; padding: 4px; min-height: 40px; align-content: center; }
.vchip {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 32px; padding: 0 10px; border-radius: 99px;
  background: rgba(0, 0, 0, 0.28); border: 2px solid transparent; font-size: 14px; font-weight: 700;
}
.vchip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.vname { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmuted { display: inline-flex; color: var(--red); }
.vmuted svg { width: 15px; height: 15px; }
.vchip.muted .vname { color: var(--muted); }
.vchip.pending { opacity: 0.55; }
.vchip.listener { border-style: dashed; border-color: var(--line); color: var(--muted); } /* a TV: listens, never speaks */
.tvmark { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); }
.tvmark .x { margin-left: auto; padding: 6px 10px; border-radius: 10px; font-size: 13px; }
.tvask { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 2px solid var(--yellow); border-radius: 20px; padding: 14px; }
.tvask b { font-size: 18px; }
.tvask .row button { flex: 1; }
.tvask .yes { background: var(--green); color: #06281a; }
.tvlink { text-decoration: none; }
.tvlink b { color: var(--ink); }
.vchip.speaking { border-color: var(--green); background: rgba(46, 194, 126, 0.22); animation: vring 0.9s ease-out infinite; }
@keyframes vring {
  from { box-shadow: 0 0 0 0 rgba(46, 194, 126, 0.85); }
  to { box-shadow: 0 0 0 7px rgba(46, 194, 126, 0); }
}
.vchip.trouble { border-color: var(--yellow); cursor: pointer; }
.vwarn { width: 16px; height: 16px; border-radius: 50%; background: var(--yellow); color: var(--card-ink); font-size: 12px; font-weight: 900; line-height: 16px; text-align: center; flex: none; }
.vnote { flex: 1 0 100%; display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 12px; padding: 8px 8px 8px 12px; font-size: 14px; color: var(--muted); }
.vnote span { flex: 1; }
.voice .vnote button { min-height: 36px; background: rgba(255, 255, 255, 0.14); color: var(--ink); }
.voice button.vnote { justify-content: center; color: var(--card-ink); background: var(--yellow); }
@media (prefers-reduced-motion: reduce) {
  .vchip.speaking { animation: none; box-shadow: 0 0 0 3px rgba(46, 194, 126, 0.45); }
}
