/* ============================================
   Live-Blitz Karte — Styles
   Dark Theme · Fullscreen · Responsive
   ============================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e17;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Karte: Vollbild --- */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* MapLibre-native Controls transparent anpassen */
.maplibregl-ctrl-attrib {
  background: rgba(10, 14, 23, 0.6) !important;
  color: rgba(255,255,255,0.4) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  border-radius: 4px 0 0 0 !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.maplibregl-ctrl-attrib a {
  color: rgba(255,255,255,0.5) !important;
}
.maplibregl-ctrl-attrib a:hover {
  color: rgba(255,255,255,0.8) !important;
}
.maplibregl-ctrl-zoom {
  background: rgba(10, 14, 23, 0.7) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 8px !important;
  overflow: hidden;
}
.maplibregl-ctrl-zoom button {
  color: rgba(255,255,255,0.7) !important;
  width: 40px !important;
  height: 40px !important;
  border-color: rgba(255,255,255,0.08) !important;
}
.maplibregl-ctrl-zoom button:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #fff !important;
}

/* Canvas Overlay für Ring-Animation */
#ring-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* --- Lade-Overlay --- */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0e17;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.8s ease;
}
.loading.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.5px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #ffeb3b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes ui-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ui-drop {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Fallback (kein WebGL) --- */
.fallback {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0e17;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}
.fallback.hidden {
  display: none;
}
.fallback-content {
  text-align: center;
  max-width: 420px;
  padding: 40px 24px;
}
.fallback-icon {
  font-size: 64px;
  display: block;
  margin-bottom: 20px;
}
.fallback h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #fff;
}
.fallback p {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
}

/* --- Verbindungs-Status --- */
.connection-status {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all 0.4s ease;
  pointer-events: none;
  animation: ui-rise 0.45s ease both;
}
.connection-status.connected {
  background: rgba(34, 197, 94, 0.15);
  color: rgba(34, 197, 94, 0.8);
  opacity: 1;
}
.connection-status.live {
  background: rgba(34, 197, 94, 0.18);
  color: rgba(190, 242, 100, 0.9);
  opacity: 1;
}
.connection-status.connecting {
  background: rgba(255, 235, 59, 0.12);
  color: rgba(255, 235, 59, 0.8);
  opacity: 1;
}
.connection-status.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: rgba(239, 68, 68, 0.8);
  opacity: 1;
}
.connection-status.visible {
  opacity: 1;
}

/* --- Kartenmodus --- */
.map-controls {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(10, 14, 23, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: ui-drop 0.42s ease both;
}
.map-controls button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.62);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.map-controls button:hover:not(:disabled) {
  color: #fff;
  background: rgba(255,255,255,0.08);
  transform: translateY(-1px);
}
.map-controls button.active {
  color: rgba(190, 242, 100, 0.95);
  background: rgba(34, 197, 94, 0.18);
}
.map-controls button:focus-visible {
  outline: 2px solid rgba(190, 242, 100, 0.72);
  outline-offset: 2px;
}
.map-controls button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* --- Location-Button --- */
.location-button {
  position: fixed;
  bottom: 24px;
  left: 16px;
  z-index: 100;
  animation: ui-rise 0.42s 0.1s ease both;
}
.location-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(10, 14, 23, 0.72);
  color: rgba(255,255,255,0.62);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.location-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  color: #fff;
  transform: translateY(-1px);
}
.location-btn:focus-visible {
  outline: 2px solid rgba(190, 242, 100, 0.72);
  outline-offset: 2px;
}
.location-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
/* Loading state — spinner overlays the icon */
.location-btn.loading .loc-icon {
  opacity: 0.25;
  transition: opacity 0.3s ease;
}
.location-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  border: 2.5px solid rgba(255,255,255,0.12);
  border-top-color: #ffeb3b;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.location-btn.loading {
  cursor: progress;
}
/* Active state (location shown) */
.location-btn.active {
  color: rgba(100, 181, 246, 0.9);
  border-color: rgba(100, 181, 246, 0.25);
  background: rgba(100, 181, 246, 0.12);
}
/* Error state */
.location-btn.error {
  color: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.1);
}
/* Location icon (inline SVG via background mask) */
.loc-icon {
  display: block;
  width: 18px;
  height: 18px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z'/%3E%3Ccircle cx='12' cy='9' r='2.5'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z'/%3E%3Ccircle cx='12' cy='9' r='2.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* --- Strike-Counter (optional, dezent) --- */
.strike-counter {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 100;
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  background: rgba(10, 14, 23, 0.5);
  padding: 6px 12px;
  border-radius: 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.05);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.strike-counter.visible {
  opacity: 1;
}

/* --- Legend Farbverlauf --- */
.legend {
  position: fixed;
  bottom: 60px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.6s ease;
  animation: ui-rise 0.48s 0.14s ease both;
}
.legend.visible {
  opacity: 1;
}
.legend-bar {
  width: 100px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #ffffff 0%, #ffeb3b 25%, #ff9800 50%, #f44336 75%, rgba(244,67,54,0) 100%);
  box-shadow: 0 0 8px rgba(255,255,255,0.05);
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  width: 100px;
  font-size: 9px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.3px;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .strike-counter {
    bottom: 72px;
    right: 12px;
    font-size: 10px;
    padding: 4px 10px;
  }
  .legend {
    bottom: 102px;
    right: 12px;
  }
  .legend-bar {
    width: 80px;
    height: 5px;
  }
  .legend-labels {
    width: 80px;
    font-size: 8px;
  }
  .connection-status {
    font-size: 10px;
    padding: 6px 14px;
    bottom: 36px;
  }
  .map-controls {
    top: 12px;
    left: 12px;
  }
  .map-controls button {
    font-size: 11px;
    padding: 7px 9px;
  }
  .location-button {
    bottom: 48px;
    left: 12px;
  }
  .location-btn {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
