/* ============================================
   PITSPOES — Custom CSS
   F1 Prediction Game | rallye.me
   Retro F1 / Pin-up Aesthetic
   ============================================ */

/* --- Reset & Box Model --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { line-height: 1.5; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); color: var(--color-text); background: var(--color-dark); min-height: 100vh; }
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }

/* --- Design Tokens --- */
:root {
  /* Core F1 branding */
  --color-red: #e10600;
  --color-red-hover: #c00500;
  --color-red-glow: rgba(225, 6, 0, 0.25);
  --color-red-subtle: rgba(225, 6, 0, 0.08);

  /* Dark foundation */
  --color-dark: #0a0a0a;
  --color-surface: #161616;
  --color-surface-2: #222222;
  --color-surface-3: #333333;
  --color-surface-hover: #2a2a2a;

  /* Retro warmth */
  --color-cream: #f5e6d3;
  --color-cream-muted: #c4a882;
  --color-champagne: #f7e7ce;

  /* Text */
  --color-text: #e5e5e5;
  --color-text-bright: #ffffff;
  --color-muted: #888888;

  /* Semantic */
  --color-green: #4ade80;
  --color-green-bg: rgba(74, 222, 128, 0.10);
  --color-green-border: rgba(74, 222, 128, 0.20);
  --color-yellow: #fbbf24;
  --color-yellow-bg: rgba(251, 191, 36, 0.10);
  --color-yellow-border: rgba(251, 191, 36, 0.20);
  --color-red-bg: rgba(225, 6, 0, 0.10);

  /* Positions — vintage metals */
  --color-p1: #d4af37;
  --color-p1-glow: rgba(212, 175, 55, 0.25);
  --color-p2: #c0c0c0;
  --color-p3: #cd7f32;
  --color-purple: #a78bfa;

  /* Typography */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Oswald', 'Impact', 'Arial Narrow', sans-serif;

  /* Spacing scale */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem;
  --sp-12: 3rem; --sp-16: 4rem; --sp-20: 5rem;

  /* Radius */
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px;
  --radius-xl: 14px; --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
  --shadow-elevated: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-glow-red: 0 0 20px var(--color-red-glow), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-glow-gold: 0 0 12px var(--color-p1-glow);
  --shadow-inset: inset 0 1px 2px rgba(0,0,0,0.3);

  /* Layout */
  --sidebar-w: 16rem;
  --tabbar-h: 4rem;

  /* Transition */
  --ease: 200ms ease;
  --ease-fast: 120ms ease;
}

/* --- Typography --- */
.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--color-text-bright);
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text-bright);
}
.label-overline {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}
.text-muted { color: var(--color-muted); }
.text-red { color: var(--color-red); }
.text-bright { color: var(--color-text-bright); }
.text-cream { color: var(--color-cream); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- App Shell --- */
.app-body {
  background: var(--color-dark);
  color: var(--color-text);
  min-height: 100vh;
}
.app-main {
  padding: var(--sp-4);
  padding-bottom: calc(var(--tabbar-h) + var(--sp-8));
}
.app-main-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-4);
}

/* --- Containers --- */
.container-narrow { max-width: 40rem; margin-left: auto; margin-right: auto; }
.container-medium { max-width: 56rem; margin-left: auto; margin-right: auto; }
.container-wide { max-width: 64rem; margin-left: auto; margin-right: auto; }
.container-login { width: 100%; max-width: 24rem; }

