/* ============================================
   Endurace - Mobile-First Design System
   Phone first, desktop second.
   ============================================ */

:root {
  --bg-0: #09090b;
  --bg-1: #0f0f12;
  --bg-2: #18181b;
  --bg-3: #1e1e24;
  --bg-4: #27272a;
  --bg-hover: #2a2a30;
  --text-0: #fafafa;
  --text-1: #d4d4d8;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-soft: rgba(239, 68, 68, 0.12);
  --accent-glow: rgba(239, 68, 68, 0.25);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.12);
  --yellow: #eab308;
  --yellow-soft: rgba(234, 179, 8, 0.12);
  --orange: #f97316;
  --purple: #a855f7;
  --border: #27272a;
  --border-light: #3f3f46;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --transition: 150ms ease;
  --tier-bronze: #CD7F32;
  --tier-silver: #C0C0C0;
  --tier-gold: #FFD700;
  --tier-platinum: #00CED1;
  --tier-diamond: #B9F2FF;
  /* Safe areas for notched phones */
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(64px + var(--sab)); /* Space for bottom tabs */
}

/* ---- Top Nav ---- */
#navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; height: 48px;
  background: rgba(15,15,18,0.92); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-top: var(--sat);
}
.nav-left { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; letter-spacing: -0.5px;
}
.logo-text { font-weight: 800; font-size: 16px; letter-spacing: -0.3px; }
/* Hide desktop nav links on mobile */
.nav-links { display: none; }
.nav-right { display: flex; align-items: center; gap: 6px; }
.nav-user-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 3px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  cursor: pointer; transition: var(--transition);
}
.nav-user-btn:hover { border-color: var(--border-light); }
.nav-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: white;
}
.nav-name { font-size: 12px; font-weight: 600; }
.nav-rating { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-2); }
.nav-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition); font-size: 14px;
  color: var(--text-2); position: relative;
  min-width: 36px; min-height: 36px; /* Touch target */
}
.nav-icon-btn:hover { background: var(--bg-3); color: var(--text-0); }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: white;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Bottom Tab Bar (mobile) ---- */
.bottom-tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 120;
  display: flex; align-items: stretch;
  background: rgba(15,15,18,0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding-bottom: var(--sab);
  height: calc(60px + var(--sab));
}
.bottom-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--text-3);
  font-family: inherit; font-size: 10px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  padding: 6px 0;
  min-height: 44px; /* Touch target */
  -webkit-tap-highlight-color: transparent;
}
.bottom-tab svg { width: 20px; height: 20px; opacity: 0.6; transition: var(--transition); }
.bottom-tab.active { color: var(--accent); }
.bottom-tab.active svg { opacity: 1; stroke: var(--accent); }
.bottom-tab:active { transform: scale(0.92); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 16px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: var(--transition); text-decoration: none; white-space: nowrap;
  min-height: 44px; /* Touch target */
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.btn-secondary { background: var(--bg-3); color: var(--text-0); }
.btn-secondary:hover { background: var(--bg-4); }
.btn-outline { background: transparent; color: var(--text-1); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-3); border-color: var(--border-light); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 8px; }
.btn-ghost:hover { color: var(--text-0); }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 36px; }
.btn-lg { padding: 14px 24px; font-size: 15px; width: 100%; }
.btn-close { background: none; border: none; color: var(--text-3); font-size: 22px; cursor: pointer; padding: 8px; line-height: 1; min-width: 44px; min-height: 44px; }
.btn-close:hover { color: var(--text-0); }
/* Social login buttons */
.social-login-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.btn-social { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer; border: 1px solid var(--border); transition: var(--transition); min-height: 44px; }
.btn-apple { background: #fff; color: #000; }
.btn-apple:hover { background: #f0f0f0; }
.btn-facebook { background: #1877F2; color: #fff; border-color: #1877F2; }
.btn-facebook:hover { background: #166FE5; }

/* Demo login */
.demo-login-section { margin-top: 4px; }
.demo-divider { text-align: center; margin-bottom: 10px; color: var(--text-3); font-size: 13px; position: relative; }
.demo-divider::before, .demo-divider::after { content: ''; position: absolute; top: 50%; width: 35%; height: 1px; background: var(--border); }
.demo-divider::before { left: 0; }
.demo-divider::after { right: 0; }
.btn-demo { width: 100%; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; cursor: pointer; border: 1px dashed var(--border); background: transparent; color: var(--text-2); transition: var(--transition); min-height: 44px; }
.btn-demo:hover { background: var(--bg-3); border-color: var(--orange); color: var(--orange); }

/* Onboarding overlay */
.onboarding-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; padding: 20px; }
.onboarding-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 28px; max-width: 400px; width: 100%; }
.onboarding-header { text-align: center; margin-bottom: 24px; }
.onboarding-header h2 { color: var(--text-0); margin: 0 0 6px; }
.onboarding-header p { color: var(--text-2); margin: 0; font-size: 14px; }
.onboarding-toggle-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-0); border-radius: 24px; border: 1px solid var(--border); transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 2px; bottom: 2px; background: var(--text-3); border-radius: 50%; transition: var(--transition); }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: white; }
.form-feedback { display: block; font-size: 12px; margin-top: 4px; min-height: 16px; }
.form-hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.btn-back { min-width: 44px; min-height: 44px; font-size: 18px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px; background: var(--bg-0); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-0); font-family: inherit; font-size: 16px; /* 16px prevents zoom on iOS */
  transition: var(--transition);
  min-height: 44px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-group input::placeholder { color: var(--text-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; cursor: pointer; font-size: 14px !important; color: var(--text-1) !important; min-height: 44px; }
.checkbox-label input { width: 20px !important; height: 20px !important; accent-color: var(--accent); }
.error-text { color: var(--accent); font-size: 13px; margin-top: 10px; text-align: center; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
  background: var(--bg-3); color: var(--text-2);
}
.badge-live { background: var(--green-soft); color: var(--green); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-outline { background: transparent; border: 1px solid var(--border); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.count-badge { background: var(--bg-4); padding: 2px 8px; border-radius: var(--radius-full); font-size: 12px; color: var(--text-2); }
.tier-badge { font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.tier-bronze { background: rgba(205,127,50,0.15); color: var(--tier-bronze); }
.tier-silver { background: rgba(192,192,192,0.15); color: var(--tier-silver); }
.tier-gold { background: rgba(255,215,0,0.15); color: var(--tier-gold); }
.tier-platinum { background: rgba(0,206,209,0.15); color: var(--tier-platinum); }
.tier-diamond { background: rgba(185,242,255,0.15); color: var(--tier-diamond); }

/* ---- Tab bar ---- */
.tab-bar, .profile-tabs {
  display: flex; gap: 2px; margin-bottom: 16px;
  background: var(--bg-2); padding: 3px; border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab-btn {
  flex: 1; padding: 8px 10px; background: transparent; border: none;
  color: var(--text-2); font-family: inherit; font-weight: 600;
  font-size: 12px; cursor: pointer; border-radius: 7px; transition: var(--transition);
  white-space: nowrap; min-height: 36px;
}
.tab-btn.active { background: var(--bg-4); color: var(--text-0); }
.tab-btn:hover:not(.active) { color: var(--text-1); }

/* ---- Pages ---- */
.page { display: none; padding: 12px; max-width: 1100px; margin: 0 auto; }
.page.active { display: block; }
.hidden { display: none !important; }
.subtitle { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.section-header h2 { font-size: 18px; }
.section-header .subtitle { margin-top: 2px; font-size: 12px; }
.mono-sm { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-2); }
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-3); font-size: 14px; }

/* ---- Login ---- */
.login-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 400px; padding: 20px 16px; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo-mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 26px; margin-bottom: 14px;
}
.login-brand h1 { font-size: 28px; font-weight: 900; letter-spacing: -1px; }
.tagline { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.login-features {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; margin-bottom: 24px;
}
.feature-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-full); font-size: 11px; font-weight: 500; color: var(--text-2);
}
.feat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.feat-dot.live { background: var(--green); box-shadow: 0 0 6px var(--green); }
.login-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
/* .login-tabs removed (social-only auth) */
.divider { display: flex; align-items: center; gap: 12px; margin: 12px 0; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---- Dashboard / Race Cards ---- */
.race-grid { display: flex; flex-direction: column; gap: 10px; }
.race-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; cursor: pointer;
  transition: var(--transition); position: relative;
  -webkit-tap-highlight-color: transparent;
}
.race-card:active { background: var(--bg-2); transform: scale(0.99); }
.race-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 8px; }
.race-card-title { font-size: 15px; font-weight: 700; }
.race-card-meta { display: flex; gap: 5px; margin-bottom: 10px; flex-wrap: wrap; }
.race-card-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); gap: 8px; }
.race-card-participants { font-size: 12px; color: var(--text-2); }
.race-card-time { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-3); }
.race-card.active-race { border-color: var(--green); }
.race-card.active-race::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--green); border-radius: var(--radius) var(--radius) 0 0; }

