.hidden {
  display: none !important;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background: #000;
  overflow: hidden;
  font-family: monospace;
  color: #fff;
  touch-action: none;
}
body.aiming {
  cursor: none;
}
#game {
  display: block;
  width: 100dvw;
  height: 100dvh;
  touch-action: none;
  /* Page-load reveal is coordinated in orbivorio.js: held at opacity 0
     until both the skybox/surface textures have GPU-uploaded and the
     ball preview has primed its first textured frame, then `.is-ready`
     fades both in on the same frame. */
  opacity: 0;
  transition: opacity 0.25s ease-out;
}
#game.is-ready {
  opacity: 1;
}

/* -- Spawn menu overlay -- */
.spawn-menu {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding-top: 36px;
  background: transparent;
  transition:
    opacity 0.5s ease,
    visibility 0.5s;
  /* Panel-shape variables shared between the box (which positions
     itself via these) and the spawn-menu ::before clip-path (which
     cuts the panel silhouette out of the ship-interior backdrop). */
  --panel-half-w: min(550px, calc(50% - 16px));
  --panel-l: calc(50% - var(--panel-half-w));
  --panel-r: calc(50% + var(--panel-half-w));
  --panel-t: 96px;
  --panel-b: calc(100% - 96px);
}
.spawn-menu.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  animation: none;
}
.spawn-menu__box {
  /* Anchored to the same --panel-t/--panel-b/--panel-l/--panel-r the
     ship-interior cutout uses, so the orange border traces exactly the
     cutout silhouette regardless of how tall the title above it ends up. */
  position: absolute;
  top: var(--panel-t);
  bottom: calc(100% - var(--panel-b));
  left: var(--panel-l);
  right: calc(100% - var(--panel-r));
  text-align: center;
  padding: 36px 56px 40px;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Inherited text-shadow keeps small labels readable on the moving planet.
     Inputs and buttons own their own backgrounds and override it. */
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 8px rgba(0, 0, 0, 0.5);
}
/* Two-layer panel:
   ::before is a theme-colored ring around the polygon — clip-path
   uses evenodd with outer polygon + inner (1px-shrunk) polygon, so
   the visible region is just the 1px gap between them. That gap
   traces every polygon edge: chamfered corners, dip slopes, and
   straight sides alike, all in theme color.
   ::after fills the inner polygon with the panel content (semi-
   transparent dark + sheen + glass-edge highlights). Planet behind
   stays visible through the inner area's transparency. */
