/* -------------------------------------------------------------
 * Cyber-Alster Neon-Dark UI Design System
 * Highly optimized, responsive, and compatible with modern Safari.
 * ------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  /* Theme Base Colors */
  --bg-main: hsl(230, 28%, 7%);
  --bg-surface: rgba(17, 24, 39, 0.65);
  --bg-surface-hover: rgba(26, 36, 56, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-glow: rgba(255, 255, 255, 0.16);
  
  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 75%);
  --text-muted: hsl(215, 12%, 50%);

  /* Neon Glow Districts */
  --color-altona: hsl(295, 100%, 65%);       /* Purple/Magenta */
  --color-bergedorf: hsl(32, 100%, 55%);     /* Warm Orange */
  --color-eimsbuettel: hsl(175, 100%, 45%);   /* Turquoise Cyan */
  --color-hamburg-mitte: hsl(345, 100%, 60%); /* Rose Red */
  --color-hamburg-nord: hsl(210, 100%, 60%);  /* electric Blue */
  --color-harburg: hsl(100, 95%, 55%);       /* Lime Green */
  --color-wandsbek: hsl(260, 100%, 65%);     /* Deep Violet */
  --color-default-path: hsl(225, 20%, 18%);
  --color-neutral-glow: hsl(200, 100%, 60%);

  /* UI Game Colors */
  --color-correct: hsl(142, 76%, 45%);
  --color-incorrect: hsl(350, 89%, 60%);
  --color-xp: hsl(47, 95%, 55%);
  
  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Space Grotesk', var(--font-sans);
  
  /* Radii & Transitions */
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: all 0.15s ease;
}

/* Reset & Scrollbar */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(220,53%,10%,1) 0, transparent 50%),
    radial-gradient(at 50% 100%, hsla(280,30%,8%,1) 0, transparent 60%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.overlay-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  touch-action: none;
}

/* Webkit Custom Scrollbar (Safari compatible) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Footer & privacy notice */
.app-footer {
  margin-top: auto;
  padding-top: 0.25rem;
  text-align: center;
}

.privacy-notice {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 40rem;
  margin: 0 auto;
}

.privacy-notice strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.footer-credit {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  opacity: 0.75;
}

/* Container & Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  gap: 1.5rem;
}

/* Header & Progress Stats */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem 1.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  
  h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--color-neutral-glow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  
  .badge {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 9999px;
    letter-spacing: 0.05em;
    color: var(--color-neutral-glow);
    text-transform: uppercase;
  }
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  
  .label {
    color: var(--text-secondary);
    font-weight: 500;
  }
  
  .value {
    color: #fff;
    font-family: var(--font-display);
  }
  
  &.xp-pill .value {
    color: var(--color-xp);
    text-shadow: 0 0 10px rgba(255, 191, 0, 0.3);
  }
  
  &.streak-pill {
    background: rgba(255, 51, 119, 0.05);
    border-color: rgba(255, 51, 119, 0.2);
    .streak-info {
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
      line-height: 1.2;
    }
    .streak-current .value {
      color: var(--color-hamburg-mitte);
      text-shadow: 0 0 10px rgba(255, 51, 119, 0.3);
    }
    .streak-best {
      font-size: 0.68rem;
      font-weight: 500;
      color: var(--text-muted);
    }
  }
}

.level-tracker {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 180px;

  .level-info {
    display: flex;
    font-size: 0.8rem;
    font-weight: 600;
    
    .rank-name {
      color: var(--color-xp);
      text-shadow: 0 0 10px rgba(255, 191, 0, 0.3);
    }
  }

  .progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    overflow: hidden;
  }

  .progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-neutral-glow), var(--color-xp));
    border-radius: 999px;
    transition: width 0.5s ease-out;
    box-shadow: 0 0 10px rgba(255, 191, 0, 0.45);
  }
}

.audio-toggle {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  
  &:hover {
    border-color: var(--border-color-glow);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
  }
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: stretch;
  flex: 1;
}

/* Left Panel - Game Console */
.console-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Glassmorphism Card Style */
.glass-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
  
  &:hover {
    border-color: var(--border-color-glow);
  }
}