/* ---- Feed ---- */
.feed-container { max-width: 600px; margin: 0 auto; }
.feed-list { display: flex; flex-direction: column; gap: 6px; }
.feed-item {
  display: flex; gap: 10px; padding: 12px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); transition: var(--transition); cursor: pointer;
}
.feed-item:active { background: var(--bg-2); }
.feed-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: white; flex-shrink: 0; }
.feed-content { flex: 1; min-width: 0; }
.feed-text { font-size: 13px; color: var(--text-1); line-height: 1.4; }
.feed-text strong { color: var(--text-0); font-weight: 600; }
.feed-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---- Modal ---- */
.modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); display: flex; align-items: flex-end;
  justify-content: center; z-index: 200; backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px; padding-bottom: calc(20px + var(--sab));
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  animation: slideUp 200ms ease;
}
.modal-sm { max-width: 400px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---- Slide Panel (Notifications) ---- */
.slide-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 100%; max-width: 100%;
  background: var(--bg-1); border-left: 1px solid var(--border);
  z-index: 200; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: slideIn 200ms ease;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); padding-top: calc(14px + var(--sat)); }
.panel-header h3 { font-size: 15px; }
.notifications-list { padding: 8px; }
.notif-item {
  display: flex; gap: 10px; padding: 12px;
  border-radius: var(--radius-sm); transition: var(--transition); cursor: pointer;
}
.notif-item:active { background: var(--bg-2); }
.notif-item.unread { background: var(--accent-soft); }
.notif-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-3); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.notif-content { flex: 1; }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-body { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Search ---- */
.search-results { max-height: 300px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
  min-height: 44px;
}
.search-result-item:active { background: var(--bg-3); }

/* ---- Lobby ---- */
.lobby-container { max-width: 800px; margin: 0 auto; }
.lobby-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lobby-info { flex: 1; }
.lobby-info h2 { font-size: 17px; }
.lobby-meta { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.lobby-content { display: flex; flex-direction: column; gap: 12px; }
.lobby-participants, .lobby-chat {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.lobby-participants h3, .lobby-chat h3 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.runner-list { display: flex; flex-direction: column; gap: 4px; }
.runner-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-0); border-radius: var(--radius-sm);
}
.runner-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: white; }
.runner-info { flex: 1; }
.runner-name { font-weight: 600; font-size: 13px; }
.runner-rating { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-3); }
.bot-badge { display: inline-block; font-size: 9px; font-weight: 700; background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; margin-left: 4px; vertical-align: middle; letter-spacing: 0.5px; }
.lobby-chat { display: flex; flex-direction: column; }
.chat-messages { flex: 1; min-height: 140px; max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; padding: 8px; background: var(--bg-0); border-radius: var(--radius-sm); }
.chat-msg { font-size: 13px; padding: 3px 0; }
.chat-msg .chat-user { font-weight: 600; color: var(--blue); }
.chat-msg .chat-text { color: var(--text-2); }
.chat-input { display: flex; gap: 6px; }
.chat-input input { flex: 1; padding: 10px 12px; background: var(--bg-0); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-0); font-family: inherit; font-size: 16px; min-height: 44px; }
.chat-input input:focus { outline: none; border-color: var(--accent); }

/* Lobby action button area */
.lobby-action-area { margin-bottom: 12px; }
.lobby-action-area .btn { width: 100%; }

