:root {
  --bg: #0a0a0f;
  --panel-bg: rgba(16, 18, 28, 0.82);
  --panel-border: rgba(120, 140, 190, 0.25);
  --fg: #e6e9f2;
  --muted: #9aa3bd;
  --a: #e06b6b;
  --b: #6b8de0;
  --accent: #7f9cff;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over element `display` rules (e.g. the
   transport's display:flex), so toggling .hidden actually hides it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* let OrbitControls handle gestures */
}

/* ---- Summary panel (top-left) ---- */
.panel {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: 320px;
  padding: 12px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  pointer-events: none; /* don't block orbit drags */
  user-select: none;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.panel .vs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.panel .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
.panel .chip.a { background: rgba(224, 107, 107, 0.18); color: #ff9b9b; }
.panel .chip.b { background: rgba(107, 141, 224, 0.18); color: #a9c0ff; }
.panel .chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.panel .chip.a .dot { background: var(--a); }
.panel .chip.b .dot { background: var(--b); }

.panel .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  color: var(--muted);
}
.panel .row b { color: var(--fg); font-weight: 600; }

.panel .verdict {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--panel-border);
  font-size: 13px;
}
.panel .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.panel .badge.knockout { background: rgba(255, 120, 90, 0.2); color: #ffb199; }
.panel .badge.spinout  { background: rgba(120, 200, 255, 0.2); color: #a9e0ff; }
.panel .badge.timeout  { background: rgba(180, 180, 200, 0.2); color: #cfd3e6; }
.panel .badge.draw     { background: rgba(180, 180, 200, 0.2); color: #cfd3e6; }

/* ---- Status / fallback message (center) ---- */
.status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-align: center;
}
.status.show { opacity: 1; }

/* ---- Collision flash (full-screen vignette) ---- */
#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 240, 210, 0.0) 35%, rgba(255, 210, 150, 0.35) 100%);
}
#flash.hit { animation: flashpop 0.32s ease-out; }
@keyframes flashpop {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Transport bar (bottom) ---- */
#transport {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  width: min(680px, calc(100% - 28px));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn.active { color: var(--accent); border-color: rgba(127, 156, 255, 0.5); }

.scrub {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0a0a0f;
  cursor: pointer;
}
.scrub::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0a0a0f;
  cursor: pointer;
}

.timecode {
  flex: 0 0 auto;
  min-width: 92px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.speed {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  cursor: pointer;
}
