:root {
  --ink: #f6f1ff;
  --muted: #b9a8de;
  --night: #120a26;
  --panel: rgba(18, 10, 38, 0.86);
  --neon: #c13cff;
  --hot: #ff3d7f;
  --amber: #ffb43d;
  --line: rgba(193, 60, 255, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: "Chakra Petch", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-family: "Press Start 2P", monospace;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 8px; }
.hud-right { align-items: flex-end; }
.hud-box {
  background: rgba(10, 5, 24, 0.72);
  border: 2px solid var(--line);
  padding: 8px 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  text-shadow: 2px 2px 0 #000;
}
.hud-box .label { color: var(--muted); font-size: 9px; }
.hud-box .big { font-size: 20px; color: var(--amber); }
.speedo .big { font-size: 26px; min-width: 3ch; text-align: right; }
#minimap {
  width: 120px;
  height: 120px;
  background: rgba(10, 5, 24, 0.55);
  border: 2px solid var(--line);
}

#progress {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, 60vw);
  height: 8px;
  background: rgba(10, 5, 24, 0.7);
  border: 2px solid var(--line);
  pointer-events: none;
}
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--neon), var(--hot)); }

#corner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(12px, 2.4vw, 22px);
  color: #fff;
  background: rgba(10, 5, 24, 0.7);
  border-left: 6px solid var(--hot);
  padding: 10px 16px;
  white-space: nowrap;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  animation: slidein 0.35s ease-out;
}
@keyframes slidein { from { opacity: 0; transform: translate(-50%, -12px); } }

/* ---------- start lights ---------- */
#lights {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: #0b0b0f;
  border: 3px solid #2a2a33;
  border-radius: 6px;
  pointer-events: none;
}
#lights span {
  width: clamp(26px, 5vw, 44px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #2a0a0a;
  box-shadow: inset 0 0 0 3px #111;
}
#lights span.on { background: #ff1a1a; box-shadow: 0 0 18px #ff1a1a, inset 0 0 0 3px #111; }

/* ---------- touch ---------- */
#touch {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(40px, calc(env(safe-area-inset-bottom) + 30px));
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}
#touch button {
  pointer-events: auto;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: rgba(10, 5, 24, 0.55);
  color: #fff;
  font-size: 30px;
  touch-action: none;
}
#touch button.brake {
  position: absolute;
  right: 0;
  bottom: 100px;
  width: 84px;
  height: 52px;
  border-radius: 26px;
  font: 10px "Press Start 2P", monospace;
}
#touch button.active { background: rgba(193, 60, 255, 0.5); }

#mute {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  background: rgba(10, 5, 24, 0.7);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  z-index: 5;
}
#mute.off { color: #666; text-decoration: line-through; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(18, 10, 38, 0.35), rgba(18, 10, 38, 0.8));
  z-index: 10;
}
.panel {
  width: min(560px, 100%);
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 0 0 0 6px rgba(18, 10, 38, 0.6), 0 0 60px rgba(193, 60, 255, 0.35);
  padding: clamp(20px, 4vw, 36px);
  text-align: center;
}
.kicker {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1, h2 {
  font-family: "Press Start 2P", monospace;
  margin: 0 0 18px;
  line-height: 1.35;
  text-shadow: 3px 3px 0 #000;
}
h1 { font-size: clamp(20px, 5vw, 34px); color: #fff; }
h1 span { color: var(--hot); }
h2 { font-size: clamp(18px, 4.4vw, 28px); color: var(--amber); }
.lead { font-size: 18px; margin: 0 0 20px; color: var(--ink); }
.lead strong { color: var(--amber); }
.controls {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 14px;
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 5px;
  margin: 0 2px;
  border: 1px solid var(--muted);
  border-bottom-width: 3px;
  border-radius: 4px;
  font: 12px "Chakra Petch", sans-serif;
  color: var(--ink);
}
body:not(.touch-device) .touch-only { display: none; }
body.touch-device .controls li:not(.touch-only) { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn {
  display: inline-block;
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(180deg, var(--hot), #c4135a);
  border: 0;
  border-bottom: 5px solid #7d0b3a;
  padding: 16px 22px;
  cursor: pointer;
  text-decoration: none;
  text-shadow: 2px 2px 0 #000;
  transition: transform 0.08s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
#btn-portfolio { background: linear-gradient(180deg, #34e07a, #18a352); border-bottom-color: #0d6331; }
.skip {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}
.skip:hover { color: var(--ink); }
.noscript { position: fixed; inset: auto 16px 16px; text-align: center; }
.noscript a { color: var(--amber); }

@media (max-width: 640px) {
  .hud-box { padding: 6px 7px; font-size: 10px; }
  .hud-box .big { font-size: 14px; }
  .speedo .big { font-size: 18px; }
  #minimap { width: 84px; height: 84px; }
  .lead { font-size: 16px; }
}

/* ---------- pause ---------- */
#pause-btn {
  position: fixed;
  right: 64px;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  background: rgba(10, 5, 24, 0.7);
  color: var(--ink);
  font: 12px "Press Start 2P", monospace;
  cursor: pointer;
  z-index: 5;
}
.btn.secondary { background: transparent; border: 2px solid var(--line); border-bottom-width: 5px; }
