/* SynthStreet — synthwave UI */
:root {
  --bg: #120024;
  --pink: #ff2d95;
  --cyan: #00f0ff;
  --orange: #ff9e1f;
  --panel: rgba(18, 0, 36, 0.88);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 10;
}
.screen.visible { display: flex; align-items: center; justify-content: center; }
.screen.overlay { background: rgba(8, 0, 18, 0.75); z-index: 40; }

/* ---------- title ---------- */
#screen-title {
  background:
    radial-gradient(ellipse at 50% 110%, #ff2d9540 0%, transparent 55%),
    linear-gradient(180deg, #0b0018 0%, #1c0140 55%, #43055f 80%, #962f6e 100%);
  flex-direction: column;
}
.title-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(92vw, 420px);
  padding-bottom: env(safe-area-inset-bottom);
}
.logo {
  font-size: clamp(40px, 11vw, 64px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 18px var(--cyan), 0 0 50px #00f0ff66;
}
.logo span {
  color: var(--pink);
  text-shadow: 0 0 18px var(--pink), 0 0 50px #ff2d9566;
}
.tagline {
  color: var(--orange);
  letter-spacing: 6px;
  text-transform: uppercase;
  font-size: 13px;
  margin-top: -10px;
}
.place-row { width: 100%; margin-top: 14px; }
#place-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px; /* 16px stops iOS zoom-on-focus */
  border: 2px solid var(--cyan);
  border-radius: 10px;
  background: #0b0018cc;
  color: #fff;
  outline: none;
  box-shadow: 0 0 12px #00f0ff44 inset, 0 0 10px #00f0ff33;
  text-align: center;
}
#place-input::placeholder { color: #9fb6c9; }

.btn {
  border: 2px solid var(--pink);
  background: #2a0145;
  color: #fff;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 0 12px #ff2d9544;
}
.btn:active { transform: scale(0.97); background: #3b0260; }
.btn-ghost { border-color: #ffffff44; background: transparent; box-shadow: none; font-weight: 400; }
.btn.small { font-size: 13px; padding: 8px 12px; }

.mode-row { display: flex; gap: 10px; width: 100%; margin-top: 4px; }
.btn-mode {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  padding: 14px 4px;
  font-size: 15px;
}
.btn-mode small { font-weight: 400; font-size: 10px; color: #d8b9ff; letter-spacing: 0; }
.btn-mode.selected { border-color: var(--cyan); box-shadow: 0 0 16px #00f0ff66; background: #013a45; }
.credits { font-size: 10px; color: #ffffff66; margin-top: 10px; }

/* ---------- loading ---------- */
#screen-loading { background: var(--bg); }
.loading-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
#loading-status { color: var(--cyan); letter-spacing: 1px; }
.spinner {
  width: 54px; height: 54px;
  border: 4px solid #ff2d9533;
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 18px #ff2d9555;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- game ---------- */
#screen-game { background: #000; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.hud-box {
  background: rgba(10, 0, 24, 0.55);
  border: 1px solid #00f0ff55;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  text-shadow: 0 0 8px var(--cyan);
}
#hud-top {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
#hud-track-name {
  position: absolute;
  bottom: calc(8px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: var(--orange); text-shadow: 0 0 8px var(--orange);
  font-size: 11px; max-width: 46vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#hud-pos { color: var(--pink); text-shadow: 0 0 8px var(--pink); font-size: 18px; }
#hud-times {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  left: 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#hud-time-best { color: var(--orange); font-size: 11px; font-weight: 400; }
#minimap {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  right: 10px;
  width: 110px; height: 110px;
  background: rgba(10, 0, 24, 0.45);
  border: 1px solid #ff2d9555;
  border-radius: 10px;
}
#hud-speed {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  font-size: 44px;
  font-weight: 900;
  font-style: italic;
  color: var(--cyan);
  text-shadow: 0 0 14px var(--cyan);
  font-variant-numeric: tabular-nums;
}
#hud-speed small { font-size: 14px; color: var(--pink); margin-left: 4px; }
#hud-message {
  position: absolute;
  top: 32vh; left: 0; right: 0;
  text-align: center;
  font-size: clamp(40px, 14vw, 90px);
  font-weight: 900;
  font-style: italic;
  color: var(--orange);
  text-shadow: 0 0 24px var(--orange);
  pointer-events: none;
}
#hud-attrib {
  position: absolute;
  bottom: calc(2px + env(safe-area-inset-bottom));
  right: 6px;
  font-size: 9px;
  color: #ffffff55;
  display: none;
}
#btn-pause {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  background: rgba(10, 0, 24, 0.55);
  border: 1px solid #ffffff44;
  color: #fff;
  border-radius: 8px;
  width: 38px; height: 32px;
  font-size: 15px;
}
#btn-brake {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  right: 14px;
  z-index: 30;
  width: 110px; height: 76px;
  border-radius: 16px;
  border: 2px solid var(--pink);
  background: rgba(64, 1, 36, 0.6);
  color: var(--pink);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 0 8px var(--pink);
}
#btn-brake.held { background: rgba(255, 45, 149, 0.45); color: #fff; }
.steer-pad {
  position: absolute;
  bottom: 16vh;
  width: 64px; height: 64px;
  border: 2px solid #00f0ff88;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #00f0ffcc;
  font-size: 26px;
  background: rgba(0, 240, 255, 0.07);
  pointer-events: none; /* steering = touch anywhere on that half */
  transition: background 0.1s, transform 0.1s;
}
#steer-left { left: 7vw; }
#steer-right { right: 7vw; }
.steer-pad.active {
  background: rgba(0, 240, 255, 0.35);
  color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 22px #00f0ff88;
}
.howto-rows { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.howto-row { display: flex; gap: 12px; align-items: center; font-size: 14px; line-height: 1.45; }
.howto-icon { min-width: 38px; text-align: center; font-size: 17px; color: var(--cyan); font-weight: 900; }
.howto-row b { color: var(--orange); }
.desktop-only { display: none; }
@media (hover: hover) and (pointer: fine) {
  .steer-pad, #btn-brake { display: none; } /* desktop: keyboard */
  .touch-only { display: none; }
  .desktop-only { display: flex; }
}

/* ---------- panels (pause / results) ---------- */
.panel {
  background: var(--panel);
  border: 2px solid var(--cyan);
  border-radius: 16px;
  box-shadow: 0 0 30px #00f0ff44;
  padding: 26px 30px;
  display: flex; flex-direction: column; gap: 12px;
  width: min(86vw, 360px);
  text-align: center;
}
.panel h2 {
  font-style: italic;
  font-size: 30px;
  color: var(--pink);
  text-shadow: 0 0 14px var(--pink);
  letter-spacing: 2px;
}
#results-body { font-size: 14px; line-height: 1.7; font-variant-numeric: tabular-nums; }
#results-body .best { color: var(--orange); }
#results-body table { width: 100%; border-collapse: collapse; }
#results-body td { padding: 2px 6px; }
#results-body td:first-child { text-align: left; color: var(--cyan); }
#results-body td:last-child { text-align: right; }
