:root {
  --bg: #010507;
  --ink: #dff6ff;
  --muted: #6f8b99;
  --line: rgba(0, 229, 255, 0.26);
  --panel: rgba(2, 10, 16, 0.62);
  --accent: #00e5ff;
  --hot: #ff8a1f;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button {
  font: 600 11px/1 Orbitron, Inter, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
button:hover { background: rgba(0, 229, 255, 0.16); }
.muted { color: var(--muted); }

/* ---------- join card ---------- */
#join {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 70%, rgba(0, 229, 255, 0.06), transparent 65%);
  padding: 16px;
}
body.playing #join { display: none; }
.card {
  width: min(410px, 100%);
  background: rgba(1, 8, 13, 0.7);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 30px 26px;
  box-shadow: 0 0 60px rgba(0, 229, 255, 0.10), inset 0 1px 0 rgba(127, 232, 255, 0.25);
  backdrop-filter: blur(8px);
}
h1 {
  margin: 0 0 8px;
  font: 800 34px/1 Orbitron, sans-serif;
  letter-spacing: 0.16em;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(0, 229, 255, 0.75);
}
h1 span { color: var(--hot); text-shadow: 0 0 22px rgba(255, 138, 31, 0.75); margin-left: 10px; }
.tag { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
input {
  display: block; width: 100%; margin-top: 6px;
  font: 600 16px Inter, sans-serif; color: var(--ink);
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); border-radius: 4px;
  padding: 10px 12px; outline: none;
  -webkit-user-select: text; user-select: text;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.14); }
#play {
  width: 100%; margin-top: 8px; padding: 15px; font-size: 15px;
  background: rgba(0, 229, 255, 0.14); border-color: var(--accent);
  box-shadow: 0 0 26px rgba(0, 229, 255, 0.28);
}
.small { font-size: 12px; color: var(--muted); margin: 14px 0 0; line-height: 1.45; }
#status:empty { display: none; }

/* ---------- HUD ---------- */
#hud { display: none; }
body.playing #hud { display: block; }
#board {
  position: fixed; top: 14px; left: 14px; width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 10px 12px; font-size: 13px; backdrop-filter: blur(6px);
}
.board-head { font: 600 11px Orbitron, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-cols { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin: 4px 0; letter-spacing: 0.04em; }
#players { list-style: none; margin: 0; padding: 0; }
#players li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
#players li .dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
#players li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#players li .sc { font-variant-numeric: tabular-nums; color: var(--muted); }
#players li.dead .nm { opacity: 0.4; text-decoration: line-through; }
#players li.watch .nm { opacity: 0.55; font-style: italic; }
#players li.me .nm { font-weight: 600; }
#botctl { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
#botctl span { flex: 1; }
#botctl button { padding: 4px 9px; }
#botctl b { min-width: 14px; text-align: center; color: var(--ink); }

#topright { position: fixed; top: 14px; right: 14px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 60vw; }

#banner { position: fixed; top: 20%; left: 0; right: 0; text-align: center; pointer-events: none; padding: 0 16px; }
#bannerBig { font: 800 72px/1 Orbitron, sans-serif; letter-spacing: 0.18em; text-shadow: 0 0 30px currentColor, 0 0 6px currentColor; }
#bannerSmall { margin-top: 14px; font: 400 15px Inter, sans-serif; color: var(--ink); text-shadow: 0 0 10px #000, 0 0 2px #000; letter-spacing: 0.02em; }
#bannerBig.pop { animation: pop 0.4s cubic-bezier(.2,.9,.3,1.3); }
@keyframes pop { from { transform: scale(1.7); opacity: 0; filter: blur(6px); } to { transform: scale(1); opacity: 1; filter: blur(0); } }

#feed { position: fixed; right: 14px; top: 58px; list-style: none; margin: 0; padding: 0; width: 280px; font-size: 13px; text-align: right; pointer-events: none; }
#feed li { margin-bottom: 4px; padding: 5px 9px; background: rgba(0, 0, 0, 0.5); border-right: 2px solid var(--accent); display: inline-block; float: right; clear: both; animation: fade 6s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#minimap { position: fixed; right: 14px; bottom: 14px; width: 190px; height: 190px; border-radius: 4px; box-shadow: 0 0 24px rgba(0, 229, 255, 0.12); }

#hudBottom { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; transition: opacity 0.4s; }
#speed { font: 800 44px/1 Orbitron, sans-serif; letter-spacing: 0.06em; color: var(--ink); text-shadow: 0 0 18px rgba(0, 229, 255, 0.6); font-variant-numeric: tabular-nums; }
#speed .unit { font: 600 11px Orbitron, sans-serif; letter-spacing: 0.2em; color: var(--muted); margin-left: 8px; vertical-align: 6px; }
#boost { position: relative; width: 260px; height: 6px; margin: 10px auto 10px; background: rgba(0, 229, 255, 0.1); border-radius: 3px; overflow: hidden; }
#boostFill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--accent), #fff); box-shadow: 0 0 14px var(--accent); transition: width 0.1s linear; }
#hudBottom.boosting #speed { color: #fff; text-shadow: 0 0 26px #fff, 0 0 40px var(--accent); }
#hint { font-size: 11px; color: var(--muted); letter-spacing: 0.03em; }

#tags { position: fixed; inset: 0; pointer-events: none; }
.tagname { position: absolute; left: 0; top: 0; font: 600 11px Inter, sans-serif; padding: 2px 6px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); white-space: nowrap; letter-spacing: 0.04em; }
.tagname.me { font-weight: 700; border: 1px solid currentColor; }

#touch { display: none; }
@media (pointer: coarse) {
  #touch { display: flex; position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 14px 22px; justify-content: space-between; gap: 18px; }
  #touch .pair { display: flex; gap: 10px; flex: 1; }
  #touch button { flex: 1; height: 76px; font-size: 22px; border-radius: 10px; background: rgba(0, 229, 255, 0.08); }
  #touch #tBrake, #touch #tBoost { font-size: 12px; }
  #touch button.on { background: rgba(0, 229, 255, 0.3); border-color: var(--accent); }
  #hudBottom { bottom: 112px; }
  #speed { font-size: 32px; }
  #boost { width: 180px; }
  #hint { display: none; }
  #board { width: 170px; font-size: 12px; }
  #feed { display: none; }
  #minimap { bottom: auto; top: 60px; width: 120px; height: 120px; }
  #bannerBig { font-size: 46px; }
}
@media (max-width: 560px) {
  #board { width: 150px; padding: 8px; }
  #topright { flex-direction: column; align-items: flex-end; max-width: none; }
  #topright button { padding: 6px 8px; font-size: 9px; }
  #minimap { top: 120px; }
  #bannerBig { font-size: 40px; }
}