/* --- Sidebar (Desktop) --- */
.sidebar {
  display: none;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--color-surface);
  border-right: 1px solid var(--color-surface-2);
  padding: var(--sp-4);
  z-index: 50;
  /* Carbon fiber texture */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.025) 1px, transparent 0);
  background-size: 4px 4px;
}
.sidebar-logo { margin-bottom: var(--sp-8); }
.sidebar-logo img { height: 3rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: var(--sp-1); flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  font-size: 0.935rem;
  font-weight: 500;
  color: var(--color-muted);
  transition: all var(--ease);
}
.sidebar-link:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.sidebar-link--cta {
  color: var(--color-red);
  font-weight: 700;
}
.sidebar-link--cta:hover { color: var(--color-text-bright); }
.sidebar-link svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.sidebar-user {
  border-top: 1px solid var(--color-surface-2);
  padding-top: var(--sp-4);
  margin-top: var(--sp-4);
}
.sidebar-user-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  transition: background var(--ease);
}
.sidebar-user-link:hover { background: var(--color-surface-2); }
.sidebar-logout {
  color: var(--color-muted);
  margin-top: var(--sp-1);
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

/* --- Tab Bar (Mobile) --- */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
}
.tab-bar-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--color-muted);
  transition: color var(--ease);
}
.tab-bar-link:hover, .tab-bar-link--active { color: var(--color-red); }
.tab-bar-link svg { width: 1.25rem; height: 1.25rem; }

/* --- Cards --- */
.card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-card);
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: var(--sp-6); right: var(--sp-6);
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: repeating-conic-gradient(
    var(--color-surface-3) 0% 25%, transparent 0% 50%
  ) 0 0 / 6px 3px;
  opacity: 0.5;
}
.card--flush { padding: 0; }
.card--flush::before { left: 0; right: 0; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.card--interactive {
  transition: border-color var(--ease), box-shadow var(--ease);
  cursor: pointer;
}
.card--interactive:hover {
  border-color: rgba(225, 6, 0, 0.25);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(225, 6, 0, 0.08);
}
.card--empty { text-align: center; padding: var(--sp-8); color: var(--color-muted); }
.card-divider { border-top: 1px solid var(--color-surface-2); padding-top: var(--sp-4); margin-top: var(--sp-4); }
.card-section { padding: var(--sp-5); }
.card-section + .card-section { border-top: 1px solid var(--color-surface-2); }

/* --- Buttons --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-5);
  background: linear-gradient(180deg, #e81a10 0%, var(--color-red) 100%);
  color: var(--color-text-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.935rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--ease);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #f02a1a 0%, var(--color-red-hover) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-red);
}
.btn-primary:active { transform: translateY(0); }
.btn-block { display: flex; width: 100%; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2) var(--sp-5);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 0.875rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--ease);
}
.btn-secondary:hover { background: var(--color-surface-3); }

/* --- Links --- */
.link-action {
  font-size: 0.75rem;
  color: var(--color-red);
  font-weight: 600;
  transition: opacity var(--ease);
}
.link-action:hover { opacity: 0.8; text-decoration: underline; }
.link-back {
  font-size: 0.875rem;
  color: var(--color-muted);
  transition: color var(--ease);
}
.link-back:hover { color: var(--color-red); }

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-sm);
  line-height: 1.4;
}
.badge--finished { background: var(--color-green-bg); color: var(--color-green); border: 1px solid var(--color-green-border); }
.badge--active { background: var(--color-red-bg); color: var(--color-red); border: 1px solid rgba(225,6,0,0.2); animation: live-pulse 2s ease-in-out infinite; }
.badge--scheduled { background: var(--color-surface-2); color: var(--color-muted); }
.badge--scored { background: var(--color-green-bg); color: var(--color-green); border: 1px solid var(--color-green-border); }
.badge--locked { background: var(--color-yellow-bg); color: var(--color-yellow); border: 1px solid var(--color-yellow-border); }
.badge--open { background: var(--color-surface-2); color: var(--color-muted); }
.badge--upcoming { background: var(--color-red-bg); color: var(--color-red); }
.badge--completed { background: var(--color-surface-2); color: var(--color-muted); }
.badge--earned { background: var(--color-surface-2); border-radius: var(--radius-lg); padding: var(--sp-2) var(--sp-3); font-size: 0.875rem; }
/* Prediction-slot badges (points feed) */
.badge--pole { background: rgba(167,139,250,0.15); color: #a78bfa;         border: 1px solid rgba(167,139,250,0.35); }
.badge--p1   { background: rgba(212,175,55,0.15);  color: var(--color-p1); border: 1px solid rgba(212,175,55,0.35);  }
.badge--p2   { background: rgba(192,192,192,0.12); color: var(--color-p2); border: 1px solid rgba(192,192,192,0.30); }
.badge--p3   { background: rgba(205,127,50,0.15);  color: var(--color-p3); border: 1px solid rgba(205,127,50,0.35);  }

/* --- Alerts / Flash Messages --- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  margin-bottom: var(--sp-2);
}
.alert--success { background: var(--color-green-bg); color: var(--color-green); border: 1px solid var(--color-green-border); }
.alert--error { background: var(--color-red-bg); color: #f87171; border: 1px solid rgba(225,6,0,0.25); }
.alert--default { background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-surface-3); }

/* --- Data Tables --- */
.data-table { width: 100%; font-size: 0.875rem; }
.data-table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-surface-2);
}
.data-table th.text-right, .data-table td.text-right { text-align: right; }
.data-table th.text-center, .data-table td.text-center { text-align: center; }
.data-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--color-surface-2);
  transition: background var(--ease-fast);
}
.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.data-table-row--highlight td { background: var(--color-red-subtle) !important; }
.data-table td:first-child { font-weight: 700; }