.spawn-menu__box::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--theme-color) 75%, transparent);
  filter: drop-shadow(
    0 0 18px color-mix(in srgb, var(--theme-color) 25%, transparent)
  );
  clip-path: polygon(
    evenodd,
    /* outer polygon (clockwise from chamfered top-left) */ 0 18px,
    18px 0,
    calc(50% - 76px) 0,
    calc(50% - 60px) 16px,
    calc(50% + 60px) 16px,
    calc(50% + 76px) 0,
    calc(100% - 18px) 0,
    100% 18px,
    100% calc(100% - 32px),
    calc(100% - 32px) 100%,
    calc(50% + 76px) 100%,
    calc(50% + 60px) calc(100% - 16px),
    calc(50% - 60px) calc(100% - 16px),
    calc(50% - 76px) 100%,
    32px 100%,
    0 calc(100% - 32px),
    /* Bridge from outer_16 to inner_16 (1px horizontal slit at
       y=100%-32). Trace inner counter-clockwise as a CLOSED loop
       all the way back to inner_16 — this includes the inner's
       LEFT EDGE (from inner_1 back up to inner_16) which was
       previously missing, leaving the left border invisible.
       Then bridge back from inner_16 to outer_16 along the same
       1px line; the two bridge edges overlap and cancel under
       evenodd. The implicit close from outer_16 back to outer_1
       runs vertically up the outer left edge — no stray edge. */
    1px calc(100% - 32px),
    32px calc(100% - 1px),
    calc(50% - 76px) calc(100% - 1px),
    calc(50% - 60px) calc(100% - 17px),
    calc(50% + 60px) calc(100% - 17px),
    calc(50% + 76px) calc(100% - 1px),
    calc(100% - 32px) calc(100% - 1px),
    calc(100% - 1px) calc(100% - 32px),
    calc(100% - 1px) 18px,
    calc(100% - 18px) 1px,
    calc(50% + 76px) 1px,
    calc(50% + 60px) 17px,
    calc(50% - 60px) 17px,
    calc(50% - 76px) 1px,
    18px 1px,
    1px 18px,
    1px calc(100% - 32px),
    0 calc(100% - 32px)
  );
}
.spawn-menu__box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Sheen highlight + dark fill */
  background:
    radial-gradient(
      ellipse 75% 55% at 25% 12%,
      rgba(255, 255, 255, 0.1) 0%,
      rgba(255, 255, 255, 0.03) 35%,
      transparent 70%
    ),
    rgba(0, 0, 0, 0.1);
  /* Glass-edge directional accents on the inner polygon's straight sides */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.55),
    inset 1px 0 0 color-mix(in srgb, var(--theme-color) 35%, transparent),
    inset -1px 0 0 color-mix(in srgb, var(--theme-color) 20%, transparent);
  clip-path: polygon(
    /* Inner polygon (matches ::before's inner) */ 1px 18px,
    18px 1px,
    calc(50% - 76px) 1px,
    calc(50% - 60px) 17px,
    calc(50% + 60px) 17px,
    calc(50% + 76px) 1px,
    calc(100% - 18px) 1px,
    calc(100% - 1px) 18px,
    calc(100% - 1px) calc(100% - 32px),
    calc(100% - 32px) calc(100% - 1px),
    calc(50% + 76px) calc(100% - 1px),
    calc(50% + 60px) calc(100% - 17px),
    calc(50% - 60px) calc(100% - 17px),
    calc(50% - 76px) calc(100% - 1px),
    32px calc(100% - 1px),
    1px calc(100% - 32px)
  );
}

/* Ship-interior backdrop (all views): hull-plate grid + lighting +
   theme-tinted dark base, clipped via clip-path to render only OUTSIDE
   the panel silhouette. The :before sits behind the title, panel, and
   anything else inside the spawn menu (z-index: -1 within the spawn
   menu's stacking context). */
.spawn-menu::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    /* Horizontal hull-plate seams: 2px shadow groove + 1px highlight. */
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 218px,
      rgba(0, 0, 0, 0.7) 218px,
      rgba(0, 0, 0, 0.7) 220px,
      rgba(255, 255, 255, 0.08) 220px,
      rgba(255, 255, 255, 0.08) 221px
    ),
    /* Vertical hull-plate seams */
    repeating-linear-gradient(
        90deg,
        transparent 0,
        transparent 218px,
        rgba(0, 0, 0, 0.7) 218px,
        rgba(0, 0, 0, 0.7) 220px,
        rgba(255, 255, 255, 0.08) 220px,
        rgba(255, 255, 255, 0.08) 221px
      ),
    /* Directional lighting: brighter upper-left, darker lower-right. */
    linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.06) 0%,
        transparent 35%,
        rgba(0, 0, 0, 0.25) 100%
      ),
    /* Solid dark base with faint theme-color undertone. */
    color-mix(in srgb, var(--theme-color) 8%, #000);
  /* Cut the panel silhouette out of the ship-interior backdrop using
     clip-path with even-odd fill rule. The polygon traces the outer
     viewport rect, bridges along the left edge to the inner panel
     polygon, traces the panel, then bridges back along the same
     left-edge path. The two bridge edges overlap and cancel, while
     the implicit close from the last vertex back to (0,0) runs
     vertically along the outer left edge — neither edge crosses
     the visible area, so evenodd parity stays correct everywhere. */
  clip-path: polygon(
    evenodd,
    0 0,
    100% 0,
    100% 100%,
    0 100%,
    0 calc(var(--panel-t) + 18px),
    var(--panel-l) calc(var(--panel-t) + 18px),
    calc(var(--panel-l) + 18px) var(--panel-t),
    calc(50% - 76px) var(--panel-t),
    calc(50% - 60px) calc(var(--panel-t) + 16px),
    calc(50% + 60px) calc(var(--panel-t) + 16px),
    calc(50% + 76px) var(--panel-t),
    calc(var(--panel-r) - 18px) var(--panel-t),
    var(--panel-r) calc(var(--panel-t) + 18px),
    var(--panel-r) calc(var(--panel-b) - 32px),
    calc(var(--panel-r) - 32px) var(--panel-b),
    calc(50% + 76px) var(--panel-b),
    calc(50% + 60px) calc(var(--panel-b) - 16px),
    calc(50% - 60px) calc(var(--panel-b) - 16px),
    calc(50% - 76px) var(--panel-b),
    calc(var(--panel-l) + 32px) var(--panel-b),
    var(--panel-l) calc(var(--panel-b) - 32px),
    var(--panel-l) calc(var(--panel-t) + 18px),
    0 calc(var(--panel-t) + 18px)
  );
}

