:root {
  --bg-top: #101825;
  --bg-bottom: #090d13;
  --txt: #eef6ff;
  --txt-dim: #b9c8d8;
  --panel: rgba(11, 18, 26, 0.8);
  --panel-strong: rgba(8, 14, 22, 0.9);
  --panel-border: rgba(176, 205, 232, 0.2);
  --panel-shadow: rgba(0, 0, 0, 0.42);
  --cyan: #8ed9ff;
  --ice: #d8f4ff;
  --warm: #ffb06f;
  --danger: #ff8b72;
  --speed-fill: 0%;
  --drift-intensity: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -18%, rgba(255, 176, 111, 0.12), transparent 34%),
    radial-gradient(circle at 14% 0%, rgba(138, 206, 255, 0.14), transparent 38%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--txt);
  font-family: "Rajdhani", "Segoe UI", sans-serif;
}

body {
  position: relative;
}

#drift-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.drift_hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.screen_fx,
.fx_gradient,
.fx_vignette,
.fx_driftflash {
  position: absolute;
  inset: 0;
}

.screen_fx {
  overflow: hidden;
}

.fx_gradient {
  background:
    linear-gradient(180deg, rgba(10, 16, 24, 0.34) 0%, rgba(10, 16, 24, 0.04) 26%, rgba(10, 16, 24, 0.18) 100%),
    radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.24));
}

.fx_vignette {
  inset: -8%;
  background: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 48%, rgba(0, 0, 0, 0.5) 100%);
}

.fx_speedlines {
  display: none;
}

.fx_driftflash {
  opacity: calc(var(--drift-intensity) * 0.24);
  background:
    radial-gradient(circle at 18% 76%, rgba(255, 143, 94, 0.32), transparent 48%),
    radial-gradient(circle at 82% 74%, rgba(123, 213, 255, 0.28), transparent 50%);
  transition: opacity 90ms linear;
}

.hud_stack {
  position: absolute;
  display: grid;
  gap: 0.78rem;
  width: min(28vw, 320px);
}

.hud_stack_left {
  top: 16px;
  left: 16px;
}

.hud_stack_right {
  top: 16px;
  right: 16px;
}

.hud_panel,
.hud_strip,
.overlay_message {
  border: 1px solid var(--panel-border);
  background:
    radial-gradient(circle at top, rgba(141, 205, 255, 0.08), transparent 55%),
    linear-gradient(180deg, var(--panel), var(--panel-strong));
  box-shadow:
    0 18px 44px var(--panel-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hud_panel {
  border-radius: 18px;
  padding: 0.95rem 1rem;
}

.hud_label {
  display: block;
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #cedcf0;
}

.hud_panel_speed {
  display: grid;
  gap: 0.7rem;
}

.hud_speedline {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

.hud_speed_value {
  font-family: "Teko", "Rajdhani", sans-serif;
  font-size: clamp(3.8rem, 7vw, 5.6rem);
  line-height: 0.8;
  letter-spacing: 0.03em;
  color: var(--ice);
  text-shadow:
    0 2px 1px rgba(0, 0, 0, 0.9),
    0 0 18px rgba(114, 198, 255, 0.2);
}

.hud_speed_unit {
  padding-bottom: 0.68rem;
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  color: var(--txt-dim);
}

.hud_meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(173, 204, 231, 0.16);
}

.hud_meter_fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan) 0%, #76b9ff 58%, var(--warm) 100%);
  box-shadow: 0 0 14px rgba(108, 194, 255, 0.4);
  transition: width 120ms linear;
}

.hud_panel_state {
  display: grid;
  gap: 0.28rem;
}

.hud_state_text {
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.hud_state_text[data-state="idle"] {
  color: #e1e8f2;
}

.hud_state_text[data-state="driving"] {
  color: #9fddff;
}

.hud_state_text[data-state="sliding"] {
  color: #ffd48d;
}

.hud_state_text[data-state="hard-drift"] {
  color: #ff9d72;
}

.hud_meta {
  font-size: 0.88rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--txt-dim);
}

.hud_meta[data-surface="track"] {
  color: #a7ebff;
}

.hud_meta[data-surface="shoulder"] {
  color: #ffd48d;
}

.hud_meta[data-surface="offroad"] {
  color: var(--danger);
}

.hud_panel_stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.hud_stat {
  display: grid;
  gap: 0.18rem;
  padding: 0.65rem 0.72rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(190, 214, 232, 0.08);
}

