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

:root {
  /* Ink-violet base, not flat black - a night-race floodlit feel that
     still leaves room for 20 procedurally-generated team colors to read
     clearly against it. */
  --bg: #120D1F;
  --bg-panel: #1D1730;
  --bg-panel-2: #271F42;
  --border: #392C57;

  --text: #F3EFFF;
  --text-dim: #A79BC9;

  /* Tabloid/broadcast accent trio - loud on purpose. */
  --accent: #FF3D8A;     /* hot pink - primary CTA, "breaking", live */
  --accent-2: #35E0C4;   /* track teal - success/positive/green-flag */
  --gold: #FFD23F;       /* caution yellow - money, odds, warnings */
  --flag-red: #FF5266;   /* red-flag - loss/DNF/danger, distinct from hot pink */
  --silver: #C9D2DE;
  --bronze: #D38B5D;
  --bg-input: #150F26;

  --font-display: 'Bungee', 'Arial Black', sans-serif;
  --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', Consolas, monospace;
  font-family: var(--font-body);
}

/* ==========================================================================
   Alternate color themes - same type system, shapes, and layout throughout;
   only the palette changes. Applied via a data-theme attribute on <html>,
   toggled by the little swatch picker (see .theme-switcher below).
   ========================================================================== */

/* "Checkered Riot" - classic livery pairing (safety orange + racing blue)
   on a warm charcoal base. Closer to real motorsport color language than
   the default's neon-tabloid energy. */
[data-theme="checkered"] {
  --bg: #161213;
  --bg-panel: #221C1D;
  --bg-panel-2: #2E2527;
  --border: #4A3A3A;
  --text: #FBEFE8;
  --text-dim: #B89C90;
  --accent: #FF6B1A;
  --accent-2: #3D8BFF;
  --gold: #FFE156;
  --flag-red: #FF3B3B;
  --bg-input: #120E0F;
}

/* "Neon Paddock" - electric violet + lime on near-black blue. The most
   unhinged of the four - leans hardest into the Chaos-archetype energy. */
[data-theme="neon"] {
  --bg: #0A0E1A;
  --bg-panel: #131A2E;
  --bg-panel-2: #1C2540;
  --border: #2E3A5C;
  --text: #EAF0FF;
  --text-dim: #8B9AC2;
  --accent: #B24BFF;
  --accent-2: #C6FF3D;
  --gold: #FFB84D;
  --flag-red: #FF3D6E;
  --bg-input: #0D1220;
}

/* "Tabloid Ink" - vintage newsprint: masthead red + mustard gold on warm
   dark brown. The most grounded/least neon of the four. */
[data-theme="tabloid"] {
  --bg: #1A1410;
  --bg-panel: #241C16;
  --bg-panel-2: #302520;
  --border: #4A3A2E;
  --text: #F7ECDD;
  --text-dim: #B8A48E;
  --accent: #E63946;
  --accent-2: #6FCF97;
  --gold: #F4A62A;
  --flag-red: #8B1E2B;
  --bg-input: #140F0C;
}

* { box-sizing: border-box; }
html { overflow-x: clip; max-width: 100%; scrollbar-gutter: stable; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); overflow-x: clip; max-width: 100%; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.3px; }

.hidden { display: none !important; }
.muted { color: var(--text-dim); font-weight: 400; font-size: 0.85em; }
.loading-state {
  grid-column: 1 / -1; text-align: center; padding: 40px 20px; color: var(--text-dim);
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase;
  animation: loading-pulse 1.2s ease-in-out infinite;
}
@keyframes loading-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.9; } }

/* ---------------- Signature: angled broadcast-graphic panels ----------------
   The recurring visual device across the app - a diagonal cut on one
   corner, echoing F1 broadcast lower-thirds and livery graphics. Applied
   via clip-path so it needs no extra markup. Two sizes: -lg for hero
   panels/cards, -sm for compact chips/buttons where a full-size cut
   would eat too much into small content. */
.cut-corner {
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}
.cut-corner-sm {
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%);
}
.hazard-stripe {
  background: repeating-linear-gradient(135deg, var(--gold) 0 10px, #1a1428 10px 20px);
}

/* ---------------- Theme switcher (floating, self-contained) ---------------- */
.theme-switcher { position: fixed; left: 16px; bottom: 16px; z-index: 200; }
.theme-switcher-toggle {
  width: 42px; height: 42px; background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text); font-size: 18px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
.theme-switcher-panel {
  position: absolute; bottom: calc(100% + 8px); left: 0; background: var(--bg-panel);
  border: 1px solid var(--border); border-top: 3px solid var(--accent); padding: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.5); width: 168px;
}
.theme-switcher-panel.hidden { display: none; }
.theme-swatch-row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; cursor: pointer; }
.theme-swatch-row:hover { background: var(--bg-panel-2); }
.theme-swatch-row.active { background: var(--bg-panel-2); }
.theme-swatch-dots { display: flex; flex-shrink: 0; }
.theme-swatch-dots span { width: 12px; height: 12px; border-radius: 50%; margin-left: -4px; border: 1px solid rgba(0,0,0,0.3); }
.theme-swatch-dots span:first-child { margin-left: 0; }
.theme-swatch-label { font-size: 12.5px; color: var(--text); }

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, var(--gold) 8px 16px);
}
.brand { font-family: var(--font-display); font-size: 18px; letter-spacing: 0.5px; color: var(--accent); }
.tabs { display: flex; gap: 6px; }
.tab-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 9px 16px; cursor: pointer; font-size: 13.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px; font-family: var(--font-body);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
}
.tab-btn:hover { color: var(--text); background: var(--bg-panel-2); }
.tab-btn.active { background: var(--accent); color: #1a0a12; border-color: var(--accent); }
.tab-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--flag-red); margin-left: 6px; vertical-align: middle;
}