/* -- View swap: hide the inactive view -- */
.spawn-menu[data-view="create"] .spawn-menu__view--landing,
.spawn-menu[data-view="create"] .spawn-menu__view--invite,
.spawn-menu[data-view="landing"] .spawn-menu__view--create,
.spawn-menu[data-view="landing"] .spawn-menu__view--invite,
.spawn-menu[data-view="invite"] .spawn-menu__view--landing,
.spawn-menu[data-view="invite"] .spawn-menu__view--create {
  display: none;
}
/* Hide identity fields on create/invite — already chosen on landing.
   Title stays visible so ORBIVOR.IO sits above the panel in every view. */
.spawn-menu[data-view="create"] #name-input,
.spawn-menu[data-view="create"] #color-picker,
.spawn-menu[data-view="invite"] #name-input,
.spawn-menu[data-view="invite"] #color-picker {
  display: none;
}
.spawn-menu__title {
  font-size: 38px;
  font-weight: bold;
  letter-spacing: 8px;
  color: #fff;
  text-shadow:
    0 2px 6px rgba(0, 0, 0, 0.85),
    0 0 18px color-mix(in srgb, var(--theme-color) 50%, transparent);
  margin-bottom: 2px;
}

/* Landing layout: vertical stack — name → color → preview ball →
   PLAY/NEW-GAME row → keymap. Centered, narrow column. */
