/* ----------------------------------------------------
   DESIGN SYSTEM & VARIABLES
   ---------------------------------------------------- */
:root {
  /* Colors - HSL Curated Harmonies */
  --bg-dark: hsl(222, 47%, 7%);
  --bg-panel: hsla(222, 40%, 12%, 0.75);
  --border-glass: hsla(0, 0%, 100%, 0.07);
  --border-glass-hover: hsla(0, 0%, 100%, 0.15);
  
  --color-primary: hsl(150, 84%, 44%); /* Vivid Emerald/Mint */
  --color-primary-glow: hsla(150, 84%, 44%, 0.3);
  
  --color-secondary: hsl(356, 75%, 55%); /* Crimson Red/Coral */
  --color-secondary-glow: hsla(356, 75%, 55%, 0.3);
  
  --color-warning: hsl(38, 92%, 50%); /* Amber/Gold */
  --color-warning-glow: hsla(38, 92%, 50%, 0.3);
  
  --text-main: hsl(210, 38%, 95%);
  --text-muted: hsl(215, 20%, 65%);
  --text-dark: hsl(222, 47%, 4%);

  /* Typography */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Shadows */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.25);
  --shadow-glow-gold: 0 0 20px rgba(245, 158, 11, 0.3);
  
  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------
   BASE RESET & LAYOUT
   ---------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  position: relative;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ----------------------------------------------------
   AMBIENT EFFECTS & PANELS
   ---------------------------------------------------- */
.ambient-glow {
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  z-index: 0;
  pointer-events: none;
}
.bg-primary {
  top: -10vw;
  left: -10vw;
  background-color: var(--color-primary);
}
.bg-secondary {
  bottom: -10vw;
  right: -10vw;
  background-color: var(--color-secondary);
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.glass-panel:hover {
  border-color: var(--border-glass-hover);
}

/* ----------------------------------------------------
   SCREENS STATE CONTROLLER
   ---------------------------------------------------- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  transform: scale(1.02);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* ----------------------------------------------------
   WELCOME SCREEN
   ---------------------------------------------------- */
.start-screen {
  background: radial-gradient(circle at center, hsl(222, 47%, 12%) 0%, var(--bg-dark) 100%);
  z-index: 30;
}

.welcome-card {
  width: 90%;
  max-width: 560px;
  padding: 40px;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.welcome-header {
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 22px;
  border: 1px solid var(--border-glass);
  margin-bottom: 20px;
  font-size: 2.5rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.flag-stripe {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50%;
}
.flag-stripe.green {
  left: 0;
  background: hsla(150, 84%, 35%, 0.15);
}
.flag-stripe.red {
  right: 0;
  background: hsla(356, 75%, 45%, 0.15);
}

.logo-icon {
  z-index: 2;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
  animation: logo-float 4s ease-in-out infinite;
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.game-title {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.game-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
  margin-bottom: 16px;
}

.date-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 6px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-warning);
  letter-spacing: 0.05em;
}

.welcome-instructions {
  text-align: left;
  margin-bottom: 35px;
}

.welcome-instructions h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--text-main);
  font-family: var(--font-display);
}

.welcome-instructions p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.categories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.category-card {
  display: flex;
  align-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  gap: 16px;
}

.cat-icon {
  font-size: 1.8rem;
}

.cat-info {
  display: flex;
  flex-direction: column;
}

.cat-title {
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.cat-multiplier {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.cat-multiplier strong {
  color: var(--text-main);
}

.score-explain {
  font-size: 0.9rem;
  color: var(--text-muted);
  background: rgba(16, 185, 129, 0.03);
  border-left: 3px solid var(--color-primary);
  padding: 12px 16px;
  border-radius: 0 12px 12px 0;
}

.score-explain p {
  margin-bottom: 4px;
}
.score-explain p:last-child {
  margin-bottom: 0;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ----------------------------------------------------
   BUTTON STYLES
   ---------------------------------------------------- */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-lg {
  padding: 16px 36px;
  font-size: 1.1rem;
  border-radius: 16px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, hsl(150, 84%, 35%) 100%);
  color: var(--text-dark);
  box-shadow: 0 10px 15px -3px var(--color-primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 20px -3px var(--color-primary-glow);
  filter: brightness(1.1);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-glass-hover);
  transform: translateY(-2px);
}

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

.pulse-glow {
  animation: pulse-glow-anim 2.5s infinite;
}

@keyframes pulse-glow-anim {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4), 0 10px 15px -3px var(--color-primary-glow); }
  50% { box-shadow: 0 0 20px 4px rgba(16, 185, 129, 0.2), 0 15px 20px -3px var(--color-primary-glow); }
}

/* ----------------------------------------------------
   GAME VIEW
   ---------------------------------------------------- */
.game-view {
  z-index: 20;
  /* iOS WebKit miscalculates touch→map coordinates when a CSS transform exists on any
     ancestor of the Leaflet container. Remove the scale() from .screen/.screen.active. */
  transform: none;
}