.tab-badge {
  margin-left: 5px; font-size: 9.5px; padding: 2px 6px; border-radius: 8px; font-weight: 800;
  vertical-align: middle; letter-spacing: 0.3px; text-transform: uppercase;
}
.tab-badge.hidden { display: none; }
.tab-badge.live { background: var(--accent); color: white; animation: badge-pulse 1.4s infinite; }
.tab-badge.betting { background: var(--gold); color: #241c00; }
@keyframes badge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.auth-area { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 14px; }

/* ---------------- Notifications ---------------- */
.notif-wrap { position: relative; }
.notif-bell { position: relative; font-size: 16px; padding: 8px 10px; }
.btn.notif-bell { clip-path: none; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: var(--flag-red); color: white;
  font-size: 10px; font-weight: 800; border-radius: 10px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--accent);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5); z-index: 50;
}
.notif-header { padding: 12px 14px; font-weight: 700; font-size: 13px; border-bottom: 1px solid var(--border); font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.5px; }
.notif-list { padding: 4px; }
.notif-item { padding: 10px 10px; font-size: 13px; line-height: 1.4; margin-bottom: 2px; }
.notif-item.unread { background: rgba(255,255,255,0.04); }
.notif-item.won { border-left: 3px solid var(--accent-2); }
.notif-item.lost { border-left: 3px solid var(--flag-red); }
.notif-item.fan { border-left: 3px solid var(--gold); }
.notif-item.triggered { border-left: 3px solid #ff8c42; }
.notif-item.admin { border-left: 3px solid #8fb2ff; }
.notif-item.streak { border-left: 3px solid var(--track-teal); }
.notif-item.sponsor-ended { border-left: 3px solid var(--silver); }
.notif-item .time { display: block; color: var(--text-dim); font-size: 11px; margin-top: 3px; }
.notif-empty { padding: 20px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ---------------- Colored bet status/payout ---------------- */
.status-won { color: var(--accent-2); font-weight: 700; }
.status-lost { color: var(--flag-red); font-weight: 700; }
.status-pending { color: var(--gold); font-weight: 700; }
.payout-positive { color: var(--accent-2); font-weight: 700; }
.payout-zero { color: var(--flag-red); }
.team-dot-inline { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.icon-img { width: 18px; height: 18px; vertical-align: -3px; object-fit: contain; }

/* ---------------- Leaderboard tab ---------------- */
.leaderboard-columns { grid-template-columns: repeat(3, 1fr); }
.leaderboard-columns > div, .standings-columns > div { min-width: 0; }
@media (max-width: 1000px) { .leaderboard-columns { grid-template-columns: 1fr; } }


.token-pill {
  background: linear-gradient(135deg, var(--bg-panel-2), var(--bg-panel)); border: 1px solid var(--gold);
  padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 13px; color: var(--gold);
  font-family: var(--font-mono);
}
.level-pill {
  background: linear-gradient(135deg, var(--bg-panel-2), var(--bg-panel)); border: 1px solid var(--accent-2);
  padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 13px; color: var(--accent-2);
  font-family: var(--font-mono); cursor: pointer;
}
.level-pill:hover { background: var(--bg-panel-2); }
.level-badge {
  display: inline-block; background: var(--bg-panel-2); border: 1px solid var(--accent-2);
  padding: 1px 6px; border-radius: 10px; font-weight: 700; font-size: 10px; color: var(--accent-2);
  font-family: var(--font-mono); vertical-align: middle;
}
.account-menu-wrap { position: relative; }
.account-menu-toggle { padding: 9px 11px; font-size: 12px; }
.account-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 130px;
  background: var(--bg-panel-2); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.account-menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  padding: 10px 14px; font-size: 13px; font-family: var(--font-body); cursor: pointer;
}
.account-menu-item:hover { background: var(--bg-panel); color: var(--accent); }

.level-progress-summary { margin-bottom: 16px; }
.level-progress-label { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.xp-bar-track { width: 100%; height: 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.level-rewards-track { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.level-reward-row {
  display: grid; grid-template-columns: 56px 70px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border); background: var(--bg-panel);
}
.level-reward-row.no-reward { opacity: 0.5; }
.level-reward-row.locked { opacity: 0.6; }
.level-reward-row.claimed, .level-reward-row.reached-unclaimed { border-color: var(--accent-2); }
.level-reward-num { font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
.level-reward-xp { font-size: 11px; }
.level-reward-icon { margin-right: 4px; }
.level-status-badge { font-size: 11px; font-weight: 700; white-space: nowrap; }
.level-status-badge.claimed, .level-status-badge.reached { color: var(--accent-2); }
.level-status-badge.locked { color: var(--text-dim); }
@media (max-width: 480px) {
  .level-reward-row { grid-template-columns: 46px 1fr auto; }
  .level-reward-xp { display: none; }
}

.btn {
  background: var(--accent); color: #1a0a12; border: none; padding: 9px 18px;
  cursor: pointer; font-weight: 700; font-size: 14px; font-family: var(--font-body);
  text-transform: uppercase; letter-spacing: 0.3px; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
}
.btn.secondary { background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text); }
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

/* ---------------- Layout ---------------- */
main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.race-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.race-header h1 { margin: 0 0 4px; font-size: 26px; }
.race-meta { color: var(--text-dim); font-size: 14px; font-family: var(--font-mono); }

.status-pill {
  display: inline-block; padding: 6px 16px; font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg-panel-2); border: 1px solid var(--border);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
.status-pill.betting { color: #1a1608; background: var(--gold); border-color: var(--gold); }
.status-pill.running { color: #06251f; background: var(--accent-2); border-color: var(--accent-2); animation: badge-pulse 1.4s infinite; }
.status-pill.finished { color: var(--text-dim); }
.countdown { text-align: right; font-size: 24px; font-weight: 700; margin-top: 6px; font-family: var(--font-mono); color: var(--gold); }
.lap-counter {
  position: absolute; bottom: 14px; right: 14px; z-index: 15;
  background: rgba(18,13,31,0.88); border: 1px solid var(--border);
  padding: 6px 12px; font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  color: var(--accent-2); letter-spacing: 0.5px;
}

.race-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.race-layout > * { min-width: 0; }
.track-wrap {
  position: relative; background: var(--bg-panel); border: 1px solid var(--border);
  padding: 10px; min-height: 420px;
}
#trackSvg { width: 100%; height: 420px; display: block; touch-action: none; }
#trackSvg.pannable { cursor: grab; }
#trackSvg.pannable:active { cursor: grabbing; }

.live-leaderboard { background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--accent); padding: 14px; max-height: 460px; overflow-y: auto; }
.live-leaderboard h3 { margin: 0 0 10px; font-size: 14px; color: var(--text); font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.5px; }
#liveLeaderboard { list-style: none; margin: 0; padding: 0; }
#liveLeaderboard li {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
#liveLeaderboard li .pos { width: 20px; color: var(--gold); font-weight: 700; font-family: var(--font-mono); }
#liveLeaderboard li .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
#liveLeaderboard li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#liveLeaderboard li .st { font-size: 11px; color: var(--text-dim); }
#liveLeaderboard li.my-bet-row { background: rgba(255,61,138,0.08); border-left: 2px solid var(--accent); padding-left: 2px; }
#liveLeaderboard li.my-sponsor-row { background: rgba(255,210,63,0.08); border-left: 2px solid var(--gold); padding-left: 2px; }

/* ---------------- Info box (tooltip) ---------------- */
.info-box {
  position: absolute; background: rgba(18,13,31,0.97); border: 1px solid var(--border); border-top: 2px solid var(--accent);
  padding: 12px 14px; font-size: 12.5px; width: 220px; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 30;
}
.info-box.pinned { pointer-events: auto; }
.info-box h4 { margin: 0 0 6px; font-size: 14px; font-family: var(--font-body); font-weight: 700; }
.info-box-header { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.info-box-header h4 { margin: 0; }
.info-box .team-tag { display: inline-block; font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.info-box .stat-row { display: flex; justify-content: space-between; margin: 2px 0; font-family: var(--font-mono); font-size: 12px; }
.info-box .stat-row span:first-child { color: var(--text-dim); font-family: var(--font-body); }
.stat-high { color: var(--accent-2); font-weight: 700; }
.stat-mid { color: var(--gold); font-weight: 700; }
.stat-low { color: var(--flag-red); font-weight: 700; }
.stat-buff { color: var(--accent-2); font-weight: 800; font-size: 0.85em; }
.info-box .close-x { position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--text-dim); }

/* ---------------- Betting panel ---------------- */
.betting-panel {
  margin-top: 20px; background: var(--bg-panel); border: 1px solid var(--border); padding: 18px;
  opacity: 1; transform: translateY(0); max-height: 3000px; overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, margin-top 0.3s ease, padding 0.3s ease;
}
.betting-panel.panel-hiding {
  opacity: 0; transform: translateY(14px); max-height: 0;
  margin-top: 0; padding-top: 0; padding-bottom: 0; border-width: 0;
}
.betting-panel h3 { margin: 0 0 14px; font-family: var(--font-display); font-size: 16px; font-weight: 400; }
.grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.grid-list > .grid-card { min-width: 0; }
.grid-card { background: var(--bg-panel-2); border: 1px solid var(--border); padding: 12px; min-width: 0; }
.grid-card .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.grid-card .swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.grid-card .dname { font-weight: 700; font-size: 14px; overflow-wrap: break-word; }
.grid-card .tname { color: var(--text-dim); font-size: 12px; overflow-wrap: break-word; }
.grid-card .odds-row { display: flex; gap: 8px; margin-top: 8px; }
.odds-btn {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  padding: 8px 6px; cursor: pointer; font-size: 12px; text-align: center; font-family: var(--font-body);
}
.odds-btn b { display: block; font-size: 15px; color: var(--accent-2); font-family: var(--font-mono); }
.odds-btn:hover { border-color: var(--accent-2); }
.odds-btn.selected { border-color: var(--accent); background: rgba(255,61,138,0.14); }
.odds-btn:disabled:not(.selected) { opacity: 0.5; cursor: not-allowed; }
.odds-btn:disabled:not(.selected):hover { border-color: var(--border); }

/* ---------------- Results panel ---------------- */

/* ---------------- Standings tab ---------------- */
.standings-header { display: flex; align-items: center; justify-content: space-between; }
.standings-header h1 { font-family: var(--font-display); }
.standings-columns { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; margin-top: 10px; }
.std-table { width: 100%; border-collapse: collapse; background: var(--bg-panel); border: 1px solid var(--border); }
.std-table th, .std-table td { padding: 8px 10px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.std-table th { color: var(--bg); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; background: var(--gold); font-weight: 700; }
.std-table tr:hover td { background: rgba(255,255,255,0.03); }

/* ---------------- Standings view toggle + Hall of Fame ---------------- */
.standings-view-toggle { display: flex; gap: 8px; }
.std-toggle-btn {
  background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 16px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: var(--font-body);
}
.std-toggle-btn:hover { border-color: var(--accent-2); color: var(--text); }
.std-toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #1a0a12; }

.hof-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0 36px; }
.hof-stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--gold); padding: 16px 12px; text-align: center; }
.hof-stat-num { font-family: var(--font-display); font-size: clamp(20px, 3vw, 28px); color: var(--gold); }
.hof-stat-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 6px; }

.hof-champions-title { font-family: var(--font-display); font-size: 18px; font-weight: 400; margin: 0 0 14px; }
.hof-champions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.hof-champion-card { background: var(--bg-panel); border: 1px solid var(--border); padding: 16px; }
.hof-champion-season { font-family: var(--font-mono); font-size: 12px; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.hof-champion-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.hof-champion-row:last-child { margin-bottom: 0; }
.hof-champion-icon { font-size: 22px; flex-shrink: 0; width: 28px; text-align: center; }
.hof-champion-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.hof-champion-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14.5px; }
.hof-champion-sub { font-size: 12px; margin-top: 2px; }

@media (max-width: 700px) {
  .hof-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
select { background: var(--bg-panel-2); color: var(--text); border: 1px solid var(--border); padding: 8px 10px; font-family: var(--font-body); font-size: 16px; }

/* ---------------- Modal ---------------- */
.modal { position: fixed; inset: 0; background: rgba(10,6,20,0.75); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--accent); padding: 24px; width: 320px; position: relative; }
#authModal .modal-card { padding-top: 36px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.modal-tabs button { flex: 1; background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text-dim); padding: 8px; cursor: pointer; font-weight: 700; font-family: var(--font-body); }
.modal-tabs button.active { color: var(--text); border-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--bg-input); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; font-size: 16px; font-family: var(--font-body);
}
.auth-form button[type=submit] { background: var(--accent); color: #1a0a12; border: none; padding: 10px; font-weight: 700; cursor: pointer; text-transform: uppercase; letter-spacing: 0.3px; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%); }
.form-error { color: var(--flag-red); font-size: 12.5px; min-height: 16px; }
.form-success { color: var(--track-teal); font-size: 12.5px; }
.auth-link { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--text-dim); text-decoration: underline; }
.auth-link:hover { color: var(--text); }

.verify-email-banner {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  background: rgba(255, 210, 63, 0.12); border-bottom: 1px solid var(--gold);
  color: var(--gold); font-size: 13px; padding: 8px 16px;
}
.ban-banner {
  display: flex; align-items: center; justify-content: center; text-align: center; gap: 6px; flex-wrap: wrap;
  background: rgba(255, 61, 61, 0.15); border-bottom: 1px solid var(--flag-red);
  color: var(--flag-red); font-size: 13px; padding: 10px 16px;
}
.banned-username { color: var(--flag-red); text-decoration: line-through; }
.injured-driver-name { color: var(--flag-red); font-weight: 700; }
.injured-status-banner {
  display: block; width: 100%; margin: 8px 0 4px; padding: 10px; box-sizing: border-box;
  text-align: center; font-size: 13.5px; font-weight: 700;
  color: var(--flag-red); background: rgba(255, 61, 61, 0.12); border: 1px solid var(--flag-red);
}
.time-chamber-driver-name { color: #B47EFF; font-weight: 700; }
.time-chamber-status-banner {
  display: block; width: 100%; margin: 8px 0 4px; padding: 10px; box-sizing: border-box;
  text-align: center; font-size: 13.5px; font-weight: 700;
  color: #B47EFF; background: rgba(180, 126, 255, 0.12); border: 1px solid #B47EFF;
}
.ill-driver-name { color: #E0A030; font-weight: 700; }
.ill-status-banner {
  display: block; width: 100%; margin: 8px 0 4px; padding: 10px; box-sizing: border-box;
  text-align: center; font-size: 13.5px; font-weight: 700;
  color: #E0A030; background: rgba(224, 160, 48, 0.12); border: 1px solid #E0A030;
}
.deceased-driver-name { color: var(--text-dim); font-weight: 700; font-style: italic; }
.deceased-status-banner {
  display: block; width: 100%; margin: 8px 0 4px; padding: 10px; box-sizing: border-box;
  text-align: center; font-size: 13.5px; font-weight: 700;
  color: var(--text-dim); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
}
.modal-close { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }

/* ---------------- Zoom controls ---------------- */
.zoom-controls { position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 4px; z-index: 15; }
.zoom-controls button {
  width: 30px; height: 30px; background: rgba(29,23,48,0.9); border: 1px solid var(--border);
  color: var(--text); font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1;
}
.zoom-controls button:hover { border-color: var(--accent-2); color: var(--accent-2); }
.zoom-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
.zoom-controls button:disabled:hover { border-color: var(--border); color: var(--text); }

/* ---------------- Clickable name links ---------------- */
.entity-link { color: inherit; text-decoration: none; cursor: pointer; border-bottom: 1px dotted currentColor; }
.entity-link:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }
.fan-mark { color: var(--gold); font-size: 0.9em; }

/* ---------------- Entity (driver/team) profile modal ---------------- */
.entity-card { width: 420px; max-width: 92vw; max-height: 84vh; overflow-y: auto; }
.entity-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.entity-header .swatch-lg { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; }
.entity-header h2 { margin: 0; font-size: 20px; font-family: var(--font-display); font-weight: 400; }
.entity-header .sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.driver-face { position: relative; width: 30px; height: 37px; flex-shrink: 0; }
.driver-face .face-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.driver-face-sm { width: 22px; height: 27px; }
.std-driver-cell { display: flex; align-items: center; gap: 8px; }
.entity-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 14px 0; }
.entity-stat { background: var(--bg-panel-2); border: 1px solid var(--border); padding: 8px 10px; }
.entity-stat .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.entity-stat .value { font-size: 16px; font-weight: 700; margin-top: 2px; font-family: var(--font-mono); }
.entity-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); font-family: var(--font-display); margin: 16px 0 6px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg-panel-2); border: 1px solid var(--border); padding: 4px 10px; font-size: 12.5px; }
.chip.like { border-color: rgba(53,224,196,0.4); }
.chip.dislike { border-color: rgba(255,82,102,0.4); }
.info-list { list-style: none; margin: 0; padding: 0; }
.info-list li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.info-list li span:first-child { color: var(--text-dim); }
.roster-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.roster-face-name { display: flex; align-items: center; gap: 8px; }

