/* Action Race — close-up cinematic side view */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #030508;
  color: #e2e8f0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
body.action-race-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.action-race-chrome {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: max(8px, env(safe-area-inset-top, 8px)) max(14px, env(safe-area-inset-right, 14px)) 8px max(14px, env(safe-area-inset-left, 14px));
  background: linear-gradient(180deg, rgba(10, 14, 24, 0.95), rgba(10, 14, 24, 0.6));
  border-bottom: 1px solid rgba(251, 191, 36, 0.2);
  z-index: 10;
  max-width: 100%;
  box-sizing: border-box;
}
/* Cinema: hide chrome during the race. Wake on pointer / Esc. */
body.action-race-racing .action-race-chrome {
  opacity: 0;
  transform: translateY(-108%);
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
body.action-race-racing.action-chrome-awake .action-race-chrome,
body.action-race-racing .action-race-chrome:focus-within {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
body.action-race-racing .action-race-status {
  opacity: 0;
  transition: opacity 0.4s ease;
}
body.action-race-racing.action-chrome-awake .action-race-status {
  opacity: 1;
}
body.action-race-racing .action-announcer-cap {
  top: max(12px, env(safe-area-inset-top, 12px));
}
/* Sticky exit only while the movie chrome is hidden. */
body:not(.action-race-racing) .action-race-exit { display: none; }
.action-race-exit {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 10px));
  left: max(10px, env(safe-area-inset-left, 10px));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.72);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fbbf24;
  font-family: Rajdhani, system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.action-race-exit:hover,
.action-race-exit:focus-visible {
  background: rgba(15, 23, 42, 0.92);
  border-color: #fbbf24;
  outline: none;
}
body.action-race-racing:not(.action-chrome-awake) .action-race-exit {
  opacity: 0.72;
}
.action-nav-dock {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 18px));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: calc(100vw - 24px);
}
.action-nav-btn,
.action-nav-dock a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(45, 212, 191, 0.4);
  background: rgba(15, 23, 42, 0.92);
  color: #5eead4;
  font-family: Rajdhani, system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  box-sizing: border-box;
}
.action-nav-btn:hover,
.action-nav-dock a:hover { border-color: #2dd4bf; color: #99f6e4; }
.action-race-brand {
  font-family: Rajdhani, system-ui, sans-serif;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: #fbbf24;
  text-transform: uppercase;
}
.action-race-meta {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #94a3b8;
}
.action-race-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2dd4bf;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  padding: 8px 12px;
  min-height: 44px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 6px;
  white-space: nowrap;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.action-race-link:hover { color: #5eead4; border-color: rgba(45, 212, 191, 0.6); }
.action-race-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  max-width: 100%;
}
.action-vibe-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid rgba(168, 130, 255, 0.4);
  background: rgba(40, 30, 70, 0.5);
  color: #c4b5fd;
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.25s ease;
  min-height: 44px;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.action-vibe-toggle .vibe-icon { font-size: 1rem; line-height: 1; }
.action-vibe-toggle:hover { border-color: rgba(168, 130, 255, 0.7); color: #ddd6fe; }
.action-vibe-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(124, 92, 220, 0.55), rgba(76, 56, 150, 0.55));
  border-color: rgba(168, 130, 255, 0.9);
  color: #f5f3ff;
  box-shadow: 0 0 16px rgba(124, 92, 220, 0.4);
}
.action-vibe-toggle[aria-pressed="true"] .vibe-icon {
  animation: vibe-pulse 1.6s ease-in-out infinite;
}
@keyframes vibe-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.18); }
}

