/* ── Fonts ─────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Lato:wght@400;700&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:         #0d1b2a;
  --surface:    #162435;
  --surface-2:  #1e3248;
  --gold:       #d4a017;
  --gold-dim:   #9a730f;
  --text:       #e8dcc8;
  --text-dim:   #8a9aaa;
  --danger:     #c0392b;
  --safe:       #27ae60;
  --accent:     #2980b9;
  --border:     rgba(212,160,23,0.3);

  /* Continent palette */
  --c-na:   #2d6b3a;
  --c-sa:   #1f5228;
  --c-eu:   #3a6b2d;
  --c-af:   #b07a12;
  --c-as:   #942020;
  --c-au:   #a04810;
  --c-an:   #3a7090;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Lato', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Shared components ──────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: 'Cinzel', serif; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.btn {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  padding: 0.65rem 1.4rem;
  border: 1px solid var(--gold-dim);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--gold);
  color: #0d0d0d;
  border-color: var(--gold);
}
.btn-primary:hover:not(:disabled) { background: #e6b020; border-color: #e6b020; }

.btn-secondary {
  background: transparent;
  color: var(--gold);
}
.btn-secondary:hover:not(:disabled) { background: rgba(212,160,23,0.1); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #e74c3c; }

.btn-safe {
  background: var(--safe);
  color: #fff;
  border-color: var(--safe);
}
.btn-safe:hover:not(:disabled) { background: #2ecc71; }

input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus { border-color: var(--gold); }
input[type="text"]::placeholder { color: var(--text-dim); }

label {
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  margin-top: 1rem;
}

.status-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0.75rem;
  min-height: 1.3em;
}
.status-msg.error { color: var(--danger); }

/* ── Lobby page ─────────────────────────────────────────────────────────────── */
.lobby-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(30,50,72,0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(148,32,32,0.15) 0%, transparent 50%);
}

.lobby-container {
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.game-title {
  font-size: 3.5rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-shadow: 0 0 30px rgba(212,160,23,0.5);
  margin-bottom: 0.25rem;
}

.game-subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.lobby-container .card { text-align: left; }
.lobby-container .card h2 {
  text-align: center;
  color: var(--gold);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.button-group .btn { flex: 1; }

.divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  margin: 1.25rem 0;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 28%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

.join-row {
  display: flex;
  gap: 0.5rem;
}
.game-id-input { flex: 1; font-family: monospace; font-size: 0.85rem; }
.join-row .btn { flex-shrink: 0; white-space: nowrap; }

/* Game code share box */
.share-box {
  background: var(--surface-2);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 1rem;
  text-align: center;
}
.share-box p { color: var(--text-dim); font-size: 0.8rem; margin-bottom: 0.4rem; }
.share-box .game-code {
  font-family: monospace;
  font-size: 1.1rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  word-break: break-all;
}
.share-box .copy-btn {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
}

/* ── Game page layout ───────────────────────────────────────────────────────── */
.game-page {
  display: grid;
  grid-template-rows: 56px 1fr 44px;
  height: 100vh;
  overflow: hidden;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.top-bar .game-title { font-size: 1.1rem; color: var(--gold); letter-spacing: 0.15em; }
.round-badge {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#player-scores {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.score-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
.score-chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.score-chip.is-me .dot { background: var(--gold); }
.score-chip.is-aggressor { border-color: var(--gold); }
.score-chip .name { color: var(--text); font-weight: 700; }
.score-chip .pts { color: var(--text-dim); }

/* Main area */
.main-area {
  display: grid;
  grid-template-columns: 340px 1fr;
  overflow: hidden;
}

/* Continent sidebar */
.continent-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sidebar-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.25rem 0.25rem 0.5rem;
}

/* Continent cards */
.continent-card {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 7px;
  padding: 0.6rem 0.75rem;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  transition: border-color 0.15s, transform 0.1s, background 0.15s;
  user-select: none;
}
.continent-card .c-icon { font-size: 1.3rem; text-align: center; }
.continent-card .c-name {
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  color: var(--text);
  letter-spacing: 0.05em;
}
.continent-card .c-owner {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 1px;
}
.continent-card .c-fort {
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: -0.05em;
}

/* Colour strip on the left edge */
.continent-card[data-id="north_america"]  { border-left: 3px solid var(--c-na); }
.continent-card[data-id="south_america"]  { border-left: 3px solid var(--c-sa); }
.continent-card[data-id="europe"]         { border-left: 3px solid var(--c-eu); }
.continent-card[data-id="africa"]         { border-left: 3px solid var(--c-af); }
.continent-card[data-id="asia"]           { border-left: 3px solid var(--c-as); }
.continent-card[data-id="australia"]      { border-left: 3px solid var(--c-au); }
.continent-card[data-id="antarctica"]     { border-left: 3px solid var(--c-an); }

/* Selectable states */
.continent-card.selectable {
  cursor: pointer;
  border-color: rgba(212,160,23,0.45);
}
.continent-card.selectable:hover { background: rgba(212,160,23,0.08); transform: translateX(2px); }
.continent-card.selectable.attack-target  { border-color: var(--danger); }
.continent-card.selectable.fortify-target { border-color: var(--safe); }
.continent-card.selectable.attack-target:hover  { background: rgba(192,57,43,0.12); }
.continent-card.selectable.fortify-target:hover { background: rgba(39,174,96,0.12); }
.continent-card.non-selectable { opacity: 0.4; }

/* Game panel (right side) */
.game-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  gap: 1.5rem;
  background-image: radial-gradient(ellipse at 50% 30%, rgba(30,50,72,0.4) 0%, transparent 70%);
}

/* State panels */
.state-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
}
.state-card h2 {
  color: var(--gold);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

/* Waiting / lobby state */
.waiting-players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}
.player-row .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold-dim);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  color: #0d0d0d;
  flex-shrink: 0;
}
.player-row.empty { opacity: 0.4; font-style: italic; color: var(--text-dim); }
.waiting-hint { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.5rem; }
.game-code-display {
  font-family: monospace;
  font-size: 0.95rem;
  background: var(--surface-2);
  border: 1px dashed var(--gold-dim);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  color: var(--gold);
  word-break: break-all;
  margin-top: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}
