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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #000;
  color: #ccc;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Segmented Control */
.segmented-control {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: calc(1rem + env(safe-area-inset-top)) 1rem 0.5rem;
  max-width: none;
}

.segment {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.5rem;
  transition: opacity 0.15s ease;
  border-radius: 6px;
  opacity: 0.35;
}

.segment:hover {
  opacity: 0.7;
}

.segment:focus-visible {
  outline: none;
  opacity: 0.55;
}

.segment.active {
  opacity: 1;
}

/* Map Container - fullscreen behind everything */
#map-container {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  overflow: hidden;
}

#map-container svg {
  width: 100%;
  height: 100%;
}

#map-container svg path,
#map-container svg polygon {
  fill: #1a1a1a;
  stroke: #333;
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 0.15s ease;
}

#map-container svg path:hover,
#map-container svg polygon:hover {
  fill: #333;
}

/* Visited state */
#map-container svg path.visited,
#map-container svg polygon.visited {
  fill: #fff;
}

#map-container svg path.visited:hover,
#map-container svg polygon.visited:hover {
  fill: #ddd;
}

/* Group-level visited (for multi-path countries) */
#map-container svg g.visited path,
#map-container svg g.visited polygon {
  fill: #fff;
}

#map-container svg g.visited path:hover,
#map-container svg g.visited polygon:hover {
  fill: #ddd;
}

/* Footer */
footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 0.5rem 0.5rem calc(1rem + env(safe-area-inset-bottom));
  margin-top: auto;
  pointer-events: none;
}

#stats {
  color: #666;
  font-weight: 400;
}

/* Tooltip */
#tooltip {
  position: fixed;
  background: #fff;
  color: #000;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 1000;
  display: none;
  white-space: nowrap;
}

/* Landing Page */
#landing {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 1.5rem;
  padding: 2rem;
}

#landing h2 {
  font-size: 1.8rem;
  color: #fff;
}

#landing p {
  color: #666;
  max-width: 400px;
  text-align: center;
  line-height: 1.5;
}

#landing form {
  display: flex;
  gap: 0.5rem;
}

#landing input {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border: 1px solid #444;
  background: #111;
  color: #fff;
  font-size: 1rem;
  outline: none;
  width: 220px;
}

#landing input:focus {
  border-color: #fff;
}

#landing button {
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: 1px solid #444;
  background: #fff;
  color: #000;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
}

#landing button:hover:not(:disabled) {
  background: #ddd;
}

#landing button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Loader */
#loader {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
}

#loader.active {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #333;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* App view hidden by default */
#app {
  display: none;
  flex-direction: column;
  flex: 1;
  position: relative;
}

#app.active {
  display: flex;
}

#landing.active {
  display: flex;
}