.spawn-menu__landing {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  width: min(360px, 100%);
  margin: 0 auto;
}
.spawn-menu__landing .spawn-menu__input {
  width: 100%;
  margin: 0;
}
.spawn-menu__landing .spawn-menu__colors-wrapper {
  width: 100%;
  margin: 0;
}
.spawn-menu__landing__preview {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80px;
  /* Drop-shadow lives on the wrapper, not the canvas itself: applying
     a CSS filter directly to a WebGL canvas can flash white during
     transitions while the compositor rasterizes the layer. */
  filter: drop-shadow(
    0 4px 14px color-mix(in srgb, var(--theme-color) 45%, transparent)
  );
  /* Held at visibility:hidden (not just opacity:0) until ball_preview.js
     reports its priming render is done. Without this, the browser can
     composite the canvas's layer before WebGL has drawn anything; some
     browsers initialize that layer to opaque white, which flashes
     through the moment the layer becomes visible. */
  visibility: hidden;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.18s ease-out,
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.spawn-menu__landing__preview.is-ready {
  visibility: visible;
  opacity: 1;
  transform: scale(1);
}
.spawn-menu__landing__ball {
  /* Three.js renders the actual player mesh into this canvas; see
     orbivorio/ball_preview.js. Reveal/scale-in happens on the wrapper. */
  width: 80px;
  height: 80px;
  display: block;
}
.spawn-menu__landing__actions {
  display: flex;
  gap: 14px;
}
.spawn-menu__landing__actions .spawn-menu__btn {
  flex: 1;
  width: auto;
  /* Trim default 44px horizontal padding so "NEW GAME" fits on one
     line in the half-width slot. */
  padding-left: 14px;
  padding-right: 14px;
}
.spawn-menu__landing__actions .spawn-menu__btn--outline {
  margin-top: 0;
}
.spawn-menu__landing__keymap {
  margin-top: 8px;
}
.spawn-menu__input {
  display: block;
  width: 280px;
  margin: 0 auto 16px;
  padding: 8px 12px;
  font: 16px monospace;
  background: #222;
  color: #fff;
  border: 1px solid var(--theme-color, #555);
  border-radius: 6px;
  text-align: center;
  outline: none;
  letter-spacing: 2px;
  transition: border-color 0.15s ease;
}
.spawn-menu__input::selection {
  background: #444;
  color: #fff;
}
orbivor-color-picker {
  display: flex;
  height: 52px;
}
.spawn-menu__colors-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
  width: 260px;
}
.spawn-menu__carousel {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  width: 160px;
  overflow-x: hidden;
  touch-action: none;
}
.spawn-menu__carousel-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.spawn-menu__picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 260px;
  margin: 0 auto 6px;
}
.spawn-menu__picker-label {
  font: 11px monospace;
  letter-spacing: 2px;
  color: #888;
  text-transform: uppercase;
  /* Three-column grid: value sits in the auto-sized center column so its
     midpoint aligns with the carousel's selected tile. The prefix + separator
     ride in a left column that right-aligns against the value. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 6px;
  align-items: baseline;
  width: 100%;
}
.spawn-menu__picker-label-group {
  grid-column: 1;
  justify-self: end;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.spawn-menu__picker-label-value {
  grid-column: 2;
  color: #fff;
  font-size: 13px;
  letter-spacing: 3px;
}
.spawn-menu__picker-label-sep {
  opacity: 0.5;
}

/* Theme picker tiles */
.spawn-menu__theme-label {
  flex: 0 0 auto;
  cursor: pointer;
  padding: 2px;
}
.spawn-menu__theme-radio {
  display: none;
}
.spawn-menu__theme-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background-size: auto 150%;
  background-position: center;
  background-color: #222;
  color: rgba(255, 255, 255, 0.7);
  font: 20px monospace;
  font-weight: bold;
  transition:
    transform 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
}
.spawn-menu__theme-swatch:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}
.spawn-menu__theme-radio:checked + .spawn-menu__theme-swatch {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow:
    0 0 5px var(--theme-color, #fff),
    0 0 10px var(--theme-color, #fff);
  animation: neon-pulse 3s infinite ease-in-out;
}

/* Size picker tiles */
.spawn-menu__size-label {
  flex: 0 0 auto;
  cursor: pointer;
  padding: 2px;
  /* Reserve the same box size regardless of disc diameter so centering is
     consistent across the carousel. */
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spawn-menu__size-radio {
  display: none;
}
.spawn-menu__size-disc {
  display: block;
  border-radius: 50%;
  background: var(--theme-color, #6688aa);
  opacity: 0.65;
  border: 2px solid rgba(255, 255, 255, 0.25);
  transition:
    transform 0.2s,
    border-color 0.2s,
    opacity 0.2s,
    box-shadow 0.2s;
}
.spawn-menu__size-disc:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.6);
  opacity: 0.85;
}
.spawn-menu__size-radio:checked + .spawn-menu__size-disc {
  border-color: #fff;
  opacity: 1;
  box-shadow:
    0 0 5px var(--theme-color, #fff),
    0 0 10px var(--theme-color, #fff);
  animation: neon-pulse 3s infinite ease-in-out;
}

/* Mode picker tiles (outside vs inside-out geometry) */
.spawn-menu__mode-label {
  flex: 0 0 auto;
  cursor: pointer;
  padding: 2px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spawn-menu__mode-radio {
  display: none;
}
.spawn-menu__mode-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background-color: #222;
  color: rgba(255, 255, 255, 0.7);
  transition:
    transform 0.2s,
    border-color 0.2s,
    color 0.2s,
    box-shadow 0.2s;
}
.spawn-menu__mode-glyph:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.95);
}
.spawn-menu__mode-radio:checked + .spawn-menu__mode-glyph {
  border-color: #fff;
  color: #fff;
  transform: scale(1.12);
  box-shadow:
    0 0 5px var(--theme-color, #fff),
    0 0 10px var(--theme-color, #fff);
  animation: neon-pulse 3s infinite ease-in-out;
}
.spawn-menu__control-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font: 32px monospace;
  font-weight: bold;
  cursor: pointer;
  padding: 0 14px;
  transition:
    color 0.2s,
    transform 0.2s;
  user-select: none;
}
.spawn-menu__control-btn:hover {
  color: #fff;
  transform: scale(1.2);
}
.spawn-menu__color-label {
  flex: 0 0 auto;
  cursor: pointer;
  padding: 2px;
}
.spawn-menu__color-radio {
  display: none;
}
.spawn-menu__color-swatch {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition:
    transform 0.2s,
    border-color 0.2s,
    box-shadow 0.2s;
  background-clip: padding-box;
}
.spawn-menu__color-swatch:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Selected state: Neon Glow + Pulse (Subtle) */
.spawn-menu__color-radio:checked + .spawn-menu__color-swatch {
  border-color: #fff;
  transform: scale(1.12);
  box-shadow:
    0 0 5px currentColor,
    0 0 10px currentColor;
  animation: neon-pulse 3s infinite ease-in-out;
}

@keyframes neon-pulse {
  0%,
  100% {
    box-shadow:
      0 0 4px currentColor,
      0 0 8px currentColor;
    transform: scale(1.1);
  }
  50% {
    box-shadow:
      0 0 8px currentColor,
      0 0 16px currentColor;
    transform: scale(1.15);
  }
}
.spawn-menu__btn {
  width: 240px;
  padding: 14px 44px;
  font: 18px monospace;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: #fff;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--theme-color) 50%, transparent) 0%,
    color-mix(in srgb, var(--theme-color) 30%, transparent) 45%,
    color-mix(in srgb, var(--theme-color) 15%, transparent) 55%,
    color-mix(in srgb, var(--theme-color) 35%, transparent) 100%
  );
  border: 2px solid color-mix(in srgb, var(--theme-color) 60%, transparent);
  border-radius: 8px;
  cursor: pointer;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 15px color-mix(in srgb, var(--theme-color) 20%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.spawn-menu__btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.2) 0%,
    rgba(255, 255, 255, 0.05) 40%,
    transparent 50%
  );
  pointer-events: none;
}
.spawn-menu__btn:hover {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--theme-color) 60%, transparent) 0%,
    color-mix(in srgb, var(--theme-color) 40%, transparent) 45%,
    color-mix(in srgb, var(--theme-color) 25%, transparent) 55%,
    color-mix(in srgb, var(--theme-color) 45%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--theme-color) 80%, transparent);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    0 0 25px color-mix(in srgb, var(--theme-color) 35%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.spawn-menu__btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.5),
    0 0 10px color-mix(in srgb, var(--theme-color) 15%, transparent),
    inset 0 2px 6px rgba(0, 0, 0, 0.3);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--theme-color) 30%, transparent) 0%,
    color-mix(in srgb, var(--theme-color) 25%, transparent) 45%,
    color-mix(in srgb, var(--theme-color) 20%, transparent) 55%,
    color-mix(in srgb, var(--theme-color) 35%, transparent) 100%
  );
}
.spawn-menu__btn:disabled {
  cursor: default;
  opacity: 0.5;
  pointer-events: none;
  animation: launch-ready 1.5s ease-in-out infinite;
}
@keyframes launch-ready {
  0%,
  100% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.4),
      0 0 15px color-mix(in srgb, var(--theme-color) 20%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
  50% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.4),
      0 0 30px color-mix(in srgb, var(--theme-color) 40%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
}
/* -- Outlined variant: same frame as PLAY, unfilled. Sits directly below it. -- */
.spawn-menu__btn--outline {
  margin-top: 14px;
  background: transparent;
  border-color: color-mix(in srgb, var(--theme-color) 45%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #ddd;
}
.spawn-menu__btn--outline::before {
  opacity: 0.3;
}
.spawn-menu__btn--outline:hover {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--theme-color) 22%, transparent) 0%,
    color-mix(in srgb, var(--theme-color) 10%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--theme-color) 75%, transparent);
  box-shadow:
    0 0 20px color-mix(in srgb, var(--theme-color) 22%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #fff;
}
.spawn-menu__btn--outline:active {
  background: color-mix(in srgb, var(--theme-color) 15%, transparent);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.35),
    0 0 8px color-mix(in srgb, var(--theme-color) 15%, transparent);
}

