@font-face {
  font-family: 'Orbitron';
  src: url('../assets/font/Orbitron-Black.ttf') format('truetype');
  font-weight: 900;
}

:root {
  --neon-cyan: #35e7ff;
  --neon-pink: #ff3ec9;
  --neon-purple: #8a5bff;
  --panel-bg: rgba(8, 10, 28, 0.82);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #04030c; overflow: hidden;
  font-family: 'Orbitron', 'Segoe UI', sans-serif;
  color: #eafcff;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#sr-canvas-root { position: fixed; inset: 0; }
#sr-canvas-root canvas { display: block; }

.neon-title {
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 30px rgba(140, 100, 255, 0.35);
}

/* ---------------- brand ---------------- */
#sr-brand {
  position: fixed; top: 10px; right: 16px; z-index: 45;
  font-size: 11px; letter-spacing: 1.5px; font-weight: 900; color: #eafcff;
  text-decoration: none; background: var(--panel-bg); border: 1px solid rgba(120,200,255,0.3);
  border-radius: 20px; padding: 5px 12px; display: flex; align-items: center; gap: 6px;
  opacity: 0.85; transition: opacity 0.15s ease;
}
#sr-brand:hover { opacity: 1; }
#sr-brand span { color: #8fb3e0; font-weight: 600; letter-spacing: 0.5px; }
#sr-brand .ph-fill, #sr-brand i { color: var(--neon-cyan); }
.neon-title .ph-fill { -webkit-text-fill-color: var(--neon-cyan); color: var(--neon-cyan); }
.sr-brand-link {
  display: inline-block; margin-top: -4px; font-size: 11px; color: #7fe9ff;
  text-decoration: none; letter-spacing: 1px;
}
.sr-brand-link:hover { text-decoration: underline; }

/* ---------------- overlays ---------------- */
.sr-overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,10,50,0.55), rgba(2,2,10,0.92));
  backdrop-filter: blur(3px);
}
.sr-overlay.hidden { display: none; }

.sr-panel {
  width: min(92vw, 440px);
  background: var(--panel-bg);
  border: 1px solid rgba(120, 200, 255, 0.35);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 0 60px rgba(80, 60, 200, 0.35), inset 0 0 30px rgba(50,180,255,0.06);
  text-align: center;
}
.sr-panel h1 { font-size: 26px; margin: 0 0 6px; }
.sr-panel h2 { font-size: 20px; margin: 0 0 14px; }
.sr-panel p { color: #b7c6e6; font-size: 13px; line-height: 1.5; margin: 6px 0 16px; }

.sr-input {
  width: 100%; padding: 12px 14px; margin-bottom: 14px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(120,200,255,0.4);
  border-radius: 8px; color: #eafcff; font-family: inherit; font-size: 15px;
  letter-spacing: 1px;
}
.sr-input:focus { outline: none; border-color: var(--neon-cyan); }

.sr-btn {
  width: 100%; padding: 13px; border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-weight: 900; letter-spacing: 2px; font-size: 14px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple)); color: #04030c;
  box-shadow: 0 0 22px rgba(60,200,255,0.45);
  transition: transform 0.12s ease;
}
.sr-btn:hover { transform: translateY(-1px); }
.sr-btn:disabled { opacity: 0.5; cursor: wait; }
.sr-btn.secondary { background: rgba(255,255,255,0.08); color: #eafcff; box-shadow: none; border: 1px solid rgba(150,200,255,0.4); }

.sr-error { color: #ff6b7a; font-size: 13px; min-height: 18px; margin-top: 6px; }

/* ---------------- game over actions + spectate ---------------- */
#sr-gameover-actions { display: flex; flex-direction: column; gap: 10px; }
#sr-gameover-actions .sr-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }

#sr-spectate-bar {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 42; display: flex; align-items: center; gap: 10px;
  background: var(--panel-bg); border: 1px solid rgba(120,200,255,0.35); border-radius: 30px;
  padding: 8px 10px; box-shadow: 0 0 30px rgba(80,60,200,0.35);
}
#sr-spectate-bar.hidden { display: none; }
.sr-spectate-nav {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(120,200,255,0.35);
  background: rgba(255,255,255,0.06); color: #eafcff; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: transform 0.1s ease, background 0.15s ease;
}
.sr-spectate-nav:hover { background: rgba(255,255,255,0.14); }
.sr-spectate-nav:active { transform: scale(0.9); }
.sr-spectate-nav:disabled { opacity: 0.35; cursor: default; }
.sr-spectate-nav:disabled:hover { background: rgba(255,255,255,0.06); }
#sr-spectate-info {
  display: flex; flex-direction: column; align-items: center; min-width: 130px; padding: 0 4px;
}
.sr-spectate-label {
  font-size: 9px; letter-spacing: 2px; color: #8fb3e0; display: flex; align-items: center; gap: 4px;
}
#sr-spectate-name {
  font-weight: 900; font-size: 15px; letter-spacing: 1px;
  color: var(--sc, #35e7ff); text-shadow: 0 0 10px var(--sc, #35e7ff);
}
#sr-spectate-exit {
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}