/* --- Forms --- */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted);
  margin-bottom: var(--sp-2);
}
.form-label .points-hint, .points-hint { color: var(--color-red); font-weight: 600; }
.form-input {
  width: 100%;
  height: 3rem;
  padding: 0 var(--sp-3);
  background: var(--color-dark);
  border: 1px solid var(--color-surface-2);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  font-size: 0.935rem;
  transition: border-color var(--ease);
  box-shadow: var(--shadow-inset);
  /* Custom select arrow */
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23888' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}
input.form-input { background-image: none; padding-right: var(--sp-3); }
.form-input:focus {
  outline: none;
  border-color: var(--color-red);
  box-shadow: var(--shadow-inset), 0 0 0 2px rgba(225,6,0,0.15);
}
.form-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-sm);
  accent-color: var(--color-red);
}
.form-help { font-size: 0.75rem; color: var(--color-muted); margin-top: var(--sp-1); }
.form-error { font-size: 0.75rem; color: #f87171; margin-top: var(--sp-1); }
.form-divider { border-top: 1px solid var(--color-surface-2); padding-top: var(--sp-6); margin-top: var(--sp-2); }

/* --- Grids --- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.grid-2-md, .grid-3-md, .grid-4-md { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }

/* --- Flex Layouts --- */
.stack { display: flex; flex-direction: column; }
.stack-xs { gap: var(--sp-1); }
.stack-sm { gap: var(--sp-2); }
.stack-md { gap: var(--sp-4); }
.stack-lg { gap: var(--sp-6); }
.stack-xl { gap: var(--sp-8); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--center { justify-content: center; }
.row--wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }

/* --- Avatars --- */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-weight: 700;
  color: var(--color-text-bright);
  flex-shrink: 0;
}
.avatar--sm { width: 1.75rem; height: 1.75rem; font-size: 0.65rem; background: var(--color-surface-2); }
.avatar--md { width: 2rem; height: 2rem; font-size: 0.7rem; background: var(--color-red); }
.avatar--lg { width: 4rem; height: 4rem; font-size: 1.25rem; background: var(--color-red); }
.avatar--xl { width: 3rem; height: 3rem; font-size: 1rem; }

/* --- Position Indicators --- */
.position--p1 { color: var(--color-p1); }
.position--p2 { color: var(--color-p2); }
.position--p3 { color: var(--color-p3); }
.position--other { color: var(--color-muted); }

/* --- Score Highlighting --- */
.score--correct { color: var(--color-green); font-weight: 600; }
.score--miss { color: var(--color-muted); }
.score-total { color: var(--color-red); font-weight: 700; }

