/* =========================================================================
   HYPERGRID — interface styling
   The canvas provides all the light; the DOM chrome stays thin, cold and
   sharp so it reads as an overlay on a CRT rather than a web page.
   ========================================================================= */

/* Orbitron and Rajdhani, self-hosted (SIL OFL 1.1; see assets/licenses). */
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/orbitron-variable.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/orbitron-variable.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('assets/fonts/orbitron-variable.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/rajdhani-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/rajdhani-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/rajdhani-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --cyan: #7df9ff;
  --cyan-dim: #3fb6c4;
  --green: #4dff9b;
  --magenta: #ff49c8;
  --amber: #ffab2e;
  --red: #ff3b5c;
  --blue: #3f7bff;
  --lime: #c6ff3d;
  --ink: #04060f;
  --panel: rgba(6, 10, 22, 0.82);
  --line: rgba(125, 249, 255, 0.28);
  --text: #dff6ff;
  --muted: rgba(223, 246, 255, 0.5);
  --font-display: 'Orbitron', 'Rajdhani', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-ui: 'Rajdhani', 'Orbitron', ui-monospace, 'SF Mono', Menlo, sans-serif;
  --glow: 0 0 6px rgba(125, 249, 255, 0.85), 0 0 18px rgba(125, 249, 255, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  /* Not "none": that would also stop menus scrolling under a finger, since
     touch-action is narrowed by every ancestor. The canvas opts out itself. */
  touch-action: pan-x pan-y;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  cursor: crosshair;
  touch-action: none;
}
body.menu-open #game { cursor: default; }

/* ============================== HUD ==================================== */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms ease;
  font-family: var(--font-display);
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
           max(18px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 5;
}
#hud.visible { opacity: 1; }

.hud-top, .hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}
.hud-bottom { align-items: flex-end; }
.hud-left, .hud-right, .hud-center { display: flex; gap: 26px; align-items: flex-start; }
.hud-center { flex-direction: column; align-items: center; gap: 4px; }
.hud-right { justify-content: flex-end; }
.hud-block.right { text-align: right; }

.hud-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--muted);
  margin-bottom: 2px;
}
.hud-label .key {
  border: 1px solid rgba(223, 246, 255, 0.25);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 9px;
  letter-spacing: 0.1em;
  margin-left: 4px;
  opacity: 0.8;
}

.hud-score {
  font-size: clamp(28px, 4.6vw, 54px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 0 8px rgba(125, 249, 255, 0.9), 0 0 28px rgba(125, 249, 255, 0.45);
  font-variant-numeric: tabular-nums;
}

.mult-block { padding-top: 14px; }
.hud-mult {
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 8px rgba(77, 255, 155, 0.8), 0 0 22px rgba(77, 255, 155, 0.35);
  font-variant-numeric: tabular-nums;
  transition: color 200ms ease;
}
.hud-mult.hot {
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255, 171, 46, 0.9), 0 0 26px rgba(255, 171, 46, 0.45);
  animation: multPulse 1.1s ease-in-out infinite;
}
@keyframes multPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.mult-track {
  width: 84px;
  height: 3px;
  background: rgba(125, 249, 255, 0.16);
  margin-top: 5px;
  overflow: hidden;
}
.mult-track > div {
  height: 100%;
  width: 100%;
  background: var(--green);
  transform-origin: left center;
  transform: scaleX(0);
  box-shadow: 0 0 8px var(--green);
  transition: transform 120ms linear;
}

.hud-mode {
  font-size: 12px;
  letter-spacing: 0.4em;
  color: rgba(223, 246, 255, 0.42);
  font-weight: 700;
}
.hud-timer {
  font-size: clamp(20px, 2.6vw, 30px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--glow);
}
.hud-timer.urgent {
  color: var(--red);
  text-shadow: 0 0 10px rgba(255, 59, 92, 0.9);
  animation: multPulse 0.5s ease-in-out infinite;
}
.hud-best {
  font-size: clamp(15px, 1.7vw, 20px);
  font-weight: 700;
  color: rgba(223, 246, 255, 0.72);
  font-variant-numeric: tabular-nums;
}