.sr-lobby-code-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0 18px; }
#sr-lobby-code { font-size: 30px; letter-spacing: 8px; font-weight: 900; color: var(--neon-cyan); text-shadow: 0 0 18px rgba(53,231,255,0.6); }

.sr-link-row { display: flex; gap: 8px; margin-bottom: 18px; }
#sr-lobby-link { flex: 1; padding: 10px; border-radius: 6px; border: 1px solid rgba(120,200,255,0.3); background: rgba(255,255,255,0.05); color: #cfe; font-size: 12px; }

#sr-lobby-players { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; }
#sr-lobby-players li { padding: 8px 10px; border-radius: 6px; background: rgba(255,255,255,0.04); margin-bottom: 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.skin-red { background: #ff5c6c; }
.skin-green { background: #5cf0a0; }
.skin-orange { background: #ffb04d; }

#sr-lobby-wait { color: #9fb3e0; font-size: 13px; }

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

.sr-hud-top-left {
  position: absolute; top: 16px; left: 16px; width: 230px;
  background: var(--panel-bg); border: 1px solid rgba(120,200,255,0.25); border-radius: 10px; padding: 10px 12px;
}
.sr-hud-label { font-size: 10px; letter-spacing: 2px; color: #8fb3e0; margin-bottom: 4px; }
.sr-bar-track { height: 12px; border-radius: 6px; background: rgba(255,255,255,0.08); overflow: hidden; margin-bottom: 6px; }
.sr-bar-track.thin { height: 6px; }
#sr-speed { height: 100%; width: 0%; background: linear-gradient(90deg,#35e7ff,#8a5bff); transition: width 0.12s ease; }
#sr-heat-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#ffb04d,#ff5c3d); transition: width 0.12s ease, background 0.2s ease; }
#sr-heat-fill.locked { background: linear-gradient(90deg,#4fb8ff,#2a6fe0); }

/* HP: 10 individual red bars in a row, each worth 10 HP */
.sr-hp-bars { display: flex; gap: 3px; margin-bottom: 4px; }
.sr-hp-seg {
  flex: 1; height: 14px; border-radius: 3px; background: rgba(255,255,255,0.08);
  overflow: hidden; position: relative; border: 1px solid rgba(255,255,255,0.06);
}
.sr-hp-seg::after {
  content: ''; position: absolute; inset: 0; width: var(--fill, 100%);
  background: linear-gradient(180deg, #ff6b6b, #e8283f);
  box-shadow: 0 0 6px rgba(255,60,70,0.6);
  transition: width 0.15s ease;
}
.sr-hp-seg.empty::after { background: transparent; box-shadow: none; }

.sr-hud-top-center {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--panel-bg); border: 1px solid rgba(120,200,255,0.25); border-radius: 20px;
  padding: 6px 18px; font-size: 12px; letter-spacing: 1px; color: #cfe;
}

.sr-mute-row {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  margin-top: 40px; pointer-events: auto; display: flex; gap: 8px;
}
#sr-mute-sfx-btn, #sr-mute-music-btn {
  cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(120,200,255,0.3);
  background: var(--panel-bg); font-size: 15px; line-height: 1; color: #eafcff;
  display: flex; align-items: center; justify-content: center; transition: transform 0.1s ease, color 0.15s ease, border-color 0.15s ease;
}
#sr-mute-sfx-btn:active, #sr-mute-music-btn:active { transform: scale(0.9); }
#sr-mute-sfx-btn.muted, #sr-mute-music-btn.muted {
  color: #ff7a8a; border-color: rgba(255,90,110,0.5);
}

.sr-hud-top-right { position: absolute; top: 16px; right: 16px; width: 210px; }
#sr-killfeed { list-style: none; margin: 0; padding: 0; text-align: right; }
#sr-killfeed li { background: var(--panel-bg); border-right: 3px solid var(--neon-pink); border-radius: 6px; padding: 6px 10px; margin-bottom: 6px; font-size: 12px; opacity: 1; transition: opacity 0.6s ease; }
#sr-killfeed li.fade { opacity: 0; }

.sr-hud-bottom-left { position: absolute; bottom: 16px; left: 16px; }
#sr-radar { width: 130px; height: 130px; border-radius: 50%; background: rgba(6,10,26,0.4); }

/* Sits directly under the "SPACE ROYALE by StudentChat" brand tag, top-right,
   with its own z-index above the brand so it never renders behind it. */
#sr-toast {
  position: fixed; top: 46px; right: 16px; z-index: 46;
  background: var(--panel-bg); border: 1px solid rgba(120,200,255,0.3); border-radius: 8px;
  padding: 8px 16px; font-size: 13px; opacity: 0; pointer-events: none;
  transform: translateY(-6px); transition: all 0.25s ease; white-space: nowrap; max-width: 70vw;
  text-align: right;
}
#sr-toast.show { opacity: 1; transform: translateY(0); }