/* -- Create view: back + title as a single inline header, then options -- */
.spawn-menu__view-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 auto 18px;
}
.spawn-menu__back {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font: 22px monospace;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: none;
  transition:
    color 0.2s,
    transform 0.2s;
}
.spawn-menu__back:hover {
  color: #fff;
  transform: translateX(-2px);
}
.spawn-menu__back-home {
  position: absolute;
  top: 24px;
  left: 24px;
  color: rgba(255, 255, 255, 0.55);
  font: bold 14px monospace;
  letter-spacing: 3px;
  text-decoration: none;
  padding: 8px 12px;
  cursor: pointer;
  transition:
    color 0.2s,
    transform 0.2s;
}
.spawn-menu__back-home:hover {
  color: #fff;
  transform: translateX(-2px);
}
.spawn-menu__view-header .spawn-menu__view-title {
  margin: 0;
}
.spawn-menu__slug {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 4px;
  color: rgb(255, 255, 255);
  margin: 14px 0 14px;
}
.spawn-menu__view-title {
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 4px;
  color: rgb(255, 255, 255);
  margin: 6px 0 14px;
}
.spawn-menu__options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 260px;
  margin: 0 auto 18px;
}
.spawn-menu__option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font: 13px monospace;
  letter-spacing: 2px;
  color: #ccc;
  cursor: text;
}
.spawn-menu__option-label {
  text-transform: uppercase;
}
.spawn-menu__option-input {
  width: 56px;
  padding: 2px 4px;
  font: 14px monospace;
  font-weight: bold;
  letter-spacing: 2px;
  background: transparent;
  color: #fff;
  border: none;
  text-align: right;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}
