/* 1A Apex Strike — UI styling. Neon-on-dark racing aesthetic. */

:root {
  --accent: #ff2d6f;
  --accent2: #1ec8ff;
  --bg0: #0a0e1a;
  --bg1: #131a30;
  --panel: rgba(18, 24, 44, 0.92);
  --text: #eef2ff;
  --muted: #93a0c4;
  --good: #39ff8b;
  --bad: #ff5c5c;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg0);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#game-canvas { position: fixed; inset: 0; z-index: 0; }
#game-canvas canvas { display: block; }

.hidden { display: none !important; }

/* ---------- Overlay / screens ---------- */
#overlay { position: fixed; inset: 0; z-index: 20; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(30, 200, 255, 0.18), transparent),
    radial-gradient(900px 600px at 10% 110%, rgba(255, 45, 111, 0.18), transparent),
    linear-gradient(160deg, var(--bg0), var(--bg1));
}
.screen.active { display: flex; }

/* When a race is running, level/results overlays keep the 3D scene visible behind */
.screen.transparent { background: rgba(6, 9, 18, 0.55); backdrop-filter: blur(2px); }

.panel {
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(120, 150, 220, 0.22);
  border-radius: 18px;
  padding: 26px 26px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.panel.center { text-align: center; }

h1, h2 { line-height: 1.15; }
h2 { font-size: 1.6rem; margin-bottom: 16px; }

.logo {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.logo-1a {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 28px rgba(255, 45, 111, 0.35);
}
.tagline { color: var(--muted); margin-bottom: 26px; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 16px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  color: var(--text);
  background: rgba(120, 150, 220, 0.14);
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  background: linear-gradient(90deg, var(--accent), #ff5e8a);
  box-shadow: 0 8px 24px rgba(255, 45, 111, 0.35);
}
.btn.ghost { background: transparent; border: 1px solid rgba(150, 170, 230, 0.4); }
.btn.big { font-size: 1.2rem; padding: 16px 40px; margin-top: 8px; }

.row { display: flex; gap: 12px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

/* ---------- Mode select ---------- */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-card {
  cursor: pointer;
  border: 2px solid rgba(150, 170, 230, 0.25);
  background: rgba(120, 150, 220, 0.08);
  border-radius: 16px;
  padding: 26px 14px;
  color: var(--text);
  transition: all 0.15s ease;
}
.mode-card:hover { border-color: var(--accent2); transform: translateY(-3px); }
.mode-card.selected { border-color: var(--accent); background: rgba(255, 45, 111, 0.12); }
.mode-emoji { font-size: 3rem; }
.mode-name { font-weight: 800; margin-top: 8px; font-size: 1.15rem; }
.mode-desc { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* ---------- Profile form ---------- */
.field-label {
  display: block;
  margin: 18px 0 8px;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.text-input {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(150, 170, 230, 0.35);
  background: rgba(8, 12, 24, 0.7);
  color: var(--text);
}
.text-input:focus { outline: none; border-color: var(--accent2); }
.error { color: var(--bad); font-size: 0.82rem; margin-top: 6px; display: none; }
.error.show { display: block; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1;
  min-width: 90px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(150, 170, 230, 0.3);
  background: rgba(120, 150, 220, 0.08);
  color: var(--text);
}
.seg button.selected { background: var(--accent2); color: #04121c; border-color: var(--accent2); }

.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-grid button {
  aspect-ratio: 1;
  font-size: 1.7rem;
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid rgba(150, 170, 230, 0.25);
  background: rgba(120, 150, 220, 0.08);
}
.avatar-grid button.selected { border-color: var(--accent); background: rgba(255, 45, 111, 0.16); }

.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.color-grid button {
  aspect-ratio: 1;
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.color-grid button.selected { border-color: #fff; transform: scale(1.12); }

/* ---------- Level intro / results ---------- */
.level-badge, .result-emoji { font-size: 2.6rem; }
.level-badge {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent2);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.blurb { color: var(--muted); margin: 8px 0 14px; }
.summary { color: var(--text); font-size: 0.9rem; margin-bottom: 14px; }
.controls-hint { color: var(--muted); font-size: 0.85rem; margin: 14px 0; }

.ranking { list-style: none; text-align: left; margin: 14px auto; max-width: 360px; }
.ranking li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: rgba(120, 150, 220, 0.08);
}
.ranking li.me { background: rgba(255, 45, 111, 0.18); border: 1px solid var(--accent); }
.ranking .pos { font-weight: 800; width: 28px; color: var(--accent2); }
.ranking .who { flex: 1; }
.ranking .av { font-size: 1.3rem; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-top {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px;
}
.hud-pill {
  background: rgba(8, 12, 24, 0.6);
  border: 1px solid rgba(150, 170, 230, 0.3);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}
#hud-position { color: var(--accent); }
.hud-progress {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  width: min(420px, 80vw); height: 8px;
  background: rgba(8, 12, 24, 0.6); border-radius: 999px; overflow: hidden;
}
#hud-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.1s linear; }
.hud-speedo {
  position: absolute; bottom: 18px; left: 22px;
  font-weight: 800; font-size: 2.4rem; line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums;
}
.hud-speedo .unit { font-size: 0.9rem; color: var(--muted); margin-left: 4px; }
.hud-pause {
  position: absolute; top: 14px; right: 14px;
  pointer-events: auto; cursor: pointer;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid rgba(150, 170, 230, 0.3);
  background: rgba(8, 12, 24, 0.6); color: var(--text); font-size: 1.1rem;
}
.hud-mute { right: 66px; }

/* Big centered countdown / messages */
.big-center {
  position: fixed; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(4rem, 18vw, 12rem); font-weight: 900;
  pointer-events: none;
  text-shadow: 0 0 40px rgba(255, 45, 111, 0.5);
}

/* ---------- Touch controls (mobile) ---------- */
#touch-controls { display: none; }
.tbtn {
  pointer-events: auto;
  width: 64px; height: 64px; margin: 6px;
  border-radius: 50%;
  border: 1px solid rgba(150, 170, 230, 0.4);
  background: rgba(8, 12, 24, 0.55); color: var(--text);
  font-size: 1.4rem;
}
.tbtn:active { background: var(--accent); }
@media (hover: none) and (pointer: coarse) {
  #touch-controls { display: block; }
  .touch-left { position: absolute; bottom: 24px; left: 16px; display: flex; }
  .touch-right { position: absolute; bottom: 24px; right: 16px; display: flex; flex-direction: column; }
}