.icon-row { display: flex; gap: 7px; align-items: center; height: 20px; }
.icon-row i {
  display: block;
  width: 15px;
  height: 15px;
  background: currentColor;
}
.icon-row .life {
  color: #fff;
  clip-path: polygon(100% 50%, 20% 100%, 42% 50%, 20% 0);
  filter: drop-shadow(0 0 5px rgba(255, 197, 61, 0.9));
}
.icon-row .bomb {
  color: var(--amber);
  clip-path: polygon(50% 0, 85% 15%, 100% 50%, 85% 85%, 50% 100%, 15% 85%, 0 50%, 15% 15%);
  filter: drop-shadow(0 0 5px rgba(255, 171, 46, 0.8));
}
.icon-row .inf { font-size: 22px; color: var(--cyan); text-shadow: var(--glow); line-height: 1; }
.icon-row .none { color: rgba(223, 246, 255, 0.3); font-size: 15px; }
.icon-row .more { font-size: 12px; color: var(--muted); }
#hud-bomb-hint.dim { opacity: 0.45; }

.hud-fps {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: rgba(223, 246, 255, 0.45);
  letter-spacing: 0.08em;
}
.hidden { display: none !important; }

/* ============================ Online HUD =============================== */

.hud-net {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 auto;
}
.crew {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 6px 12px 6px 10px;
  border: 1px solid rgba(223, 246, 255, 0.14);
  background: rgba(4, 6, 15, 0.55);
}
.crew i {
  grid-row: span 2;
  width: 8px;
  height: 8px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  transform: rotate(45deg);
}
.crew-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  white-space: nowrap;
}
.crew-name em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-left: 4px;
}
.crew-role {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(223, 246, 255, 0.5);
  font-weight: 700;
  white-space: nowrap;
}
.crew.down { opacity: 0.55; }
.crew.down .crew-role { color: var(--red); }
.ping {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(223, 246, 255, 0.4);
  padding-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.net-banner {
  position: fixed;
  top: max(84px, calc(env(safe-area-inset-top) + 72px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 8px 18px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #fff;
  background: rgba(4, 6, 15, 0.8);
  border: 1px solid rgba(255, 59, 92, 0.5);
  box-shadow: 0 0 22px rgba(255, 59, 92, 0.25);
  pointer-events: none;
  white-space: nowrap;
  animation: hintPulse 1.8s ease-in-out infinite;
}

/* ============================ Touch controls =========================== */

#touch-ui { display: none; }
body.touch-play #touch-ui { display: block; }

.touch-btn {
  position: fixed;
  z-index: 12;
  display: grid;
  place-items: center;
  border: 1px solid rgba(223, 246, 255, 0.28);
  background: rgba(4, 6, 15, 0.45);
  color: rgba(223, 246, 255, 0.85);
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn:active { background: rgba(125, 249, 255, 0.2); border-color: var(--cyan); }

#touch-menu {
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
}

/* Up the right edge, clear of where a resting thumb starts the aim stick. */
#touch-bomb {
  right: max(14px, env(safe-area-inset-right));
  top: 36%;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border-color: rgba(255, 171, 46, 0.55);
  box-shadow: 0 0 18px rgba(255, 171, 46, 0.18);
}
#touch-bomb .bomb-glyph {
  width: 24px;
  height: 24px;
  background: var(--amber);
  clip-path: polygon(50% 0, 85% 15%, 100% 50%, 85% 85%, 50% 100%, 15% 85%, 0 50%, 15% 15%);
  filter: drop-shadow(0 0 6px rgba(255, 171, 46, 0.9));
}
#touch-bomb .count {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: var(--ink);
  border: 1px solid rgba(255, 171, 46, 0.6);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  color: #fff;
}
#touch-bomb.empty { opacity: 0.35; }
#touch-bomb.hidden { display: none; }

/* During touch play the thumbs own the bottom of the screen: lives move to the
   top centre, bombs live on their button, and keyboard hints go away. */
body.touch-play #fullscreen-btn { display: none; }
body.touch-play .hud-right { display: none; }
body.touch-play #hud-bomb-hint { display: none; }
body.touch-play .hud-bottom {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
body.touch-play .hud-bottom .hud-label { display: none; }
body.touch-play .hud-fps { order: 3; }

#rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 32px 24px;
  text-align: center;
  background: var(--ink);
}
#rotate-hint p {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #fff;
  text-shadow: var(--glow);
}
#rotate-hint span { font-size: 14px; color: rgba(223, 246, 255, 0.6); max-width: 30ch; }
#rotate-hint button {
  margin-top: 10px;
  padding: 10px 16px;
  background: none;
  border: 1px solid rgba(223, 246, 255, 0.25);
  color: rgba(223, 246, 255, 0.7);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.2em;
  touch-action: manipulation;
}
.rotate-phone {
  width: 44px;
  height: 76px;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  box-shadow: var(--glow);
  animation: rotatePhone 2.4s ease-in-out infinite;
}
@keyframes rotatePhone {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}
@media (orientation: portrait) {
  body.touch-device.in-game:not(.portrait-ok) #rotate-hint { display: grid; }
}