.game-view.active {
  transform: none;
}

/* Top HUD Bar */
.game-hud {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  height: 70px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
  color: var(--text-main);
}
.hud-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-glass-hover);
  transform: translateY(-1px);
}

.hud-details {
  display: flex;
  flex-direction: column;
}

.hud-game-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.hud-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.progress-dots {
  display: flex;
  gap: 8px;
}

.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.2);
  transition: all var(--transition-fast);
  position: relative;
}

.progress-dot.active {
  background: var(--color-warning);
  box-shadow: var(--shadow-glow-gold);
  transform: scale(1.2);
}

.progress-dot.correct {
  background: var(--color-primary);
  box-shadow: var(--shadow-glow-green);
}

.progress-dot.incorrect {
  background: var(--color-secondary);
}

.progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Prompt Panel */
.prompt-panel {
  position: absolute;
  top: 105px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 16px 28px;
  gap: 20px;
  width: 90%;
  max-width: 520px;
  animation: prompt-slide var(--transition-normal) forwards;
}

@keyframes prompt-slide {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.prompt-icon {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--border-glass);
}

.prompt-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.prompt-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--color-primary);
}

.prompt-location {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 2px 0;
  color: #ffffff;
  font-family: var(--font-display);
}

.prompt-region {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Fullscreen Map styling */
.fullscreen-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Customized Leaflet Styling to Blend Premiumly */
.leaflet-container {
  background: var(--bg-dark) !important;
}

.leaflet-bar {
  border: 1px solid var(--border-glass) !important;
  box-shadow: var(--shadow-lg) !important;
  background: var(--bg-panel) !important;
  backdrop-filter: blur(10px) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.leaflet-bar a {
  background-color: transparent !important;
  color: var(--text-main) !important;
  border-bottom: 1px solid var(--border-glass) !important;
  transition: background-color var(--transition-fast);
}

.leaflet-bar a:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

.leaflet-control-zoom {
  margin-top: 175px !important; /* Move zoom control down to clear hud and prompt */
}

/* Leaflet Attribution styling */
.leaflet-control-attribution {
  background: rgba(11, 15, 25, 0.8) !important;
  color: var(--text-muted) !important;
  backdrop-filter: blur(4px);
  border-top-left-radius: 8px;
}

/* Custom Marker Styling */
/* These are inner elements inside Leaflet's marker container.
   Width/height fill the container set by iconSize so animations don't fight Leaflet's translate3d. */
.custom-marker-pulse {
  width: 100%;
  height: 100%;
  background: var(--color-secondary);
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 0 var(--color-secondary-glow);
  animation: marker-pulse 1.8s infinite;
}

.custom-marker-target {
  width: 100%;
  height: 100%;
  background: var(--color-primary);
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: target-float 2.5s ease-in-out infinite;
}

@keyframes marker-pulse {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes target-float {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.1); filter: brightness(1.2); }
}

/* Result Overlay Drawer (Slides from bottom) */
.result-card {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 1000;
  width: 90%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.result-card.hidden {
  transform: translateX(-50%) translateY(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.result-emoji {
  font-size: 1.8rem;
}

.result-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.res-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 10px;
}

.res-stat-box.highlight {
  background: rgba(16, 185, 129, 0.03);
  border-color: rgba(16, 185, 129, 0.2);
}
.res-stat-box.highlight .res-stat-value {
  color: var(--color-primary);
  font-weight: 800;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.res-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.res-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-display);
}

.result-score-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.result-score-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-secondary) 0%, var(--color-warning) 50%, var(--color-primary) 100%);
  border-radius: 3px;
  transition: width 1.2s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.result-near-location {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2px 0;
}

.result-near-location.hidden {
  display: none;
}

.result-near-location strong {
  color: var(--text-main);
  font-weight: 600;
}

/* ----------------------------------------------------
   SUMMARY SCREEN
   ---------------------------------------------------- */
.summary-screen {
  background: radial-gradient(circle at center, hsl(222, 47%, 10%) 0%, var(--bg-dark) 100%);
  z-index: 25;
  /* position: fixed bypasses parent overflow:hidden on both iOS WebKit and Android Chrome,
     making this element its own independent scroll container */
  position: fixed;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 40px 0;
  justify-content: flex-start;
  align-items: center;
}

.summary-container {
  width: 90%;
  max-width: 600px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin: auto;
}

.summary-header {
  text-align: center;
}

.summary-title {
  font-size: 2.2rem;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.summary-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Radial Score Ring */
.score-ring-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.score-ring-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 16px;
}

.score-ring {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.score-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 8;
}

.score-ring-fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.29; /* 2 * PI * 54 */
  stroke-dashoffset: 339.29;
  transition: stroke-dashoffset 1.8s cubic-bezier(0.1, 0.8, 0.2, 1);
  filter: drop-shadow(0 0 8px var(--color-primary-glow));
}