/* ---------------- Fan system ---------------- */
.fan-btn {
  display: block; width: 100%; margin: 12px 0 4px; padding: 10px; cursor: pointer;
  background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text); font-weight: 700; font-size: 13.5px;
}
.fan-btn:hover { border-color: var(--gold); color: var(--gold); }
.fan-btn.active { background: rgba(255,210,63,0.12); border-color: var(--gold); color: var(--gold); }
.fan-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.fan-btn:disabled:hover { border-color: var(--border); color: var(--text); }
.fan-login-hint { display: block; margin: 12px 0 4px; font-size: 12.5px; }
.value.fan-value { display: flex; align-items: center; gap: 6px; }
.profile-summary .card .value.fan-value { font-size: 13px; }
.fan-none { font-size: 14px; font-weight: 400; }
.season-finish-banner {
  display: block; width: 100%; margin: 12px 0 4px; padding: 10px; text-align: center;
  background: var(--bg-panel-2); border: 1px solid var(--border); font-weight: 700; font-size: 13.5px;
}
.season-finish-banner.champion { border-color: var(--gold); color: var(--gold); }
.season-finish-banner.second { border-color: var(--silver); color: var(--silver); }
.season-finish-banner.third { border-color: var(--bronze); color: var(--bronze); }

/* ---------------- In-race driver decal showcase ---------------- */
.driver-showcase {
  position: absolute; pointer-events: none; z-index: 25;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  opacity: 0; transition: opacity 0.4s ease;
}
.driver-showcase.visible { opacity: 1; }
.driver-showcase .driver-showcase-label {
  font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap;
  /* No background box behind this anymore, so it needs its own contrast
     against a busy track image - a strong dark text-shadow stands in
     for that instead of a solid backing panel. */
  text-shadow: 0 1px 2px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.95);
}
/* Small triangle pointing from the showcase toward whichever driver it's
   currently attached to - direction is set by positionDriverShowcase()
   based on which side of the driver it ended up placed on. */