/* ============================ Overlay ================================== */

#overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
  background:
    radial-gradient(ellipse at center, rgba(4, 6, 15, 0.35) 0%, rgba(2, 3, 9, 0.88) 78%);
  backdrop-filter: blur(3px) saturate(115%);
  -webkit-backdrop-filter: blur(3px) saturate(115%);
  animation: fadeIn 200ms ease both;
}
#overlay.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 34px 38px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 46px rgba(63, 123, 255, 0.16),
    inset 0 0 70px rgba(63, 123, 255, 0.05);
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 249, 255, 0.35) transparent;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: panelIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: rgba(125, 249, 255, 0.3); }

/* Corner brackets */
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--cyan);
  opacity: 0.7;
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.panel h2 {
  margin: 0 0 22px;
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: 0.34em;
  text-shadow: var(--glow);
  text-align: center;
}

/* Logo */
.logo { text-align: center; margin-bottom: 26px; }
.logo h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 9vw, 86px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 10px rgba(125, 249, 255, 0.95),
    0 0 34px rgba(125, 249, 255, 0.55),
    0 0 78px rgba(63, 123, 255, 0.45);
  animation: logoFlicker 7s linear infinite;
}
.logo h1 span {
  color: var(--green);
  text-shadow:
    0 0 10px rgba(77, 255, 155, 0.95),
    0 0 34px rgba(77, 255, 155, 0.5),
    0 0 78px rgba(77, 255, 155, 0.35);
}
@keyframes logoFlicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.72; }
  98% { opacity: 1; }
  98.6% { opacity: 0.85; }
}
.tagline {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.44em;
  color: rgba(223, 246, 255, 0.45);
  font-weight: 600;
}

/* ============================== Menu =================================== */

.menu { display: flex; flex-direction: column; gap: 4px; }

.item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 18px;
  padding: 13px 18px 13px 22px;
  border: 1px solid transparent;
  border-left: 2px solid rgba(125, 249, 255, 0.15);
  background: rgba(125, 249, 255, 0.02);
  cursor: pointer;
  user-select: none;
  transition: background 130ms ease, border-color 130ms ease, transform 130ms ease;
  outline: none;
}
.item.compact { padding: 9px 16px 9px 20px; }
.item .label {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.17em;
  color: rgba(223, 246, 255, 0.78);
  transition: color 130ms ease, text-shadow 130ms ease;
}
.item .detail {
  grid-column: 1 / -1;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(223, 246, 255, 0.4);
  margin-top: -2px;
}
.item .badge {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(77, 255, 155, 0.65);
  white-space: nowrap;
}

