:root {
  --bg: #1b1530;
  --panel: #2a2248;
  --panel-2: #372d5c;
  --text: #f4f1ff;
  --muted: #b3a9d6;
  --accent: #ffcc33;
  --good: #3ddc84;
  --bad: #ff5c7a;
  --blue: #5cc8ff;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 30px; margin: 8px 0 4px; }
h2 { font-size: 22px; margin: 18px 0 8px; }
h3 { font-size: 17px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 8px; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px 16px;
  background: var(--panel-2); font-weight: 600; cursor: pointer; touch-action: manipulation;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; }
button.primary { background: var(--accent); color: #231a00; }
button.good { background: var(--good); color: #002611; }
button.bad { background: var(--bad); color: #2b0009; }
button.small { display: inline-block; width: auto; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
button.link { background: none; padding: 6px; width: auto; color: var(--muted); text-decoration: underline; font-weight: 400; }
button.huge { font-size: 24px; padding: 22px; }
input, select, textarea {
  width: 100%; background: var(--panel-2); border: 2px solid transparent; border-radius: 12px; padding: 12px 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input.code { font-size: 28px; letter-spacing: 8px; text-align: center; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }

.code-big { font-size: 56px; font-weight: 800; letter-spacing: 10px; color: var(--accent); line-height: 1; }
.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--panel-2); }
.players li:last-child { border-bottom: 0; }
.players .name { flex: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; }
.dot.off { background: #6b6190; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.badge.accent { background: var(--accent); color: #231a00; }

.games { display: grid; gap: 8px; }
.game-card { text-align: left; padding: 14px 16px; border: 2px solid transparent; }
.game-card.selected { border-color: var(--accent); background: #3f3468; }
.game-card .title { font-size: 19px; }
.game-card .desc { font-weight: 400; font-size: 14px; color: var(--muted); margin-top: 2px; }

.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.topbar .title { flex: 1; font-weight: 700; font-size: 18px; }

.word {
  font-size: clamp(30px, 10vw, 52px); font-weight: 800; text-align: center; line-height: 1.1;
  padding: 28px 12px; background: var(--panel); border-radius: var(--radius); margin: 12px 0; word-break: break-word;
}
.word.hidden { color: var(--muted); letter-spacing: 6px; }
.timer { font-size: 64px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; margin: 8px 0; }
.timer.low { color: var(--bad); }
.big-msg { font-size: 22px; text-align: center; font-weight: 700; margin: 16px 0; }

.scores { width: 100%; border-collapse: collapse; }
.scores td { padding: 6px 4px; border-bottom: 1px solid var(--panel-2); }
.scores td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.scores tr.me td { color: var(--accent); }

.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.team { background: var(--panel); border-radius: var(--radius); padding: 12px; border: 2px solid transparent; }
.team.active { border-color: var(--accent); }
.team .score { font-size: 28px; font-weight: 800; }
.team ul { list-style: none; padding: 0; margin: 6px 0; font-size: 15px; }

.results li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 8px; }
.results { list-style: none; padding: 0; margin: 0; }
.results .ok { color: var(--good); }
.results .no { color: var(--bad); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 12px; border: 2px solid transparent; }
.card.turn { border-color: var(--accent); }
.card.solved { opacity: 0.65; }
.card .who { font-size: 14px; color: var(--muted); }
.card .w { font-size: 20px; font-weight: 700; margin-top: 4px; word-break: break-word; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #000c; color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; z-index: 10;
}
.conn { position: fixed; top: 0; left: 0; right: 0; text-align: center; background: var(--bad); color: #2b0009; font-size: 14px; padding: 4px; z-index: 5; }

a { color: inherit; }
a.game-card { display: block; text-decoration: none; background: var(--panel-2); border-radius: 14px; font-weight: 600; }
a.game-card .desc + .desc { margin-top: 6px; color: var(--accent); }
a.game-card:active { transform: scale(0.98); }
.banner { display: block; text-decoration: none; background: var(--accent); color: #231a00; font-weight: 600; }
.back { display: inline-block; color: var(--muted); text-decoration: none; padding: 4px 0; }
.rules { margin: 0; padding-left: 20px; }
.rules li + li { margin-top: 6px; }