.showcase-arrow { position: absolute; width: 0; height: 0; }
.showcase-arrow-down { left: 50%; bottom: -7px; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 7px solid var(--gold); }
.showcase-arrow-up { left: 50%; top: -7px; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 7px solid var(--gold); }
.showcase-arrow-left { top: 50%; left: -7px; transform: translateY(-50%); border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 7px solid var(--gold); }
.showcase-arrow-right { top: 50%; right: -7px; transform: translateY(-50%); border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 7px solid var(--gold); }

/* ---------------- Post-race podium overlay ---------------- */
.podium-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,7,18,0.85);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
}
.podium-overlay.visible { opacity: 1; pointer-events: auto; cursor: pointer; }
.podium-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--gold);
  border-radius: 8px; padding: 20px 28px; min-width: 280px; max-width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.podium-title { font-family: var(--font-display); font-size: 16px; color: var(--gold); text-align: center; margin-bottom: 14px; }
.podium-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.podium-row:last-child { border-bottom: none; }
.podium-row-main { flex: 1; min-width: 0; }
.podium-driver-name { font-weight: 700; }
.podium-team-name { font-size: 12px; }
.podium-bettors { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.podium-bettor { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: var(--bg-panel-2); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 3px; }
.bet-type-tag { display: inline-block; width: 13px; height: 13px; line-height: 13px; text-align: center; border-radius: 3px; font-size: 9px; font-weight: 800; }
.bet-type-tag.win { background: rgba(255,210,63,0.18); color: var(--gold); border: 1px solid var(--gold); }
.bet-type-tag.podium { background: rgba(53,224,196,0.18); color: var(--accent-2); border: 1px solid var(--accent-2); }
.bet-type-tag.lost { opacity: 0.4; }

/* ---------------- Profile tab ---------------- */
.profile-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0 24px; }
.profile-summary .card { background: var(--bg-panel); border: 1px solid var(--border); padding: 14px; min-width: 0; }
.profile-summary .card .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; overflow-wrap: break-word; }
.profile-summary .card .value { font-size: 22px; font-weight: 700; margin-top: 4px; overflow-wrap: break-word; font-family: var(--font-mono); }
.profile-summary .card .value.gold { color: var(--gold); }
.profile-summary .card .value.good { color: var(--accent-2); }
.skeleton-card { opacity: 0.5; animation: skeletonPulse 1.4s ease-in-out infinite; }
.skeleton-card .value { color: var(--text-dim); }
@keyframes skeletonPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.6; } }
.profile-summary .card .value.bad { color: var(--flag-red); }