.item.focused {
  background: rgba(125, 249, 255, 0.09);
  border-color: rgba(125, 249, 255, 0.4);
  border-left-color: var(--cyan);
  transform: translateX(3px);
}
.item.focused .label { color: #fff; text-shadow: var(--glow); }
.item.focused .detail { color: rgba(223, 246, 255, 0.66); }
.item.focused::before {
  content: '▶';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: var(--cyan);
  text-shadow: var(--glow);
}
.item.danger.focused { border-left-color: var(--red); background: rgba(255, 59, 92, 0.1); }
.item.danger.focused .label { color: #ffdbe2; text-shadow: 0 0 8px rgba(255, 59, 92, 0.9); }
.item.danger.focused::before { color: var(--red); }

/* Controls inside items */
.value { display: flex; align-items: center; gap: 9px; }
.arrow {
  background: none;
  border: 1px solid rgba(125, 249, 255, 0.25);
  color: rgba(223, 246, 255, 0.7);
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 9px;
  cursor: pointer;
  padding: 0;
  transition: all 120ms ease;
}
.arrow:hover { background: rgba(125, 249, 255, 0.18); color: #fff; border-color: var(--cyan); }
.bar {
  display: block;
  width: 96px;
  height: 4px;
  background: rgba(125, 249, 255, 0.16);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--cyan);
  transform-origin: left center;
  box-shadow: 0 0 8px var(--cyan);
}
.num {
  font-family: var(--font-display);
  font-size: 12px;
  min-width: 46px;
  text-align: right;
  color: rgba(223, 246, 255, 0.82);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
.num.wide { min-width: 78px; text-align: center; }

.switch {
  display: block;
  width: 40px;
  height: 20px;
  border: 1px solid rgba(125, 249, 255, 0.3);
  position: relative;
  transition: all 140ms ease;
}
.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: rgba(223, 246, 255, 0.35);
  transition: all 140ms cubic-bezier(0.4, 1.4, 0.5, 1);
}
.switch.on { border-color: var(--green); background: rgba(77, 255, 155, 0.12); }
.switch.on i { left: 22px; background: var(--green); box-shadow: 0 0 10px var(--green); }

.footer {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.26em;
  color: rgba(223, 246, 255, 0.32);
  font-weight: 600;
}

.custom { margin-bottom: 20px; }

.item.disabled { cursor: default; }
.item.disabled .label { color: rgba(223, 246, 255, 0.38); }
.item.disabled.focused { background: rgba(125, 249, 255, 0.04); border-color: rgba(125, 249, 255, 0.16); transform: none; }
.item.disabled.focused .label { color: rgba(223, 246, 255, 0.5); text-shadow: none; }

/* Text fields sit inside a menu row so they share its focus treatment. */
.text-field {
  width: min(220px, 44vw);
  background: rgba(4, 6, 15, 0.6);
  border: 1px solid rgba(125, 249, 255, 0.25);
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 7px 10px;
  outline: none;
  border-radius: 0;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
.text-field::placeholder { color: rgba(223, 246, 255, 0.28); }
.text-field:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 16px rgba(125, 249, 255, 0.25); }
.text-field.code { width: 150px; font-size: 22px; letter-spacing: 0.5em; text-align: center; padding: 6px 4px 6px 12px; }

/* ================================ Lobby ================================ */

.lobby { display: grid; gap: 16px; }
.room {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.room > span {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(223, 246, 255, 0.45);
  font-weight: 700;
}
.room b {
  font-family: var(--font-display);
  font-size: clamp(38px, 8vw, 56px);
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #fff;
  text-shadow: 0 0 14px rgba(255, 197, 61, 0.7), 0 0 40px rgba(255, 197, 61, 0.3);
  margin-right: -0.3em;
}
.lobby-ping {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(223, 246, 255, 0.45);
}
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(223, 246, 255, 0.16);
  background: rgba(125, 249, 255, 0.03);
  min-width: 0;
}
.seat i {
  grid-row: span 2;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.seat-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat-role {
  font-size: 10px;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: rgba(223, 246, 255, 0.5);
}
.seat.empty {
  grid-template-columns: 1fr;
  border-style: dashed;
  animation: hintPulse 2.2s ease-in-out infinite;
}
.seat.empty .seat-name { color: rgba(223, 246, 255, 0.55); }
.lobby-mode {
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: rgba(223, 246, 255, 0.6);
}
.invite-url {
  margin: 0;
  padding: 8px 10px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: rgba(223, 246, 255, 0.8);
  background: rgba(4, 6, 15, 0.6);
  border: 1px solid rgba(125, 249, 255, 0.2);
  overflow-wrap: anywhere;
  user-select: all;
}

.net-status { display: grid; justify-items: center; gap: 14px; padding: 10px 0; }
.net-status p, .net-note {
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.2em;
  line-height: 1.8;
  color: rgba(223, 246, 255, 0.55);
}
.net-note b { color: #fff; font-family: var(--font-display); letter-spacing: 0.3em; }
.net-error {
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(223, 246, 255, 0.8);
}

.crew-kills b { color: var(--accent) !important; text-shadow: 0 0 10px var(--accent) !important; }
.table-wrap { overflow-x: auto; }

/* =========================== Leaderboards ============================== */

.score-head {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--green);
  text-align: center;
  margin-bottom: 12px;
  text-shadow: 0 0 10px rgba(77, 255, 155, 0.5);
}
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.score-table th {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(223, 246, 255, 0.4);
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(125, 249, 255, 0.18);
  font-weight: 600;
}
.score-table th:first-child, .score-table td:first-child { text-align: left; width: 28px; }
.score-table td {
  padding: 6px 8px;
  text-align: right;
  color: rgba(223, 246, 255, 0.72);
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(125, 249, 255, 0.06);
}
.score-table tr.top td { color: #fff; text-shadow: 0 0 8px rgba(125, 249, 255, 0.5); }
.empty {
  text-align: center;
  padding: 22px;
  color: rgba(223, 246, 255, 0.35);
  letter-spacing: 0.2em;
  font-size: 12px;
}
.stats {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(223, 246, 255, 0.38);
}

/* ============================ Game over ================================ */

.record {
  text-align: center;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.34em;
  color: var(--amber);
  text-shadow: 0 0 14px rgba(255, 171, 46, 0.8);
  margin-bottom: 8px;
  animation: multPulse 1.3s ease-in-out infinite;
}
.final-score {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 0 14px rgba(125, 249, 255, 0.9), 0 0 44px rgba(125, 249, 255, 0.45);
  font-variant-numeric: tabular-nums;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
}
.result-grid > div {
  border: 1px solid rgba(125, 249, 255, 0.14);
  padding: 10px 12px;
  text-align: center;
  background: rgba(125, 249, 255, 0.03);
}
.result-grid span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(223, 246, 255, 0.4);
  margin-bottom: 4px;
  font-weight: 700;
}
.result-grid b {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(125, 249, 255, 0.5);
}

/* ============================== Help =================================== */

.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 28px; }
.help-grid section h3 {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.26em;
  color: var(--cyan);
  margin: 0 0 8px;
  text-shadow: 0 0 10px rgba(125, 249, 255, 0.4);
}
.help-grid p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: rgba(223, 246, 255, 0.62); }
.help-grid dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.help-grid dt {
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: rgba(223, 246, 255, 0.85);
  white-space: nowrap;
}
.help-grid dd { margin: 0; font-size: 12.5px; line-height: 1.45; color: rgba(223, 246, 255, 0.52); }
.help-grid dl.enemies { grid-template-columns: 1fr; gap: 1px; }
.help-grid dl.enemies dt { margin-top: 7px; }
.help-grid b { color: rgba(223, 246, 255, 0.9); font-weight: 700; }

.c-geom, .c-weaver { color: var(--green) !important; }
.c-grunt { color: var(--blue) !important; }
.c-wanderer { color: var(--magenta) !important; }
.c-pinwheel { color: var(--amber) !important; }
.c-snake { color: var(--lime) !important; }
.c-blackhole { color: var(--red) !important; }
.c-rocket { color: var(--cyan) !important; }
.c-nest { color: #ffe14d !important; }

/* ============================= Chrome ================================== */

#fullscreen-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 30;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 22, 0.5);
  border: 1px solid rgba(125, 249, 255, 0.2);
  color: rgba(223, 246, 255, 0.6);
  cursor: pointer;
  transition: all 140ms ease;
  opacity: 0.35;
}
#fullscreen-btn:hover { opacity: 1; border-color: var(--cyan); color: #fff; }
body.menu-open #fullscreen-btn { opacity: 0.8; }

#audio-hint {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  font-size: 10px;
  letter-spacing: 0.26em;
  color: rgba(223, 246, 255, 0.4);
  pointer-events: none;
  animation: hintPulse 2.4s ease-in-out infinite;
}
@keyframes hintPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.8; } }
#audio-hint.hidden { display: none; }
body:not(.menu-open) #audio-hint { display: none; }

#loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--ink);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: rgba(223, 246, 255, 0.5);
  transition: opacity 320ms ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(125, 249, 255, 0.18);
  border-top-color: var(--cyan);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#fatal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-content: center;
  text-align: center;
  padding: 40px;
  background: var(--ink);
}
#fatal.visible { display: grid; }
#fatal h1 {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.24em;
  color: var(--red);
  text-shadow: 0 0 16px rgba(255, 59, 92, 0.6);
  margin: 0 0 14px;
}
#fatal p { max-width: 460px; font-size: 14px; line-height: 1.6; color: rgba(223, 246, 255, 0.6); margin: 0 auto; }

/* ============================ Responsive =============================== */

/* Buttons in menus respond to the first tap on touch screens. */
.item, .arrow { touch-action: manipulation; }

@media (max-width: 860px) {
  .help-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 26px 20px 20px; }
  .hud-center { display: none; }
  .item { padding: 11px 14px 11px 18px; }
  .item .label { font-size: 13px; }
  .bar { width: 64px; }
}

@media (max-width: 560px) {
  .seats { grid-template-columns: 1fr; }
  .hud-net { gap: 6px; }
  .crew { padding: 5px 8px; }
  .crew-role { display: none; }
  .hud-left { gap: 14px; }
  .score-table th:nth-child(5), .score-table td:nth-child(5),
  .score-table th:nth-child(6), .score-table td:nth-child(6) { display: none; }
  .value { gap: 6px; }
  .num { min-width: 38px; font-size: 11px; }
  #hud { padding: 12px; }
}

@media (max-height: 560px) {
  /* Short landscape phones: the lobby's actions must fit without scrolling. */
  .lobby-screen h2 { display: none; }
  .lobby { gap: 10px; }
  .room b { font-size: 34px; }
  .seat { padding: 8px 12px; }
  .seat-name { font-size: 13px; }
  .lobby-mode { font-size: 12px; }
  .lobby-screen .item .detail { display: none; }
  .lobby-screen .custom { margin-bottom: 10px; }
  .logo h1 { font-size: clamp(30px, 7vw, 52px); }
  .logo { margin-bottom: 14px; }
  .panel { padding: 20px 24px 16px; }
  .item { padding: 9px 14px 9px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