/* Mode Selection Cards */
.mode-selector {
  h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .modes-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
  
  .mode-icon {
    font-size: 1.25rem;
    filter: grayscale(1);
    transition: var(--transition-fast);
  }
  
  &:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    .mode-icon {
      filter: grayscale(0);
      transform: scale(1.1);
    }
  }
  
  &.active {
    color: #fff;
    background: rgba(0, 162, 255, 0.1);
    border-color: rgba(0, 162, 255, 0.4);
    box-shadow: inset 0 0 10px rgba(0, 162, 255, 0.15);
    .mode-icon {
      filter: grayscale(0);
    }
  }
}

/* Segment selector (Stadtteile / Bezirke) */
.segment-selector {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  gap: 0.3rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;

  &:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
  }

  &.active {
    background: rgba(0, 162, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(0, 162, 255, 0.3);
    box-shadow: inset 0 0 10px rgba(0, 162, 255, 0.1);
  }
}

/* Text input & autocomplete (game modes) */
.autocomplete-container {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid var(--border-color-glow);
  border-radius: var(--radius-md);
  max-height: 180px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
  margin-bottom: 5px;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.autocomplete-item {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition-fast);

  &:hover,
  &.active {
    background: rgba(0, 162, 255, 0.15);
    color: #fff;
  }
}

.text-input-field {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: #fff;
  font-family: var(--font-sans);
  font-size: max(1rem, 16px);
  transition: var(--transition-fast);
  outline: none;

  &:focus {
    border-color: rgba(0, 162, 255, 0.5);
    box-shadow: 0 0 10px rgba(0, 162, 255, 0.2);
    background: rgba(0, 0, 0, 0.4);
  }
}

.round-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.round-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-neutral-glow);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Gameplay Interactive Section */
.game-play-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 250px;
}

.prompt-box {
  text-align: center;
  margin-bottom: 1.5rem;
  
  .prompt-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-neutral-glow);
    margin-bottom: 0.4rem;
  }
  
  .prompt-target {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    
    &.highlight {
      color: var(--color-neutral-glow);
      text-shadow: 0 0 15px rgba(0, 162, 255, 0.4);
    }
  }
  
  .prompt-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
  }
}

/* Multiple Choice Grid */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  width: 100%;
}

.choice-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
  
  .choice-letter {
    color: var(--text-muted);
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
  }
  
  &:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(2px);
  }

  &:active {
    transform: scale(0.98);
  }

  &.correct {
    background: rgba(20, 184, 166, 0.15);
    border-color: var(--color-correct);
    color: #fff;
    box-shadow: 0 0 15px rgba(20, 184, 166, 0.25);
    pointer-events: none;
  }

  &.incorrect {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--color-incorrect);
    color: #fff;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.25);
    pointer-events: none;
  }
}

/* Info Panels (Stadtteil details) */
.info-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.3s ease-out;

  .detail-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    
    h2 {
      font-family: var(--font-display);
      font-size: 1.4rem;
      font-weight: 700;
      color: #fff;
    }
    
    .bezirk-tag {
      display: inline-block;
      font-size: 0.75rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-top: 0.25rem;
      padding: 0.15rem 0.5rem;
      border-radius: var(--radius-sm);
    }
  }

  .detail-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .detail-stat {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    
    .ds-label {
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-bottom: 0.25rem;
    }
    
    .ds-value {
      font-family: var(--font-display);
      font-weight: 700;
      font-size: 1.1rem;
      color: #fff;
    }
  }
  
  .detail-trivia {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    background: rgba(0, 162, 255, 0.03);
    border: 1px solid rgba(0, 162, 255, 0.15);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    position: relative;
    
    &::before {
      content: "💡";
      margin-right: 0.4rem;
    }
  }
}

.empty-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  gap: 0.75rem;
  
  .ei-icon {
    font-size: 2rem;
    opacity: 0.5;
  }
}

/* Progression & District Unlocker Card */
.unlocker-card {
  .district-progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.75rem;
  }
}

