* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #10131c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  touch-action: none;
  overscroll-behavior: none;
}

#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#score-box {
  position: absolute; left: 14px; bottom: 14px;
  background: rgba(0,0,0,0.45); border-radius: 8px;
  padding: 8px 14px; font-weight: 700; font-size: 1rem;
}
#score { color: #4dd0e1; }

#leaderboard {
  position: absolute; top: 12px; right: 12px;
  list-style: none; counter-reset: lb;
  background: rgba(0,0,0,0.45); border-radius: 8px;
  padding: 8px 12px; min-width: 150px;
  font-size: 0.78rem; line-height: 1.6;
}
#leaderboard li { counter-increment: lb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
#leaderboard li::before { content: counter(lb) ". "; color: #8899aa; }
#leaderboard li.me { color: #4dd0e1; font-weight: 700; }
#leaderboard li:first-child { color: #ffd54f; }
#leaderboard li:first-child.me { color: #4dd0e1; }

#minimap {
  position: absolute; right: 12px; bottom: 12px;
  background: rgba(0,0,0,0.4); border-radius: 50%;
}

#banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; padding: 8px 18px;
  font-size: 0.9rem; font-weight: 600; text-align: center; max-width: 90vw;
}

/* ---------- Touch controls ---------- */
.touch-ctrl { z-index: 20; }
#joystick {
  position: fixed; left: 24px; bottom: 24px;
  width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.2);
}
#stick {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: translate(-50%, -50%);
}
#boost-btn {
  position: fixed; right: 26px; bottom: 40px;
  width: 84px; height: 84px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(0,188,212,0.35);
  font-size: 2rem; color: #fff;
  -webkit-tap-highlight-color: transparent;
}
#boost-btn:active { background: rgba(0,188,212,0.7); }
/* score-box collides with the joystick on small screens — move it up */
html.device-phone #score-box, html.device-tablet #score-box { left: 14px; bottom: 170px; }

/* ---------- Overlays (menu / death) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 20px; text-align: center;
  background: radial-gradient(circle at 50% 35%, #1c2438 0%, #10131c 75%);
}
.overlay h1 { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 800; }
.overlay h2 { font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 800; }
.tagline { color: #8899aa; margin-top: -8px; }

#name-input {
  width: min(320px, 80vw); padding: 12px 16px;
  border-radius: 10px; border: 2px solid #2c3a52;
  background: #1a2233; color: #fff;
  font-size: 1.05rem; text-align: center; outline: none;
}
#name-input:focus { border-color: #4dd0e1; }

.mode-buttons { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 170px; padding: 18px 22px;
  border-radius: 14px; border: 2px solid rgba(255,255,255,0.15);
  background: #1a2233; color: #fff; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.mode-btn:hover { transform: translateY(-3px); border-color: #fff; }
.mode-btn--ai { background: linear-gradient(160deg, #14532d, #1a2233 80%); }
.mode-btn--online { background: linear-gradient(160deg, #1e3a8a, #1a2233 80%); }
.mode-icon { font-size: 2.2rem; }
.mode-name { font-size: 1.2rem; font-weight: 800; }
.mode-desc { font-size: 0.75rem; color: #9fb0c3; }

#online-msg {
  color: #ff6b6b; font-weight: 700; max-width: 420px; line-height: 1.4;
  background: rgba(255,77,77,0.1); border: 1px solid rgba(255,77,77,0.35);
  border-radius: 8px; padding: 10px 16px;
}
.controls-hint { color: #8899aa; font-size: 0.85rem; max-width: 420px; }
.back-link { color: #4dd0e1; text-decoration: none; font-weight: 600; font-size: 0.9rem; }
#death-cause { color: #8899aa; }