.hud_stat_value {
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  color: var(--ice);
}

.overlay_message {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  min-width: min(80vw, 520px);
  padding: 0.72rem 1rem;
  border-radius: 999px;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f3f8ff;
}

.hud_strip {
  position: absolute;
  bottom: 16px;
  max-width: min(36vw, 420px);
  padding: 0.72rem 0.9rem;
  border-radius: 14px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  line-height: 1.35;
  color: #d4e0ec;
}

.hud_strip_left {
  left: 16px;
}

.hud_strip_right {
  right: 16px;
  text-align: right;
}

.touch_controls {
  display: none;
}

.top_nav {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  pointer-events: auto;
}

.top_nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.72rem 0.98rem;
  border-radius: 12px;
  color: var(--txt);
  text-decoration: none;
  background: rgba(9, 14, 22, 0.82);
  border: 1px solid rgba(148, 188, 220, 0.24);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.26);
}

.top_nav a:hover {
  border-color: rgba(190, 226, 255, 0.5);
  color: #f6fbff;
}

@media (max-width: 1024px) and (pointer: coarse), (max-width: 820px) {
  .touch_controls {
    position: absolute;
    left: max(12px, calc(env(safe-area-inset-left, 0px) + 8px));
    right: max(12px, calc(env(safe-area-inset-right, 0px) + 8px));
    bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    z-index: 6;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
  }

  .touch_cluster {
    display: flex;
    gap: 10px;
    pointer-events: auto;
  }

  .touch_cluster--drive {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: min(54vw, 320px);
  }

  .touch_btn {
    min-width: 72px;
    min-height: 48px;
    padding: 0.7rem 0.92rem;
    border-radius: 16px;
    border: 1px solid rgba(178, 220, 249, 0.28);
    background:
      radial-gradient(circle at top, rgba(142, 217, 255, 0.08), transparent 54%),
      linear-gradient(180deg, rgba(12, 18, 26, 0.92), rgba(7, 11, 18, 0.9));
    color: var(--txt);
    font-family: "Orbitron", "Rajdhani", sans-serif;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow:
      0 16px 28px rgba(0, 0, 0, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
    touch-action: none;
    pointer-events: auto;
  }

  .touch_btn--primary {
    border-color: rgba(255, 191, 131, 0.36);
    color: #fff0de;
    background:
      radial-gradient(circle at top, rgba(255, 185, 118, 0.14), transparent 56%),
      linear-gradient(180deg, rgba(56, 30, 16, 0.92), rgba(13, 14, 20, 0.9));
  }

  .touch_btn--accent {
    border-color: rgba(255, 164, 114, 0.4);
    color: #fff1e4;
    background:
      radial-gradient(circle at top, rgba(255, 143, 94, 0.14), transparent 58%),
      linear-gradient(180deg, rgba(57, 24, 20, 0.92), rgba(16, 13, 18, 0.92));
  }

  .touch_btn--ghost {
    min-width: 84px;
  }

  .touch_btn:active {
    filter: brightness(1.08);
    transform: translateY(1px);
  }

  .hud_strip {
    display: none;
  }

  .overlay_message {
    top: auto;
    bottom: 112px;
    min-width: 0;
    width: calc(100vw - 24px);
  }
}

@media (max-width: 980px) {
  .hud_stack {
    width: min(42vw, 300px);
  }

  .hud_panel_stats {
    grid-template-columns: 1fr 1fr;
  }

  .hud_strip {
    max-width: min(44vw, 360px);
  }
}

@media (max-width: 720px) {
  .hud_stack {
    width: calc(100vw - 32px);
  }

  .hud_stack_left,
  .hud_stack_right {
    position: absolute;
    left: 16px;
    right: 16px;
  }

  .hud_stack_left {
    top: 16px;
  }

  .hud_stack_right {
    top: auto;
    bottom: 82px;
  }

  .overlay_message {
    top: auto;
    bottom: 176px;
    min-width: 0;
    width: calc(100vw - 32px);
  }

  .hud_speed_value {
    font-size: clamp(3.2rem, 12vw, 4.8rem);
  }

  .hud_strip {
    left: 16px;
    right: 16px;
    max-width: none;
    text-align: left;
  }

  .hud_strip_left {
    bottom: 16px;
  }

  .hud_strip_right {
    display: none;
  }

  .top_nav {
    top: auto;
    right: 16px;
    bottom: 16px;
  }
}