/* ---- Countdown Overlay ---- */
.countdown-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 300;
}
.countdown-number {
  font-size: 100px; font-weight: 900; color: var(--accent);
  text-shadow: 0 0 80px var(--accent-glow);
  animation: pulse 1s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
}
.countdown-text { font-size: 16px; color: var(--text-2); margin-top: 10px; font-weight: 500; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---- Active Race ---- */
.page-race { padding: 0 !important; }
.race-view { height: calc(100vh - 48px); height: calc(100dvh - 48px); display: flex; flex-direction: column; overflow: hidden; }
.race-header-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--bg-1); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.race-timer, .race-position { text-align: center; min-width: 64px; }
.timer-label, .position-label { display: block; font-size: 9px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.5px; }
.timer-value { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 700; color: var(--green); }
.position-value { font-size: 22px; font-weight: 900; color: var(--yellow); }
.btn-dnf { color: var(--text-3); font-size: 11px; padding: 4px 10px; border: 1px solid var(--border); align-self: center; }
.btn-dnf:hover { color: var(--red); border-color: var(--red); }
#btn-back-to-lobby { font-size: 11px; padding: 4px 10px; border: 1px solid var(--border); align-self: center; }
.race-title-bar { text-align: center; flex: 1; min-width: 0; }
.race-title-bar h3 { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.race-my-stats-bar {
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 8px; background: var(--bg-1); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.race-my-stats-bar .stat { text-align: center; flex: 1; }
.race-my-stats-bar .stat-value { display: block; font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; }
.race-my-stats-bar .stat-label { font-size: 9px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.3px; }

.race-progress-bar {
  position: relative; height: 28px; background: var(--bg-1);
  border-radius: 0; flex-shrink: 0; overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.progress-fill { position: absolute; top: 0; left: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--orange)); transition: width 0.5s ease; }
.progress-runners { position: absolute; top: 0; left: 0; right: 0; height: 100%; pointer-events: none; }
.progress-runner-dot {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 800; color: white;
  transition: left 0.5s ease;
}
.progress-runner-dot.me { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); width: 22px; height: 22px; font-size: 9px; }
.progress-runner-dot.other { background: var(--bg-4); border: 2px solid var(--border-light); font-size: 8px; }
.catcher-car {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 900;
  transition: left 0.5s ease; box-shadow: 0 0 12px var(--accent-glow);
}

.race-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.race-map {
  position: relative; background: var(--bg-1);
  flex: 1; min-height: 200px; overflow: hidden;
}
.maplibregl-canvas { outline: none; }

/* Map markers */
.map-marker { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.map-marker-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); position: relative;
}
.map-marker-me .map-marker-dot { width: 18px; height: 18px; box-shadow: 0 0 12px rgba(239,68,68,0.4); }
.map-marker-dot[data-pos="1"]::after,
.map-marker-dot[data-pos="2"]::after,
.map-marker-dot[data-pos="3"]::after {
  content: attr(data-pos); position: absolute; top: -8px; right: -8px;
  background: #eab308; color: #000; font-size: 8px; font-weight: 800;
  width: 14px; height: 14px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
}
.map-marker-label {
  font-size: 10px; color: #fafafa; font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8); white-space: nowrap; margin-top: 2px;
}
.map-marker-me .map-marker-label { font-size: 12px; }

/* Results route map */
.results-map-container { margin: 16px 0; border-radius: var(--radius); overflow: hidden; }
.results-map-heading {
  font-size: 14px; font-weight: 700; color: var(--text-0);
  padding: 10px 12px 8px; background: var(--bg-1); border: 1px solid var(--border);
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
  text-align: center; letter-spacing: 0.5px;
}
.results-map { height: 200px; border-radius: var(--radius); }
.results-map.results-map-tall { height: 300px; border-radius: 0; }
.results-map-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px;
  padding: 8px; background: var(--bg-1); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
}
.map-stat { text-align: center; }
.map-stat-value { display: block; font-size: 14px; font-weight: 700; color: var(--text-0); font-family: 'JetBrains Mono', monospace; }
.map-stat-label { font-size: 10px; color: var(--text-3); }

/* Stats overlay removed — now using race-my-stats-bar above map */
.map-overlay { display: none; }

.race-standings {
  background: var(--bg-1); border-top: 1px solid var(--border);
  padding: 10px 12px; overflow-y: auto; flex-shrink: 0;
  max-height: 180px;
}
.race-standings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.race-standings h4 { font-size: 12px; }
.standings-list { display: flex; flex-direction: column; gap: 3px; }
.standing-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: var(--bg-0); border-radius: var(--radius-sm); font-size: 12px;
  transition: var(--transition);
}
.standing-item.me { border: 1px solid var(--accent); background: var(--accent-soft); }
.standing-pos { font-weight: 800; font-size: 13px; min-width: 20px; text-align: center; }
.standing-pos.pos-1 { color: var(--yellow); }
.standing-pos.pos-2 { color: var(--tier-silver); }
.standing-pos.pos-3 { color: var(--tier-bronze); }
.standing-info { flex: 1; min-width: 0; }
.standing-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.standing-dist { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-2); }
.standing-pace { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-3); text-align: right; }
.standing-separator { text-align: center; color: var(--text-3); font-size: 14px; padding: 2px 0; letter-spacing: 4px; }
.standing-total { text-align: center; font-size: 11px; color: var(--text-3); padding: 6px 0 2px; border-top: 1px solid var(--border); margin-top: 4px; }
.audio-controls { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ---- Results ---- */
.results-container { max-width: 650px; margin: 0 auto; text-align: center; }
.results-header { margin-bottom: 20px; }
.results-header h2 { font-size: 24px; font-weight: 900; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin-bottom: 20px; }
.podium-place { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.podium-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: white; border: 2px solid;
}
.podium-1 .podium-avatar { border-color: var(--yellow); width: 48px; height: 48px; font-size: 18px; }
.podium-2 .podium-avatar { border-color: var(--tier-silver); }
.podium-3 .podium-avatar { border-color: var(--tier-bronze); }
.podium-stand {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 8px 14px; text-align: center; min-width: 80px;
}
.podium-1 .podium-stand { height: 80px; background: linear-gradient(180deg, var(--yellow-soft), var(--bg-1)); }
.podium-2 .podium-stand { height: 60px; }
.podium-3 .podium-stand { height: 45px; }
.podium-name { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.podium-time { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-2); margin-top: 2px; }
.podium-medal { font-size: 18px; font-weight: 900; }
.podium-medal.gold { color: var(--yellow); }
.podium-medal.silver { color: var(--tier-silver); }
.podium-medal.bronze { color: var(--tier-bronze); }
.results-table-container {
  background: var(--bg-1); border-radius: var(--radius);
  border: 1px solid var(--border); overflow-x: auto; margin-bottom: 16px; text-align: left;
  -webkit-overflow-scrolling: touch;
}
.results-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.results-table th { padding: 8px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); background: var(--bg-2); border-bottom: 1px solid var(--border); }
.results-table td { padding: 8px 10px; font-size: 13px; border-bottom: 1px solid var(--border); }
.results-table tr:last-child td { border-bottom: none; }
.results-table .me-row { background: var(--accent-soft); }
.results-table .dimmed-row { opacity: 0.5; }
.rating-change { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.rating-change.positive { color: var(--green); }
.rating-change.negative { color: var(--accent); }
.xp-earned { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--purple); }
.results-actions { display: flex; flex-direction: column; gap: 8px; }
.results-actions .btn { width: 100%; }