/* ---------------- Account settings ---------------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 12px 0 28px; }
.settings-card { background: var(--bg-panel); border: 1px solid var(--border); padding: 16px; }
.settings-card h3 { margin: 0 0 8px; font-size: 14px; font-family: var(--font-display); font-weight: 400; }
.settings-card input {
  display: block; width: 100%; margin: 6px 0; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); padding: 9px 11px; font-size: 13.5px; font-family: var(--font-body);
}
.settings-card .btn { width: 100%; margin-top: 4px; }
.settings-card .form-error { margin-top: 6px; }
.settings-card-danger { border-color: var(--flag-red); }
.settings-card-danger h3 { color: var(--flag-red); }
.btn.danger { background: var(--flag-red); color: #fff; }


/* ---------------- Shop ---------------- */
.shop-grid, .inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 14px 0 28px; }
.item-card { background: var(--bg-panel); border: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.item-card .item-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item-card .item-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.item-card .item-name { font-weight: 700; font-size: 15px; overflow-wrap: break-word; }
.item-card .item-category { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.item-card .item-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.4; flex: 1; overflow-wrap: break-word; }
.item-card .item-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.item-card .item-price { font-weight: 700; color: var(--gold); font-size: 14px; font-family: var(--font-mono); }
.item-card .item-qty { font-size: 12px; color: var(--text-dim); }

/* ---------------- Banana placement ---------------- */
.placement-banner {
  background: rgba(255,210,63,0.12); border: 1px solid var(--gold);
  padding: 12px 16px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px;
}

.featured-race-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, rgba(255,210,63,0.18), rgba(255,61,138,0.14));
  border: 1px solid var(--gold); padding: 12px 16px; margin-bottom: 14px;
}
.featured-race-banner #featuredRaceIcon { font-size: 32px; flex-shrink: 0; }
.featured-race-title { font-weight: 800; font-size: 15px; color: var(--gold); }
.featured-race-title #featuredRaceMultiplier { font-weight: 700; color: var(--accent); }
.hazard-marker { cursor: default; }
.hazard-marker text { font-size: 16px; text-anchor: middle; dominant-baseline: central; }
.placement-preview { opacity: 0.4; pointer-events: none; }
.placement-preview text { font-size: 18px; text-anchor: middle; dominant-baseline: central; }


