/* Modern Quiz Game Styles */
:root {
  /* Main theme - used everywhere */
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #1a1625;
  --bg-card: #252033;
  --bg-input: #2f2841;
  --text: #f0eef5;
  --text-muted: #9ca3af;
  --border: #3d3654;
  --accent: #ec4899;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  min-height: 100vh;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastSlideIn 0.3s ease-out;
  pointer-events: auto;
  max-width: 400px;
  text-align: center;
}

.toast.error {
  border-color: var(--danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), var(--bg-card));
}

.toast.success {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), var(--bg-card));
}

.toast.info {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), var(--bg-card));
}

.toast.hiding {
  animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

#app {
  min-height: 100vh;
}

/* Screens */
.screen {
  display: none;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.screen.active {
  display: block;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

/* Home Screen */
#home-screen {
  display: none;
  background: var(--bg);
}

#home-screen.active {
  display: block;
}

.home-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.logo {
  font-family: 'Nunito', sans-serif;
  font-size: 4.5rem;
  font-weight: 900;
  margin: 0;
  color: var(--text);
  letter-spacing: -2px;
  line-height: 1;
}

.tagline {
  color: var(--text-muted);
  margin: 0.5rem 0 3rem 0;
  font-size: 1.1rem;
}

/* Play Button */
.btn-play {
  background: var(--primary);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  padding: 1rem 5rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.btn-play:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(139, 92, 246, 0.4);
}

.btn-play:active {
  transform: translateY(0);
}

/* Multiplayer Section */
.multiplayer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  width: 100%;
  max-width: 280px;
}

.section-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-room {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}

.btn-room:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

.join-room {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.join-room input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.join-room input::placeholder {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

.join-room input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-join {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}

.btn-join:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

/* Live ticker */
.live-ticker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#live-count {
  font-weight: 600;
  color: var(--text);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.2rem;
}

/* Inputs */
input, select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg-input);
  color: var(--text);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

input::placeholder {
  color: var(--text-muted);
}

/* Shared screen styles */
.screen-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.screen-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
}

.screen-header .back-link {
  position: static;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.screen-header .back-link:hover {
  color: var(--text);
}

.screen-header .header-logo {
  font-family: 'Nunito', sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.screen-header .header-logo:hover {
  color: var(--text);
}

.back-link {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--text);
}

.screen-title {
  font-family: 'Nunito', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.screen-subtitle {
  color: var(--text-muted);
  margin: 0 0 2rem 0;
}

.screen-subtitle span {
  color: var(--primary);
  font-weight: 600;
}

/* Primary action button - used across screens */
.btn-primary-action {
  background: var(--primary);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.85rem 2.5rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

.btn-primary-action:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn-primary-action:active {
  transform: translateY(0);
}

/* Name Screen */
.name-form {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
}

.name-form input {
  flex: 1;
  padding: 0.85rem 1rem;
  border-radius: 10px;
}

.name-form .btn-primary-action {
  padding: 0.85rem 1.5rem;
}

.name-form .btn-primary-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Color selection on name screen */
.color-selection {
  margin-top: 1.5rem;
  text-align: center;
}

.color-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem 0;
}

.color-picker-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.room-player-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.room-player-count.full {
  color: var(--danger);
  font-weight: 600;
}

/* Lobby Screen */
.lobby-content {
  min-height: 100vh;
  padding: 2rem;
  max-width: 700px;
  margin: 0 auto;
}

.lobby-room-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 3rem 0 2rem 0;
}

.lobby-room-header code {
  background: var(--bg-card);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--primary);
}

.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}

.btn-copy:hover {
  border-color: var(--primary);
  color: var(--text);
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

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

.lobby-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
}

.lobby-players {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.25rem;
}

.lobby-players ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lobby-players li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lobby-players li:last-child {
  border-bottom: none;
}

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

