/* StreetsRace - Design System & Global Styles
   Mobile-first. Dark touge aesthetic.
   Primary: phones (375px+). PC: 1024px+
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg-base:     #0a0a0f;
  --bg-surface:  #13131a;
  --bg-card:     rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-overlay:  rgba(10,10,15,0.92);

  --accent-red:    #e63946;
  --accent-red-dim: rgba(230,57,70,0.15);
  --accent-blue:   #4361ee;
  --accent-blue-dim: rgba(67,97,238,0.15);
  --accent-green:  #06ffa5;
  --accent-green-dim: rgba(6,255,165,0.12);
  --accent-orange: #ff9f1c;
  --accent-yellow: #ffd60a;

  --text-primary:  #f8f9fa;
  --text-secondary:#c9cad8;
  --text-muted:    #6b6e87;
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);

  /* Segment score colors */
  --score-excellent: #06ffa5;
  --score-good:      #ffd60a;
  --score-average:   #ff9f1c;
  --score-poor:      #e63946;
}

[data-theme="light"] {
  --bg-base:        #f4f5f9;
  --bg-surface:     #ffffff;
  --bg-card:        rgba(0, 0, 0, 0.03);
  --bg-card-hover:  rgba(0, 0, 0, 0.06);
  --bg-overlay:     rgba(255, 255, 255, 0.94);
  --text-primary:   #111319;
  --text-secondary: #3a3d4d;
  --text-muted:     #70738a;
  --border:         rgba(0, 0, 0, 0.08);
  --border-strong:  rgba(0, 0, 0, 0.16);
}

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Typography */
  --font: 'Outfit', system-ui, sans-serif;

  /* Layout */
  --navbar-h: 56px;
  --bottom-nav-h: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow-red:   0 0 24px rgba(230,57,70,0.35);
  --shadow-glow-blue:  0 0 24px rgba(67,97,238,0.35);
  --shadow-glow-green: 0 0 24px rgba(6,255,165,0.35);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-mid:  250ms;
  --duration-slow: 400ms;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, select, textarea { font-family: var(--font); }

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }

/* ── Typography ────────────────────────────────────────────────── */
.text-xs   { font-size: 11px; line-height: 1.4; }
.text-sm   { font-size: 13px; line-height: 1.5; }
.text-base { font-size: 15px; line-height: 1.5; }
.text-lg   { font-size: 18px; line-height: 1.4; }
.text-xl   { font-size: 22px; line-height: 1.3; }
.text-2xl  { font-size: 28px; line-height: 1.2; }
.text-3xl  { font-size: 36px; line-height: 1.15; }
.fw-400 { font-weight: 400; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fw-900 { font-weight: 900; }
.text-red   { color: var(--accent-red); }
.text-blue  { color: var(--accent-blue); }
.text-green { color: var(--accent-green); }
.text-muted { color: var(--text-muted); }

/* ── Layout ────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  z-index: 1000;
  background: var(--bg-overlay);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  flex: 1;
}

.navbar-logo .logo-sr { color: var(--accent-red); }
.navbar-logo .logo-dot { color: var(--text-muted); font-weight: 400; }

.navbar-logo svg,
.navbar-logo img {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-link {
  display: none; /* hidden on mobile, shown on desktop */
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease);
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--accent-red); }

#lang-toggle {
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  letter-spacing: 0.05em;
  transition: all var(--duration-fast) var(--ease);
}
#lang-toggle:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
  background: var(--accent-blue-dim);
}

