:root {
  --bg: #111827;
  --panel: #1f2937;
  --panel2: #273449;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --grey: #6b7280;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 520px; margin: 0 auto; padding: 16px; min-height: 100%; }

h1 { font-size: 1.6rem; margin-bottom: 4px; }
h2 { font-size: 1.2rem; margin-bottom: 10px; }
p.sub { color: var(--muted); margin-bottom: 18px; }
.brand { text-align: center; margin: 28px 0 22px; }
.brand .logo {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #a855f7 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 800; color: #fff;
}

.card {
  background: var(--panel); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=number], select {
  width: 100%; padding: 13px 14px; font-size: 1.05rem;
  background: var(--panel2); color: var(--text);
  border: 1px solid #374151; border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: .92rem; }
.check input { width: 20px; height: 20px; }

button {
  font-size: 1.05rem; font-weight: 600; border: none; cursor: pointer;
  border-radius: 10px; padding: 14px 18px; color: #fff;
  background: var(--accent-strong); width: 100%; margin-top: 12px;
  min-height: 48px;
}
button.secondary { background: var(--panel2); color: var(--text); }
button.ghost { background: transparent; color: var(--accent); }
button.danger { background: var(--red); }
button.small { width: auto; padding: 8px 14px; font-size: .9rem; min-height: 40px; margin-top: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.err { color: var(--red); font-size: .9rem; margin-top: 10px; min-height: 1.2em; }

/* ---- lobby ---- */
.code-banner {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel2); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
}
.code-banner .code { font-size: 1.5rem; font-weight: 800; letter-spacing: .25em; }
ul.players { list-style: none; }
ul.players li {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid #374151;
}
ul.players li:last-child { border-bottom: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pname { flex: 1; }
.pname .tag { font-size: .72rem; color: var(--muted); margin-left: 6px; }
.pstatus { font-size: .82rem; font-weight: 600; }
.pstatus.ready { color: var(--green); }
.pstatus.notready { color: var(--muted); }
.pstatus.off { color: var(--red); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---- game ---- */
.game-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-size: .9rem; color: var(--muted);
}
.prompt-card { text-align: center; padding: 22px 18px; }
.big-letter {
  font-size: 4.2rem; font-weight: 800; line-height: 1;
  color: var(--accent); margin: 6px 0;
}
.cat-title { font-size: 1.25rem; font-weight: 700; }
.cat-desc { color: var(--muted); font-size: .92rem; margin-top: 6px; }

.timer-wrap { margin: 14px 0 6px; }
.timer-num {
  font-variant-numeric: tabular-nums; text-align: center;
  font-size: 2rem; font-weight: 800;
}
.timer-bar { height: 10px; background: var(--panel2); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.timer-bar > div { height: 100%; background: var(--green); width: 100%; transition: width .2s linear; }
.timer-warn .timer-num { color: var(--red); animation: pulse .5s infinite alternate; }
.timer-warn .timer-bar > div { background: var(--red); }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
  .timer-warn .timer-num { animation: none; }
}

.answer-input {
  font-size: 1.3rem !important; text-align: center; padding: 16px !important;
}
.submitted-note { text-align: center; color: var(--green); font-weight: 600; margin-top: 10px; min-height: 1.3em; }
.subcount { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 8px; }

.countdown {
  font-size: 5rem; font-weight: 800; text-align: center; color: var(--accent);
  padding: 30px 0;
}

/* ---- results ---- */
.result-line {
  display: flex; align-items: center; gap: 10px; padding: 11px 4px;
  border-bottom: 1px solid #374151;
}
.result-line:last-child { border-bottom: none; }
.badge {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 800; color: #fff;
}
.badge.unique { background: var(--green); }
.badge.duplicate { background: var(--yellow); color: #111; }
.badge.invalid, .badge.disputed { background: var(--red); }
.badge.blank { background: var(--grey); }
.r-answer { flex: 1; min-width: 0; }
.r-answer .who { font-size: .78rem; color: var(--muted); }
.r-answer .what { font-weight: 600; overflow-wrap: anywhere; }
.r-answer .why { font-size: .78rem; color: var(--muted); }
.r-points { font-weight: 800; font-variant-numeric: tabular-nums; }
.r-points.p10 { color: var(--green); }
.r-points.p5 { color: var(--yellow); }
.r-points.p0 { color: var(--grey); }

table.lb { width: 100%; border-collapse: collapse; }
table.lb td, table.lb th { padding: 9px 6px; text-align: left; border-bottom: 1px solid #374151; }
table.lb tr:last-child td { border-bottom: none; }
table.lb .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
tr.me td { color: var(--accent); font-weight: 700; }

.winner-box { text-align: center; padding: 26px 16px; }
.winner-box .trophy { font-size: 3rem; }
.winner-box .wname { font-size: 1.5rem; font-weight: 800; margin-top: 8px; }

.vote-line { padding: 12px 4px; border-bottom: 1px solid #374151; }
.vote-line:last-child { border-bottom: none; }
.vote-btns { display: flex; gap: 10px; margin-top: 8px; }
.vote-btns button { margin-top: 0; }
.vote-btns .valid { background: var(--green); }
.vote-btns .invalid { background: var(--red); }
.voted { color: var(--muted); font-size: .85rem; margin-top: 8px; }

#toasts { position: fixed; top: 12px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  background: #0f172a; border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: .92rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 90%;
}
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.topbar .who { font-size: .85rem; color: var(--muted); }
.linkish { color: var(--accent); background: none; border: none; font-size: .85rem; cursor: pointer; padding: 4px; width: auto; min-height: 0; margin: 0; }
.muted { color: var(--muted); font-size: .88rem; }
.center { text-align: center; }
.mt { margin-top: 14px; }