.lobby-players .host-badge {
  background: var(--accent);
  color: var(--bg);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.lobby-players .ready-badge {
  background: var(--success);
  color: var(--bg);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

/* Color Picker Swatches */
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, opacity 0.15s;
  padding: 0;
}

.color-swatch:hover:not(.taken) {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.color-swatch.selected {
  border-color: white;
  transform: scale(1.1);
}

.color-swatch.taken {
  opacity: 0.25;
  cursor: not-allowed;
}

.color-swatch.taken::after {
  content: '✕';
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: rgba(0, 0, 0, 0.5);
  height: 100%;
}

.lobby-settings {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.setting-group select {
  width: 100%;
  border-radius: 8px;
}

/* Game Mode Selection */
.game-mode-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-mode-option {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.game-mode-option:hover {
  border-color: var(--primary);
}

.game-mode-option.selected {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

.game-mode-option input {
  display: none;
}

.game-mode-option .mode-title {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.game-mode-option .mode-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.game-mode-option.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Session History */
.session-history {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
}

.session-history.hidden {
  display: none;
}

.session-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.stat-games {
  font-weight: 600;
  color: var(--text);
}

.stat-divider {
  color: var(--text-muted);
}

.stat-player {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
}

.stat-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.game-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-game {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 0.85rem;
}

.history-number {
  color: var(--text-muted);
  font-weight: 600;
  min-width: 2rem;
}

.history-quiz {
  color: var(--text);
  flex: 1;
}

.history-players {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.history-player.winner {
  font-weight: 700;
}

.host-controls {
  text-align: center;
  margin-top: 1rem;
}

.host-controls.hidden {
  display: none;
}

.btn-start {
  padding: 1rem 3rem;
  font-size: 1.2rem;
}

.waiting-message {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1.5rem;
}

.ready-controls {
  text-align: center;
  margin-top: 1rem;
}

.ready-controls.hidden {
  display: none;
}

.btn-ready {
  padding: 0.8rem 2.5rem;
  font-size: 1.1rem;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.btn-ready:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

.btn-ready.ready {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-ready.ready:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.waiting-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  font-style: italic;
}

.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--secondary);
  box-shadow: none;
}

/* Game Top Bar */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: transparent;
}

.btn-back {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem 0;
  transition: color 0.15s;
}

.btn-back:hover {
  color: var(--text);
}

.game-logo {
  font-family: 'Nunito', sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.game-logo:hover {
  color: var(--text);
}

/* Game Screen - New Layout */
#game-screen.active {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Countdown skeleton mode - show outlines only */
#game-screen.countdown-mode .game-header,
#game-screen.countdown-mode .game-sidebar,
#game-screen.countdown-mode .map-container,
#game-screen.countdown-mode .guess-input-container {
  position: relative;
}

#game-screen.countdown-mode .game-header > *,
#game-screen.countdown-mode .game-info-section > *,
#game-screen.countdown-mode .leaderboard-section > *,
#game-screen.countdown-mode .regions-list > *,
#game-screen.countdown-mode .map-container > *,
#game-screen.countdown-mode .guess-input-container > * {
  visibility: hidden;
}

#game-screen.countdown-mode .game-header,
#game-screen.countdown-mode .game-info-section,
#game-screen.countdown-mode .leaderboard-section,
#game-screen.countdown-mode .regions-list,
#game-screen.countdown-mode .map-container,
#game-screen.countdown-mode .guess-input-container {
  border: 2px dashed var(--border);
  background: transparent;
  border-radius: 12px;
}

#game-screen.countdown-mode .game-info-section,
#game-screen.countdown-mode .leaderboard-section,
#game-screen.countdown-mode .regions-list {
  min-height: 100px;
}

#game-screen.countdown-mode .guess-input-container {
  min-height: 60px;
}

.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  flex: 1;
  padding: 1rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .game-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .game-sidebar {
    display: none;
  }
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding-bottom: 1rem;
}

/* Hide skeleton outline for sidebar when quiz doesn't use it */
#game-screen.countdown-mode .game-sidebar.no-skeleton,
#game-screen.countdown-mode .game-sidebar.no-skeleton .game-info-section,
#game-screen.countdown-mode .game-sidebar.no-skeleton .leaderboard-section,
#game-screen.countdown-mode .game-sidebar.no-skeleton .regions-list {
  border: none;
  background: transparent;
}

.game-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  position: relative;
}