.district-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  
  .dp-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 6px var(--text-muted);
  }
  
  .dp-name {
    font-weight: 600;
    flex: 1;
    color: var(--text-secondary);
  }
  
  .dp-score {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-muted);
  }
  
  .dp-lock {
    font-size: 0.8rem;
    opacity: 0.5;
  }
  
  &.unlocked {
    .dp-name {
      color: #fff;
    }
    .dp-score {
      color: var(--text-primary);
    }
  }
  
  &.locked {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.03);
    opacity: 0.5;
    
    .dp-indicator:not(.line-color-indicator) {
      background: transparent;
      border: 1px solid var(--text-muted);
      box-shadow: none;
    }

    .dp-indicator.line-color-indicator {
      opacity: 0.65;
      border: none;
    }
  }
  
  &.active-unlock {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
  }
}

/* Right Panel - Map Section */
.map-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.map-container-wrapper {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 500px;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  
  &:hover {
    border-color: var(--border-color-glow);
  }
  
  &:active {
    cursor: grabbing;
  }
}

.map-prompt-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.65rem 1rem 0.75rem;
  background: rgba(10, 15, 30, 0.92);
  border-top: 1px solid var(--border-color);
  text-align: center;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  &[hidden] {
    display: none !important;
  }

  .map-prompt-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-neutral-glow);
    margin-bottom: 0.15rem;
  }

  .map-prompt-target {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;

    &.highlight {
      color: var(--color-neutral-glow);
      text-shadow: 0 0 15px rgba(0, 162, 255, 0.4);
    }
  }

  .map-prompt-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
  }
}

/* Floating Tooltip — fixed to viewport so it follows the cursor */
.map-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  z-index: 10000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  display: none;
  transform: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
  max-width: min(280px, 90vw);
  
  .tooltip-bezirk {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.1rem;
  }
}

/* SVG Hamburg Map Styling */
.hamburg-map-svg {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  transform-origin: center;
  will-change: transform;
}

.hamburg-map-svg.smooth-transition {
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Water styling (Elbe, Alster) — subtle, integrated with map */
.water-group {
  pointer-events: none;
}

.water-group .water-body {
  fill: hsl(215, 22%, 11%);
  stroke: none;
  opacity: 0.92;
}

.water-group .water-outline {
  fill: none;
  stroke: hsl(210, 18%, 18%);
  stroke-width: 0.45;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.7;
}

/* Legacy water classes (kept for name-all-active overrides) */
.water-group .water-fill {
  fill: hsl(215, 22%, 11%);
  stroke: hsl(210, 18%, 18%);
  stroke-width: 0.45;
  stroke-linejoin: round;
}

.water-group .water-shimmer {
  display: none;
}

.water-group .water-channel-bed,
.water-group .water-channel-glow,
.water-group .water-channel {
  display: none;
}

/* Sporcle round feedback on map */
.stadtteil-path.round-correct {
  fill: hsla(142, 70%, 42%, 0.55) !important;
  stroke: var(--color-correct) !important;
  stroke-width: 2px !important;
  filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.45)) !important;
}

.stadtteil-path.round-incorrect {
  fill: hsla(350, 85%, 55%, 0.5) !important;
  stroke: var(--color-incorrect) !important;
  stroke-width: 2px !important;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.4)) !important;
}

.stadtteil-path.bezirk-hover-highlight {
  fill: rgba(0, 162, 255, 0.12) !important;
  stroke: rgba(0, 200, 255, 0.65) !important;
  stroke-width: 1.2px !important;
}

.map-text-label {
  font-family: var(--font-sans);
  font-size: 7px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(7, 10, 20, 0.92);
  stroke-width: 2.5px;
  stroke-linejoin: round;
  fill: #fff;
}

.map-text-label.label-correct {
  fill: #bbf7d0;
  stroke: rgba(20, 80, 40, 0.95);
}

.map-text-label.label-incorrect {
  fill: #fecaca;
  stroke: rgba(100, 20, 30, 0.95);
}

/* SVG Path States — uniform thin Stadtteil outlines */
.stadtteil-path {
  fill: var(--color-default-path);
  stroke: var(--bg-main);
  stroke-width: 0.35px;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill 0.25s ease, stroke 0.25s ease, stroke-width 0.2s ease, filter 0.2s ease;
  transform-origin: center;
}

/* Hover and Glowing borders based on Bezirk CSS Classes */
.stadtteil-path:hover {
  stroke-width: 1.5px !important;
  stroke: #fff !important;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6)) !important;
  z-index: 10;
}