/* ---- Leaderboard ---- */
.leaderboard-container { max-width: 650px; margin: 0 auto; }
.leaderboard-container h2 { margin-bottom: 12px; font-size: 18px; }
.leaderboard-list { display: flex; flex-direction: column; gap: 4px; }
.lb-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
  min-height: 48px;
}
.lb-item:active { background: var(--bg-2); }
.lb-item.me { border-color: var(--accent); background: var(--accent-soft); }
.lb-rank { font-weight: 800; font-size: 15px; min-width: 24px; text-align: center; color: var(--text-3); }
.lb-rank.rank-1 { color: var(--yellow); }
.lb-rank.rank-2 { color: var(--tier-silver); }
.lb-rank.rank-3 { color: var(--tier-bronze); }
.lb-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; font-size: 12px; flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-stats { font-size: 11px; color: var(--text-3); display: flex; gap: 8px; margin-top: 1px; }
.lb-value { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px; text-align: right; flex-shrink: 0; }

/* ---- Season ---- */
.season-container { max-width: 650px; margin: 0 auto; }
.season-header { margin-bottom: 16px; }
.season-header h2 { font-size: 18px; }
.season-info {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px;
}
.season-stat {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.season-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; display: block; }
.season-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ---- Profile ---- */
.profile-container { max-width: 650px; margin: 0 auto; }
.profile-header {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px;
  background: var(--bg-1); border-radius: var(--radius-lg);
  border: 1px solid var(--border); margin-bottom: 12px;
}
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: white; border: 2px solid; flex-shrink: 0;
}
.profile-details { flex: 1; min-width: 0; }
.profile-name { font-size: 18px; font-weight: 800; }
.profile-username { color: var(--text-3); font-size: 13px; }
.profile-bio { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.profile-tier-rating { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.profile-rating-num { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; }
.profile-level { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--purple); font-weight: 600; }
.profile-social { display: flex; gap: 12px; margin-top: 5px; font-size: 12px; color: var(--text-2); }
.profile-social strong { color: var(--text-0); font-weight: 700; }
.profile-social span { cursor: pointer; }
.profile-social span:hover { color: var(--text-0); }
.profile-actions { display: flex; gap: 8px; margin-top: 8px; }
.profile-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 12px;
}
.profile-stat-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; text-align: center;
}
.profile-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; display: block; }
.profile-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.profile-tab-content { margin-top: 0; }
.profile-race-list { display: flex; flex-direction: column; gap: 4px; }
.profile-race-item {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  gap: 8px;
}
.profile-race-title { font-weight: 600; font-size: 13px; }
.profile-race-detail { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.profile-race-result { text-align: right; flex-shrink: 0; }
.profile-race-pos { font-weight: 700; font-size: 14px; }

/* ---- Race History Cards ---- */
.race-history-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.race-history-card:hover {
  transform: translateY(-1px);
  border-color: var(--text-3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.race-history-card.gold { border-left: 3px solid #ffd700; }
.race-history-card.silver { border-left: 3px solid #c0c0c0; }
.race-history-card.bronze { border-left: 3px solid #cd7f32; }
.race-history-pos {
  font-size: 18px; font-weight: 700; min-width: 36px; text-align: center;
  flex-shrink: 0; color: var(--text-2);
}
.race-history-pos.gold { color: #ffd700; }
.race-history-pos.silver { color: #c0c0c0; }
.race-history-pos.bronze { color: #cd7f32; }
.race-history-center { flex: 1; min-width: 0; }
.race-history-title {
  font-weight: 600; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.race-history-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font-size: 12px; color: var(--text-3); flex-wrap: wrap;
}
.race-history-meta .badge-sm {
  background: var(--bg-2); padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600;
}
.race-history-date { opacity: 0.6; }
.race-history-rating {
  font-weight: 700; font-size: 14px; flex-shrink: 0; min-width: 40px; text-align: right;
}

/* ---- Achievements ---- */
.achievements-grid { display: flex; flex-direction: column; gap: 6px; }
.achievement-card {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); transition: var(--transition);
}
.achievement-card.locked { opacity: 0.4; }
.achievement-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--bg-3); flex-shrink: 0;
}
.achievement-info { flex: 1; min-width: 0; }
.achievement-name { font-weight: 700; font-size: 13px; }
.achievement-desc { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* ---- Toast ---- */
#toast-container { position: fixed; bottom: calc(68px + var(--sab)); left: 12px; right: 12px; z-index: 500; display: flex; flex-direction: column; gap: 6px; }
.toast {
  padding: 12px 16px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow);
  animation: toastIn 200ms ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--accent); }
.toast.info { border-left: 3px solid var(--blue); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---- History Page ---- */
.history-container { max-width: 650px; margin: 0 auto; }
.history-container h2 { font-size: 18px; }

.history-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.history-stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.history-stat-card .stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-0);
  font-family: 'JetBrains Mono', monospace;
}

.history-stat-card .stat-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.history-item:active { background: var(--bg-2); }

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.history-item-name {
  font-weight: 600;
  color: var(--text-0);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}

.history-item-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.history-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.history-stat .value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
}

.history-stat .label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-item-extra {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-3);
  flex-wrap: wrap;
}

.history-item-extra span {
  display: flex;
  align-items: center;
  gap: 3px;
}

#history-load-more {
  width: 100%;
  margin-top: 8px;
}

.history-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3);
}

.history-empty .connect-btn {
  margin-top: 12px;
}

/* ---- Race Section Headers (Active / Upcoming split) ---- */
.race-section {
  margin-bottom: 1.5rem;
}
.race-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 0.75rem;
  padding-left: 2px;
}
.race-section-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ---- Clickable History Items ---- */
.history-item-clickable {
  cursor: pointer;
  position: relative;
  transition: background 0.15s, transform 0.1s;
}
.history-item-clickable:hover {
  background: var(--bg-2);
  transform: translateX(2px);
}
.history-item-clickable:active {
  transform: translateX(0);
}
.history-item-arrow {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 1.2rem;
  font-weight: 300;
}

/* ---- Community Race Banner ---- */
.community-race-banner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 16px;
  background: linear-gradient(135deg, var(--bg-1), var(--accent-soft));
  border: 1px solid var(--accent); border-radius: var(--radius-lg);
  margin-bottom: 14px; position: relative; overflow: hidden;
}
.community-race-banner::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}
.community-race-info { flex: 1; z-index: 1; }
.community-race-title { font-size: 16px; font-weight: 800; margin-top: 4px; }
.community-race-subtitle { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.community-race-countdown { text-align: center; z-index: 1; }
.countdown-digits { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
.countdown-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }
.community-race-banner .btn { z-index: 1; width: 100%; }

/* ---- Official Badge & Race Card ---- */
.badge-official { background: linear-gradient(135deg, var(--accent-soft), rgba(249,115,22,0.15)); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); font-weight: 700; letter-spacing: 0.5px; }
.race-card.official-race { border-color: rgba(249,115,22,0.4); }
.race-card.official-race::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--orange), var(--accent)); border-radius: var(--radius) var(--radius) 0 0; }