.sr-hint { position: absolute; bottom: 16px; right: 16px; font-size: 11px; color: #7f97c4; text-align: right; line-height: 1.6; }

/* ---------------- touch controls ---------------- */
#sr-touch-root { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.sr-joystick-zone {
  /* Thumb-sized, not palm-sized. Sits low-left where a thumb naturally
     rests when the phone is held in landscape. */
  position: absolute; left: 18px; bottom: 18px; width: 96px; height: 96px; pointer-events: auto;
}
.sr-joystick-base {
  width: 100%; height: 100%; border-radius: 50%;
  background: rgba(255,255,255,0.06); border: 2px solid rgba(120,200,255,0.4);
  display: flex; align-items: center; justify-content: center;
}
.sr-joystick-knob {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7fe9ff, #2790c9);
  box-shadow: 0 0 18px rgba(53,231,255,0.6);
}

.sr-fire-btn {
  position: absolute; right: 26px; bottom: 30px; width: 64px; height: 64px; pointer-events: auto;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9d9d, #d13a4a);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 900;
  box-shadow: 0 0 18px rgba(255,60,60,0.5); color: #fff; cursor: pointer;
  transition: transform 0.08s ease;
}
.sr-fire-btn.active { transform: scale(0.92); }
.sr-fire-btn.weapon-locked { background: radial-gradient(circle at 35% 30%, #9fd4ff, #2a7fd6); box-shadow: 0 0 18px rgba(60,140,255,0.6); }
/* thumb-sized on touch devices specifically — easy to hit, doesn't hog the screen */
.sr-fire-btn-touch { width: 56px; height: 56px; right: 18px; bottom: 18px; font-size: 19px; }
.sr-fire-btn-desktop-hint { right: 30px; bottom: 34px; width: 66px; height: 66px; font-size: 18px; opacity: 0.8; }
.sr-cooldown-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.sr-cooldown-ring circle { fill: none; stroke: #fff9c4; stroke-width: 4; opacity: 0.85; }

/* ---------- floating nametags (always on screen) ---------- */
#sr-nametags { position: fixed; inset: 0; z-index: 15; pointer-events: none; overflow: hidden; }
.sr-tag {
  position: absolute; top: 0; left: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 20px;
  background: rgba(8,10,28,0.78);
  border: 1.5px solid var(--tagc, #35e7ff);
  box-shadow: 0 0 12px color-mix(in srgb, var(--tagc, #35e7ff) 55%, transparent), inset 0 0 8px rgba(255,255,255,0.06);
  font-size: 11px; letter-spacing: 1px; color: #fff; white-space: nowrap;
  will-change: transform;
}
.sr-tag-name { font-weight: 900; color: var(--tagc, #35e7ff); text-shadow: 0 0 8px var(--tagc, #35e7ff); max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.sr-tag-dist { color: #9fb3e0; font-size: 10px; }
.sr-tag-arrow { color: var(--tagc, #35e7ff); font-size: 11px; line-height: 1; }
.sr-tag.edge { background: rgba(20,8,30,0.88); animation: sr-tag-pulse 1.2s ease-in-out infinite; }
.sr-tag.locked { background: rgba(60,8,20,0.9); transform-origin: center; box-shadow: 0 0 18px #ff3e5e, inset 0 0 10px rgba(255,62,94,0.35); }
@keyframes sr-tag-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.75; } }

/* ---------- crosshair with lock states (SVG, pixel-perfect centered) ---------- */
#sr-crosshair {
  position: fixed; left: 50%; top: 50%; width: 48px; height: 48px; z-index: 16;
  margin-left: -24px; margin-top: -24px; /* exact pixel centering, no subpixel drift from % transforms */
  pointer-events: none;
}
#sr-crosshair svg { display: block; width: 100%; height: 100%; overflow: visible; }
#sr-crosshair .sr-ch-ring {
  fill: none; stroke: rgba(53,231,255,0.55); stroke-width: 2;
  transition: stroke 0.15s ease, r 0.15s ease;
  transform-origin: 24px 24px;
}
#sr-crosshair .sr-ch-tick {
  stroke: rgba(53,231,255,0.7); stroke-width: 2; stroke-linecap: round;
  transition: stroke 0.15s ease;
}
#sr-crosshair .sr-ch-dot {
  fill: rgba(53,231,255,0.9); transition: fill 0.15s ease;
}
#sr-crosshair[data-state="soft"] .sr-ch-ring,
#sr-crosshair[data-state="soft"] .sr-ch-tick { stroke: #ffe27a; }
#sr-crosshair[data-state="soft"] .sr-ch-dot { fill: #ffe27a; }
#sr-crosshair[data-state="soft"] svg { animation: sr-x-pulse 0.7s ease-in-out infinite; transform-origin: center; }
#sr-crosshair[data-state="locked"] .sr-ch-ring,
#sr-crosshair[data-state="locked"] .sr-ch-tick { stroke: #ff3e5e; }
#sr-crosshair[data-state="locked"] .sr-ch-dot { fill: #ff3e5e; }
#sr-crosshair[data-state="locked"] .sr-ch-ring { r: 15; transform: scale(1.03); }
#sr-crosshair[data-state="charging"] .sr-ch-ring,
#sr-crosshair[data-state="charging"] .sr-ch-tick { stroke: #8a5bff; }
#sr-crosshair[data-state="charging"] .sr-ch-dot { fill: #8a5bff; }
#sr-crosshair[data-state="cooldown"] .sr-ch-ring,
#sr-crosshair[data-state="cooldown"] .sr-ch-tick { stroke: rgba(140,150,180,0.5); }
#sr-crosshair[data-state="cooldown"] .sr-ch-dot { fill: rgba(140,150,180,0.6); }
@keyframes sr-x-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
#sr-lock-label {
  position: fixed; left: 50%; top: calc(50% + 34px); transform: translateX(-50%);
  z-index: 16; pointer-events: none; font-size: 11px; letter-spacing: 1.5px;
  background: rgba(8,10,28,0.8); border: 1px solid rgba(255,62,94,0.6); color: #ffb3c0;
  padding: 3px 12px; border-radius: 12px; opacity: 0; transition: opacity 0.15s ease;
  white-space: nowrap;
}
#sr-lock-label.show { opacity: 1; }

/* legacy lobby dots + new colors */
.skin-red { background: #ff5c6c; }
.skin-green { background: #5cf0a0; }
.skin-orange { background: #ffb04d; }
.skin-cyan { background: #35e7ff; }
.skin-magenta { background: #ff3ec9; }
.skin-lime { background: #7dff5c; }
.skin-amber { background: #ffb04d; }
.skin-violet { background: #8a5bff; }

@media (max-width: 720px) {
  .sr-hud-top-right { width: 160px; }
  .sr-hud-top-left { width: 190px; }
  .sr-hint { display: none; }
  #sr-crosshair { width: 52px; height: 52px; margin-left: -26px; margin-top: -26px; opacity: 0.9; }
  .sr-tag-name { max-width: 90px; }
  .sr-mute-row { margin-top: 34px; gap: 6px; }
  #sr-mute-sfx-btn, #sr-mute-music-btn { width: 30px; height: 30px; font-size: 13px; }
  #sr-spectate-bar { bottom: 16px; padding: 6px 8px; gap: 6px; }
  #sr-spectate-info { min-width: 100px; }
  #sr-spectate-name { font-size: 13px; }
}

/* ================= v2 ADDITIONS ================= */

/* Generic hide helper — previously only .sr-overlay.hidden existed, so the
   host-only LAUNCH button stayed visible for every joiner. */
.hidden { display: none !important; }

/* ---------- lobby: two independent columns ---------- */
/* The overlay itself scrolls and centers; each column caps its own height
   and scrolls internally. Adding pilots grows the roster, never the page,
   so the LAUNCH button and the controls guide stay put. */
#sr-lobby-overlay { overflow-y: auto; padding: 20px 16px; align-items: center; }

.sr-lobby-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 900px;
  margin: auto;
}
.sr-lobby-main  { flex: 0 1 440px; margin: 0; display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.sr-lobby-guide { flex: 0 0 300px; margin: 0; text-align: left; padding: 16px 18px; max-height: calc(100vh - 40px); overflow-y: auto; }

/* roster is the only part allowed to grow, and it scrolls when it does */
.sr-lobby-players-scroll { overflow-y: auto; max-height: 190px; margin-bottom: 4px; }
.sr-lobby-players-scroll #sr-lobby-players { margin-bottom: 0; }
.sr-lobby-count-line { margin: 8px 0 14px !important; font-size: 12px; color: #8fb3e0; }
.sr-lobby-actions { margin-top: auto; }

/* thin scrollbars so the panels don't look chopped up */
.sr-lobby-players-scroll::-webkit-scrollbar,
.sr-lobby-guide::-webkit-scrollbar,
#sr-lobby-overlay::-webkit-scrollbar { width: 6px; }
.sr-lobby-players-scroll::-webkit-scrollbar-thumb,
.sr-lobby-guide::-webkit-scrollbar-thumb,
#sr-lobby-overlay::-webkit-scrollbar-thumb { background: rgba(120,200,255,0.3); border-radius: 3px; }

/* ---------- controls guide contents ---------- */
#sr-guide-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0 0 10px; margin: 0;
  background: none; border: none; cursor: default;
  font-family: inherit; color: inherit;
}
.sr-guide-caret { display: none; color: #8fb3e0; }
.sr-controls-title {
  font-size: 10px; letter-spacing: 2px; color: #8fb3e0;
  display: flex; align-items: center; gap: 6px;
}
.sr-ctrl-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #cfe0ff; padding: 6px 0;
}
.sr-ctrl-row + .sr-ctrl-row { border-top: 1px solid rgba(255,255,255,0.05); }
.sr-ctrl-keys { display: flex; gap: 4px; flex: 0 0 auto; min-width: 74px; }
.sr-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 5px; background: rgba(255,255,255,0.09);
  border: 1px solid rgba(150,200,255,0.4); border-bottom-width: 2px;
  font-size: 11px; font-weight: 900; color: #eafcff;
}
.sr-key.wide { min-width: 52px; font-size: 10px; letter-spacing: 1px; }
.sr-ctrl-desc { color: #a9bde0; line-height: 1.4; }
.sr-ctrl-desc b { color: #eafcff; font-weight: 900; }
.sr-controls-note {
  font-size: 11px; color: #7f97c4; margin: 12px 0 0 !important; line-height: 1.5;
  padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08);
}
#sr-controls-touch, #sr-controls-desktop { display: none; }
body.sr-touch #sr-controls-touch { display: block; }
body:not(.sr-touch) #sr-controls-desktop { display: block; }

/* ---------- leave game button ---------- */
/* Sits directly under the HP / HEAT / SPEED pane on the top left, so it
   reads as part of that panel instead of floating loose in the corner.
   `top` is set from JS to match the real measured height of that pane. */
#sr-leave-btn {
  position: fixed; top: 150px; left: 18px; z-index: 31;
  pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 900; letter-spacing: 1.5px;
  background: rgba(30,8,18,0.72); color: #ffb3c0;
  border: 1px solid rgba(255,90,120,0.5);
  transition: background 0.15s ease, transform 0.1s ease;
}
#sr-leave-btn:hover { background: rgba(70,12,30,0.9); color: #fff; }
#sr-leave-btn:active { transform: scale(0.94); }
#sr-leave-btn.confirm { background: #c4173a; color: #fff; border-color: #ff6b8a; }


/* lobby leave sits inline under the panel */
#sr-lobby-leave-btn { margin-top: 10px; }

/* Narrow screens: there's no room for two columns, so they stack and the
   guide collapses to a tappable header. Everything stays inside one
   scrollable overlay instead of running off the bottom. */
@media (max-width: 860px) {
  .sr-lobby-layout { flex-direction: column; align-items: stretch; max-width: 440px; gap: 12px; }
  .sr-lobby-main, .sr-lobby-guide { flex: 0 0 auto; max-height: none; overflow: visible; }
  #sr-lobby-overlay { align-items: flex-start; }
  .sr-lobby-players-scroll { max-height: 150px; }

  #sr-guide-toggle { cursor: pointer; padding: 2px 0; }
  .sr-guide-caret { display: block; transition: transform 0.2s ease; }
  .sr-lobby-guide.collapsed .sr-guide-caret { transform: rotate(180deg); }
  .sr-lobby-guide.collapsed .sr-guide-body { display: none; }
  .sr-guide-body { padding-top: 8px; }
}

@media (max-width: 720px) {
  #sr-leave-btn { left: 12px; padding: 5px 8px; font-size: 9px; }
  .sr-ctrl-row { font-size: 11px; padding: 5px 0; }
  .sr-ctrl-keys { min-width: 64px; }
  .sr-lobby-guide { padding: 12px 14px; }
}

/* ---------- mobile thrust / brake pad ---------- */
.sr-throttle-pad {
  /* Tucked just inboard of the fire button so one thumb covers throttle and
     trigger without moving off the corner. */
  position: absolute; right: 82px; bottom: 18px; z-index: 25;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: auto; touch-action: none;
}
.sr-thr-btn {
  width: 44px; height: 40px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20,30,60,0.65); border: 1px solid rgba(120,200,255,0.45);
  color: #9fe8ff; font-size: 19px;
  box-shadow: 0 0 16px rgba(60,200,255,0.2);
  user-select: none; -webkit-user-select: none;
}
.sr-thr-btn.active {
  background: rgba(53,231,255,0.35); color: #fff;
  border-color: #35e7ff; box-shadow: 0 0 22px rgba(53,231,255,0.65);
}

/* ---------- rotate-to-landscape prompt (touch only) ---------- */
/* iOS Safari ignores screen.orientation.lock(), so on portrait phones we ask
   for the rotation instead of letting the game render into a sliver. */
#sr-rotate-prompt {
  position: fixed; inset: 0; z-index: 200;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px;
  background: rgba(4,6,18,0.97); color: #cfe0ff;
}
#sr-rotate-prompt i { font-size: 54px; color: #35e7ff; animation: sr-rot 2s ease-in-out infinite; }
#sr-rotate-prompt p { font-size: 13px; letter-spacing: 1px; margin: 0; }
@keyframes sr-rot { 0%,45% { transform: rotate(0deg); } 60%,100% { transform: rotate(-90deg); } }
body.sr-touch.sr-in-match #sr-rotate-prompt { display: flex; }
@media (orientation: landscape) { body.sr-touch.sr-in-match #sr-rotate-prompt { display: none !important; } }

/* landscape phones are short — pull the HUD in tight so it doesn't eat the view */
@media (orientation: landscape) and (max-height: 500px) {
  .sr-hud-top-left, .sr-hud-top-center, .sr-hud-top-right { transform: scale(0.85); transform-origin: top; }
  #sr-leave-btn { top: 118px; }
  .sr-hint { display: none; }
}

/* ---------- entry fee slider + cash line ---------- */
.sr-cash-line { display:flex; align-items:center; justify-content:center; gap:8px; font-size:14px; color:#eafcff; margin: 4px 0 12px; }
.sr-cash-line img { width:18px; height:18px; }
.sr-fee-label { display:block; font-size:11px; letter-spacing:2px; color:#8fb3e0; margin: 10px 0 6px; }
.sr-fee-label b { color:var(--neon-cyan); font-size:13px; }
#sr-fee-slider { width:100%; accent-color: var(--neon-pink); min-height:34px; touch-action: manipulation; }
.sr-fee-prize { font-size:12px; color:#8fb3e0; margin: 2px 0 12px; }
.sr-fee-prize b { color:#ffe27a; }
.sr-announce-row { display:flex; align-items:center; justify-content:center; gap:8px; font-size:12px; color:#8fb3e0; margin: 10px 0 4px; cursor:pointer; }
.sr-announce-row input { width:16px; height:16px; accent-color: var(--neon-cyan); }
.sr-lobby-fee-line { margin: -6px 0 12px !important; font-size:12px; color:#ffe27a; }

/* ---------- center kill popup ---------- */
#sr-kill-popup {
  position: fixed; top: 12%; left: 50%; z-index: 60; pointer-events: none;
  transform: translateX(-50%) scale(0.6);
  background: rgba(10, 6, 28, 0.88);
  border: 1px solid rgba(255, 90, 120, 0.65);
  border-radius: 12px; padding: 10px 22px;
  font-size: 17px; font-weight: 800; letter-spacing: 0.5px; color: #fff;
  text-shadow: 0 0 14px rgba(255, 60, 90, 0.8);
  box-shadow: 0 0 30px rgba(255, 60, 90, 0.35);
  opacity: 0; white-space: nowrap; max-width: 92vw;
  overflow: hidden; text-overflow: ellipsis;
}
#sr-kill-popup.dim { border-color: rgba(150, 150, 190, 0.5); text-shadow: none; box-shadow: 0 0 18px rgba(120, 120, 180, 0.25); }
#sr-kill-popup.show { animation: sr-killpop 2.3s ease forwards; }
@keyframes sr-killpop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.6); }
  10% { opacity: 1; transform: translateX(-50%) scale(1.06); }
  18% { transform: translateX(-50%) scale(1); }
  78% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.98) translateY(-8px); }
}

/* ---------- win-screen kill table ---------- */
#sr-gameover-kills { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
#sr-gameover-kills li {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(150, 180, 255, 0.18);
  border-radius: 8px; padding: 7px 12px; font-size: 13px;
}
#sr-gameover-kills .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#sr-gameover-kills .nm { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sr-gameover-kills .kl { color: #ffe27a; font-weight: 800; white-space: nowrap; }
#sr-gameover-kills li.me { border-color: rgba(53, 231, 255, 0.55); }
#sr-gameover-kills li.dead { opacity: 0.55; }

/* ---------- death panel (right after your death, match still live) ---------- */
#sr-death-panel { max-width: min(360px, 92vw); }
#sr-death-actions { display: flex; gap: 10px; margin-top: 14px; }
#sr-death-actions .sr-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }
#sr-death-sub { color: #9fb3e0; font-size: 13px; margin: 6px 0 0; }

/* ---------- 3-2-1-GO countdown ---------- */
#sr-countdown {
  position: fixed; inset: 0; z-index: 55; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
#sr-countdown.hidden { display: none; }
#sr-countdown-num {
  font-family: 'Alfa Slab One', 'Orbitron', sans-serif;
  font-size: min(22vw, 150px); color: #fff;
  text-shadow: 0 0 18px rgba(53, 231, 255, 0.9), 0 0 60px rgba(138, 91, 255, 0.7);
}
#sr-countdown-num.pop { animation: sr-countpop 0.62s ease forwards; }
#sr-countdown-num.go {
  background: linear-gradient(90deg, #5cffcf, #35e7ff, #c4b5fd);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 22px rgba(53, 231, 255, 0.9));
}
@keyframes sr-countpop {
  0% { opacity: 0; transform: scale(1.7); }
  25% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(0.96); }
  100% { opacity: 0; transform: scale(0.9); }
}
