html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: #0d1320;
  color: #e8ecf2;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

#app canvas {
  display: block;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-variant-numeric: tabular-nums;
}

.hud-speed {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  text-align: center;
  width: 300px;
}

.hud-speed .value {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -2px;
  font-style: italic;
}

.hud-speed .unit {
  margin-left: 6px;
  font-size: 16px;
  font-weight: 700;
  opacity: 0.8;
}

.hud-speed .bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.hud-speed .fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #31e8ff, #ff3d7f);
}

.hud-speed .sub {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.7;
}

.hud-lap {
  position: absolute;
  left: 20px;
  top: 16px;
  min-width: 200px;
  font-size: 14px;
}

.hud-lap .row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  opacity: 0.8;
}

.hud-lap .row.big {
  font-size: 22px;
  font-weight: 700;
  opacity: 1;
}

.hud-flags {
  position: absolute;
  top: 18%;
  width: 100%;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #ffd23f;
}

.hud-banner {
  position: absolute;
  top: 30%;
  width: 100%;
  text-align: center;
  font-size: 48px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 2px;
  opacity: 0;
  transition: opacity 0.4s;
}

.hud-banner .note {
  margin: 8px auto 0;
  max-width: min(560px, 90vw);
  font-size: 15px;
  font-weight: 500;
  font-style: normal;
  letter-spacing: 0;
  line-height: 1.4;
}

.hud-map {
  position: absolute;
  left: 16px;
  top: 130px;
  width: 240px;
  height: 240px;
  background: rgba(5, 10, 20, 0.45);
  border-radius: 8px;
}

.hud-help {
  position: absolute;
  left: 20px;
  bottom: 14px;
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.65;
  max-width: 30vw;
}

.lil-gui.root {
  --width: 300px;
}

/* Touch play ------------------------------------------------------------ */

#touch {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
}

#touch-buttons {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  right: calc(env(safe-area-inset-right) + 10px);
  z-index: 6;
  display: none;
  gap: 8px;
}

#touch-buttons button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  background: rgba(10, 16, 28, 0.55);
  color: #e8ecf2;
  font-size: 18px;
  touch-action: none;
}

#touch-buttons button:active {
  background: rgba(49, 232, 255, 0.35);
}

body.touch #touch {
  display: block;
}

body.touch #touch-buttons {
  display: flex;
}

body.touch .hud-help,
body.touch .stats {
  display: none;
}

body.touch .hud-speed {
  top: calc(env(safe-area-inset-top) + 92px);
  bottom: auto;
  width: 160px;
}

body.touch .hud-speed .value {
  font-size: 44px;
}

body.touch .hud-lap {
  left: calc(env(safe-area-inset-left) + 12px);
  top: calc(env(safe-area-inset-top) + 10px);
  min-width: 140px;
  font-size: 12px;
}

body.touch .hud-lap .row.big {
  font-size: 16px;
}

body.touch .hud-banner .note {
  margin: 8px auto 0;
  max-width: min(560px, 90vw);
  font-size: 15px;
  font-weight: 500;
  font-style: normal;
  letter-spacing: 0;
  line-height: 1.4;
}

.hud-map {
  left: auto;
  right: calc(env(safe-area-inset-right) + 10px);
  top: calc(env(safe-area-inset-top) + 64px);
  width: 96px;
  height: 96px;
}

body.touch .hud-flags {
  top: 30%;
  font-size: 16px;
}

body.touch .hud-banner {
  top: 36%;
  font-size: 36px;
}

.stick {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

body.thumb-down .stick {
  opacity: 1;
}

.stick-ring,
.stick-airbrake,
.stick-knob {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.stick-ring {
  width: calc(var(--steer) * 2);
  height: calc(var(--steer) * 2);
  border: 2px solid rgba(232, 236, 242, 0.45);
  background: rgba(10, 16, 28, 0.2);
}

.stick.braking .stick-ring {
  border-color: rgba(255, 210, 63, 0.9);
}

/* Half-rings beyond full lock: the airbrake zones. */
.stick-airbrake {
  width: calc(var(--air) * 2);
  height: calc(var(--air) * 2);
  border: 8px solid transparent;
  box-sizing: border-box;
}

.stick-airbrake.left {
  border-left-color: #ff3d7f;
}

.stick-airbrake.right {
  border-right-color: #31e8ff;
}

.stick-knob {
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  transform: none;
  background: rgba(232, 236, 242, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.touch-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 18%);
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.75;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  transition: opacity 0.3s;
}

body.thumb-down .touch-hint,
body.raced .touch-hint {
  opacity: 0;
}