/* ---- Dashboard Stats Bar ---- */
.dashboard-stats-bar { display: flex; gap: 12px; margin-bottom: 14px; padding: 10px 12px; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); flex-wrap: wrap; justify-content: center; }
.dash-stat { text-align: center; }
.dash-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; display: block; }
.dash-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }
.rating-chip { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 4px; }
.rating-chip.positive { color: var(--green); background: var(--green-soft); }
.rating-chip.negative { color: var(--accent); background: var(--accent-soft); }

/* ---- Enhanced Results ---- */
.results-personal { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; text-align: center; }
.results-personal h3 { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.personal-stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.personal-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; display: block; }
.personal-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ---- Rating Change Animation ---- */
.rating-change-display { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.rating-change-visual { display: flex; align-items: center; justify-content: center; gap: 12px; font-family: 'JetBrains Mono', monospace; }
.rating-change-visual.animate-in { animation: fadeSlideUp 0.6s ease-out; }
.rating-before { font-size: 16px; color: var(--text-3); }
.rating-arrow { font-size: 20px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-sm); }
.rating-arrow.positive { color: var(--green); background: var(--green-soft); }
.rating-arrow.negative { color: var(--accent); background: var(--accent-soft); }
.rating-after { font-size: 22px; font-weight: 800; }
.rating-after.positive { color: var(--green); }
.rating-after.negative { color: var(--accent); }
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Achievement Toast ---- */
.achievement-toast { display: flex !important; align-items: center; gap: 10px; padding: 12px 14px !important; background: linear-gradient(135deg, var(--bg-3), rgba(234,179,8,0.08)) !important; border: 1px solid var(--yellow) !important; border-left: 4px solid var(--yellow) !important; animation: achievementPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.ach-toast-icon { font-size: 24px; flex-shrink: 0; }
.ach-toast-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--yellow); font-weight: 700; }
.ach-toast-name { font-size: 13px; font-weight: 700; margin-top: 2px; }
.ach-toast-desc { font-size: 11px; color: var(--text-2); margin-top: 1px; }
@keyframes achievementPop { 0% { opacity: 0; transform: translateY(20px) scale(0.8); } 60% { transform: translateY(-3px) scale(1.02); } 100% { opacity: 1; transform: translateY(0) scale(1); } }

/* ---- Pulse animation ---- */
.btn-pulse { animation: btnPulse 1.5s ease-in-out infinite; }
@keyframes btnPulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); } 50% { box-shadow: 0 0 0 8px transparent; } }

/* ---- PB Message ---- */
.pb-message { margin-top: 12px; padding: 10px 16px; background: var(--green-soft); border: 1px solid var(--green); border-radius: var(--radius-sm); color: var(--green); font-weight: 600; font-size: 13px; }

/* Warmup Timer */
.warmup-timer-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
  padding: 8px 0;
}

/* Warmup Status Badge */
.badge-warmup {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Warmup Announcement Overlay */
.warmup-announcement {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 32px;
  font-weight: 900;
  color: white;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
  text-shadow: 0 0 40px rgba(0,0,0,0.8);
  letter-spacing: 2px;
  padding: 0 20px;
  width: 100%;
}

.warmup-announcement.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.warmup-announcement.milestone {
  color: var(--text-1);
  font-size: 28px;
}

.warmup-announcement.urgent {
  color: var(--orange);
  font-size: 36px;
  text-shadow: 0 0 30px rgba(249, 115, 22, 0.5);
}

.warmup-announcement.final {
  color: var(--accent);
  font-size: 48px;
  text-shadow: 0 0 40px rgba(239, 68, 68, 0.6);
  animation: announcePulse 0.5s ease-in-out infinite alternate;
}

@keyframes announcePulse {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.05); }
}

/* Signed Up Button */
.btn-signed-up {
  background: rgba(34, 197, 94, 0.1) !important;
  color: var(--green) !important;
  border: 1px solid rgba(34, 197, 94, 0.3) !important;
}

/* Cooldown Indicator */
.cooldown-active {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: var(--radius);
  margin-bottom: 12px;
  color: #60a5fa;
  font-weight: 600;
  font-size: 13px;
}

.cooldown-dot {
  width: 10px;
  height: 10px;
  background: #60a5fa;
  border-radius: 50%;
  animation: cooldownPulse 1.5s ease-in-out infinite;
}

@keyframes cooldownPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Segment Stats (Warmup / Race / Cooldown) */
.segment-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0;
}

.segment {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.warmup-segment { border-top: 3px solid var(--orange); }
.race-segment { border-top: 3px solid var(--green); }
.cooldown-segment { border-top: 3px solid #60a5fa; }

.segment-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.segment-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 3px;
}

.segment-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-3);
}

