:root {
  --bg-dark: rgba(12, 16, 24, 0.74);
  --border-glass: rgba(120, 175, 255, 0.22);
  --accent-blue: #2f88ff;
  --accent-neon: #4da2ff;
  --text-main: #f2f6fc;
  --text-dim: #9aa8be;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #6c6e72;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

body.hud-hidden #hud-top,
body.hud-hidden #camera-panel,
body.hud-hidden #hud-bottom {
  opacity: 0;
  pointer-events: none;
}

#hud-top,
#camera-panel,
#hud-bottom {
  transition: opacity 0.25s ease;
}

.glass-panel {
  background: var(--bg-dark);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Top Bar */
#hud-top {
  position: fixed;
  top: 16px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 10;
}

.brand-block {
  background: var(--bg-dark);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent-neon);
  margin-bottom: 2px;
}

.brand-block h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-block h1 .accent {
  color: var(--accent-neon);
  font-weight: 600;
}

.gpu-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--bg-dark);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  min-width: 72px;
}

.gpu-pill {
  max-width: 260px;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#stat-fps {
  color: #4ade80;
}

/* Right/Left Side Panel */
#camera-panel {
  position: fixed;
  top: 98px;
  left: 18px;
  width: 256px;
  padding: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent-neon);
}

.cam-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.scene-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.scene-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.scene-btn:hover {
  background: rgba(47, 136, 255, 0.22);
}

.scene-btn.active {
  background: linear-gradient(135deg, #0d8a58, #14b875);
  border-color: #6ee7b7;
  box-shadow: 0 0 14px rgba(20, 184, 117, 0.42);
  color: #fff;
}

.cam-btn, .action-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: center;
}

.cam-btn:hover, .action-btn:hover {
  background: rgba(47, 136, 255, 0.22);
  border-color: rgba(77, 162, 255, 0.55);
}

.cam-btn.active {
  background: linear-gradient(135deg, #1b66d1, #2f88ff);
  border-color: #7ab8ff;
  box-shadow: 0 0 14px rgba(47, 136, 255, 0.45);
  color: #fff;
}

.panel-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 2px 0;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #dce5f2;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--accent-blue);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: #dce5f2;
}

.slider-top {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

#steer-sens-val {
  color: var(--accent-neon);
  font-weight: 700;
}

.slider-row input[type="range"] {
  width: 100%;
  height: 5px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.action-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.accent-btn {
  background: linear-gradient(135deg, rgba(25, 96, 210, 0.55), rgba(56, 138, 255, 0.45));
  border-color: rgba(96, 172, 255, 0.55);
}

.race-btn {
  background: linear-gradient(135deg, #b81226, #e62e45);
  border-color: #ff8fa0;
  font-weight: 800;
  font-size: 11.5px;
  padding: 8px 10px;
  box-shadow: 0 0 16px rgba(230, 46, 69, 0.38);
}

.race-btn:hover {
  background: linear-gradient(135deg, #d4162d, #ff4259);
  border-color: #ffc2cb;
}

/* Head-to-Head 2x R34 Race Telemetry Bar */
#race-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  min-width: 310px;
}

.race-pos {
  font-size: 20px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0d8a58, #16c17c);
  color: #fff;
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.race-pos.second {
  background: linear-gradient(135deg, #b81226, #e62e45);
}

.race-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.race-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.race-title {
  color: #dbeafe;
}

.race-gap {
  color: #4ade80;
  font-variant-numeric: tabular-nums;
}

.race-gap.behind {
  color: #fb7185;
}

.race-bar-track {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  overflow: visible;
}

.race-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f88ff, #60a5fa);
  border-radius: 99px;
  transition: width 0.1s linear;
}

.race-bar-rival {
  position: absolute;
  top: -3px;
  left: 0%;
  width: 10px;
  height: 12px;
  border-radius: 3px;
  background: #ff334b;
  border: 1.5px solid #fff;
  transform: translateX(-50%);
  transition: left 0.1s linear;
}

.race-timer {
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fde047;
  min-width: 62px;
  text-align: right;
}

#race-banner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 34px;
  border-radius: 16px;
  background: rgba(10, 14, 24, 0.84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(120, 185, 255, 0.55);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-shadow: 0 0 24px rgba(77, 162, 255, 0.85);
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#race-banner.hidden {
  opacity: 0;
  transform: translate(-50%, -60%) scale(0.92);
}

/* Bottom HUD */
#hud-bottom {
  position: fixed;
  bottom: 16px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 10;
}

.controls-hint {
  padding: 9px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: #d4deed;
}

kbd {
  display: inline-block;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  margin-right: 2px;
}

.speedo-box {
  padding: 10px 18px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 220px;
  justify-content: flex-end;
}

.odo-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 10px;
  padding-right: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.odo-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.odo-val {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #93c5fd;
}

.speed-num {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 0 16px rgba(77, 162, 255, 0.65);
}

.speed-unit {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}

.gear-badge {
  margin-left: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(47, 136, 255, 0.26);
  border: 1px solid rgba(90, 168, 255, 0.55);
  font-size: 13px;
  font-weight: 800;
  color: #7cc0ff;
}

@media (max-width: 820px) {
  #camera-panel {
    width: 215px;
    padding: 10px;
  }
  .controls-hint {
    display: none;
  }
}