/* Moody idle poster — AI key art between races */
.action-race-poster {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #05060b center/cover no-repeat;
  background-image: url('/assets/vibe-bg.jpg?v=3.1.0');
  opacity: 1;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
body.action-race-racing .action-race-poster {
  opacity: 0;
  visibility: hidden;
}
.action-race-poster-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(5, 8, 16, 0) 0%, rgba(5, 8, 16, 0.55) 78%),
    linear-gradient(180deg, rgba(5, 8, 16, 0.55) 0%, rgba(5, 8, 16, 0.1) 40%, rgba(5, 8, 16, 0.85) 100%);
}
.action-race-poster-text {
  position: absolute;
  left: max(20px, env(safe-area-inset-left, 20px));
  bottom: 18%;
  max-width: 80%;
}
.poster-kicker {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: #c4b5fd;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85), 0 0 16px rgba(124, 92, 220, 0.35);
}
.poster-title {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 900;
  line-height: 1.04;
  color: #f5f3ff;
  text-shadow: 0 2px 30px rgba(124, 92, 220, 0.5), 0 2px 8px rgba(0, 0, 0, 0.8);
}
.poster-title span {
  font-size: 0.5em;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.08em;
}
/* Venue home-city tag — reads like a stadium plate, not the tagline */
.poster-title .poster-city {
  font-size: 0.55em;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.12em;
}
@media (prefers-reduced-motion: reduce) {
  .action-vibe-toggle[aria-pressed="true"] .vibe-icon { animation: none; }
  .action-race-live { animation: none; }
}

/* SFX toggle uses the same pill shape as Vibe but a teal accent so the two
   controls (soundtrack vs. race SFX/announcer) read as distinct switches. */
.action-sfx-toggle {
  border-color: rgba(45, 212, 191, 0.4);
  background: rgba(15, 40, 40, 0.5);
  color: #5eead4;
}
.action-sfx-toggle:hover { border-color: rgba(45, 212, 191, 0.7); color: #99f6e4; }
.action-sfx-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.5), rgba(13, 120, 105, 0.5));
  border-color: rgba(45, 212, 191, 0.9);
  color: #f0fdfa;
  box-shadow: 0 0 16px rgba(45, 212, 191, 0.35);
  animation: none;
}
.action-sfx-toggle[aria-pressed="false"] .vibe-icon { opacity: 0.55; }