/* Styling paths per Bezirk when active/discovered */
.stadtteil-path.unlocked-bezirk {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(255, 255, 255, 0.1);
}

.stadtteil-path[data-bezirk="Altona"].discovered { fill: hsla(295, 100%, 65%, 0.15); stroke: hsla(295, 100%, 65%, 0.4); }
.stadtteil-path[data-bezirk="Bergedorf"].discovered { fill: hsla(32, 100%, 55%, 0.15); stroke: hsla(32, 100%, 55%, 0.4); }
.stadtteil-path[data-bezirk="Eimsbüttel"].discovered { fill: hsla(175, 100%, 45%, 0.15); stroke: hsla(175, 100%, 45%, 0.4); }
.stadtteil-path[data-bezirk="Hamburg-Mitte"].discovered { fill: hsla(345, 100%, 60%, 0.15); stroke: hsla(345, 100%, 60%, 0.4); }
.stadtteil-path[data-bezirk="Hamburg-Nord"].discovered { fill: hsla(210, 100%, 60%, 0.15); stroke: hsla(210, 100%, 60%, 0.4); }
.stadtteil-path[data-bezirk="Harburg"].discovered { fill: hsla(100, 95%, 55%, 0.15); stroke: hsla(100, 95%, 55%, 0.4); }
.stadtteil-path[data-bezirk="Wandsbek"].discovered { fill: hsla(260, 100%, 65%, 0.15); stroke: hsla(260, 100%, 65%, 0.4); }

/* Highlight state (Explorer Selection or Target) */
.stadtteil-path.selected {
  stroke-width: 2px !important;
  z-index: 20;
}
.stadtteil-path[data-bezirk="Altona"].selected { fill: hsla(295, 100%, 65%, 0.45); stroke: var(--color-altona) !important; filter: drop-shadow(0 0 8px var(--color-altona)) !important; }
.stadtteil-path[data-bezirk="Bergedorf"].selected { fill: hsla(32, 100%, 55%, 0.45); stroke: var(--color-bergedorf) !important; filter: drop-shadow(0 0 8px var(--color-bergedorf)) !important; }
.stadtteil-path[data-bezirk="Eimsbüttel"].selected { fill: hsla(175, 100%, 45%, 0.45); stroke: var(--color-eimsbuettel) !important; filter: drop-shadow(0 0 8px var(--color-eimsbuettel)) !important; }
.stadtteil-path[data-bezirk="Hamburg-Mitte"].selected { fill: hsla(345, 100%, 60%, 0.45); stroke: var(--color-hamburg-mitte) !important; filter: drop-shadow(0 0 8px var(--color-hamburg-mitte)) !important; }
.stadtteil-path[data-bezirk="Hamburg-Nord"].selected { fill: hsla(210, 100%, 60%, 0.45); stroke: var(--color-hamburg-nord) !important; filter: drop-shadow(0 0 8px var(--color-hamburg-nord)) !important; }
.stadtteil-path[data-bezirk="Harburg"].selected { fill: hsla(100, 95%, 55%, 0.45); stroke: var(--color-harburg) !important; filter: drop-shadow(0 0 8px var(--color-harburg)) !important; }
.stadtteil-path[data-bezirk="Wandsbek"].selected { fill: hsla(260, 100%, 65%, 0.45); stroke: var(--color-wandsbek) !important; filter: drop-shadow(0 0 8px var(--color-wandsbek)) !important; }

/* Blinking animation for Card quiz */
.stadtteil-path.blink {
  animation: mapPulse 1.5s infinite ease-in-out;
  stroke: #fff !important;
  stroke-width: 1.5px;
  z-index: 15;
}

/* Success / Failure visual responses on map */
.stadtteil-path.correct-flash {
  fill: hsla(142, 76%, 45%, 0.5) !important;
  stroke: var(--color-correct) !important;
  stroke-width: 2.5px !important;
  filter: drop-shadow(0 0 12px var(--color-correct)) !important;
  z-index: 30;
}