.spawn-menu__option-input::-webkit-outer-spin-button,
.spawn-menu__option-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.spawn-menu__option-row:focus-within {
  border-color: color-mix(in srgb, var(--theme-color) 60%, transparent);
  background: rgba(255, 255, 255, 0.05);
}
.spawn-menu__option-select {
  width: 128px;
  padding: 5px 22px 5px 10px;
  font: 14px monospace;
  letter-spacing: 1px;
  background-color: rgba(0, 0, 0, 0.55);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M0 0l5 6 5-6z' fill='white' opacity='0.7'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 9px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  text-align: center;
  text-align-last: center;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  transition: border-color 0.1s ease;
}
.spawn-menu__option-select:hover {
  border-color: color-mix(in srgb, var(--theme-color) 50%, transparent);
}
.spawn-menu__option-select:focus {
  border-color: var(--theme-color);
}
.spawn-menu__option-select option {
  background: #111;
  color: #fff;
}
.spawn-menu__option-hint {
  font: 10px monospace;
  letter-spacing: 2px;
  color: #667;
  text-align: center;
}

.spawn-menu__message {
  display: none;
  margin: 0 auto 16px;
  padding: 8px 14px;
  text-align: center;
  font: 13px monospace;
  color: #ffb0b0;
  letter-spacing: 1px;
  background: rgba(255, 80, 80, 0.08);
  border: 1px solid rgba(255, 120, 120, 0.3);
  border-radius: 6px;
}
.spawn-menu__message.visible {
  display: block;
}
.spawn-menu__landing__keymap {
  font: 12px monospace;
  color: #889;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.spawn-menu__keymap {
  display: grid;
  grid-template-columns: repeat(6, auto);
  column-gap: 8px;
  align-items: center;
  justify-content: center;
}
.spawn-menu__keymap > * + * {
  margin-left: 0;
}
/* Add a separator gap between key/action pairs (every 3rd, 5th column). */
.spawn-menu__keymap > :nth-child(2n + 1):not(:first-child) {
  margin-left: 22px;
}
.spawn-menu__controls--mobile {
  display: none;
  margin: 0;
}
.spawn-menu__key {
  color: #ccc;
  white-space: nowrap;
  padding-right: 4px;
}
.spawn-menu__action {
  color: #889;
  white-space: nowrap;
}
@media (pointer: coarse) {
  .spawn-menu__controls--mobile {
    display: block;
    color: #aaa;
  }
  .spawn-menu__keymap {
    display: none; /* Hide keyboard helpers on primarily touch devices */
  }
}

