/* PoliGuesser — styles */

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

:root {
  --color-bg:           #1a1a2e;
  --color-surface:      #16213e;
  --color-surface-2:    #0f3460;
  --color-accent:       #e84040;
  --color-accent-dim:   rgba(232, 64, 64, 0.15);
  --color-correct:      #4caf50;
  --color-correct-dim:  rgba(76, 175, 80, 0.15);
  --color-text:         #f0f0f0;
  --color-text-muted:   #8888a0;
  --color-border:       #2a2a4a;
  --radius:             8px;
  --radius-lg:          14px;
  --font:               system-ui, -apple-system, sans-serif;
  --transition-fast:    0.15s ease;
  --top-bar-height:     52px;
  --bottom-bar-height:  64px;
}

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

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}


/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 28px;
  height: 48px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: opacity var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { opacity: 0.8; }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-primary:hover { background: #c93535; border-color: #c93535; }

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { border-color: var(--color-text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  padding: 0 16px;
}
.btn-ghost:hover { color: var(--color-text); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}


/* ── Home screen ─────────────────────────────────────────────────────────── */

.view-home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 24px;
}

.home-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.home-title {
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--color-text);
}

.home-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 280px;
}

.home-buttons .btn {
  width: 100%;
  height: 52px;
  font-size: 1.05rem;
}


/* ── Game screen layout ──────────────────────────────────────────────────── */
/*
  .game-screen
    .top-bar        ← player roster (challenge) or score (practice)
    .map-area       ← fills remaining height; SVG lives here
    .bottom-bar     ← guess input
*/

.game-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
.top-bar {
  flex-shrink: 0;
  height: var(--top-bar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-bar::-webkit-scrollbar { display: none; }

/* Score chip inside top bar (practice mode) */
.score-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  user-select: none;
}
.score-chip .correct { color: var(--color-correct); }
.score-chip .wrong   { color: var(--color-accent); }

/* Player chips (challenge mode) */
.player-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  border: 2px solid transparent;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}
.player-chip.active {
  border-color: var(--color-accent);
  color: var(--color-text);
  background: var(--color-accent-dim);
}
.player-chip .chip-score {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Quit button in top bar */
.btn-quit {
  margin-left: auto;
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  font-size: 0.8rem;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.btn-quit:hover { color: var(--color-text); border-color: var(--color-text-muted); }

/* Map area */
.map-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--color-bg);
  touch-action: none; /* hand off all touch events to pointer handlers */
}

.map-area svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Country paths — game map */
.map-area svg path {
  fill: #b0b4cc;
  stroke: #70748a;
  stroke-width: 0.5;
  transition: fill 0.2s ease;
  cursor: default;
}

.map-area svg path.highlighted {
  fill: var(--color-accent);
  stroke: #b03030;
  stroke-width: 0.8;
}

.map-area svg path.flash-correct {
  fill: var(--color-correct);
  stroke: #2e7d32;
  stroke-width: 0.8;
  transition: fill 0.1s ease;
}

.map-area svg path.flash-wrong {
  animation: pulse-wrong 0.7s ease;
}

@keyframes pulse-wrong {
  0%   { fill: #e84040; }
  40%  { fill: #ff7070; }
  100% { fill: #e84040; }
}

/* Loading / error message centred in map area */
.map-load-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}
.map-load-error { color: var(--color-accent); }

/* Bottom bar */
.bottom-bar {
  flex-shrink: 0;
  height: var(--bottom-bar-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}

/* Guess input */
.guess-input {
  flex: 1;
  height: 40px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  padding: 0 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.guess-input::placeholder { color: var(--color-text-muted); }
.guess-input:focus { border-color: var(--color-text-muted); }


/* ── Feedback overlay ─────────────────────────────────────────────────────── */

.feedback-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 10;
  animation: fade-in-out 0.85s ease forwards;
}
.feedback-banner.correct {
  background: var(--color-correct-dim);
  border: 1px solid var(--color-correct);
  color: var(--color-correct);
}
.feedback-banner.wrong {
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
}

@keyframes fade-in-out {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}


/* ── Score history panel ─────────────────────────────────────────────────── */

.score-panel {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 30, 0.92);
  backdrop-filter: blur(4px);
  z-index: 20;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.score-panel-header h2 { font-size: 1rem; font-weight: 700; }

.score-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 0.88rem;
}
.score-panel-row .result-icon { font-size: 1rem; flex-shrink: 0; }
.score-panel-row.correct { border-left: 3px solid var(--color-correct); }
.score-panel-row.wrong   { border-left: 3px solid var(--color-accent); }


/* ── Map Picker dialog ───────────────────────────────────────────────────── */

.view-map-picker {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 20px;
  overflow-y: auto;
}

.map-picker-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.map-picker-header h2 { font-size: 1.2rem; font-weight: 700; }

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.region-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.region-card:hover,
.region-card.selected {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
}

.region-card-name {
  font-weight: 700;
  font-size: 1rem;
}
.region-card-count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.region-card-thumb {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--color-surface-2);
}
.region-card-thumb svg {
  width: 100%;
  height: 100%;
}
.region-card-thumb svg path {
  fill: #4a5580;
  stroke: #2a3560;
  stroke-width: 0.8;
}

.map-picker-footer {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}


/* ── Add Players screen ───────────────────────────────────────────────────── */

.view-add-players {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.add-players-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.add-players-header h2 { font-size: 1.2rem; font-weight: 700; }

.add-player-row {
  display: flex;
  gap: 8px;
}

.player-name-input {
  flex: 1;
  height: 44px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  padding: 0 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.player-name-input::placeholder { color: var(--color-text-muted); }
.player-name-input:focus { border-color: var(--color-text-muted); }

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
}

.player-remove-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition-fast);
}
.player-remove-btn:hover { color: var(--color-accent); }

.add-players-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.add-players-hint {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}


/* ── Session summary ─────────────────────────────────────────────────────── */

.view-summary {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.summary-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.summary-header p { color: var(--color-text-muted); font-size: 0.9rem; }

.summary-stats {
  display: flex;
  gap: 12px;
}
.stat-box {
  flex: 1;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  border: 1px solid var(--color-border);
}
.stat-box .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.stat-box .stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-box.correct .stat-value { color: var(--color-correct); }
.stat-box.wrong   .stat-value { color: var(--color-accent); }

.summary-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.summary-missed-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.missed-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent);
  color: var(--color-text);
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}
.leaderboard-row.first { border-color: #f0c040; background: rgba(240,192,64,0.08); }
.lb-rank { font-size: 1.1rem; width: 24px; text-align: center; }
.lb-name { flex: 1; font-weight: 600; }
.lb-score { font-size: 1.1rem; font-weight: 800; color: var(--color-correct); }

.summary-footer {
  display: flex;
  gap: 10px;
  padding-bottom: 8px;
}