.stadtteil-path.incorrect-flash {
  fill: hsla(350, 89%, 60%, 0.5) !important;
  stroke: var(--color-incorrect) !important;
  stroke-width: 2.5px !important;
  filter: drop-shadow(0 0 12px var(--color-incorrect)) !important;
  z-index: 30;
  animation: mapShake 0.4s ease-in-out;
}

/* Locked paths: still receive clicks (handled in JS) so pan/drag does not steal focus */
.stadtteil-path.locked-path {
  fill: rgba(0, 0, 0, 0.4);
  stroke: rgba(255, 255, 255, 0.02);
  cursor: not-allowed;
}

/* Floating Neuwerk Special Overlay box */
.neuwerk-overlay {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 50;
  
  .no-badge {
    background: var(--color-hamburg-mitte);
    color: #fff;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 6px var(--color-hamburg-mitte);

    &.is-unlocked {
      background: var(--color-correct);
      box-shadow: 0 0 6px var(--color-correct);
    }
  }
  
  &:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(17, 24, 39, 0.95);
    transform: translateY(-1px);
  }
}

/* Map Controls (Zoom / Help) */
.map-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  
  .zoom-btns {
    display: flex;
    gap: 0.4rem;
  }
  
  .control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    transition: var(--transition-fast);
    
    &:hover {
      background: rgba(255, 255, 255, 0.1);
      color: #fff;
    }
  }
  
  .map-hint {
    color: var(--text-muted);
    font-weight: 500;
  }
}

/* Onboarding & Overlay Modal */
.overlay-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.4s ease-out;
  overscroll-behavior: contain;
  overflow-y: auto;
}

.modal-content {
  background: radial-gradient(circle at top right, rgba(0, 162, 255, 0.08), transparent 60%), var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #fff 40%, var(--color-neutral-glow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  
  p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
  }
}

.modal-features {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
  margin-bottom: 1.75rem;
}

.mf-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  
  .mf-icon {
    font-size: 1.25rem;
  }
  
  .mf-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    
    strong {
      color: #fff;
      display: block;
      margin-bottom: 0.1rem;
    }
  }
}

.action-btn-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.secondary-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;

  &:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
  }

  &:active {
    transform: scale(0.98);
  }
}

.secondary-btn.danger-outline {
  color: var(--color-incorrect);
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.06);

  &:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fff;
  }
}

.text-input-field.input-shake {
  animation: inputShake 0.35s ease-in-out;
  border-color: var(--color-incorrect) !important;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.name-all-active .stadtteil-path {
  fill: rgba(12, 18, 35, 0.28) !important;
  stroke: rgba(255, 255, 255, 0.06) !important;
}

.name-all-active .stadtteil-path.round-correct {
  fill: hsla(142, 70%, 42%, 0.55) !important;
  stroke: var(--color-correct) !important;
  stroke-width: 2px !important;
  filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.45)) !important;
}

body.segment-stadtteile .stadtteil-path.unlocked-bezirk:not(.round-correct):not(.round-incorrect):not(.selected):not(.blink):not(.bezirk-excluded) {
  stroke-width: 0.35px;
  stroke: var(--bg-main);
}

/* Bezirk boundary overlay — always visible, thicker than Stadtteil lines */
.bezirk-boundaries-group {
  pointer-events: none;
}

.bezirk-boundary-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1.35px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bezirk-boundary-glow {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 2.8px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Grayed-out Bezirke when not included in active game */
.stadtteil-path.bezirk-excluded {
  fill: rgba(4, 8, 18, 0.72) !important;
  stroke: rgba(255, 255, 255, 0.03) !important;
  stroke-width: 0.35px !important;
  filter: grayscale(0.85) brightness(0.45) !important;
  cursor: default !important;
  pointer-events: none !important;
}

.stadtteil-path.bezirk-excluded:hover {
  stroke-width: 0.35px !important;
  stroke: rgba(255, 255, 255, 0.03) !important;
  filter: grayscale(0.85) brightness(0.45) !important;
}

.round-end-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.round-end-actions .primary-btn,
.round-end-actions .secondary-btn {
  flex: 1;
  padding: 0.75rem;
}

.bezirk-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
  text-align: left;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.bezirk-picker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.25rem 0.15rem;
  border-radius: var(--radius-sm);
}

.bezirk-picker-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.bezirk-picker-item input {
  accent-color: var(--color-neutral-glow);
}