@media (max-width: 600px) {
  .spawn-menu__title {
    font-size: 28px;
    letter-spacing: 5px;
  }
  .spawn-menu__box {
    padding: 28px 20px 28px;
  }
  .spawn-menu__landing__actions {
    flex-direction: column;
  }
  .spawn-menu__keymap > :nth-child(2n + 1):not(:first-child) {
    margin-left: 12px;
  }
  .spawn-menu__keymap {
    column-gap: 6px;
  }
}
.leaderboard {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 260px;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 12px;
  font: 13px monospace;
  color: #fff;
  pointer-events: none;
  border-radius: 6px;
  line-height: 1.5;
  z-index: 10;
}
.leaderboard.expanded {
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}
.leaderboard__list {
  overflow-y: auto;
  flex: 1 1 auto;
}
.leaderboard__header {
  color: #666;
  font-size: 11px;
  margin-bottom: 4px;
}
.leaderboard__row {
  overflow: hidden;
  white-space: nowrap;
}
.leaderboard__row--me {
  font-weight: bold;
}
.leaderboard__sep {
  color: #666;
  font-size: 11px;
}
.leaderboard__btn {
  color: #999;
  font-size: 11px;
  margin-top: 4px;
  text-align: center;
  cursor: pointer;
  padding: 2px 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  pointer-events: auto;
}
.leaderboard__btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ccc;
}
.charge-meter {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 12px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  display: none;
  z-index: 10;
}
.charge-meter__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0f0, #ff0, #f00);
}

/* -- Help overlay -- */
.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 110;
  justify-content: center;
  align-items: center;
}

.help-overlay.visible {
  display: flex;
}
.help-overlay__box {
  background: rgba(0, 0, 0, 0.35);
  padding: 24px 36px;
  border-radius: 8px;
  font: 14px monospace;
  color: rgba(255, 255, 255, 0.8);
}
.help-overlay__row {
  margin: 8px 0;
}
.spawn-menu:not(.hidden) ~ .help-overlay .help-overlay__box {
  background: rgba(0, 0, 0, 0.8);
}
.help-overlay__key {
  display: inline-block;
  min-width: 80px;
  color: #fff;
  font-weight: bold;
}

/* -- Eaten message -- */
.eaten-message {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font: 24px monospace;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 120;
  opacity: 0;
  transition: opacity 0.5s;
}
.eaten-message.visible {
  opacity: 1;
}

/* Hide HUD elements when spawn menu is visible */
.spawn-menu:not(.hidden) ~ .compass-btn,
.spawn-menu:not(.hidden) ~ .leaderboard,
.spawn-menu:not(.hidden) ~ .charge-meter,
.spawn-menu:not(.hidden) ~ .name-tags,
.spawn-menu:not(.hidden) ~ .copy-link-btn {
  display: none !important;
}