.score-ring-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-ring-number {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  font-family: var(--font-display);
}

.score-ring-max {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.rank-badge {
  background: linear-gradient(135deg, var(--color-warning) 0%, hsl(38, 92%, 40%) 100%);
  color: var(--text-dark);
  font-family: var(--font-display);
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  margin-bottom: 8px;
  box-shadow: var(--shadow-glow-gold);
}

.rank-description {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Map Summary percourse */
.summary-map-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 8px;
}

.summary-map {
  width: 100%;
  height: 220px;
  border-radius: 16px;
  border: 1px solid var(--border-glass);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

/* Breakdown Grid List */
.breakdown-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  gap: 16px;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.breakdown-item:hover {
  background: rgba(255, 255, 255, 0.04);
  transform: scale(1.01);
}

.breakdown-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-muted);
  width: 24px;
}

.breakdown-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.breakdown-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.breakdown-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breakdown-score-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-points {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.breakdown-emoji {
  font-size: 1.25rem;
}

/* User Stats Grid */
.stats-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
}

.stat-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Footer Sharing */
.summary-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
}

.next-challenge {
  display: flex;
  flex-direction: column;
}

.timer-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.timer-clock {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-warning);
  letter-spacing: 0.02em;
}

/* ----------------------------------------------------
   MODALS & STATS OVERLAY
   ---------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 90%;
  max-width: 500px;
  padding: 30px;
  position: relative;
  transform: translateY(0);
  transition: transform var(--transition-normal);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-overlay.hidden .modal-card {
  transform: translateY(20px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 12px;
}

.modal-header h2 {
  font-size: 1.5rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}
.modal-close:hover {
  color: #ffffff;
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Score Distribution Charts */
.stats-charts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chart-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.chart-label {
  width: 75px;
  color: var(--text-muted);
  font-weight: 500;
}

.chart-bar-bg {
  flex: 1;
  height: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  min-width: 20px;
  transition: width 1s ease-out;
}

.chart-bar-fill.active {
  background: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
}

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

.toast {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass-hover);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in-out 3s ease forwards;
}

@keyframes toast-in-out {
  0% { transform: translateY(-20px); opacity: 0; }
  10% { transform: translateY(0); opacity: 1; }
  90% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-20px); opacity: 0; }
}

/* ----------------------------------------------------
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ---------------------------------------------------- */
@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .btn {
    padding: 12px 20px;
    font-size: 0.95rem;
    border-radius: 12px;
  }
  
  .btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: 14px;
  }

  /* Welcome Screen */
  .welcome-card {
    padding: 24px 16px;
    border-radius: 16px;
  }
  
  .game-title {
    font-size: 2.2rem;
  }
  
  .game-subtitle {
    font-size: 0.95rem;
    letter-spacing: 0.1em;
  }

  /* HUD Panel */
  .game-hud {
    top: 10px;
    left: 10px;
    right: 10px;
    padding: 0 12px;
    height: 60px;
    border-radius: 16px;
  }

  .hud-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .hud-game-name {
    font-size: 0.95rem;
  }

  .progress-dot {
    width: 10px;
    height: 10px;
  }

  .progress-label {
    font-size: 0.7rem;
  }

  /* Prompt Panel */
  .prompt-panel {
    top: 80px;
    padding: 12px 16px;
    gap: 12px;
  }

  .prompt-icon {
    font-size: 1.6rem;
    padding: 6px;
    border-radius: 10px;
  }

  .prompt-location {
    font-size: 1.15rem;
  }

  .prompt-region {
    font-size: 0.75rem;
  }

  .leaflet-control-zoom {
    margin-top: 145px !important;
  }

  /* Result Box */
  .result-card {
    bottom: 20px;
    padding: 16px;
    gap: 12px;
  }

  .result-header h3 {
    font-size: 1.1rem;
  }

  .result-emoji {
    font-size: 1.5rem;
  }

  .res-stat-value {
    font-size: 0.95rem;
  }

  .res-stat-label {
    font-size: 0.65rem;
  }

  /* Summary Modal */
  .summary-screen {
    padding: 16px 0;
  }

  .summary-container {
    padding: 24px 16px;
    border-radius: 16px;
    gap: 20px;
  }

  .summary-title {
    font-size: 1.7rem;
  }

  .score-ring-wrapper {
    width: 130px;
    height: 130px;
  }

  .score-ring-number {
    font-size: 2.2rem;
  }

  .rank-badge {
    font-size: 0.85rem;
  }

  .summary-map {
    height: 160px;
  }

  .stat-num {
    font-size: 1.25rem;
  }

  .stat-lbl {
    font-size: 0.65rem;
  }

  .summary-footer {
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
  }
  
  .summary-footer button {
    width: 100%;
  }

  .timer-clock {
    font-size: 1.25rem;
  }
}