.log-modal-content {
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.log-section-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 0 0 0.5rem 0;
}

.log-trophy-section,
.log-rank-section,
.log-history-section {
  margin-bottom: 1.25rem;
  text-align: left;
}

.trophy-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.45rem;
}

.trophy-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
  transition: filter 0.2s, opacity 0.2s;
}

.trophy-tile--locked {
  filter: grayscale(1);
  opacity: 0.38;
}

.trophy-tile--earned {
  border-color: rgba(255, 191, 0, 0.45);
  background: rgba(255, 191, 0, 0.08);
  box-shadow: 0 0 12px rgba(255, 191, 0, 0.15);
}

.trophy-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.trophy-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.log-rank-current {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 0.65rem 0;
}

.rank-ladder {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.rank-ladder-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rank-ladder-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--border-color);
}

.rank-ladder-step--passed .rank-ladder-dot {
  background: var(--color-correct);
  border-color: var(--color-correct);
}

.rank-ladder-step--current .rank-ladder-dot {
  background: var(--color-xp);
  border-color: var(--color-xp);
  box-shadow: 0 0 8px rgba(255, 191, 0, 0.5);
}

.rank-ladder-step--upcoming .rank-ladder-name,
.rank-ladder-step--upcoming .rank-ladder-xp {
  opacity: 0.45;
}

.rank-ladder-step--current .rank-ladder-name {
  color: var(--color-xp);
  font-weight: 700;
}

.rank-ladder-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex: 1;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.rank-ladder-name {
  color: #fff;
  font-weight: 600;
}

.rank-ladder-xp {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.rank-xp-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.rank-xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-neutral-glow), var(--color-xp));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.log-rank-progress-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 0 0.35rem 0;
}

.log-xp-hints {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log-xp-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

.log-empty-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.game-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
  text-align: left;
}

.game-history-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
}

.game-history-item .gh-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.game-history-item .gh-mode {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
}

.game-history-item .gh-score {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.game-history-item .gh-districts {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.game-history-item .gh-duration {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.timer-display.timer-warning {
  color: var(--color-incorrect);
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  50% { opacity: 0.65; }
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10001;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  bottom: -12px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-rise 2.2s ease-out forwards;
}

@keyframes confetti-rise {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-110vh) translateX(var(--x-drift, 0px)) rotate(720deg);
    opacity: 0;
  }
}

.name-all-active .stadtteil-path.bezirk-excluded {
  fill: rgba(2, 5, 12, 0.82) !important;
  stroke: rgba(255, 255, 255, 0.02) !important;
  filter: grayscale(0.9) brightness(0.3) !important;
}

.name-all-active .water-group .water-body,
.name-all-active .water-group .water-outline,
.name-all-active .water-group .water-fill,
.name-all-active .water-group .water-shimmer,
.name-all-active .water-group .water-channel,
.name-all-active .water-group .water-channel-glow,
.name-all-active .water-group .water-channel-bed {
  opacity: 0.35;
}

.sad-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10001;
  background: rgba(10, 15, 30, 0.25);
  overflow: hidden;
}

.sad-raindrop {
  position: absolute;
  top: -20px;
  width: 2px;
  height: 14px;
  background: linear-gradient(to bottom, transparent, rgba(120, 140, 180, 0.35));
  border-radius: 1px;
  animation: sad-rain var(--fall-dur, 1.1s) linear forwards;
}

@keyframes sad-rain {
  0% { transform: translateY(0); opacity: 0.6; }
  100% { transform: translateY(110vh); opacity: 0; }
}

body.segment-bezirke .stadtteil-path.unlocked-bezirk {
  stroke-width: 0.35px;
  stroke: rgba(255, 255, 255, 0.08);
  fill: rgba(255, 255, 255, 0.03);
}