/* Position-specific score colours (race leaderboard) */
.score--pole { color: var(--color-purple); font-weight: 600; }
.score--p1   { color: var(--color-p1);     font-weight: 600; }
.score--p2   { color: var(--color-p2);     font-weight: 600; }
.score--p3   { color: var(--color-p3);     font-weight: 600; }
.score-total--prominent {
    color: var(--color-text);
    font-weight: 800;
    font-size: 1.05em;
    background: rgba(225, 6, 0, 0.10);
    border-radius: var(--radius-sm);
    padding: var(--sp-1) var(--sp-2);
}
.score-total--zero { color: var(--color-muted); font-weight: 400; }

/* --- Constructor Stripe --- */
.constructor-stripe {
  width: 4px;
  height: 1.25rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* --- Stat Boxes --- */
.stat-box { text-align: center; }
.stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.stat-value--red { color: var(--color-red); }
.stat-label { font-size: 0.7rem; color: var(--color-muted); margin-top: 2px; }

/* --- Tab Group (Switcher) --- */
.tab-group {
  display: inline-flex;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-surface-2);
  border-radius: var(--radius-lg);
  padding: 3px;
}
.tab {
  padding: var(--sp-2) var(--sp-4);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  transition: all var(--ease);
}
.tab:hover { color: var(--color-text); }
.tab--active {
  background: var(--color-red);
  color: var(--color-text-bright);
}

/* --- Podium --- */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--sp-4);
  height: 12rem;
  margin-bottom: var(--sp-8);
}
.podium-slot { text-align: center; }
.podium-slot--p1 { width: 7rem; }
.podium-slot--p2 { width: 6rem; }
.podium-slot--p3 { width: 6rem; }
.podium-avatar { margin: 0 auto var(--sp-2); }
.podium-name { font-size: 0.75rem; font-weight: 500; }
.podium-name--p1 { font-size: 0.875rem; font-weight: 700; }
.podium-points { font-size: 0.75rem; color: var(--color-red); font-weight: 600; }
.podium-bar {
  margin-top: var(--sp-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: podium-rise 0.8s ease-out forwards;
  transform: scaleY(0);
  transform-origin: bottom;
}
.podium-bar--p1 { height: 7.5rem; background: rgba(212,175,55,0.15); border: 1px solid rgba(212,175,55,0.25); animation-delay: 0.2s; }
.podium-bar--p2 { height: 5rem; background: rgba(192,192,192,0.12); border: 1px solid rgba(192,192,192,0.20); animation-delay: 0.4s; }
.podium-bar--p3 { height: 3.75rem; background: rgba(205,127,50,0.12); border: 1px solid rgba(205,127,50,0.20); animation-delay: 0.6s; }
.podium-rank { font-family: var(--font-display); padding-bottom: var(--sp-2); }
.podium-rank--1 { font-size: 1.5rem; color: var(--color-p1); }
.podium-rank--2 { font-size: 1.125rem; color: var(--color-p2); }
.podium-rank--3 { font-size: 1.125rem; color: var(--color-p3); }

/* --- Timeline --- */
.timeline { position: relative; }
.timeline-line {
  position: absolute;
  left: 1rem; top: 0; bottom: 0;
  width: 2px;
  background: var(--color-surface-2);
}
.timeline-item { position: relative; padding-left: 3rem; margin-bottom: var(--sp-6); }
.timeline-dot {
  position: absolute;
  left: 0.625rem; top: 0.75rem;
  width: 0.75rem; height: 0.75rem;
  border-radius: var(--radius-full);
  border: 2px solid;
}
.timeline-dot--past { background: var(--color-red); border-color: var(--color-red); }
.timeline-dot--future { background: var(--color-surface); border-color: var(--color-muted); }

/* --- Session Results Row --- */
.result-row {
  display: flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-5);
  font-size: 0.875rem;
  transition: background var(--ease-fast);
}
.result-row:hover { background: rgba(255,255,255,0.02); }
.result-position {
  width: 2rem;
  font-weight: 700;
  flex-shrink: 0;
}
.result-driver { flex: 1; }
.result-driver-code { font-weight: 600; }
.result-driver-name { color: var(--color-muted); margin-left: var(--sp-1); }
.result-constructor { color: var(--color-muted); font-size: 0.75rem; margin-right: var(--sp-4); }
.result-time { min-width: 6rem; text-align: right; font-family: 'JetBrains Mono', 'SF Mono', monospace; font-size: 0.75rem; }
.result-points { width: 3.5rem; text-align: right; color: var(--color-muted); font-size: 0.75rem; }
.result-fastest { color: var(--color-purple); font-size: 0.75rem; margin-left: var(--sp-2); }
.result-status { font-size: 0.75rem; color: #f87171; }

/* Q-round badge — shown inline after qualifying lap times */
.q-round-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  margin-left: var(--sp-1);
  vertical-align: middle;
  background: var(--color-surface-3);
  color: var(--color-muted);
  letter-spacing: 0.02em;
}
.q-round-badge--q3 { background: var(--color-green-bg); color: var(--color-green); }
.q-round-badge--q2 { background: var(--color-yellow-bg); color: var(--color-yellow); }