/* track svg elements */
.track-line { fill: none; stroke: #3A2F5C; stroke-width: 14; stroke-linejoin: round; }
.track-line-inner { fill: none; stroke: var(--bg-input); stroke-width: 8; stroke-linejoin: round; }
.track-section { fill: none; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.75; cursor: pointer; pointer-events: stroke; }
.track-section:hover { opacity: 1; }
.start-line { stroke: #ffffff; stroke-width: 3; opacity: 0.7; }
.car-dot { cursor: pointer; stroke: var(--bg); stroke-width: 1.5; filter: drop-shadow(0 0 4px currentColor); }
.car-dot.dnf { opacity: 0.25; filter: none; }
.car-dot-ring { fill: none; stroke: var(--gold); stroke-width: 2.5; opacity: 0; pointer-events: none; transition: opacity 0.1s; }
.car-dot-ring.active { opacity: 1; }
.car-dot-bet-ring {
  fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 3; opacity: 0; pointer-events: none;
  transition: opacity 0.2s; animation: betRingSpin 6s linear infinite;
}
.car-dot-bet-ring.active { opacity: 1; }
@keyframes betRingSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.car-label { font-size: 9px; fill: var(--bg); font-weight: 800; text-anchor: middle; pointer-events: none; }

@media (max-width: 860px) {
  .race-layout { grid-template-columns: 1fr; }
  .standings-columns { grid-template-columns: 1fr; }
}

/* ---------------- Toast notifications ---------------- */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 300; max-width: 340px;
}
.toast {
  background: var(--bg-panel); border: 1px solid var(--border); padding: 12px 16px;
  font-size: 13.5px; line-height: 1.4; box-shadow: 0 10px 28px rgba(0,0,0,0.5);
  animation: toast-in 0.18s ease-out; transition: opacity 0.18s ease-in, transform 0.18s ease-in;
}
.toast.error { border-left: 3px solid var(--flag-red); }
.toast.success { border-left: 3px solid var(--accent-2); }
.toast.info { border-left: 3px solid var(--gold); }
.toast.fading { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.buy-row { display: flex; gap: 6px; }
.buy-qty-input {
  width: 56px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  padding: 8px 6px; text-align: center; font-size: 13px; font-family: var(--font-mono);
}
.buy-row .btn { flex: 1; }

.item-passive { font-size: 12.5px; text-align: center; padding: 8px 0; }

/* ---------------- Sponsorship decals ---------------- */
/* Each decal-layer is a white/transparent PNG masked over a solid
   background-color (set inline per-layer), which is what lets a single
   source image be tinted to ANY arbitrary color rather than a fixed
   palette - a CSS filter could only approximate this. */
.decal-stack { position: relative; width: 60px; height: 60px; flex-shrink: 0; }
.decal-stack-sm { width: 32px; height: 32px; }
.decal-stack-md { width: 48px; height: 48px; }
.decal-stack-lg { width: 140px; height: 140px; }
.decal-layer {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.decal-base-layer { -webkit-mask-image: none; mask-image: none; }
.decal-border-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.team-logo { position: relative; display: inline-block; flex-shrink: 0; vertical-align: middle; }
.team-logo-layer {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.team-logo-sm { width: 20px; height: 20px; margin-right: 6px; }
.team-logo-lg { width: 56px; height: 56px; }
.decal-list { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.decal-part-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.decal-part-icon img { max-width: 100%; max-height: 100%; }
/* No sizing on this or its image - trophies render at whatever size
   they're uploaded at, same as their highlight image. */
.trophy-shop-icon { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.trophy-shop-icon img { max-width: 100%; max-height: 100%; object-fit: contain; }
.trophy-shop-description { font-size: 11px; color: var(--text-dim); line-height: 1.35; }
.rarity-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

.decal-designer { display: flex; gap: 24px; flex-wrap: wrap; margin: 14px 0 28px; align-items: flex-start; }
.decal-preview-wrap {
  background: var(--bg-panel); border: 1px solid var(--border); padding: 20px;
  display: flex; align-items: center; justify-content: center; min-width: 180px; min-height: 180px;
}
.decal-controls { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.decal-control-row { display: flex; align-items: center; gap: 10px; }
.decal-control-row label { width: 90px; font-size: 13px; color: var(--text-dim); flex-shrink: 0; }
.decal-control-row select { flex: 1; background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; font-family: var(--font-body); }
.color-swatch-btn { width: 40px; height: 36px; border: 1px solid var(--border); cursor: pointer; padding: 0; flex-shrink: 0; }
.color-swatch-btn:hover { border-color: var(--accent-2); }

.color-picker-popover {
  position: fixed; z-index: 400; background: var(--bg-panel); border: 1px solid var(--border);
  padding: 12px; width: 200px; box-shadow: 0 10px 28px rgba(0,0,0,0.55);
}
.color-picker-sv { position: relative; width: 100%; height: 130px; cursor: crosshair; margin-bottom: 10px; }
.color-picker-sv canvas { width: 100%; height: 100%; display: block; }
.color-picker-sv-cursor {
  position: absolute; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 3px rgba(0,0,0,0.9); transform: translate(-50%,-50%); pointer-events: none;
}
.color-picker-hue {
  position: relative; width: 100%; height: 14px; margin-bottom: 10px; cursor: pointer;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.color-picker-hue-cursor { position: absolute; top: -2px; width: 4px; height: 18px; background: #fff; border: 1px solid #000; transform: translateX(-50%); pointer-events: none; }
.color-picker-hex-row { display: flex; gap: 8px; align-items: center; }
.color-picker-swatch-preview { width: 26px; height: 26px; border: 1px solid var(--border); flex-shrink: 0; }
.color-picker-hex-input {
  flex: 1; min-width: 0; background: var(--bg-input); border: 1px solid var(--border); color: var(--text);
  padding: 6px 8px; font-family: var(--font-mono); font-size: 12.5px; text-transform: uppercase;
}
.decal-control-note { flex: 1; font-size: 12px; }

@media (max-width: 700px) {
  /* Forces an explicit top-to-bottom stack (viewer, then controls
     below it) rather than relying on flex-wrap - .decal-controls has
     flex:1 in the base rules above, which sets flex-basis:0%, and that
     took precedence over a plain width:100% override, so the previous
     attempt at this stayed side-by-side (and overflowing) instead of
     actually stacking. flex-direction:column sidesteps that entirely:
     there's only one item per row, full stop, no flex-basis math to
     fight. align-items:center centers the viewer (and anything else)
     horizontally within that column. */
  .decal-designer { flex-direction: column; align-items: center; flex-wrap: nowrap; }
  .decal-preview-wrap { width: 100%; max-width: 260px; box-sizing: border-box; }
  .decal-controls { flex: none; width: 100%; min-width: 0; }
  /* min-width:0 lets a flex child actually shrink below its content's
     natural width instead of forcing the row wider than the viewport -
     without it, the fixed-width label + swatch button alone can be
     enough to push a <select> (and the row containing it) past the
     screen edge on narrow phones. */
  .decal-control-row select { min-width: 0; }
}

.sponsor-picker { margin: 14px 0 28px; display: flex; flex-direction: column; gap: 14px; }
.sponsor-driver-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; }
.sponsor-driver-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  background: var(--bg-panel); border: 1px solid var(--border); padding: 10px 8px; cursor: pointer;
}
.sponsor-driver-card:hover { border-color: var(--accent-2); }
.sponsor-driver-card.selected { border-color: var(--accent); background: rgba(255,61,138,0.1); }
.sponsor-driver-card.disabled { opacity: 0.4; cursor: not-allowed; }
.sponsor-driver-name { font-size: 12.5px; font-weight: 700; }
.sponsor-driver-team { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sponsor-driver-badge { font-size: 10px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: 0.3px; }
.sponsor-races-row { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.sponsor-races-row label { font-size: 13px; color: var(--text-dim); }
.sponsor-races-row input[type=number] { width: 70px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text); padding: 8px; font-family: var(--font-mono); }
.sponsor-price { margin-left: auto; font-weight: 700; color: var(--gold); font-family: var(--font-mono); display: flex; align-items: center; gap: 4px; }

.my-sponsorships-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.sponsorship-row { display: flex; align-items: center; gap: 12px; background: var(--bg-panel); border: 1px solid var(--border); padding: 10px 14px; }
.sponsorship-row.expired { opacity: 0.5; }
.pagination-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin: -14px 0 24px; }
.pagination-controls button:disabled { opacity: 0.4; cursor: not-allowed; }
.sponsorship-info { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }

.info-box-decal { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: 11px; }
.entity-decal-banner {
  display: flex; align-items: center; gap: 10px; margin: 10px 0;
  padding: 8px 10px; background: var(--bg-panel-2); border: 1px solid var(--border); font-size: 12.5px;
}

/* ---------------- Badges ---------------- */
/* ---------------- Trophy Case ---------------- */
.trophy-case {
  position: relative; width: 100%; height: 450px; margin: 10px 0 4px;
  background: var(--bg-panel); border: 1px solid var(--border);
  overflow: hidden; /* items are clamped to stay within bounds anyway - this is just a visual backstop */
  touch-action: none; /* dragging handles its own touch behavior; without this, touch-drag also tries to scroll the page */
  /* Trophy case items each carry their own persistent z-index (an
     ever-incrementing per-item counter, stored in the DB, that only
     ever goes up over the item's lifetime as it gets picked up/moved
     around) - without this, those values are compared in the page's
     GLOBAL stacking order, and a long-arranged trophy case can easily
     accumulate a z-index well past the topbar's own (20), letting an
     item render on top of the sticky header while scrolling. isolation
     creates a new stacking context scoped to just this element, so no
     child z-index here - however high - can ever escape above
     anything outside the trophy case, the topbar included.
  */
  isolation: isolate;
}
.trophy-case-empty-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 13px; pointer-events: none;
}
.trophy-case-item {
  position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; /* centered on its stored x/y point */
  user-select: none; -webkit-user-select: none;
}
.trophy-case-item.draggable { cursor: grab; }
.trophy-case-item.draggable.dragging { cursor: grabbing; z-index: 10; }
.trophy-case-item.unearned .trophy-case-item-img { filter: brightness(0.35) saturate(0.6); }
/* No sizing/positioning styling on the highlight image itself beyond
   what's needed to center it behind the badge - it renders at its own
   native size, same as the token icon elsewhere. */
.trophy-case-item-highlight {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  opacity: 0; transition: opacity 0.15s ease; pointer-events: none; z-index: 0;
}
.trophy-case-item:hover .trophy-case-item-highlight { opacity: 1; }
.trophy-case-item-img { position: relative; width: 100%; height: 100%; object-fit: contain; z-index: 1; pointer-events: none; }
/* Trophies render at whatever size they're uploaded at (same idea as
   their highlight image) instead of being forced into the badge-sized
   64x64 slot - some will be large, some small, by design. */
.trophy-case-item[data-item-type="trophy"] .trophy-case-item-img { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: auto; height: auto; }
.trophy-case-tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  background: var(--bg-panel); border: 1px solid var(--gold); border-top: 2px solid var(--gold);
  padding: 8px 12px; max-width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.trophy-case-tooltip-name { font-weight: 700; font-size: 13px; color: var(--gold); margin-bottom: 3px; }
.trophy-case-tooltip-desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.35; }
.trophy-case-tooltip-progress-bar { background: var(--bg-input); height: 6px; overflow: hidden; margin-top: 6px; }
.trophy-case-tooltip-progress-fill { background: var(--accent-2); height: 100%; }
.trophy-case-tooltip-progress-text { font-size: 10.5px; color: var(--text-dim); margin-top: 4px; font-family: var(--font-mono); }

.notif-item.badge { border-left: 3px solid var(--gold); }

.shop-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.shop-header h1 { font-family: var(--font-display); }
.shop-countdown { font-size: 13px; color: var(--text-dim); background: var(--bg-panel-2); border: 1px solid var(--border); padding: 6px 12px; }
.shop-countdown span { color: var(--gold); font-weight: 700; font-family: var(--font-mono); }

/* ---------------- Admin panel ---------------- */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; margin-top: 16px; }
.admin-sidebar { display: flex; flex-direction: column; gap: 6px; }
.admin-nav-btn {
  text-align: left; background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-dim);
  padding: 10px 14px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: var(--font-body);
}
.admin-nav-btn:hover { color: var(--text); }
.admin-nav-btn.active { background: var(--bg-panel-2); color: var(--text); border-color: var(--accent); }
.admin-content { background: var(--bg-panel); border: 1px solid var(--border); border-top: 3px solid var(--accent); padding: 20px; }
.admin-panel input, .admin-panel select {
  display: block; width: 100%; max-width: 360px; margin: 8px 0; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; font-size: 14px; font-family: var(--font-body);
}
.admin-btn-row { display: flex; gap: 8px; margin-top: 8px; }
.admin-checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 13.5px; margin: 8px 0; cursor: pointer; }
@media (max-width: 700px) { .admin-layout { grid-template-columns: 1fr; } }

.admin-driver-results { max-height: 160px; overflow-y: auto; margin: 4px 0; }
.admin-driver-result {
  padding: 8px 10px; border: 1px solid var(--border); margin-bottom: 4px;
  cursor: pointer; font-size: 13px; display: flex; justify-content: space-between;
}
.admin-driver-result:hover { border-color: var(--accent-2); }
.admin-driver-result.selected { border-color: var(--gold); background: rgba(255,210,63,0.1); }

.item-card { position: relative; }
.item-card.on-sale { border-color: var(--accent-2); }
.sale-badge {
  position: absolute; top: -8px; right: 10px; background: var(--accent-2); color: #04211a;
  font-size: 11px; font-weight: 800; padding: 3px 8px; clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}
.item-price-strike { color: var(--text-dim); text-decoration: line-through; font-size: 12px; }
.item-price.sale { color: var(--accent-2); }



/* ==========================================================================
   Mobile
   Primary breakpoint at 700px (matches the existing .admin-layout rule) -
   below this, the tab bar becomes a hamburger dropdown and tables condense.
   A tighter 480px breakpoint handles very narrow phones specifically.
   ========================================================================== */

.nav-toggle {
  display: none; /* shown only under the mobile breakpoint below */
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 18px; line-height: 1; padding: 6px 10px; cursor: pointer;
}

/* Username/logout duplicate for the mobile dropdown - always in the DOM,
   only ever visible under the 700px breakpoint (see below), where the
   header versions are hidden instead. */
.mobile-nav-user { display: none; }

/* A table's own natural content width (long team/player names, several
   numeric columns) can exceed a phone's viewport even after padding is
   trimmed - this makes that scroll within its own box instead of
   pushing the whole page wider. Harmless no-op on desktop where content
   already fits. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; min-width: 0; }
.table-scroll .std-table { min-width: 100%; }

@media (max-width: 700px) {
  main { padding: 14px 12px 40px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }

  /* ---- Betting panel: the grid-list only fits one column on a narrow
     screen instead of several side by side, so the same driver roster
     takes much more vertical space here than on desktop - the fixed
     max-height (needed so the show/hide transition has something
     concrete to animate to/from, since CSS can't transition to/from
     "auto") was tall enough for a multi-column desktop layout but not
     for everyone stacked in a single column, clipping the last driver's
     betting box off the bottom via the panel's overflow:hidden. ---- */
  .betting-panel { max-height: 10000px; }

  /* ---- Topbar: brand + hamburger + a trimmed header-right (just the
     notif bell and token count - username/logout move into the dropdown
     below so the row doesn't have to cram four things into ~370px) ---- */
  .topbar { flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 10px; padding: 10px 12px; row-gap: 8px; max-width: 100vw; overflow-x: hidden; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; order: 3; flex-shrink: 0; }
  .header-right { order: 2; margin-left: 0; gap: 8px; min-width: 0; flex-shrink: 0; }
  .brand { order: 1; font-size: 17px; flex-shrink: 0; }
  .notif-wrap { min-width: 0; }
  .auth-area { min-width: 0; }
  .auth-username-link, .account-menu-wrap, #authArea .level-pill { display: none; }
  .token-pill { font-size: 12px; padding: 5px 9px; }

  .tabs {
    order: 10; flex-basis: 100%; width: 100%; max-width: 100%; min-width: 0;
    display: none; flex-direction: column; gap: 2px;
    background: var(--bg-panel-2); border: 1px solid var(--border);
    padding: 6px; margin-top: 2px;
    overflow-x: hidden;
  }
  .tabs.open { display: flex; }
  .tab-btn { width: 100%; text-align: left; padding: 12px 14px; clip-path: none; }

  .mobile-nav-user {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
    min-width: 0;
  }
  .mobile-nav-username { color: var(--text); font-weight: 700; font-size: 14px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

  /* ---- Notification dropdown shouldn't run off the right edge ---- */
  .notif-dropdown {
    position: fixed; width: auto; left: 10px; right: 10px; top: 62px;
    max-width: none;
  }

  /* ---- Standings / leaderboard / bet history: condense horizontally.
     table-scroll (see base rules above) is the safety net; this trims
     padding/font and truncates long names so scrolling is rarely even
     needed. ---- */
  .standings-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .std-table th, .std-table td { padding: 7px 6px; font-size: 12.5px; }
  .std-table .col-hide-narrow { display: none; } /* Podiums/DNFs, bet Type/Odds - still visible on a driver/bet's own profile if needed */
  .std-table td { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---- Shop: rotation timer moves under the title (left-aligned)
     instead of pinned to the far right, and cards go full-width so
     their footer (price + buy button) has room to breathe. ---- */
  .shop-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .shop-grid, .inventory-grid { grid-template-columns: 1fr; gap: 10px; }
  .item-card { padding: 11px; gap: 6px; }
  .item-card .item-icon { font-size: 24px; }

  /* ---- Profile: stat cards and badge cards to a fixed 2-column grid,
     which fits reliably instead of the auto-fit minmax computation
     occasionally landing just past the edge of the viewport. ---- */
  .profile-summary { grid-template-columns: repeat(2, 1fr); }
  
  /* ---- Modal shouldn't overflow narrow screens ---- */
  .modal-card { width: 92vw; max-width: 360px; padding: 18px; }

  /* ---- Buttons/inputs: comfortable tap targets ---- */
  .btn { font-size: 14px; }
  /* select and .auth-form input stay at 16px even here - see the comment
     on .auth-form input's base rule above. Any text-input-like element
     under 16px triggers iOS Safari's zoom-on-focus, which doesn't
     reliably reset afterward and was the actual cause of the page
     appearing too wide specifically after signing in on mobile. */
}

@media (max-width: 480px) {
  /* ---- Very narrow phones: trim standings further and shrink the brand/title chrome ---- */
  .std-table th, .std-table td { padding: 6px 4px; font-size: 11.5px; }
  .std-table td { max-width: 72px; }
  .brand { font-size: 15px; }
  .modal-card { padding: 14px; }
}

/* ---------------- News feed ---------------- */
.news-feed { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.news-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-panel); border: 1px solid var(--border); padding: 12px 14px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.25);
}
.news-icon { flex-shrink: 0; margin-top: 2px; }
.news-icon img { display: block; }
.news-body { flex: 1; min-width: 0; }
.news-headline { font-weight: 700; line-height: 1.35; overflow-wrap: break-word; font-size: 15px; }
.news-links { font-size: 12.5px; margin-top: 5px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.news-driver-chip { display: inline-flex; align-items: center; gap: 4px; }
.news-link-sep { color: var(--text-dim); }
.news-time { font-size: 11px; font-family: var(--font-mono); color: var(--text-dim); }
.news-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.news-like-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim); font-size: 12px;
  padding: 3px 9px; cursor: pointer; font-family: var(--font-mono); flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px;
}
.news-like-btn:hover { border-color: var(--flag-red); color: var(--text); }
.news-like-btn.liked { border-color: var(--flag-red); color: var(--flag-red); background: rgba(255,82,102,0.08); }
.news-like-count { font-weight: 700; }