.game-info-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.game-info-quiz {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.game-info-mode {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.leaderboard-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
}

.leaderboard-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.leaderboard-section ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.leaderboard-section li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.leaderboard-section li:first-child {
  background: var(--primary);
}

.leaderboard-section li.me {
  border: 2px solid var(--primary);
}

.leaderboard-section .score {
  font-weight: 700;
}

/* Regions List */
.regions-list {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

.region-group {
  margin-bottom: 1rem;
}

.region-group:last-child {
  margin-bottom: 0;
}

.region-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.5rem;
  padding: 0.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  border-radius: 4px;
}

.region-header:hover {
  background: var(--bg-input);
}

.region-toggle {
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.region-group.collapsed .region-toggle {
  transform: rotate(-90deg);
}

.region-name {
  flex: 1;
}

.region-header .region-count {
  color: var(--text-muted);
  font-weight: 400;
}

.region-countries {
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.region-group.collapsed .region-countries {
  max-height: 0 !important;
  opacity: 0;
  margin: 0;
}

.region-countries {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.country-slot {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-input);
  color: transparent;
  -webkit-text-fill-color: transparent;
  transition: all 0.2s;
  font-size: 0.75rem;
}

.country-slot.found {
  background: var(--success);
  color: white;
  -webkit-text-fill-color: white;
}

.country-slot.found.mine {
  background: var(--primary);
}

.country-slot.missed {
  background: #ef4444;
  color: white;
  -webkit-text-fill-color: white;
}

.country-slot.revealed {
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
}

/* Answer Grid (list-only layout) */
.answer-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns, 5), 1fr);
  gap: 0.5rem;
  padding: 1rem;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

.answer-slot {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--bg-input);
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-align: center;
  transition: all 0.2s;
  min-height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.8rem;
}

.answer-slot.found {
  background: var(--success);
  color: white;
  -webkit-text-fill-color: white;
}

.answer-slot.found.mine {
  background: var(--primary);
}

.answer-slot.missed {
  background: #ef4444;
  color: white;
  -webkit-text-fill-color: white;
}

.answer-slot.revealed {
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 12px;
}

.timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.timer.warning {
  color: #f59e0b;
}

.timer.danger {
  color: #ef4444;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.progress {
  font-size: 1.2rem;
  color: var(--text-muted);
}

.progress span:first-child {
  color: var(--success);
  font-weight: 700;
}

.guess-input-container input {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.25rem;
  text-align: center;
}

.guess-input-container input.shake {
  animation: shake 0.4s ease-in-out;
  border-color: #f59e0b;
}