/* -- Compass button (mobile) -- */
.compass-btn {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
  font: 18px monospace;
  z-index: 10;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.compass-btn:active,
.compass-btn.active {
  background: rgba(255, 255, 255, 0.3);
}
@media (pointer: coarse) {
  .compass-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* -- Jump reticle -- */
.jump-reticle {
  display: none;
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 15;
}
.jump-reticle.visible {
  display: block;
}
.jump-reticle svg {
  position: absolute;
  transform: translate(-50%, -50%);
}

/* -- Name tags -- */
.name-tags {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.name-tag {
  position: absolute;
  top: 0;
  left: 0;
  font: 11px monospace;
  color: #fff;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 0 4px #000;
  white-space: nowrap;
  will-change: transform;
}

/* -- Copy-link button (top-right, in-game) -- */
.copy-link-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  font-family: monospace;
  cursor: pointer;
  z-index: 10;
  transition:
    padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    gap 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}
.copy-link-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}
.copy-link-btn:active {
  transform: translateY(1px);
}
.copy-link-btn__label {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  /* Fixed width sized for the longest label ("LINK COPIED") so the button
     doesn't reflow when swapping between "COPY LINK" and "LINK COPIED". */
  width: 104px;
  transition:
    width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
}
.copy-link-btn__icon {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  transition: color 0.15s ease;
}
.copy-link-btn--compact {
  padding: 10px;
  gap: 0;
}
.copy-link-btn--compact .copy-link-btn__label {
  width: 0;
  opacity: 0;
}
.copy-link-btn--copied {
  background: rgba(80, 200, 120, 0.25);
  border-color: rgba(80, 200, 120, 0.6);
  color: #9f9;
}
.copy-link-btn--copied .copy-link-btn__icon {
  color: #9f9;
}
@media (pointer: coarse) {
  .copy-link-btn {
    padding: 12px 16px;
    min-height: 44px;
  }
  .copy-link-btn--compact {
    padding: 12px;
    min-width: 44px;
  }
}

/* -- Invite view (shown after LAUNCH, before joining) -- */
.spawn-menu__invite-slug {
  display: block;
  width: fit-content;
  margin: 0 auto 20px;
  padding: 12px 20px;
  font: 16px monospace;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid color-mix(in srgb, var(--theme-color) 45%, transparent);
  border-radius: 6px;
  cursor: pointer;
  user-select: all;
  white-space: nowrap;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.spawn-menu__invite-slug:hover {
  border-color: color-mix(in srgb, var(--theme-color) 75%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--theme-color) 20%, transparent);
}
.spawn-menu__invite-domain {
  font: 11px monospace;
  letter-spacing: 1px;
  color: #778;
  text-transform: lowercase;
  margin-bottom: 4px;
}
.spawn-menu__invite-code-wrap {
  margin: 0 auto 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.spawn-menu__invite-code-label {
  font: 10px monospace;
  letter-spacing: 3px;
  color: #889;
  text-transform: uppercase;
}
.spawn-menu__invite-code {
  font: 28px monospace;
  font-weight: bold;
  letter-spacing: 8px;
  color: #fff;
  padding-left: 8px; /* offset letter-spacing so text renders centered */
  text-shadow: 0 0 12px color-mix(in srgb, var(--theme-color) 35%, transparent);
}
.spawn-menu__invite-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 14px auto 0;
}
/* Outline buttons inside actions share a gap; suppress their default top margin. */
.spawn-menu__invite-actions .spawn-menu__btn--outline {
  margin-top: 0;
}
/* Green flash when COPY LINK succeeds — overrides the outlined button fill. */
.spawn-menu__btn--copied {
  color: #9f9 !important;
  background: rgba(80, 200, 120, 0.18) !important;
  border-color: rgba(80, 200, 120, 0.6) !important;
  box-shadow: 0 0 14px rgba(80, 200, 120, 0.25) !important;
}
