/* SLIP — neon UI */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --neon: #00e5ff;
  --bg: #05050f;
  --panel: rgba(10, 12, 28, .88);
  --text: #dfe8ff;
  --dim: #7482a8;
}
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: .06em;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px;
  background: radial-gradient(ellipse at 50% 40%, rgba(0,229,255,.06), transparent 60%);
}
.logo {
  font-size: clamp(64px, 16vw, 130px);
  font-weight: 800; font-style: italic;
  color: #fff;
  text-shadow: 0 0 18px var(--neon), 0 0 60px var(--neon), 3px 3px 0 #ff2d78;
}
.tagline { color: var(--dim); margin-bottom: 18px; text-transform: uppercase; font-size: 13px; }
.help { color: var(--dim); font-size: 12px; margin-top: 12px; text-align: center; }
.error { color: #ff5d5d; font-size: 13px; }

form#join-form { display: flex; flex-direction: column; gap: 12px; width: min(340px, 90vw); }
input[type=text] {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(0,229,255,.35);
  border-radius: 6px;
  color: var(--text);
  font: inherit; text-transform: uppercase;
  padding: 12px 14px; width: 100%; outline: none;
}
input[type=text]:focus { border-color: var(--neon); box-shadow: 0 0 12px rgba(0,229,255,.35); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
button {
  font: inherit; color: var(--text); cursor: pointer;
  background: rgba(0,229,255,.08);
  border: 1px solid rgba(0,229,255,.4);
  border-radius: 6px; padding: 10px 14px;
  transition: box-shadow .15s, background .15s;
}
button:hover { background: rgba(0,229,255,.18); box-shadow: 0 0 14px rgba(0,229,255,.3); }
button.big {
  font-size: 17px; font-weight: 700; padding: 14px;
  background: linear-gradient(90deg, rgba(0,229,255,.25), rgba(255,45,120,.25));
  border-color: var(--neon);
  text-shadow: 0 0 8px rgba(255,255,255,.6);
}
button.big.armed { background: linear-gradient(90deg, rgba(124,255,79,.3), rgba(0,229,255,.25)); border-color: #7cff4f; }
.swatches { display: flex; gap: 10px; justify-content: center; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid transparent; padding: 0;
}
.swatch.selected { border-color: #fff; box-shadow: 0 0 12px currentColor; transform: scale(1.15); }

/* ---------- panel (lobby / results / waiting) ---------- */
.panel {
  background: var(--panel);
  border: 1px solid rgba(0,229,255,.25);
  border-radius: 12px;
  padding: 26px 30px;
  width: min(680px, 94vw);
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 0 40px rgba(0,229,255,.12);
  display: flex; flex-direction: column; gap: 16px;
}
.panel h2 { font-size: 22px; letter-spacing: .12em; }
.panel h3 { font-size: 12px; color: var(--dim); margin-bottom: 8px; letter-spacing: .2em; }
#room-code { color: var(--neon); cursor: pointer; text-decoration: underline dotted; }
#room-code::after { content: attr(data-code); }
.lobby-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 22px; }
@media (max-width: 640px) { .lobby-grid { grid-template-columns: 1fr; } }

#lobby-players li, #results-list li, #waiting-standings li {
  list-style: none; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; margin-bottom: 6px;
  background: rgba(255,255,255,.04); font-size: 14px;
}
#lobby-players li.self, #results-list li.self { outline: 1px solid rgba(0,229,255,.4); }
#lobby-players i, #results-list i, #waiting-standings i {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  box-shadow: 0 0 8px currentColor;
}
#lobby-players em, #results-list em, #waiting-standings em { margin-left: auto; font-style: normal; color: var(--dim); font-size: 12px; }
#lobby-players li em:empty::after { content: '…'; }

#track-picker { display: flex; flex-direction: column; gap: 8px; }
.track-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.12);
}
.track-card.selected { border-color: var(--neon); box-shadow: 0 0 14px rgba(0,229,255,.35); background: rgba(0,229,255,.08); }
.track-card canvas { flex: none; }
.track-card b { display: block; font-size: 14px; }
.track-card span { font-size: 11px; color: var(--dim); }

#results-list b { width: 44px; font-size: 18px; }
#results-list li.place-1 { background: linear-gradient(90deg, rgba(255,200,60,.18), rgba(255,255,255,.03)); }
#results-list li.place-2 { background: linear-gradient(90deg, rgba(200,210,230,.14), rgba(255,255,255,.03)); }
#results-list li.place-3 { background: linear-gradient(90deg, rgba(200,120,60,.14), rgba(255,255,255,.03)); }