/* ── Bottom Navigation (Mobile) ────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  z-index: 1000;
  background: var(--bg-overlay);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease);
  letter-spacing: 0.02em;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.bottom-nav-item.active { color: var(--accent-red); }
.bottom-nav-item.active svg { filter: drop-shadow(0 0 6px var(--accent-red)); }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              transform var(--duration-mid) var(--ease);
}
.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}
.card.clickable { cursor: pointer; }
.card.clickable:active { transform: scale(0.98); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  transition: all var(--duration-fast) var(--ease);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-red);
  color: #fff;
  box-shadow: 0 4px 16px rgba(230,57,70,0.35);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: var(--shadow-glow-red); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-strong); }

.btn-blue {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 4px 16px rgba(67,97,238,0.35);
}
.btn-blue:hover { filter: brightness(1.1); box-shadow: var(--shadow-glow-blue); }

.btn-sm { padding: 8px 14px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { padding: 16px 28px; font-size: 16px; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }

/* ── Badge ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-red   { background: var(--accent-red-dim);   color: var(--accent-red);   border: 1px solid rgba(230,57,70,0.2); }
.badge-blue  { background: var(--accent-blue-dim);  color: var(--accent-blue);  border: 1px solid rgba(67,97,238,0.2); }
.badge-green { background: var(--accent-green-dim); color: var(--accent-green); border: 1px solid rgba(6,255,165,0.2); }
.badge-gray  { background: rgba(255,255,255,0.06);  color: var(--text-muted);   border: 1px solid var(--border); }

/* ── Score Ring ────────────────────────────────────────────────── */
.score-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring .score-value {
  position: absolute;
  font-weight: 800;
  letter-spacing: -0.04em;
}

/* ── Score Bar ─────────────────────────────────────────────────── */
.score-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.score-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.score-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s var(--ease);
}

/* ── Form Elements ─────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-dim);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6e87' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Upload Drop Zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  transition: all var(--duration-mid) var(--ease);
  cursor: pointer;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent-red);
  background: var(--accent-red-dim);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  color: var(--text-muted);
}
.upload-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.upload-hint { font-size: 12px; color: var(--text-muted); }

/* ── Bottom Sheet (Mobile) ─────────────────────────────────────── */
.bottom-sheet {
  position: fixed;
  bottom: var(--bottom-nav-h);
  left: 0; right: 0;
  z-index: 500;
  background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--ease);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet.peek { transform: translateY(calc(100% - 140px)); }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto var(--space-2);
  flex-shrink: 0;
  cursor: grab;
}
.sheet-content {
  overflow-y: auto;
  flex: 1;
  padding: 0 var(--space-4) var(--space-6);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-mid) var(--ease);
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-5) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  transform: translateY(40px);
  transition: transform var(--duration-mid) var(--ease);
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-backdrop.open .modal {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-xl);
    margin: auto;
    transform: scale(0.96);
  }
  .modal-backdrop.open .modal { transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.modal-title { font-size: 20px; font-weight: 800; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 18px;
  transition: all var(--duration-fast) var(--ease);
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ── Segment List Item ─────────────────────────────────────────── */
.segment-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
  border-bottom: 1px solid var(--border);
}
.segment-item:hover { background: var(--bg-card); }
.segment-item:last-child { border-bottom: none; }
.segment-rank {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--text-muted);
}
.segment-rank.rank-1 { background: var(--accent-green-dim); color: var(--accent-green); }
.segment-rank.rank-2 { background: rgba(255,214,10,0.12); color: var(--accent-yellow); }
.segment-rank.rank-3 { background: rgba(255,159,28,0.12); color: var(--accent-orange); }

.segment-info { flex: 1; min-width: 0; }
.segment-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segment-meta { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.segment-score {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

/* ── Score Color Utils ─────────────────────────────────────────── */
.score-excellent { color: var(--score-excellent); }
.score-good      { color: var(--score-good); }
.score-average   { color: var(--score-average); }
.score-poor      { color: var(--score-poor); }

/* ── Loading Spinner ───────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 100;
  border-radius: inherit;
}
.loading-overlay p {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ── Toasts ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--navbar-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  animation: toastIn 0.3s var(--ease) forwards, toastOut 0.3s var(--ease) 2.7s forwards;
  pointer-events: all;
}
.toast-success { background: var(--accent-green); color: #0a0a0f; }
.toast-error   { background: var(--accent-red);   color: #fff; }
.toast-info    { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-strong); backdrop-filter: blur(12px); }

@keyframes toastIn  { from { opacity: 0; transform: translateY(-8px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ── Leaflet overrides ─────────────────────────────────────────── */
.leaflet-container { background: #0d1117; font-family: var(--font); }
.leaflet-tile { filter: brightness(0.85) saturate(0.8) hue-rotate(200deg); }
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
  border-bottom-color: var(--border) !important;
  font-size: 18px;
  line-height: 30px;
  width: 36px;
  height: 36px;
}
.leaflet-control-zoom a:hover { background: var(--bg-card-hover) !important; color: var(--text-primary) !important; }
.leaflet-control-attribution { display: none !important; }
.leaflet-popup-content-wrapper {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-md) !important;
}
.leaflet-popup-tip { background: var(--bg-surface) !important; }

/* ── Chrono Leaderboard ────────────────────────────────────────── */
.chrono-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.chrono-row:last-child { border-bottom: none; }
.chrono-pos {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
}
.chrono-pos.p1 { color: var(--accent-green); }
.chrono-pos.p2 { color: var(--accent-yellow); }
.chrono-pos.p3 { color: var(--accent-orange); }

.chrono-car { font-size: 13px; font-weight: 700; }
.chrono-nick { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.chrono-time-display { font-size: 16px; font-weight: 900; letter-spacing: -0.03em; color: var(--accent-green); }
.chrono-gps-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-blue);
  background: var(--accent-blue-dim);
  padding: 2px 5px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  display: inline-block;
  margin-top: 2px;
}

