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

body {
  height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  color: #eee;
}

#map {
  position: absolute;
  inset: 0;
  background: #0f3460;
}

.leaflet-container {
  background: #0f3460;
}

/* ─── Top bar ─── */
#topbar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(1100px, calc(100vw - 24px));
  margin-top: 12px;
  background: rgba(26, 26, 46, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  overflow: hidden;
  transition: background 0.2s;
}

#topbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  cursor: pointer;
  user-select: none;
}

#topbar-header h1 {
  font-size: 18px;
  letter-spacing: 2px;
  color: #e94560;
  font-weight: 700;
}

#topbar-toggle {
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: transform 0.2s, background 0.15s;
}

#topbar-toggle:hover {
  background: rgba(255,255,255,0.08);
}

#topbar.collapsed #topbar-toggle {
  transform: rotate(-90deg);
}

#topbar-content {
  padding: 0 18px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  max-height: 70vh;
  overflow-y: auto;
}

#topbar.collapsed #topbar-content {
  display: none;
}

/* ─── Setup panel ─── */
#setup-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  padding-top: 14px;
}

.setup-col h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  margin-bottom: 8px;
}

.setup-actions {
  display: flex;
  align-items: flex-end;
}

#region-checkboxes,
#criteria-checkboxes,
#overlay-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#region-checkboxes label,
#criteria-checkboxes label,
#overlay-toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}

#region-checkboxes label:hover,
#criteria-checkboxes label:hover,
#overlay-toggles label:hover {
  background: rgba(255,255,255,0.08);
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #e94560;
}

button {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#start-btn {
  background: #e94560;
  color: white;
  width: 100%;
}

#start-btn:disabled {
  background: rgba(255,255,255,0.08);
  color: #666;
  cursor: not-allowed;
}

#start-btn:not(:disabled):hover {
  background: #c73652;
  transform: translateY(-1px);
}

/* ─── Quiz panel ─── */
#quiz-panel {
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#prompt-area {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 14px 18px;
}

#prompt-label {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 4px;
}

#prompt-text {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

#flag-display {
  font-size: 56px;
  text-align: center;
  margin-top: 6px;
  line-height: 1;
}

#score-area {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 20px;
  font-weight: 700;
}

#score-area #score {
  color: #4ecca3;
}

#streak {
  font-size: 13px;
  color: #aaa;
  font-weight: 400;
}

#streak-count {
  color: #f0a500;
  font-weight: 700;
}

#feedback {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

#feedback.correct {
  background: rgba(78, 204, 163, 0.2);
  color: #4ecca3;
}

#feedback.incorrect {
  background: rgba(233, 69, 96, 0.2);
  color: #e94560;
}

#feedback.attempts-remaining {
  background: rgba(240, 165, 0, 0.15);
  color: #f0a500;
}

.quiz-actions,
.results-actions {
  display: flex;
  gap: 8px;
}

#next-btn {
  background: #4ecca3;
  color: #1a1a2e;
  flex: 1;
}

#next-btn:hover {
  background: #3db88f;
}

#quit-btn {
  background: transparent;
  color: #aaa;
  border: 1px solid rgba(255,255,255,0.15);
  flex: 1;
}

#quit-btn:hover {
  border-color: #e94560;
  color: #e94560;
}

/* ─── Results panel ─── */
#results-panel {
  padding-top: 14px;
  text-align: center;
}

#results-panel h2 {
  color: #e94560;
  font-size: 20px;
  margin-bottom: 14px;
}

#results-panel p {
  font-size: 16px;
  margin-bottom: 8px;
}

#missed-summary {
  margin: 14px 0;
  text-align: left;
}

#missed-summary h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e94560;
  margin-bottom: 6px;
}

#missed-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  padding: 0;
}

#missed-list li {
  padding: 4px 0;
  font-size: 13px;
  color: #ccc;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

#retry-btn {
  background: #f0a500;
  color: #1a1a2e;
  flex: 1;
}

#retry-btn:hover {
  background: #d99400;
}

#restart-btn {
  background: #e94560;
  color: white;
  flex: 1;
}

#restart-btn:hover {
  background: #c73652;
}

#close-btn {
  background: transparent;
  color: #aaa;
  border: 1px solid rgba(255,255,255,0.15);
  flex: 1;
}

#close-btn:hover {
  border-color: #aaa;
  color: #ccc;
}

.hidden {
  display: none !important;
}

/* ─── Map decorations ─── */
.correct-marker {
  background: rgba(78, 204, 163, 0.3);
  border: 2px solid #4ecca3;
  border-radius: 50%;
  width: 20px;
  height: 20px;
}

.highlight-correct {
  animation: pulse-correct 0.6s ease-out;
}

@keyframes pulse-correct {
  0% { fill-opacity: 0.3; }
  50% { fill-opacity: 0.7; }
  100% { fill-opacity: 0.3; }
}

.country-label,
.city-label,
.flag-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  white-space: nowrap;
  pointer-events: none;
}

.country-label {
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.6);
  letter-spacing: 0.5px;
}

.city-label {
  color: rgba(240, 165, 0, 0.85);
  font-size: 10px;
  font-weight: 500;
  text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.6);
}

.city-dot {
  width: 4px;
  height: 4px;
  background: rgba(240, 165, 0, 0.85);
  border-radius: 50%;
  pointer-events: none;
}

.flag-label {
  font-size: 18px;
  text-shadow: 0 0 4px rgba(0,0,0,0.6);
}

.ocean-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
  white-space: nowrap;
}