/* Vibe Lounge modal (shared markup from vibe-music.js) on action cinema */
.vibe-lounge-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(6px);
}
.vibe-lounge-overlay.active,
.vibe-lounge-overlay.is-open { display: flex; }
.vibe-lounge-card {
  position: relative;
  width: min(420px, 100%);
  max-height: min(88vh, 640px);
  overflow: auto;
  padding: 0 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(168, 130, 255, 0.35);
  background: linear-gradient(180deg, rgba(18, 14, 36, 0.97) 0%, rgba(8, 10, 18, 0.98) 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(124, 92, 220, 0.18);
  color: #e8e6f5;
}
.vibe-lounge-hero {
  height: 100px;
  border-radius: 16px 16px 0 0;
  background:
    linear-gradient(180deg, rgba(8, 10, 18, 0.2) 0%, rgba(8, 10, 18, 0.95) 100%),
    url('/assets/vibe-bg.jpg') center/cover no-repeat;
}
.vibe-lounge-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 18px 8px;
  margin-top: -32px;
  position: relative;
}
.vibe-lounge-kicker {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: #a882ff;
  text-transform: uppercase;
}
.vibe-lounge-title {
  margin: 2px 0 0;
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 900;
  color: #f5f3ff;
}
.vibe-lounge-sub { margin: 2px 0 0; font-size: 0.75rem; color: #94a3b8; }
.vibe-lounge-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12); background: rgba(0,0,0,0.35);
  color: #cbd5e1; cursor: pointer; font-size: 1rem; line-height: 1;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.vibe-lounge-power {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 18px 12px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  gap: 10px;
}
.vibe-lounge-power-label { font-weight: 700; font-size: 0.88rem; color: #e2e8f0; }
.vibe-power-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px; min-height: 44px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.3);
  color: #94a3b8; font-family: Rajdhani, system-ui, sans-serif;
  font-weight: 800; letter-spacing: 0.06em; line-height: 1; white-space: nowrap;
  cursor: pointer; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.vibe-power-btn.is-on, .vibe-power-btn[aria-pressed="true"] {
  color: #f5f3ff; border-color: rgba(168,130,255,0.8);
  background: linear-gradient(180deg, rgba(124,92,220,0.55), rgba(76,56,150,0.55));
}
.vibe-track-list { display: flex; flex-direction: column; gap: 8px; padding: 0 14px; }
.vibe-track-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03);
  color: inherit; cursor: pointer; min-height: 48px;
}
.vibe-track-opt.is-selected, .vibe-track-opt[aria-pressed="true"] {
  border-color: rgba(168,130,255,0.75); background: rgba(124,92,220,0.18);
}
.vibe-track-label {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.95rem; font-weight: 800; letter-spacing: 0.04em; color: #f1f5f9;
}
.vibe-track-meta { font-size: 0.72rem; color: #94a3b8; line-height: 1.35; }
.vibe-lounge-footnote { margin: 14px 18px 0; font-size: 0.7rem; color: #64748b; }

/* Broadcast caption — B17 announcer commentary, docked below the chrome. */
.action-announcer-cap {
  position: absolute;
  top: max(60px, calc(env(safe-area-inset-top, 0px) + 54px));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92%, 560px);
  width: max-content;
  padding: 7px 16px;
  border-radius: 20px;
  background: rgba(6, 10, 18, 0.78);
  border: 1px solid rgba(74, 222, 128, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  color: #4ade80;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  letter-spacing: 0.02em;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  transition: opacity 0.3s ease;
}
.action-announcer-mic { font-size: 0.85rem; opacity: 0.85; flex: 0 0 auto; }
#action-announcer-text:empty { opacity: 0; }
/* Hide the empty green capsule — text:empty left the pill chrome visible. */
.action-announcer-cap:has(#action-announcer-text:empty) {
  opacity: 0;
  visibility: hidden;
}
body.dt-calm-stage .action-announcer-cap {
  display: none !important;
}

.action-race-stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  background: #000;
}
#action-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.action-race-status {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(251, 191, 36, 0.25);
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fbbf24;
  pointer-events: none;
  z-index: 5;
}
.action-race-status.is-error { color: #f87171; border-color: rgba(248, 113, 113, 0.4); }
/* Animation Bible Phase 1: broadcast text lands with weight — spring
   scale-in with overshoot (never a dead swap). Anchored at translateX(-50%)
   so the pop never shifts the pill off its center line. */
.action-race-status.status-pop {
  animation: status-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes status-pop {
  0% { transform: translateX(-50%) scale(0.86); opacity: 0.4; }
  60% { transform: translateX(-50%) scale(1.06); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .action-race-status.status-pop { animation: none; }
  .action-race-live { animation: none; }
  .action-race-results { transition: opacity 0.2s ease; }
}
.action-race-live {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  border-radius: 3px;
  animation: action-live-pulse 1.2s ease-in-out infinite;
}
@keyframes action-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Narrow phones — chrome + chrome controls stay on-screen */
@media (max-width: 480px) {
  .action-race-brand { font-size: 0.88rem; letter-spacing: 0.06em; }
  .action-race-meta {
    font-size: 0.7rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .action-race-controls { justify-content: flex-end; }
  .action-announcer-cap {
    max-width: calc(100% - 24px);
    font-size: 0.78rem;
    padding: 6px 12px;
  }
  .action-race-results-title { font-size: clamp(1.4rem, 8vw, 2.2rem); }
  .action-race-results-places { font-size: 0.88rem; padding: 8px 14px; }
}

.action-race-results {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  z-index: 100;
  text-align: center;
  pointer-events: none;
  max-width: min(92vw, 420px);
  padding: 22px 20px 18px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #1a2235 0%, #0f172a 100%);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 16px;
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.22), 0 20px 60px rgba(0, 0, 0, 0.55);
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.action-race-results.has-nav {
  pointer-events: auto;
}
.action-race-results-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.action-race-results-nav .action-nav-btn--primary {
  background: #fbbf24;
  color: #0f172a;
  border-color: #fbbf24;
  font-weight: 800;
}
.action-race-results.is-active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.action-race-results-kicker {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #14b8a6;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.action-race-results-title {
  font-family: Rajdhani, system-ui, sans-serif;
  font-weight: 900;
  font-size: 2.2rem;
  letter-spacing: 0.08em;
  color: #fbbf24;
  text-transform: uppercase;
  text-shadow: 0 0 40px rgba(251, 191, 36, 0.5), 0 2px 8px rgba(0, 0, 0, 0.8);
}
.action-race-results-places {
  margin-top: 12px;
  padding: 10px 22px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 10px;
  font-family: Rajdhani, system-ui, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #e2e8f0;
  letter-spacing: 0.04em;
}