/* ---- Lobby Countdowns ---- */
.lobby-countdowns {
  display: flex;
  gap: 10px;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.countdown-item {
  text-align: center;
  flex: 1;
}

.countdown-label-text {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 2px;
}

.countdown-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.countdown-item.active-status .countdown-value {
  color: var(--green);
  font-size: 14px;
}

.countdown-item.elapsed .countdown-value {
  color: var(--text-2);
}

/* ---- Active Race Banner ---- */
.active-race-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  padding-top: calc(6px + var(--sat));
  background: linear-gradient(135deg, var(--accent), #dc2626);
  color: white;
  font-weight: 600;
  font-size: 12px;
  animation: slideDown 0.3s ease-out;
  min-height: 36px;
}

.active-race-banner.urgent {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  animation: slideDown 0.3s ease-out, urgentPulse 1s ease-in-out infinite;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes urgentPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

body.has-active-banner #navbar {
  top: calc(36px + var(--sat));
}

body.has-active-banner main {
  padding-top: calc(36px + var(--sat));
}

/* Hide bottom tabs during race/lobby */
.page-race.active ~ #bottom-tabs,
body.in-race .bottom-tabs { display: none; }

/* When race page is active, remove bottom padding */
body.in-race { padding-bottom: 0; }

/* ============================================
   DESKTOP ENHANCEMENTS (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
  body { padding-bottom: 0; } /* No bottom tabs on desktop */

  #navbar { padding: 0 20px; height: 56px; }
  .nav-left { gap: 28px; }
  .logo-mark { width: 28px; height: 28px; font-size: 15px; }
  .logo-text { font-size: 17px; }
  .nav-links { display: flex; gap: 2px; }
  .nav-link {
    padding: 6px 14px; border-radius: var(--radius-full);
    color: var(--text-2); cursor: pointer; font-weight: 500;
    font-size: 13px; transition: var(--transition); text-decoration: none;
  }
  .nav-link:hover { color: var(--text-0); background: var(--bg-3); }
  .nav-link.active { color: var(--text-0); background: var(--bg-3); }
  .nav-right { gap: 8px; }
  .nav-avatar { width: 28px; height: 28px; font-size: 11px; }
  .nav-name { font-size: 13px; }
  .nav-rating { font-size: 11px; }

  /* Hide bottom tabs on desktop */
  .bottom-tabs { display: none !important; }

  /* Pages */
  .page { padding: 20px; }
  .section-header h2 { font-size: 22px; }

  /* Race grid */
  .race-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
  .race-card:hover { border-color: var(--border-light); background: var(--bg-2); transform: translateY(-1px); box-shadow: var(--shadow); }

  /* Lobby two-column */
  .lobby-content { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .lobby-info h2 { font-size: 18px; }
  .lobby-action-area .btn { width: auto; }
  .lobby-action-area { margin-bottom: 16px; }
  .chat-messages { min-height: 180px; max-height: 350px; }

  /* Race view */
  .race-view { height: calc(100vh - 96px); }
  .race-header-bar { padding: 10px 16px; border-radius: var(--radius); margin: 10px 10px 0; border: 1px solid var(--border); }
  .timer-value { font-size: 24px; }
  .position-value { font-size: 24px; }
  .race-timer, .race-position { min-width: 90px; }
  .timer-label, .position-label { font-size: 10px; letter-spacing: 1px; }

  .race-my-stats-bar {
    margin: 0 10px; padding: 10px 16px;
    border: 1px solid var(--border); border-top: none;
  }
  .race-my-stats-bar .stat-value { font-size: 18px; }
  .race-my-stats-bar .stat-label { font-size: 10px; }

  .race-progress-bar { margin: 0 10px; height: 36px; border-radius: var(--radius-full); border: 1px solid var(--border); }

  .race-body { display: grid; grid-template-columns: 1fr 280px; gap: 10px; padding: 10px; }
  .race-map { border-radius: var(--radius); border: 1px solid var(--border); }
  .race-standings { border-radius: var(--radius); border: 1px solid var(--border); border-top: 1px solid var(--border); max-height: none; padding: 14px; }
  .race-standings h4 { font-size: 13px; margin-bottom: 10px; }

  /* Results */
  .results-header h2 { font-size: 28px; }
  .podium { gap: 12px; }
  .podium-avatar { width: 48px; height: 48px; font-size: 18px; }
  .podium-1 .podium-avatar { width: 56px; height: 56px; }
  .podium-stand { padding: 10px 20px; min-width: 90px; }
  .podium-1 .podium-stand { height: 100px; }
  .podium-2 .podium-stand { height: 75px; }
  .podium-3 .podium-stand { height: 55px; }
  .results-actions { flex-direction: row; justify-content: center; }
  .results-actions .btn { width: auto; }

  /* Profile */
  .profile-stats { grid-template-columns: repeat(4, 1fr); }
  .profile-header { padding: 24px; gap: 20px; }
  .profile-avatar { width: 68px; height: 68px; font-size: 24px; }
  .profile-name { font-size: 20px; }

  /* Personal stats */
  .personal-stats-grid { grid-template-columns: repeat(4, 1fr); }

  /* Achievements grid */
  .achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }

  /* History */
  .history-summary { grid-template-columns: repeat(4, 1fr); }
  .history-item-stats { grid-template-columns: repeat(4, 1fr); }

  /* Season */
  .season-info { grid-template-columns: repeat(3, 1fr); }

  /* Community race banner */
  .community-race-banner { flex-direction: row; text-align: left; gap: 20px; padding: 20px 24px; }
  .community-race-banner .btn { width: auto; }
  .countdown-digits { font-size: 32px; }

  /* Segment stats */
  .segment-stats { grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

  /* Lobby countdowns */
  .lobby-countdowns { gap: 20px; padding: 16px; }
  .countdown-value { font-size: 28px; }

  /* Modals */
  .modal { align-items: center; }
  .modal-content { border-radius: var(--radius-lg); padding: 24px; }

  /* Slide panel */
  .slide-panel { width: 380px; max-width: 380px; }

  /* Toast */
  #toast-container { bottom: 20px; left: auto; right: 20px; max-width: 320px; }

}

/* ---- Pricing Page ---- */
.pricing-container { max-width: 760px; margin: 0 auto; padding: 16px; }
.pricing-header { text-align: center; margin-bottom: 24px; }
.pricing-header h1 { font-size: 24px; font-weight: 900; letter-spacing: -0.5px; }

.login-plans-link { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-3); }
.login-plans-link a { color: var(--accent); cursor: pointer; text-decoration: none; }
.login-plans-link a:hover { text-decoration: underline; }

.billing-toggle {
  display: flex; gap: 2px; padding: 3px; background: var(--bg-2);
  border-radius: var(--radius); margin: 0 auto 24px; width: fit-content;
}
.toggle-btn {
  padding: 8px 20px; border: none; background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
  font-family: inherit;
}
.toggle-btn.active { background: var(--bg-4); color: var(--text-0); }
.save-badge {
  display: inline-block; padding: 1px 6px; background: var(--green-soft);
  color: var(--green); border-radius: var(--radius-full); font-size: 10px;
  font-weight: 700; margin-left: 4px;
}

.pricing-cards { display: flex; flex-direction: column; gap: 16px; }
.pricing-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; position: relative;
}
.pricing-card-pro { border-color: var(--accent); }
.pricing-card-pro::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--accent); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.popular-badge {
  position: absolute; top: -10px; right: 16px;
  background: var(--accent); color: white; padding: 2px 10px;
  border-radius: var(--radius-full); font-size: 11px; font-weight: 700;
}
.pricing-card-header { margin-bottom: 20px; }
.pricing-card-header h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.pricing-price { display: flex; align-items: baseline; gap: 2px; margin-bottom: 4px; }
.price-amount { font-size: 36px; font-weight: 900; letter-spacing: -1px; }
.price-period { font-size: 14px; color: var(--text-3); }
.pricing-desc { font-size: 13px; color: var(--text-2); }

.pricing-features { list-style: none; margin-bottom: 20px; }
.pricing-features li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 13px; color: var(--text-1);
}
.feature-excluded { color: var(--text-3); }
.feat-check { color: var(--green); font-weight: 700; font-size: 14px; width: 18px; text-align: center; }
.feat-x { color: var(--text-3); font-size: 14px; width: 18px; text-align: center; }