.guess-input-container input.shake::placeholder {
  color: #f59e0b;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* Map Container */
.map-container {
  position: relative;
  flex: 1;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  overflow: hidden;
}

/* When map container has answer grid (list-only quiz), allow scrolling */
.map-container:has(.answer-grid) {
  overflow-y: auto;
  align-items: flex-start;
}

.map-container svg {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.map-container svg path {
  fill: var(--bg-input);
  stroke: var(--border);
  stroke-width: 0.5;
  transition: fill 0.3s ease;
}

.map-container svg path.found,
.map-container svg g.found path {
  fill: var(--success);
}

.map-container svg path.found.mine,
.map-container svg g.found.mine path {
  fill: var(--primary);
}

.map-container svg path.missed,
.map-container svg g.missed path {
  fill: #ef4444;
}

.map-container svg path:hover,
.map-container svg g:hover path {
  opacity: 0.8;
}

/* Map tooltip */
.map-tooltip {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s;
}

.map-tooltip.visible {
  opacity: 1;
}

/* Centered map notification */
.map-notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 2rem;
  font-size: 1.25rem;
  font-weight: 600;
  z-index: 20;
  animation: notificationFade 3s ease-out forwards;
}

@keyframes notificationFade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Old styles kept for compatibility */
.leaderboard ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.leaderboard li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.leaderboard li .name {
  flex: 1;
}

/* First place background and "me" border are set dynamically via inline styles */

.leaderboard li .score {
  font-weight: 700;
}

.gave-up-badge {
  font-size: 0.7rem;
  background: #ef4444;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
}


.activity-feed {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  width: 280px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  max-height: 150px;
  overflow-y: auto;
  font-size: 0.85rem;
  z-index: 50;
}

.activity-item {
  padding: 0.25rem 0;
  color: var(--text-muted);
  animation: slideIn 0.3s ease-out;
}

.activity-item .player-name {
  color: var(--primary);
  font-weight: 600;
}

.activity-item .answer {
  color: var(--success);
}

.activity-item.gave-up {
  color: #ef4444;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Countdown Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

/* Modal styles */
.modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal h2 {
  margin-bottom: 1rem;
}

.modal p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Quiz Selection Modal */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.quiz-option {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: var(--bg);
}

.quiz-option-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.quiz-option-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.countdown-number {
  font-size: 10rem;
  font-weight: 800;
  color: var(--primary);
  animation: countdownPop 1s ease-out infinite;
}

@keyframes countdownPop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

/* Game Over Overlay */
.game-over-modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem 3rem;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.winner-crown {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: crownBounce 0.6s ease-out;
}

@keyframes crownBounce {
  0% { transform: translateY(-20px) scale(0); }
  50% { transform: translateY(5px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

.winner-name {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.game-over-scores {
  margin-bottom: 1.5rem;
}

.game-over-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.game-over-buttons .btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.game-over-buttons .btn-secondary:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

.score-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--bg-input);
}

.score-row.winner {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid var(--primary);
}

.score-place {
  font-weight: 700;
  color: var(--text-muted);
  width: 1.5rem;
}

.score-name {
  font-weight: 600;
  flex: 1;
  text-align: left;
}

.score-breakdown {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.score-answers {
  color: var(--text);
  font-weight: 600;
}

.score-plus,
.score-equals {
  color: var(--text-muted);
}

.score-time {
  color: var(--warning);
  font-weight: 500;
}

.score-final {
  color: var(--success);
  font-weight: 700;
  font-size: 1rem;
}

.score-row:not(.winner) .score-final {
  color: var(--text);
}

/* Solo Completion Overlay */
.solo-complete-modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2.5rem 3rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease-out;
}

.solo-complete-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: crownBounce 0.6s ease-out;
}

.solo-complete-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 0.5rem 0;
}

.solo-complete-message {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem 0;
}

.solo-complete-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: 12px;
}

.solo-stat {
  text-align: center;
}

.solo-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.solo-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.solo-complete-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.solo-complete-buttons .btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.solo-complete-buttons .btn-secondary:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

.solo-complete-buttons .btn-primary {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.solo-complete-buttons .btn-primary:hover {
  background: var(--primary-hover);
}

/* Results Screen */
.results-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.results-title {
  font-family: 'Nunito', sans-serif;
  font-size: 2.5rem;
  font-weight: 900;
  margin: 0;
  color: var(--text);
}

.results-score {
  font-family: 'Nunito', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  margin: 1rem 0 2.5rem 0;
  color: var(--success);
}

.results-score .results-divider {
  color: var(--text-muted);
  margin: 0 0.25rem;
}

.results-sections {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

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

.results-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
}

.results-leaderboard ol {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
}

.results-leaderboard li {
  display: flex;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.results-leaderboard li:last-child {
  border-bottom: none;
}

.results-leaderboard li:first-child {
  background: var(--primary);
}

.results-leaderboard .rank {
  margin-right: 0.75rem;
  color: var(--text-muted);
}

.results-leaderboard li:first-child .rank {
  color: white;
}

/* Missed Answers */
.results-missed {
  overflow: hidden;
}

.missed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 12px;
  max-height: 250px;
  overflow-y: auto;
}

.missed-item {
  background: var(--bg-input);
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--danger);
}

/* Quiz Selector Button (Lobby) */
.quiz-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.quiz-select-btn:hover {
  border-color: var(--primary);
}

.quiz-select-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quiz-select-btn:disabled:hover {
  border-color: var(--border);
}

.quiz-select-icon {
  font-size: 1.5rem;
}

.quiz-select-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.quiz-select-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quiz-select-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Quiz Selector Modal */
.quiz-selector-modal {
  background: var(--bg-card);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quiz-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.quiz-selector-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.quiz-selector-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.quiz-selector-close:hover {
  color: var(--text);
}

.quiz-selector-search {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.quiz-selector-search input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 8px;
}

.quiz-selector-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* Category sections */
.quiz-category {
  margin-bottom: 0.5rem;
}

.quiz-category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.quiz-category-header:hover {
  background: var(--bg-input);
}

.quiz-category-toggle {
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.quiz-category.collapsed .quiz-category-toggle {
  transform: rotate(-90deg);
}

.quiz-category-name {
  flex: 1;
}

.quiz-category-count {
  font-weight: 400;
  font-size: 0.75rem;
}

.quiz-category-items {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.quiz-category.collapsed .quiz-category-items {
  max-height: 0 !important;
}

/* Quiz items */
.quiz-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.quiz-item:hover {
  background: var(--bg-input);
}

.quiz-item.selected {
  background: rgba(99, 102, 241, 0.15);
}

.quiz-item.coming-soon {
  opacity: 0.5;
  cursor: not-allowed;
}

.quiz-item.coming-soon:hover {
  background: none;
}

.quiz-item-icon {
  font-size: 1.5rem;
  width: 2rem;
  text-align: center;
}

.quiz-item-info {
  flex: 1;
  min-width: 0;
}

.quiz-item-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quiz-item-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quiz-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.quiz-item-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.quiz-item-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--secondary);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quiz-item-badge.coming-soon {
  background: var(--border);
}

/* No results */
.quiz-no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}