/* ---------- race HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#hud > div { position: absolute; }
#hud-lap { top: 18px; left: 20px; font-size: 20px; font-weight: 700; text-shadow: 0 0 10px rgba(0,229,255,.8); }
#hud-time { top: 46px; left: 20px; font-size: 13px; color: var(--dim); }
#hud-place { top: 12px; right: 20px; font-size: 34px; font-weight: 800; text-shadow: 0 0 12px rgba(255,45,120,.8); }
#hud-place small { font-size: 15px; color: var(--dim); }
#hud-speed-wrap { bottom: 26px; left: 50%; transform: translateX(-50%); text-align: center; }
#hud-speed { font-size: 44px; font-weight: 800; text-shadow: 0 0 14px var(--neon); }
#hud-speed-wrap small { color: var(--dim); margin-left: 6px; }
#hud-speedbar-track { width: 220px; height: 4px; background: rgba(255,255,255,.1); border-radius: 2px; margin: 4px auto 0; }
#hud-speedbar { height: 100%; width: 0; border-radius: 2px; background: linear-gradient(90deg, var(--neon), #ff2d78); box-shadow: 0 0 8px var(--neon); }
#wrong-way {
  top: 30%; left: 50%; transform: translateX(-50%);
  font-size: 28px; font-weight: 800; color: #ff5d5d;
  text-shadow: 0 0 16px rgba(255,60,60,.9);
  animation: blink .5s steps(2) infinite;
}
#finished-banner {
  top: 24%; left: 50%; transform: translateX(-50%);
  font-size: 36px; font-weight: 800; color: #7cff4f;
  text-shadow: 0 0 20px rgba(124,255,79,.8);
}
@keyframes blink { 50% { opacity: .25; } }

#countdown {
  position: fixed; top: 38%; left: 50%; transform: translate(-50%, -50%);
  z-index: 8; font-size: clamp(90px, 22vw, 180px); font-weight: 800; font-style: italic;
  color: #fff; text-shadow: 0 0 30px var(--neon), 0 0 90px var(--neon);
  pointer-events: none;
}
#countdown.pulse { animation: pop .8s ease-out; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }

/* ---------- ship picker ---------- */
#ship-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ship-card {
  text-align: left; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px;
  background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.14);
}
.ship-card.selected { border-color: var(--neon); box-shadow: 0 0 14px rgba(0,229,255,.35); background: rgba(0,229,255,.08); }
.ship-card b { font-size: 13px; letter-spacing: .08em; }
.ship-card > span { font-size: 9px; color: var(--dim); min-height: 22px; margin-bottom: 3px; }
.ship-card .stat { display: flex; align-items: center; gap: 6px; }
.ship-card .stat label { font-size: 8px; color: var(--dim); width: 22px; }
.ship-card .cells { display: flex; gap: 2px; }
.ship-card .cells i {
  width: 9px; height: 4px; border-radius: 1px;
  background: rgba(255,255,255,.12);
}
.ship-card .cells i.on { background: var(--neon); box-shadow: 0 0 4px var(--neon); }
.ship-card.selected .cells i.on { background: #fff; box-shadow: 0 0 5px var(--neon); }
.ship-tag { display: block; font-size: 9px; color: var(--dim); letter-spacing: .1em; }

/* ---------- boost screen FX ---------- */
#boost-fx { position: fixed; inset: 0; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .18s; }
#boost-fx.active { opacity: 1; }
#boost-fx .lines {
  position: absolute; inset: -22%;
  background: repeating-conic-gradient(from 0deg,
    transparent 0deg 4.5deg,
    rgba(170,225,255,.5) 4.5deg 5.3deg,
    transparent 5.3deg 9.5deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 34%, black 78%);
  mask-image: radial-gradient(circle at 50% 50%, transparent 34%, black 78%);
  opacity: 0;
}
#boost-fx.active .lines { opacity: .32; animation: boostspin .9s linear infinite; }
@keyframes boostspin {
  from { transform: rotate(0deg) scale(1.06); }
  to   { transform: rotate(11deg) scale(1); }
}
#boost-fx .flash {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(200,245,255,0) 25%, rgba(110,200,255,.5) 100%);
  opacity: 0;
}
#boost-fx.active .flash { animation: boostflash .55s ease-out; }
@keyframes boostflash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: var(--panel); border: 1px solid rgba(0,229,255,.35); border-radius: 6px;
  padding: 8px 18px; font-size: 13px;
  opacity: 0; transform: translateY(-8px); transition: all .3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 6; }
#zone-left, #zone-right {
  position: absolute; bottom: 0; top: 40%; width: 34%;
  display: flex; align-items: flex-end; justify-content: center;
  color: rgba(255,255,255,.25); font-size: 70px; padding-bottom: 30px;
}
#zone-left { left: 0; } #zone-right { right: 0; }
#zone-left.active, #zone-right.active { color: var(--neon); }
#btn-brake {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 52px; border-radius: 26px; font-weight: 700;
  background: rgba(255,45,120,.15); border-color: rgba(255,45,120,.5);
}
#btn-brake.active { background: rgba(255,45,120,.4); }
#btn-reset {
  position: absolute; top: 76px; right: 16px;
  width: 44px; height: 44px; border-radius: 50%;
}
