*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --liberal: #1a4d8f;
  --liberal-lit: #3a7bd5;
  --liberal-fill: #2258a8;
  --fascist: #8b1a1a;
  --fascist-lit: #c0392b;
  --fascist-fill: #a52020;
  --bg: #0d0d1a;
  --surface: #111128;
  --card: #181830;
  --text: #e8e8f0;
  --text-dim: #7a7a9a;
  --accent: #e94560;
  --yellow: #f1c40f;
  --green: #27ae60;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

/* ── Screens ───────────────────────────────────────────────────── */
.screen { display: none; height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Join screen ───────────────────────────────────────────────── */
#screen-join {
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px;
}
.logo {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
}
.hint { color: var(--text-dim); font-size: 1rem; text-align: center; max-width: 500px; }
.join-area {
  display: flex;
  gap: 12px;
  align-items: center;
}
input[type="text"] {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 2px solid #333;
  background: var(--card);
  color: var(--text);
  font-size: 1.3rem;
  text-align: center;
  letter-spacing: 0.2em;
  outline: none;
  width: 160px;
  transition: border-color 0.2s;
}
input[type="text"]:focus { border-color: var(--accent); }
button {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.85; }
.error { color: var(--accent); font-size: 0.9rem; }
.hidden { display: none !important; }
.divider-text { color: var(--text-dim); font-size: 0.9rem; }
.room-code-label { font-size: 2rem; font-weight: 900; color: var(--yellow); letter-spacing: 0.2em; }