body.segment-bezirke .stadtteil-path[data-bezirk="Altona"].unlocked-bezirk { fill: hsla(295, 80%, 55%, 0.12); }
body.segment-bezirke .stadtteil-path[data-bezirk="Bergedorf"].unlocked-bezirk { fill: hsla(32, 80%, 50%, 0.12); }
body.segment-bezirke .stadtteil-path[data-bezirk="Eimsbüttel"].unlocked-bezirk { fill: hsla(175, 70%, 42%, 0.12); }
body.segment-bezirke .stadtteil-path[data-bezirk="Hamburg-Mitte"].unlocked-bezirk { fill: hsla(345, 80%, 55%, 0.12); }
body.segment-bezirke .stadtteil-path[data-bezirk="Hamburg-Nord"].unlocked-bezirk { fill: hsla(210, 75%, 52%, 0.12); }
body.segment-bezirke .stadtteil-path[data-bezirk="Harburg"].unlocked-bezirk { fill: hsla(100, 70%, 48%, 0.12); }
body.segment-bezirke .stadtteil-path[data-bezirk="Wandsbek"].unlocked-bezirk { fill: hsla(260, 75%, 55%, 0.12); }

.game-play-area .secondary-btn {
  width: 100%;
}

body.segment-bezirke .stadtteil-path:hover:not(.bezirk-hover-highlight):not(.selected):not(.blink) {
  stroke-width: 0.35px !important;
  stroke: rgba(255, 255, 255, 0.05) !important;
  filter: none !important;
}

.primary-btn {
  background: linear-gradient(135deg, var(--color-neutral-glow), var(--color-wandsbek));
  border: none;
  color: #fff;
  padding: 0.9rem 2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: 0 4px 15px rgba(0, 162, 255, 0.4);
  width: 100%;
  
  &:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 162, 255, 0.6);
  }
  
  &:active {
    transform: translateY(1px);
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes mapPulse {
  0% { fill: rgba(255, 255, 255, 0.04); }
  50% { fill: rgba(255, 255, 255, 0.25); filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4)); }
  100% { fill: rgba(255, 255, 255, 0.04); }
}

@keyframes mapShake {
  0%, 100% { transform: translate(0, 0); }
  20%, 60% { transform: translate(-3px, 0); }
  40%, 80% { transform: translate(3px, 0); }
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .console-panel {
    order: 2;
  }
  
  .map-panel {
    order: 1;
  }
  
  .map-container-wrapper {
    min-height: 420px;
  }
  
  .hamburg-map-svg {
    max-height: 55vh;
    max-height: 55dvh;
  }

  .map-prompt-bar {
    display: block;
  }

  body.in-round .segment-selector,
  body.in-round .mode-selector {
    display: none;
  }

  body.in-round .map-container-wrapper {
    min-height: min(42vh, 42dvh, 320px);
  }
}

@media (min-width: 1025px) {
  .map-prompt-bar {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 1rem 1.25rem;
  }
  
  .stats-bar {
    gap: 0.65rem;
  }
  
  .stat-pill {
    padding: 0.45rem 0.7rem;
    font-size: 0.82rem;
  }
  
  .level-tracker {
    min-width: 0;
    flex: 1 1 140px;
  }
  
  .map-container-wrapper {
    min-height: 380px;
  }
  
  .modal-content {
    padding: 1.5rem;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .overlay-modal {
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    align-items: flex-start;
    padding-top: max(2rem, env(safe-area-inset-top));
  }
}

@media (max-width: 640px) {
  .app-container {
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    gap: 0.75rem;
  }
  
  .app-header {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: stretch;
  }
  
  .brand {
    justify-content: space-between;
    width: 100%;
  }
  
  .brand .badge {
    display: none;
  }
  
  .stats-bar {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
  }
  
  .level-tracker {
    width: 100%;
    order: 10;
  }
  
  .audio-toggle {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  
  .glass-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }
  
  .map-container-wrapper {
    min-height: min(52vh, 52dvh, 380px);
    border-radius: var(--radius-md);
    padding: 0.5rem;
  }

  body.in-round .map-container-wrapper {
    min-height: min(38vh, 38dvh, 280px);
  }
  
  .hamburg-map-svg {
    max-height: none;
  }

  .map-prompt-bar .map-prompt-target {
    font-size: 1.2rem;
  }
  
  .brand h1 {
    font-size: 1.25rem;
  }
  
  .segment-btn {
    min-height: 44px;
    font-size: 0.8rem;
    padding: 0.6rem 0.4rem;
  }
  
  .mode-btn {
    min-height: 48px;
    padding: 0.75rem 0.85rem;
  }
  
  .choice-btn {
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    min-height: 48px;
  }
  
  .prompt-box .prompt-target {
    font-size: 1.5rem;
  }
  
  .map-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
  }
  
  .map-controls .zoom-btns {
    width: 100%;
    justify-content: center;
  }
  
  .map-controls .control-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    font-size: 1.1rem;
  }
  
  .map-controls .control-btn#btn-zoom-reset {
    flex: 1;
    min-height: 44px;
  }
  
  .map-hint {
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.35;
  }
  
  .neuwerk-overlay {
    top: max(0.5rem, env(safe-area-inset-top));
    right: 0.5rem;
    font-size: 0.7rem;
    padding: 0.5rem 0.65rem;
  }
  
  .primary-btn,
  .secondary-btn {
    min-height: 48px;
  }
  
  .autocomplete-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .privacy-notice {
    font-size: 0.68rem;
    padding: 0 0.25rem;
  }
}

