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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.alert-active #speed-panel {
  top: auto;
  bottom: 100px;
  opacity: 0.85;
}

#map {
  width: 100%;
  height: 100%;
}

#install-hint {
  position: absolute;
  bottom: 100px;
  left: 12px;
  right: 12px;
  z-index: 1002;
  background: #1e2327;
  color: #fff;
  padding: 12px 40px 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

#install-hint.hidden { display: none; }

#install-hint-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 18px;
  padding: 4px 8px;
}

#speed-panel {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 1000;
  background: #1e2327;
  color: #fff;
  border-radius: 16px;
  padding: 12px 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  min-width: 88px;
}

#speed-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#speed-unit {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

#speed-panel.speeding {
  background: #d1383d;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 2px 22px rgba(209,56,61,0.8); }
}

#limit-row { margin-top: 8px; }
#limit-row.hidden { display: none; }

#limit-badge {
  display: inline-block;
  background: #fff;
  color: #1e2327;
  border: 3px solid #d1383d;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  line-height: 32px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

#fine-banner {
  position: absolute;
  top: max(90px, calc(env(safe-area-inset-top) + 70px));
  left: 12px;
  right: 12px;
  z-index: 1001;
  background: #d1383d;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

#fine-banner.hidden { display: none; }
#fine-icon { font-size: 24px; flex-shrink: 0; }

#alert-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: linear-gradient(180deg, #ff6b00 0%, #e8482c 100%);
  color: #fff;
  padding: max(16px, env(safe-area-inset-top)) 20px 20px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  gap: 16px;
  animation: alert-flash 1.2s ease-in-out infinite;
}

#alert-banner.hidden { display: none; }

@keyframes alert-flash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

#alert-icon {
  font-size: 48px;
  line-height: 1;
  flex-shrink: 0;
}

.alert-body { flex: 1; min-width: 0; }

#alert-label {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

#alert-distance {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

#report-fab {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  right: max(20px, env(safe-area-inset-right));
  z-index: 1000;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #e8482c;
  color: #fff;
  font-size: 28px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

#report-menu {
  position: absolute;
  bottom: calc(100px + env(safe-area-inset-bottom));
  right: max(20px, env(safe-area-inset-right));
  z-index: 1000;
  background: #1e2327;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  width: min(260px, calc(100vw - 40px));
  max-height: 60vh;
  overflow-y: auto;
}

#report-menu.hidden { display: none; }

.report-menu-header {
  color: #fff;
  font-size: 13px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.report-btn {
  background: #2c3338;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px 12px;
  text-align: left;
  font-size: 16px;
}

.report-btn:active { background: #3a4248; }

#report-cancel {
  margin-top: 4px;
  background: transparent;
  color: #e8482c;
  border: none;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
}

.leaflet-popup-content button {
  margin-top: 6px;
  margin-right: 4px;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
}

.vote-confirm { background: #2ea043; color: #fff; }
.vote-deny { background: #d1383d; color: #fff; }

@media (min-width: 768px) {
  #alert-banner {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(480px, 90vw);
    border-radius: 0 0 20px 20px;
  }
  #fine-banner {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 480px;
  }
}