/* Expand / collapse button below results */
.result-expand {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--color-surface-2);
  text-align: center;
}
.result-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-surface-3);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-4);
  border-radius: var(--radius-full);
  transition: all var(--ease);
}
.result-expand-btn:hover {
  color: var(--color-text);
  border-color: rgba(225, 6, 0, 0.35);
}

/* --- Points Feed (home page dashboard) --- */
.points-feed-race { padding: var(--sp-3) 0; }
.points-feed-race + .points-feed-race {
  border-top: 1px solid var(--color-surface-2);
  padding-top: var(--sp-3);
  margin-top: 0;
}
.points-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
  gap: var(--sp-2);
}
.points-feed-race-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  transition: color var(--ease);
}
.points-feed-race-name:hover { color: var(--color-red); }
.points-feed-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 3px 0;
}
/* Fixed width so the tag pills always have room in the middle */
.points-feed-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  width: 7rem;
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
}
.points-feed-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.points-feed-pips { flex: 1; display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; min-height: 1.5rem; }
.points-feed-total {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 3.5rem;
  text-align: right;
  color: var(--color-muted);
}
.points-feed-total--scored {
  color: var(--color-text-bright);
  font-weight: 700;
  font-size: 0.85rem;
}

/* --- News Cards --- */
.news-card {
  display: flex;
  gap: var(--sp-4);
  transition: border-color var(--ease);
}
.news-card-image {
  width: 6rem; height: 6rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-surface-2);
}
.news-card-image img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--ease);
}
.news-card:hover .news-card-image img { transform: scale(1.05); }
.news-card-body { flex: 1; min-width: 0; }
.news-card-title {
  font-weight: 600;
  transition: color var(--ease);
}
.news-card:hover .news-card-title { color: var(--color-red); }
.news-card-summary { font-size: 0.875rem; color: var(--color-muted); margin-top: var(--sp-1); }
.news-card-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); font-size: 0.75rem; color: var(--color-muted); }
.news-card-source { background: var(--color-surface-2); padding: 2px var(--sp-2); border-radius: var(--radius-sm); }

/* News grid for homepage */
.news-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); }
.news-grid-card { text-align: left; }
.news-grid-image {
  aspect-ratio: 16/9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--sp-2);
  background: var(--color-surface-2);
}
.news-grid-image img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--ease); }
.news-grid-card:hover .news-grid-image img { transform: scale(1.05); }

/* --- Chart Container --- */
.chart-container { position: relative; height: 300px; }
.chart-container--tall { height: 400px; }
.chart-container--medium { height: 350px; }