/* Touch devices: reduce hover-only motion */
@media (hover: none) and (pointer: coarse) {
  .choice-btn:hover,
  .mode-btn:hover,
  .segment-btn:hover,
  .glass-card:hover {
    transform: none;
  }
  
  .choice-btn:active,
  .mode-btn:active,
  .segment-btn:active {
    transform: scale(0.98);
    opacity: 0.92;
  }
}

/* Slider Switch CSS */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  transition: 0.3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: 0.3s;
  border-radius: 50%;
}
.switch input:checked + .slider {
  background-color: rgba(0, 162, 255, 0.15);
  border-color: rgba(0, 162, 255, 0.4);
}
.switch input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--color-neutral-glow);
  box-shadow: 0 0 8px var(--color-neutral-glow);
}

/* --- TunnelQuiz transit map --- */
.transit-map-svg {
  width: 100%;
  height: auto;
  display: block;
  transform-origin: 0 0;
  cursor: grab;
  touch-action: none;
}
.transit-map-svg.smooth-transition {
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.map-bg-path {
  fill: rgba(255, 255, 255, 0.03);
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 0.5;
}
.line-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
  pointer-events: stroke;
  stroke-width: calc(3.5 / var(--map-zoom, 1));
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.line-path.active, .line-path.selected {
  opacity: 1;
  stroke-width: calc(5 / var(--map-zoom, 1));
  filter: drop-shadow(0 0 6px currentColor);
}
.line-path.dimmed { opacity: 0.2; }
.line-path.blink {
  animation: stationBlink 0.9s ease-in-out infinite;
}
.line-path.locked-path { opacity: 0.15; pointer-events: none; }
.line-path.round-correct { stroke: var(--color-correct) !important; opacity: 1; }
.line-path.round-incorrect { stroke: var(--color-incorrect) !important; opacity: 1; }
.station-dot {
  fill: #fff;
  stroke: rgba(0, 0, 0, 0.5);
  stroke-width: 1;
  pointer-events: none;
  transition: fill 0.2s ease, r 0.2s ease;
}
.station-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
  pointer-events: all;
}
@media (hover: none) and (pointer: coarse) {
  .station-hit { r: 22; }
}
.station-hit.selected + .station-dot,
.station-dot.selected {
  fill: var(--color-neutral-glow);
  filter: drop-shadow(0 0 8px var(--color-neutral-glow));
}
.station-hit.blink + .station-dot,
.station-dot.blink {
  animation: stationBlink 0.9s ease-in-out infinite;
  fill: var(--color-xp);
}
.station-hit.discovered + .station-dot { fill: rgba(20, 184, 166, 0.9); }
.station-hit.round-correct + .station-dot,
.station-dot.round-correct { fill: var(--color-correct); }
.station-hit.round-incorrect + .station-dot,
.station-dot.round-incorrect { fill: var(--color-incorrect); }
.station-hit.locked-path + .station-dot { opacity: 0.35; }
.station-group.line-excluded { opacity: 0.12; pointer-events: none; }
@keyframes stationBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(1.15); }
}
.line-picker, .bezirk-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.line-picker-item, .bezirk-picker-item { display: flex; align-items: center; gap: 0.25rem; font-size: 0.78rem; }