.pricing-consent {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11px; color: var(--text-3); margin-bottom: 12px; cursor: pointer; line-height: 1.4;
}
.pricing-consent input { margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.pricing-consent a { color: var(--accent); }
.pricing-cta { width: 100%; }
.pricing-footer {
  text-align: center; font-size: 12px; color: var(--text-3);
  margin-top: 24px;
}

@media (min-width: 768px) {
  .pricing-cards { flex-direction: row; max-width: 700px; margin: 0 auto; }
  .pricing-card { flex: 1; }
}

/* ============================================
   LARGE DESKTOP (min-width: 1024px)
   ============================================ */
@media (min-width: 1024px) {
  .page { max-width: 1100px; }
  .login-brand h1 { font-size: 32px; }
  .community-race-title { font-size: 18px; }
}

/* ============================================
   WELCOME CARD (New Users)
   ============================================ */
.welcome-card {
  background: linear-gradient(135deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 12px;
}
.welcome-card h2 { font-size: 20px; margin-bottom: 4px; }
.welcome-card > p { color: var(--text-2); font-size: 13px; margin-bottom: 16px; }
.welcome-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.welcome-step {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 13px; color: var(--text-1);
}
.welcome-step-num {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.welcome-step strong { color: var(--text-0); }

/* ============================================
   FREE RACE COUNTER
   ============================================ */
.free-race-counter {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; margin: 0 12px 8px;
  background: var(--bg-2); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-2);
}
.free-race-link { color: var(--accent); cursor: pointer; font-weight: 600; }

/* ============================================
   QUICK RACE BUTTON
   ============================================ */
.btn-accent {
  background: var(--accent); color: #fff;
  border: none; padding: 8px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: background var(--transition);
}
.btn-accent:hover { background: var(--accent-hover); }

/* ============================================
   CHALLENGES PAGE
   ============================================ */
.challenges-container { padding: 16px; }
.challenges-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.challenge-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.challenge-card.completed { opacity: 0.7; border-color: var(--green); }
.challenge-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.challenge-title { font-weight: 600; font-size: 15px; }
.challenge-desc { color: var(--text-2); font-size: 12px; margin-bottom: 10px; }
.challenge-progress-bar {
  height: 6px; background: var(--bg-4); border-radius: 3px;
  overflow: hidden; margin-bottom: 8px;
}
.challenge-progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width 0.3s ease;
}
.challenge-footer {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
}
.challenge-reward { color: var(--green); font-weight: 600; }
.challenge-meta {
  display: flex; gap: 12px; margin-top: 6px;
  font-size: 11px; color: var(--text-3);
}

/* ============================================
   STORE PAGE
   ============================================ */
.store-container { padding: 16px; }
.store-header { display: flex; justify-content: space-between; align-items: center; }
.store-balance {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-3); padding: 6px 12px; border-radius: var(--radius-full);
  font-weight: 700; font-size: 14px; color: var(--yellow);
}
.store-tabs { display: flex; gap: 4px; margin: 12px 0; }
.store-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-top: 8px;
}
.store-item {
  background: var(--bg-2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 6px;
}
.store-item-header { display: flex; justify-content: space-between; width: 100%; }
.store-item-rarity { font-size: 9px; font-weight: 700; letter-spacing: 0.05em; }
.store-item-icon { font-size: 32px; margin: 4px 0; }
.store-item-name { font-weight: 600; font-size: 13px; }
.store-item-desc { font-size: 11px; color: var(--text-2); }
.store-item-action { margin-top: 8px; }
.btn-disabled { opacity: 0.5; cursor: not-allowed; }

/* Store inventory section */
.store-section-title {
  font-size: 15px; font-weight: 700; margin: 20px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.inventory-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.inventory-item {
  background: var(--bg-2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 4px; cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.inventory-item:hover { transform: translateY(-2px); }
.inventory-item.equipped { border-color: var(--accent); }
.inventory-item .item-icon { font-size: 28px; }
.inventory-item .item-name { font-size: 12px; font-weight: 600; }
.inventory-item .item-status { font-size: 10px; color: var(--text-3); }
.inventory-item.equipped .item-status { color: var(--accent); font-weight: 600; }

/* Avatar preview card */
.avatar-preview-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; margin-bottom: 16px;
}
.avatar-preview-card .preview-label {
  font-size: 11px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 600;
}
.avatar-preview-card .preview-name {
  font-weight: 600; font-size: 14px;
}
.avatar-preview-card .preview-equipped {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
}
.avatar-preview-card .equipped-slot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.equipped-slot .slot-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; }
.equipped-slot .slot-value { font-size: 12px; font-weight: 600; }
.equipped-slot .slot-none { font-size: 12px; color: var(--text-3); font-style: italic; }

/* ============================================
   AVATAR FRAMES
   ============================================ */
.avatar-wrapper {
  position: relative; display: inline-flex;
}
.avatar-frame {
  position: absolute; inset: -3px;
  border-radius: 50%; pointer-events: none;
}
.avatar-frame-bronze {
  border: 2px solid #cd7f32;
  box-shadow: 0 0 6px rgba(205, 127, 50, 0.5);
  animation: bronze-pulse 4s ease-in-out infinite;
}
@keyframes bronze-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(205, 127, 50, 0.5); }
  50% { box-shadow: 0 0 10px rgba(205, 127, 50, 0.7), 0 0 3px rgba(255, 200, 100, 0.3); }
}
.avatar-frame-silver {
  border: 2.5px solid #c0c0c0;
  box-shadow: 0 0 6px rgba(192, 192, 192, 0.6);
  animation: silver-shimmer 3s ease-in-out infinite;
}
@keyframes silver-shimmer {
  0%, 100% { box-shadow: 0 0 6px rgba(192, 192, 192, 0.6); border-color: #c0c0c0; }
  50% { box-shadow: 0 0 12px rgba(220, 220, 255, 0.8), 0 0 4px rgba(255, 255, 255, 0.4); border-color: #d8d8e8; }
}
.avatar-frame-gold {
  border: 3px solid #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
  animation: gold-pulse 3s ease-in-out infinite;
}
@keyframes gold-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.6); }
  50% { box-shadow: 0 0 16px rgba(255, 215, 0, 0.9), 0 0 6px rgba(255, 255, 100, 0.4); }
}
.avatar-frame-diamond {
  border: 3px solid #b9f2ff;
  box-shadow: 0 0 12px rgba(185, 242, 255, 0.7), inset 0 0 4px rgba(185, 242, 255, 0.2);
  animation: diamond-shimmer 2s ease-in-out infinite;
}
@keyframes diamond-shimmer {
  0% { box-shadow: 0 0 12px rgba(185, 242, 255, 0.7); border-color: #b9f2ff; }
  25% { box-shadow: 0 0 18px rgba(200, 180, 255, 0.9), 0 0 6px rgba(255, 255, 255, 0.5); border-color: #c8b4ff; }
  50% { box-shadow: 0 0 20px rgba(185, 242, 255, 1), 0 0 8px rgba(255, 255, 255, 0.6); border-color: #e0f8ff; }
  75% { box-shadow: 0 0 18px rgba(180, 255, 220, 0.9), 0 0 6px rgba(255, 255, 255, 0.5); border-color: #b4ffdc; }
  100% { box-shadow: 0 0 12px rgba(185, 242, 255, 0.7); border-color: #b9f2ff; }
}
.avatar-frame-fire {
  border: 3px solid #ff6b35;
  box-shadow: 0 0 10px rgba(255, 107, 53, 0.7);
  animation: fire-glow 1s ease-in-out infinite;
}
@keyframes fire-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 107, 53, 0.7); border-color: #ff6b35; }
  25% { box-shadow: 0 0 14px rgba(255, 50, 0, 0.8), 0 0 6px rgba(255, 200, 0, 0.5); border-color: #ff3200; }
  50% { box-shadow: 0 0 18px rgba(255, 69, 0, 0.9), 0 0 8px rgba(255, 220, 0, 0.6); border-color: #ff4500; }
  75% { box-shadow: 0 0 12px rgba(255, 140, 0, 0.8), 0 0 5px rgba(255, 80, 0, 0.5); border-color: #ff8c00; }
}

/* Frame sizes for different avatar contexts */
.nav-avatar .avatar-frame { inset: -2px; }
.profile-avatar .avatar-frame { inset: -5px; }
.podium-avatar .avatar-frame { inset: -4px; }

/* Name glow effects for premium frame owners */
.name-glow-gold { text-shadow: 0 0 6px rgba(255, 215, 0, 0.5); }
.name-glow-diamond { text-shadow: 0 0 8px rgba(185, 242, 255, 0.6); }
.name-glow-fire { text-shadow: 0 0 8px rgba(255, 107, 53, 0.5); }

/* Cosmetic showcase badges on profiles */
.cosmetic-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.cosmetic-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.1);
}
.cosmetic-badge-common { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }
.cosmetic-badge-uncommon { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.cosmetic-badge-rare { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.cosmetic-badge-epic { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.cosmetic-badge-legendary { background: rgba(255, 215, 0, 0.15); color: #ffd700; }

/* ============================================
   CELEBRATION ANIMATIONS
   ============================================ */
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes firework-spark {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* Coin icons */
.coin-icon { font-weight: 800; color: var(--yellow); font-size: 16px; }
.coin-icon-sm { font-weight: 800; color: var(--yellow); font-size: 12px; margin-right: 2px; }
.nav-coins {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600; color: var(--yellow);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--bg-3);
}
.nav-coins:hover { background: var(--bg-4); }

/* ============================================
   FIRST-RACE TIPS
   ============================================ */
.tips-list { display: flex; flex-direction: column; gap: 12px; }
.tip-item { display: flex; gap: 10px; font-size: 13px; color: var(--text-1); }
.tip-icon { font-size: 20px; flex-shrink: 0; }
.tip-item strong { color: var(--text-0); }

/* ============================================
   GPS SIGNAL INDICATOR
   ============================================ */
.gps-indicator {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; margin-left: 8px;
}
.gps-good { background: var(--green); box-shadow: 0 0 6px var(--green); }
.gps-ok { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.gps-poor { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: gps-blink 1s infinite; }
@keyframes gps-blink { 50% { opacity: 0.4; } }

/* ============================================
   CONNECTION BANNER
   ============================================ */
.connection-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  padding: 6px 16px; text-align: center;
  font-size: 12px; font-weight: 600;
  transition: all 0.3s ease;
}
.connection-banner.disconnected { background: var(--accent); color: #fff; }
.connection-banner.reconnected { background: var(--green); color: #fff; }
.connection-banner.hidden { transform: translateY(-100%); }

/* ============================================
   RESULTS XP / COINS
   ============================================ */
.results-xp-coins {
  display: flex; justify-content: center; gap: 16px;
  margin: 12px 0;
}
.xp-coin-item {
  font-size: 18px; font-weight: 700;
  padding: 8px 16px; border-radius: var(--radius);
}
.xp-item { background: var(--blue-soft); color: var(--blue); }
.coin-item { background: var(--yellow-soft); color: var(--yellow); display: flex; align-items: center; gap: 4px; }

/* ============================================
   WHAT'S NEXT CARD
   ============================================ */
.whats-next-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin: 16px 0;
}
.whats-next-card h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-2); }
.wn-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-1);
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.wn-item:last-child { border-bottom: none; }
.wn-icon { font-size: 16px; flex-shrink: 0; }
.wn-clickable { cursor: pointer; border-radius: var(--radius-sm); }
.wn-clickable:hover { background: var(--bg-3); }

/* ============================================
   LEVEL UP MODAL
   ============================================ */
.level-up-animation {
  padding: 20px 0;
}
.level-up-number {
  font-size: 48px; font-weight: 900;
  color: var(--yellow);
  animation: level-pulse 0.6s ease-out;
}
.level-up-text {
  font-size: 20px; font-weight: 700; color: var(--text-0);
  margin-top: 4px;
}
.level-up-reward {
  color: var(--yellow); font-weight: 600; font-size: 14px;
}
@keyframes level-pulse {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   ACHIEVEMENT PROGRESS
   ============================================ */
.achievement-progress-section {
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.achievement-progress-item {
  padding: 6px 0;
}
.achievement-progress-info {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-1);
}
.achievement-progress-pct { color: var(--text-2); }

/* ============================================
   CATCHER CAR WARNING
   ============================================ */
.catcher-warning {
  position: absolute; top: -20px; right: 0;
  font-size: 11px; font-weight: 700;
  color: var(--accent); animation: catcher-pulse 0.8s infinite;
}
@keyframes catcher-pulse {
  50% { opacity: 0.5; }
}

/* ============================================
   BOT BADGE (enhanced)
   ============================================ */
.bot-badge {
  display: inline-block;
  font-size: 9px; font-weight: 700;
  background: var(--bg-4); color: var(--text-3);
  padding: 1px 4px; border-radius: 3px;
  margin-left: 4px; vertical-align: middle;
  letter-spacing: 0.03em;
}