.game-code-display:hover { background: rgba(212,160,23,0.1); }
.game-code-display::after { content: ' 📋'; font-size: 0.85rem; }

/* Question phase */
.question-prompt {
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 1.5rem;
}
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.choice-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.8rem 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  font-family: 'Lato', sans-serif;
}
.choice-btn:hover:not(:disabled) { background: rgba(212,160,23,0.1); border-color: var(--gold-dim); }
.choice-btn:active:not(:disabled) { transform: scale(0.97); }
.choice-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.choice-btn.answered { border-color: var(--accent); background: rgba(41,128,185,0.15); }
.choice-label {
  display: inline-block;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--gold);
  margin-right: 0.5rem;
  font-size: 0.85rem;
}

/* Timer bar */
.timer-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.timer-bar {
  height: 100%;
  background: var(--gold);
  transition: width 0.1s linear, background 0.3s;
  border-radius: 3px;
}
.timer-bar.urgent { background: var(--danger); }
.timer-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.submitted-msg { color: var(--safe); font-size: 0.9rem; margin-top: 0.75rem; }

/* Action phase */
.aggressor-badge {
  display: inline-block;
  background: rgba(212,160,23,0.15);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  color: var(--gold);
  margin-bottom: 1rem;
}
.action-buttons { display: flex; gap: 0.75rem; justify-content: center; margin: 1rem 0; }
.action-hint { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.5rem; }
.action-mode-active {
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.action-mode-active span { color: var(--gold); font-weight: 700; }
.cancel-link {
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  margin-top: 0.5rem;
  display: inline-block;
}
.cancel-link:hover { color: var(--text); }

/* Duel phase */
.duel-banner {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.duel-banner strong { color: var(--text); }
.duel-banner .vs { color: var(--danger); font-weight: 700; margin: 0 0.3rem; }
.spectator-anim {
  font-size: 2.5rem;
  margin: 1rem 0;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Game over */
.winner-banner {
  font-size: 2rem;
  margin: 0.5rem 0 1rem;
}
.final-scores {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
}
.final-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
}
.final-score-row.winner {
  border: 1px solid var(--gold);
  background: rgba(212,160,23,0.1);
  color: var(--gold);
}
.final-score-row .pts { font-weight: 700; }

/* Status bar */
.status-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  gap: 0.5rem;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--safe);
  flex-shrink: 0;
}
.status-dot.offline { background: var(--danger); }
.status-dot.connecting { background: var(--gold); animation: pulse 0.8s infinite; }

/* Notification overlay */
.notification {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.85rem 1.5rem;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  color: var(--gold);
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  pointer-events: none;
  max-width: 90vw;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.notification.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.notification .n-sub { color: var(--text-dim); font-size: 0.78rem; font-family: 'Lato', sans-serif; margin-top: 0.25rem; }

/* Rankings display inside notification */
.rankings-list { list-style: none; margin-top: 0.5rem; }
.rankings-list li {
  padding: 0.25rem 0;
  font-family: 'Lato', sans-serif;
  font-size: 0.85rem;
  color: var(--text);
}
.rankings-list li:first-child { color: var(--gold); }

/* Responsive: collapse sidebar on small screens */
@media (max-width: 700px) {
  .main-area { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .continent-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 160px;
  }
  .continent-card {
    grid-template-columns: 1.5rem 1fr auto;
    width: calc(50% - 0.2rem);
    font-size: 0.8rem;
  }
  .continent-card .c-name { font-size: 0.7rem; }
  .game-panel { padding: 1.25rem; }
  .choices-grid { grid-template-columns: 1fr; }
}