/* --- Countdown --- */
.countdown { font-weight: 600; }
.countdown--live { color: var(--color-red); }
.countdown--closed { color: var(--color-muted); }

/* --- Pagination --- */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-8); }
.pagination-link {
  padding: var(--sp-2) var(--sp-4);
  background: var(--color-surface);
  border: 1px solid var(--color-surface-2);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  transition: border-color var(--ease);
}
.pagination-link:hover { border-color: rgba(225,6,0,0.25); }
.pagination-info { font-size: 0.875rem; color: var(--color-muted); padding: var(--sp-2) var(--sp-4); }

/* --- Prediction Card (inline display) --- */
.prediction-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
  font-size: 0.875rem;
}
.prediction-slot-label { font-size: 0.7rem; color: var(--color-muted); }
.prediction-slot-value { font-weight: 500; }

/* --- Session Header Row --- */
.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--color-surface-2);
}
.session-header-title { font-weight: 600; }
.session-header-meta { display: flex; align-items: center; gap: var(--sp-2); }
.session-header-time { font-size: 0.75rem; color: var(--color-muted); }

/* --- Race Card (in calendar list) --- */
.race-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}
.race-round {
  width: 2.5rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-muted);
  flex-shrink: 0;
}
.race-info { flex: 1; min-width: 0; }
.race-name { font-weight: 600; }
.race-circuit { font-size: 0.875rem; color: var(--color-muted); margin-top: 2px; }
.race-date-col { text-align: right; flex-shrink: 0; }
.race-date { font-size: 0.875rem; }
.race-sessions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); margin-left: 3.5rem; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-surface); }
::-webkit-scrollbar-thumb { background: var(--color-surface-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-surface-3); }

/* --- Animations --- */
@keyframes podium-rise {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Spacing helpers --- */
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.pt-2 { padding-top: var(--sp-2); }
.pt-4 { padding-top: var(--sp-4); }
.pt-6 { padding-top: var(--sp-6); }

/* --- Responsive Visibility --- */
.hide-mobile { display: none; }
.hide-mobile-cell { display: none; }
.hide-desktop { display: initial; }

/* --- Media Queries (desktop: 768px+) --- */
@media (min-width: 768px) {
  .sidebar { display: flex; }
  .tab-bar { display: none; }
  .app-main {
    margin-left: var(--sidebar-w);
    padding: var(--sp-4) var(--sp-8);
    padding-bottom: var(--sp-8);
  }
  .grid-2-md { grid-template-columns: repeat(2, 1fr); }
  .grid-3-md { grid-template-columns: repeat(3, 1fr); }
  .grid-4-md { grid-template-columns: repeat(4, 1fr); }
  .hide-mobile { display: initial; }
  .hide-mobile-cell { display: table-cell; }
  .hide-desktop { display: none; }
  .news-card-image { width: 8rem; height: 6rem; }
  .news-grid { grid-template-columns: repeat(3, 1fr); }
  .prediction-grid { grid-template-columns: repeat(4, 1fr); }
  .result-row { padding: var(--sp-2) var(--sp-5); }
}

/* --- Login page specific --- */
.login-logo { height: 8rem; margin: 0 auto var(--sp-4); }
.login-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; text-align: center; }
.login-subtitle { font-size: 0.875rem; color: var(--color-muted); text-align: center; margin-top: var(--sp-1); }
.login-footer { text-align: center; font-size: 0.75rem; color: var(--color-muted); margin-top: var(--sp-6); }
.login-error {
  background: var(--color-red-bg);
  color: #f87171;
  border: 1px solid rgba(225,6,0,0.25);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
  font-size: 0.875rem;
}

/* --- Misc helpers --- */
.w-full { width: 100%; }
.inline-block { display: inline-block; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }

/* --- HTMX loading indicator --- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; animation: spin 0.8s linear infinite; }
.htmx-request.htmx-indicator { display: inline; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); display: inline-block; } }