/* ── Timer Display ─────────────────────────────────────────────── */
.timer-display {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -0.05em;
  color: var(--accent-green);
  text-shadow: var(--shadow-glow-green);
  font-variant-numeric: tabular-nums;
  text-align: center;
  font-feature-settings: "tnum";
}
.timer-display.running { animation: timerGlow 1s ease-in-out infinite alternate; }
@keyframes timerGlow {
  from { text-shadow: 0 0 16px rgba(6,255,165,0.4); }
  to   { text-shadow: 0 0 32px rgba(6,255,165,0.9), 0 0 60px rgba(6,255,165,0.3); }
}

/* ── GPS Validation Badge ──────────────────────────────────────── */
.gps-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  font-weight: 600;
}
.gps-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.gps-dot.active { background: var(--accent-green); animation: gpsPulse 1.5s ease-in-out infinite; }
@keyframes gpsPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(6,255,165,0.4); } 50% { box-shadow: 0 0 0 6px rgba(6,255,165,0); } }

/* ── Elevation Chart Container ─────────────────────────────────── */
.elevation-chart-wrap {
  position: relative;
  height: 120px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-base);
}

/* ── Community Trace Card ──────────────────────────────────────── */
.trace-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--duration-mid) var(--ease);
}
.trace-card:hover {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 1px var(--accent-red), var(--shadow-md);
  transform: translateY(-2px);
}
.trace-card:active { transform: scale(0.98) translateY(0); }

.trace-card-map {
  height: 140px;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}
.trace-card-score {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.trace-card-body { padding: var(--space-3) var(--space-4) var(--space-4); }
.trace-card-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.trace-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ── Divider ───────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-5) 0;
}

/* ── Stat Chip ─────────────────────────────────────────────────── */
.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 80px;
}
.stat-chip-value { font-size: 22px; font-weight: 900; letter-spacing: -0.04em; }
.stat-chip-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Desktop overrides ─────────────────────────────────────────── */
@media (min-width: 768px) {
  :root { --navbar-h: 64px; }
  .bottom-nav { display: none; }
  .nav-link { display: inline-flex; }

  .bottom-sheet {
    position: static;
    transform: none;
    border-radius: var(--radius-xl);
    max-height: none;
    border: 1px solid var(--border);
  }
  .sheet-handle { display: none; }
}

@media (min-width: 1024px) {
  :root {
    --space-4: 20px;
    --space-5: 28px;
  }
}

/* ── Page padding for fixed bars ───────────────────────────────── */
.page-content {
  padding-top: var(--navbar-h);
  padding-bottom: var(--bottom-nav-h);
  min-height: 100dvh;
}

@media (min-width: 768px) {
  .page-content { padding-bottom: 0; }
}

/* ── Animations ────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

.fade-in  { animation: fadeIn  var(--duration-mid) var(--ease) both; }
.slide-in { animation: slideIn var(--duration-mid) var(--ease) both; }

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-4);
  text-align: center;
}
.empty-state svg { color: var(--text-muted); opacity: 0.5; width: 48px; height: 48px; }
.empty-state p { font-size: 14px; color: var(--text-muted); max-width: 240px; }

/* ── Segment Type Colors ───────────────────────────────────────── */
[data-type="touge"]     { --type-color: var(--accent-blue); }
[data-type="straight"]  { --type-color: var(--accent-red); }
[data-type="circuit"]   { --type-color: var(--accent-green); }
[data-type="hillclimb"] { --type-color: var(--accent-orange); }