/* ── Header ────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid #222240;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 18px; }
.room-tag { font-size: 1rem; font-weight: 700; letter-spacing: 0.08em; }
.room-tag strong { color: var(--yellow); font-size: 1.2rem; letter-spacing: 0.2em; }
.phase-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}
.deck-info { font-size: 0.85rem; color: var(--text-dim); }
.deck-info strong { color: var(--text); }
.deck-breakdown { font-size: 0.8rem; }
.deck-lib  { color: var(--liberal-lit); font-weight: 700; }
.deck-fasc { color: var(--fascist-lit); font-weight: 700; }
.close-room-btn {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid #444;
  color: #888;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  width: auto;
  transition: border-color 0.15s, color 0.15s;
}
.close-room-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Policy tracks ─────────────────────────────────────────────── */
.tracks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px;
  flex-shrink: 0;
}
.track { display: flex; flex-direction: column; gap: 6px; }
.track-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.track-slots {
  display: flex;
  gap: 8px;
}
.slot {
  flex: 1;
  height: 52px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid transparent;
  transition: background 0.3s, border-color 0.3s;
  line-height: 1.2;
  text-align: center;
}
.slot.liberal {
  background: #1a2f52;
  border-color: #2258a8;
  color: #6fa8dc;
}
.slot.liberal.enacted {
  background: transparent;
  border: 3px solid var(--liberal-lit);
  color: var(--liberal-lit);
}
.slot.fascist {
  background: #2e1010;
  border-color: #6b1a1a;
  color: #e06666;
}
.slot.fascist.enacted {
  background: transparent;
  border: 3px solid var(--fascist-lit);
  color: var(--fascist-lit);
}
.slot.win { position: relative; }
.slot.win.liberal.enacted { box-shadow: 0 0 18px var(--liberal-lit); }
.slot.win.fascist.enacted { box-shadow: 0 0 18px var(--fascist-lit); }
.power-label {
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  opacity: 0.8;
  display: block;
  line-height: 1;
  text-transform: uppercase;
}
.track-win-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: right;
}
.track-win-label.liberal { color: #6fa8dc; }
.track-win-label.fascist { color: #e06666; }

/* ── Mid row ────────────────────────────────────────────────────── */
.mid-row {
  display: flex;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
}

/* ── Election tracker ──────────────────────────────────────────── */
.election-tracker-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
}
.box-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.box-label-count {
  color: var(--yellow);
  letter-spacing: 0.1em;
}
.tracker-pips {
  display: flex;
  gap: 8px;
}
.pip {
  flex: 1;
  height: 34px;
  border-radius: 6px;
  background: #222240;
  border: 2px solid #333360;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  transition: background 0.3s, border-color 0.3s;
}
.pip.active {
  background: var(--yellow);
  border-color: #d4ac0d;
  color: #111;
}
.pip.chaos.active {
  background: var(--accent);
  border-color: #c0392b;
  color: #fff;
}

/* ── Government ─────────────────────────────────────────────────── */
.government-box {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gov-row {
  display: flex;
  gap: 10px;
}
.gov-card {
  flex: 1;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.president-card  { background: #1a2840; border: 2px solid #2d4a70; }
.chancellor-card { background: #1a2820; border: 2px solid #2d6040; }
.gov-title {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.gov-name {
  font-size: 1.2rem;
  font-weight: 700;
}
.nominee-label {
  font-size: 0.8rem;
  color: var(--yellow);
}

/* ── Bottom row ─────────────────────────────────────────────────── */
.bottom-row {
  display: flex;
  gap: 12px;
  padding: 10px 20px;
  flex: 1;
  min-height: 0;
}

/* ── Players ─────────────────────────────────────────────────────── */
.players-box {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}
.player-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  overflow: hidden;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  transition: opacity 0.3s;
  min-width: 0;
}
.player-list li.dead {
  opacity: 0.35;
  text-decoration: line-through;
}
.player-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}
.badge-president  { background: #2258a8; color: #fff; }
.badge-chancellor { background: #27ae60; color: #fff; }
.badge-nominated  { background: var(--yellow); color: #111; }
.badge-investigated { background: #555; color: #ccc; }
.offline-dot { color: #e94560; font-size: 0.7rem; vertical-align: middle; }
.remove-player-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid #444;
  color: #888;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1.4;
  width: auto;
}
.remove-player-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── History ─────────────────────────────────────────────────────── */
.history-box {
  flex: 2;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}
.history-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
}
.history-entry {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.82rem;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.history-entry .h-round {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 1px;
}
.history-entry .h-msg { flex: 1; }
.history-entry.h-liberal   { border-left: 3px solid var(--liberal-lit); }
.history-entry.h-fascist   { border-left: 3px solid var(--fascist-lit); }
.history-entry.h-vote-pass { border-left: 3px solid var(--green); }
.history-entry.h-vote-fail { border-left: 3px solid #555; }
.history-entry.h-executive { border-left: 3px solid var(--yellow); }
.history-entry.h-chaos     { border-left: 3px solid var(--accent); }
.history-entry.h-game-over { border-left: 3px solid #fff; background: #1a1a1a; }
.h-liberal-text { color: var(--liberal-lit); font-weight: 600; }
.h-fascist-text { color: var(--fascist-lit); font-weight: 600; }
.h-name         { color: var(--text); font-weight: 600; }
.h-dim          { color: var(--text-dim); }

/* ── Votes ───────────────────────────────────────────────────────── */
.votes-box {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.vote-progress-text {
  font-size: 0.9rem;
  color: var(--text-dim);
}
.vote-reveal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.vote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.82rem;
}
.vote-ja   { color: var(--green); font-weight: 700; }
.vote-nein { color: var(--accent); font-weight: 700; }

/* ── Status banner ───────────────────────────────────────────────── */
.status-banner {
  padding: 10px 20px;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  color: var(--yellow);
  flex-shrink: 0;
}

/* ── Game over overlay ───────────────────────────────────────────── */
.gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.gameover-inner {
  background: var(--card);
  border-radius: 20px;
  padding: 48px;
  max-width: 640px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  box-shadow: 0 20px 80px rgba(0,0,0,0.8);
}
.go-headline {
  font-size: 3rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.go-headline.liberal { color: var(--liberal-lit); }
.go-headline.fascist { color: var(--fascist-lit); }
.go-reason { font-size: 1.1rem; color: var(--text-dim); }
.go-roles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-height: 40vh;
  overflow-y: auto;
}
.go-role-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.95rem;
}
.go-role-badge { font-weight: 700; text-transform: uppercase; font-size: 0.8rem; }
.go-role-badge.liberal { color: #6fa8dc; }
.go-role-badge.fascist { color: #e06666; }
.go-role-badge.hitler  { color: #ff4444; }