.candle-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim); font-size: 12px;
  padding: 3px 9px; cursor: pointer; font-family: var(--font-mono); flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px;
}
.candle-btn img { width: 16px; height: 16px; vertical-align: middle; }
.candle-btn:hover { border-color: var(--gold); color: var(--text); }
.candle-btn.lit { border-color: var(--gold); color: var(--gold); background: rgba(255,210,63,0.1); }
.candle-count { font-weight: 700; }

.news-item.news-race_result { border-left: 4px solid var(--gold); }
.news-item.news-milestone { border-left: 4px solid var(--accent-2); }
.news-item.news-bet_win { border-left: 4px solid var(--accent-2); }
.news-item.news-season { border-left: 4px solid var(--accent); }
.news-item.news-admin { border-left: 4px solid var(--accent); background: rgba(255,61,138,0.06); }
.news-item.news-injury { border-left: 4px solid var(--flag-red); }
.news-item.news-injury_recovery { border-left: 4px solid var(--track-teal); }
.news-item.news-trade { border-left: 4px solid #8fb2ff; }
.news-item.news-flavor {
  border-left: 4px solid var(--text-dim); background: var(--bg-panel-2);
  transform: rotate(-0.3deg);
}
.news-item.news-flavor:nth-child(even) { transform: rotate(0.3deg); }
.news-item.news-race_result .news-headline,
.news-item.news-season .news-headline { font-size: 16.5px; }
.news-item.news-pinned { border-left-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 3px 0 rgba(0,0,0,0.25); }
.news-pinned-badge { margin-right: 4px; }
.news-pin-btn {
  align-self: flex-start; flex-shrink: 0; background: var(--bg-panel-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px; padding: 4px 8px; cursor: pointer; font-family: var(--font-body);
  white-space: nowrap;
}
.news-pin-btn:hover { color: var(--gold); border-color: var(--gold); }

@media (max-width: 700px) {
  .news-item { padding: 10px 12px; gap: 10px; min-width: 0; }
}

/* ---------------- Footer ---------------- */
.app-footer {
  text-align: center; padding: 24px 16px 32px; font-size: 12px; color: var(--text-dim); font-family: var(--font-mono);
}
.app-footer a { color: var(--text-dim); text-decoration: none; }
.app-footer a:hover { color: var(--accent-2); text-decoration: underline; }
.app-footer .footer-dot { margin: 0 8px; opacity: 0.5; }

/* ============ GUIDED TUTORIAL ============ */
/* Spotlight uses the standard "9999px box-shadow" trick: the small
   div sized/positioned exactly over the target has a huge box-shadow
   spread that darkens the ENTIRE viewport except within its own
   bounds, creating the illusion of a cutout without any SVG masking.
   #tutorialOverlay itself is just a full-viewport click-catcher (its
   own background stays transparent - the darkening is 100% the
   spotlight's box-shadow) so nothing underneath is reachable while a
   tour is active, spotlighted element included - steps are purely
   informational and never require interacting with what's highlighted. */
.tutorial-overlay { position: fixed; inset: 0; z-index: 3000; }
.tutorial-spotlight {
  position: fixed; z-index: 3001; pointer-events: none;
  border: 2px solid var(--accent); border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(8,4,18,0.82), 0 0 24px rgba(255,61,138,0.5);
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.tutorial-bubble {
  position: fixed; z-index: 3002;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; max-width: 320px; width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.tutorial-bubble.tutorial-bubble-centered {
  left: 50% !important; top: 50% !important; transform: translate(-50%, -50%);
  max-width: 380px;
}
.tutorial-bubble-x {
  position: absolute; top: 6px; right: 8px; background: none; border: none;
  color: var(--text-dim); font-size: 20px; line-height: 1; cursor: pointer; padding: 6px;
}
.tutorial-bubble-x:hover { color: var(--text); }
.tutorial-bubble-title { font-family: var(--font-display); font-size: 15px; margin: 0 24px 8px 0; color: var(--accent); }
.tutorial-bubble-text { font-size: 14px; line-height: 1.5; color: var(--text); margin-bottom: 14px; }
.tutorial-bubble-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tutorial-bubble-actions { display: flex; gap: 8px; }
#tutorialBackBtn:disabled { opacity: 0.4; cursor: not-allowed; }
.tutorial-skip-link {
  display: block; width: 100%; margin: 10px 0 0; background: none; border: none;
  color: var(--text-dim); font-size: 12px; text-decoration: underline; text-align: center; cursor: pointer; padding: 4px;
}
.tutorial-skip-link:hover { color: var(--text); }
