:root {
  --bg: #0b0e14;
  --bg-2: #121825;
  --panel: #171f2e;
  --panel-2: #1f2a3d;
  --line: #2a3650;
  --text: #eef2f8;
  --muted: #9aa7bd;
  --accent: #f2c14e;
  --accent-2: #ffd97a;
  --danger: #e5484d;
  --ok: #3ecf8e;
  --mafia: #e5484d;
  --town: #4f9cf5;
  --night: #0a1024;
  --day: #2b2214;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1c2740 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.35;
}
body.phase-night { background: radial-gradient(1200px 600px at 20% -10%, #15214a 0%, var(--night) 60%); }
body.phase-day, body.phase-vote, body.phase-dawn { background: radial-gradient(1200px 600px at 20% -10%, #4a3a1c 0%, var(--day) 60%); }
body.phase-ended { background: radial-gradient(1200px 600px at 20% -10%, #2d1c4a 0%, #120b1e 60%); }

h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.15; }
p { margin: 0 0 0.8em; }
a { color: var(--accent-2); }
button, input, select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 0.8em 1.2em;
  background: var(--panel-2);
  color: var(--text);
  min-height: 44px;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
button:hover { background: #26324a; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button.primary { background: var(--accent); color: #1a1405; font-weight: 700; }
button.primary:hover { background: var(--accent-2); }
button.danger { background: var(--danger); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.big { font-size: 1.25rem; padding: 1em 1.4em; border-radius: 16px; }
input[type="text"], select {
  width: 100%;
  padding: 0.8em 1em;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  min-height: 48px;
}
input[type="text"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.3em; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; }
.center { text-align: center; }
.badge {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.8em;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge.ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.4); }
.badge.warn { color: var(--accent); border-color: rgba(242, 193, 78, 0.4); }
.badge.danger { color: var(--danger); border-color: rgba(229, 72, 77, 0.4); }
.badge.mafia { color: var(--mafia); border-color: rgba(229, 72, 77, 0.4); }
.badge.town { color: var(--town); border-color: rgba(79, 156, 245, 0.4); }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.18em;
  font-weight: 800;
}

.subtitles {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  min-height: 3.2em;
}
.subtitles .current { font-size: 1.15em; }
.subtitles .prev { color: var(--muted); font-size: 0.9em; margin-top: 0.3em; }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.timer.urgent { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 0.8em 1.2em;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: 92vw;
}
.toast.error { border-color: var(--danger); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 1rem;
}
.overlay .panel { max-width: 520px; width: 100%; text-align: center; }

.player-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
}
.player-chip.dead { opacity: 0.55; }
.player-chip.dead .name { text-decoration: line-through; }
.player-chip .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.player-chip .dot.on { background: var(--ok); }
.player-chip .dot.off { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
