/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --text-muted:#8b949e;
  --accent:    #1f6feb;
  --green:     #2ea043;
  --red:       #da3633;
  --yellow:    #d29922;
  --radius:    8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; }
body { background: var(--bg); color: var(--text); }

/* ── Lobby page ──────────────────────────────────────────────────────────── */
.lobby-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.lobby-container {
  width: 100%;
  max-width: 860px;
}

.lobby-header {
  text-align: center;
  margin-bottom: 36px;
}

.title-logo {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
}

.lobby-header h1 {
  font-size: 2.8em;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #f0c060, #e05a2a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 1.05em;
}

.lobby-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 600px) { .lobby-cards { grid-template-columns: 1fr; } }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h2 {
  font-size: 1.15em;
  margin-bottom: 16px;
  color: var(--text);
}

.card-hint {
  font-size: 0.82em;
  color: var(--text-muted);
  margin-top: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1em;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
  text-align: center;
}
.btn:hover  { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-small  { width: auto; padding: 5px 12px; font-size: 0.85em; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-success   { background: var(--green); color: #fff; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-warning   { background: var(--yellow); color: #000; }
.btn:disabled  { opacity: 0.4; cursor: default; }

/* ── Lobby room ──────────────────────────────────────────────────────────── */
.lobby-room {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.session-code {
  font-size: 1.8em;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: #f0c060;
  font-family: monospace;
}

.player-list-section h3 { margin-bottom: 10px; }

.player-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  padding: 8px 12px;
  border-radius: 6px;
}

.player-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge {
  font-size: 0.72em;
  background: var(--yellow);
  color: #000;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.lobby-actions { display: flex; flex-direction: column; gap: 10px; }
.waiting-msg { color: var(--text-muted); text-align: center; font-size: 0.9em; }

/* ── Error banner ────────────────────────────────────────────────────────── */
.error-banner {
  background: #5a1a1a;
  border: 1px solid var(--red);
  color: #ff8080;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.hidden { display: none !important; }

/* ── Game page layout ────────────────────────────────────────────────────── */
.game-page {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 0;
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1em;
  color: #f0c060;
}

.logo-small { font-size: 1.4em; }

#sidebar section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

#sidebar h3 {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Players list */
#players-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.pl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 0.9em;
}

.pl-item.current-turn {
  background: rgba(31,111,235,0.15);
  border: 1px solid rgba(31,111,235,0.4);
}

.pl-item.eliminated {
  opacity: 0.4;
  text-decoration: line-through;
}

.pl-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pl-name { flex: 1; }
.pl-count { font-size: 0.8em; color: var(--text-muted); }

/* Phase info */
.phase-info {
  background: var(--bg3);
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 0.88em;
  margin-bottom: 8px;
  line-height: 1.5;
}

.phase-actions { display: flex; flex-direction: column; gap: 6px; }
.phase-actions .btn { font-size: 0.85em; padding: 7px 12px; }

/* Continents */
#continents-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.cont-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82em;
  padding: 3px 6px;
  border-radius: 4px;
}
.cont-dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }
.cont-name { flex: 1; }
.cont-bonus { color: var(--yellow); font-weight: 600; }
.cont-owner { font-size: 0.78em; color: var(--text-muted); }

/* Log */
#game-log { list-style: none; display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
#game-log li { font-size: 0.78em; color: var(--text-muted); padding: 2px 0; border-bottom: 1px solid var(--bg3); }

.sidebar-footer { padding: 12px 16px; margin-top: auto; }

/* ── Map area ────────────────────────────────────────────────────────────── */
#map-area {
  flex: 1;
  overflow: hidden;
  background: #0a1628;
  position: relative;
}

#game-map {
  width: 100%;
  height: 100%;
}

/* ── SVG Map elements ────────────────────────────────────────────────────────── */
.territory-poly {
  cursor: default;
  transition: filter 0.12s;
}

.territory-poly.t-clickable {
  cursor: pointer;
}

.territory-poly.t-clickable:hover {
  filter: brightness(1.22) saturate(1.1);
}

.territory-poly.t-source {
  filter: drop-shadow(0 0 6px rgba(240,192,96,0.8));
}

.territory-poly.t-target {
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(255,80,80,0.8));
}

.territory-armies {
  pointer-events: none;
  font-size: 12px;
  font-weight: 800;
  fill: #fff;
  dominant-baseline: central;
  text-anchor: middle;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.territory-name {
  pointer-events: none;
  font-size: 8.5px;
  font-weight: 600;
  fill: rgba(255,255,255,0.90);
  dominant-baseline: hanging;
  text-anchor: middle;
  font-family: 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.03em;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 300px;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.modal-content h3 { margin-bottom: 10px; font-size: 1.2em; }
.modal-content p  { color: var(--text-muted); margin-bottom: 16px; font-size: 0.9em; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.dice-choice label { display: block; color: var(--text-muted); margin-bottom: 8px; font-size: 0.88em; }

.dice-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.dice-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1em;
  font-weight: 700;
  transition: all 0.15s;
  text-align: center;
}
.dice-btn:hover { border-color: var(--accent); background: rgba(31,111,235,0.15); }
.dice-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Winner overlay ──────────────────────────────────────────────────────── */
.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.winner-content {
  text-align: center;
  background: var(--bg2);
  border: 2px solid #f0c060;
  border-radius: 16px;
  padding: 48px 64px;
  box-shadow: 0 0 60px rgba(240,192,96,0.3);
}

.winner-trophy { font-size: 72px; margin-bottom: 12px; }
.winner-content h2 { font-size: 2.2em; color: #f0c060; margin-bottom: 6px; }
.winner-content p  { color: var(--text-muted); margin-bottom: 24px; }

/* ── Attack toast ────────────────────────────────────────────────────────── */
.attack-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  z-index: 150;
  min-width: 280px;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 0.9em;
}

.dice-display {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 8px;
}

.dice-group { text-align: center; }
.dice-group label { font-size: 0.75em; color: var(--text-muted); display: block; margin-bottom: 4px; }
.dice-row { display: flex; gap: 4px; justify-content: center; }
.die {
  width: 28px; height: 28px;
  background: var(--bg3);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1em;
  border: 1px solid var(--border);
}
.die.attack-die  { border-color: #e74c3c; color: #e74c3c; }
.die.defend-die  { border-color: #3498db; color: #3498db; }

.toast-result { font-size: 0.85em; color: var(--text-muted); }
