@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700;800&family=Orbitron:wght@700;800;900&family=Rajdhani:wght@600;700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0a0a14;
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f1f5f9;
}

.tabular {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

#game-canvas {
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* =========================================
   BOOT / LOADING SCREEN
   Sits above everything from the very first paint (it is plain HTML+CSS, so
   it is visible while the ES modules and CDN chunks are still downloading).
   main.js advances the bar and fades it out once the game is genuinely ready.
   ========================================= */
.boot-loader {
  position: fixed;
  inset: 0;
  /* Above every in-app overlay, including the injected auth chip (9500). */
  z-index: 9600;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% 0%, #0d1230 0%, #070812 55%, #05060c 100%);
  overflow: hidden;
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.boot-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.8;
}
.boot-aurora {
  /* Same hero glow as the menu, slightly dimmer so the panel reads. */
  opacity: 0.75;
}
.boot-panel {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.boot-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: #b9e8ff;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 229, 255, 0.4);
  background: rgba(8, 14, 32, 0.72);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.18), inset 0 0 12px rgba(0, 229, 255, 0.08);
}
.boot-title {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(26px, 6vw, 46px);
  letter-spacing: 0.08em;
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.5), 0 0 44px rgba(255, 45, 149, 0.3);
}
.boot-title span {
  color: #ff2d95;
  text-shadow: 0 0 18px rgba(255, 45, 149, 0.65), 0 0 44px rgba(255, 45, 149, 0.35);
}
.boot-sub {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: #7d93bd;
  text-transform: uppercase;
}
.boot-bar {
  position: relative;
  width: 100%;
  height: 6px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(0, 229, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.22);
  overflow: hidden;
}
.boot-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #00e5ff 0%, #7b2ff7 55%, #ff2d95 100%);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.7), 0 0 28px rgba(255, 45, 149, 0.35);
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.boot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #8aa0c7;
  text-transform: uppercase;
}
.boot-meta #boot-percent {
  color: #00e5ff;
}
.boot-tip {
  margin-top: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(138, 160, 199, 0.55);
  min-height: 14px;
  transition: opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .boot-aurora {
    animation: none;
  }
}

/* Planet-orbit load state. The mesh is in the WebGL scene; this is just the caption.
   The menu scrim lifts so the orbits read instead of a blurred half-built arena. */
.arena-loader {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 140;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.arena-loader.hidden {
  opacity: 0;
  visibility: hidden;
}
.arena-loader-label {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #d8f7ff;
  background: rgba(6, 10, 24, 0.78);
  border: 1px solid rgba(0, 229, 255, 0.5);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.28);
}
.arena-loader-label span {
  color: #00e5ff;
  margin-right: 8px;
}
/* The exoplanet is the main-menu backdrop. The loading state used to be the
   only time this veil lifted; keep it lifted so the planet does not pop. */
/* Veil 0.28 (was 0.18): backdrop ~12% darker so the buttons and the selected
   fighter carry the accent. */
#start-menu {
  background: rgba(6, 8, 18, 0.28);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.arena-loading #start-menu {
  background: rgba(6, 8, 18, 0.28);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* =========================================
   GENERIC MENU SCREENS (Start, Pause, Win)
   ========================================= */
.menu-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
  opacity: 1;
  visibility: visible;
  /* Fast (100ms) — a 250ms visibility fade made rapid clicks land in the gap
     where the overlay is still "visible" but not interactive (felt dead on Mac). */
  transition: opacity 0.1s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.1s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.menu-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Generic Cyber Card Container */
.menu-card {
  background: linear-gradient(180deg, rgba(16, 22, 46, 0.94) 0%, rgba(10, 12, 24, 0.98) 100%);
  border: none;
  border-radius: 20px;
  padding: 24px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 620px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85),
              0 0 40px rgba(0, 229, 255, 0.18);
  animation: popIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

/* D variant: the top shimmer line removed (was reading as a frame). */

/* =========================================
   START MENU — shining aurora background
   (huly-style hero glow: layered radial blobs,
    blur rendered once, transform-only animation)
   ========================================= */
/* Clipping wrapper: the animated aurora bleeds + rotates freely inside it
   without ever extending the page's scroll area. */
.menu-aurora-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.85; /* slightly more transparent aurora / grid / scanlines */
}

.menu-aurora {
  position: absolute;
  inset: -15%; /* bleed past the clip for a rich glow */
  pointer-events: none;
  background:
    radial-gradient(42% 38% at 24% 32%, rgba(0, 229, 255, 0.26), transparent 70%),
    radial-gradient(46% 42% at 76% 24%, rgba(255, 45, 149, 0.2), transparent 70%),
    radial-gradient(56% 52% at 52% 82%, rgba(124, 58, 237, 0.24), transparent 72%),
    radial-gradient(30% 26% at 88% 70%, rgba(0, 229, 255, 0.14), transparent 70%);
  filter: blur(80px);
  animation: auroraShift 16s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes auroraShift {
  0%   { transform: rotate(-5deg) scale(1) translate(0, 0); }
  50%  { transform: rotate(3deg) scale(1.09) translate(2%, -1.6%); }
  100% { transform: rotate(-2deg) scale(1.05) translate(-2%, 1.6%); }
}

/* Faint CRT scanlines over everything — sells the "arena broadcast" vibe at
   near-zero cost (single repeating-linear-gradient). */
.menu-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(10, 10, 20, 0.35) 3px,
    transparent 4px
  );
  opacity: 0.35;
  mix-blend-mode: multiply;
}

/* Staggered entrance: each menu panel fades + slides up in sequence so the
   card assembles instead of blinking in as one block (game-ui-ux). Runs once
   on load; the start menu is visible at boot so this plays exactly once. */
#start-menu .fighter-select-panel,
#start-menu .map-select-panel,
#start-menu .diff-select-panel,
#start-menu .bot-select-panel,
#start-menu .vs-showcase,
#start-menu .menu-actions,
#start-menu .menu-controls-guide {
  animation: riseIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
#start-menu .menu-header            { animation: riseIn 0.42s cubic-bezier(0.16,1,0.3,1) backwards; }
#start-menu .fighter-select-panel   { animation-delay: 0.06s; }
#start-menu .map-select-panel       { animation-delay: 0.12s; }
#start-menu .diff-select-panel      { animation-delay: 0.18s; }
#start-menu .bot-select-panel       { animation-delay: 0.24s; }
#start-menu .vs-showcase            { animation-delay: 0.30s; }
#start-menu .menu-actions           { animation-delay: 0.36s; }
#start-menu .menu-controls-guide    { animation-delay: 0.42s; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hover spotlight: selector tabs and menu buttons light up under the cursor
   with a soft radial glow that tracks mouse position. The custom property
   --mx/--my is written by JS; the gradient itself is static so this stays
   GPU-cheap (transform/opacity only). */
.char-tab-btn,
.map-tab-btn,
.diff-tab-btn,
.cyber-btn {
  position: relative;
  overflow: hidden;
}
.char-tab-btn::after,
.map-tab-btn::after,
.diff-tab-btn::after,
.cyber-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0; /* above the button's own background, below its text content */
  opacity: 0;
  transition: opacity 0.2s ease;
  background: radial-gradient(
    220px circle at var(--mx, 50%) var(--my, 50%),
    rgba(0, 229, 255, 0.18),
    transparent 60%
  );
  pointer-events: none;
}
.char-tab-btn:hover::after,
.map-tab-btn:hover::after,
.diff-tab-btn:hover::after,
.cyber-btn:hover::after {
  opacity: 1;
}

/* Keep labels/thumbs above the spotlight overlay layer */
.char-tab-btn > *,
.map-tab-btn > *,
.diff-tab-btn > *,
.cyber-btn > * {
  position: relative;
  z-index: 1;
}

#start-menu .menu-card {
  z-index: 1;
}

/* Shimmering neon line across the start-card top edge */
.start-card::before {
  background: linear-gradient(90deg, transparent, #00e5ff, #ff2d95, #00e5ff, transparent);
  background-size: 300% 100%;
  animation: lineShimmer 4.5s linear infinite;
}

@keyframes lineShimmer {
  from { background-position: 0% 0; }
  to   { background-position: 300% 0; }
}

@keyframes popIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Badges */
.neon-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 6px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00e5ff;
  box-shadow: 0 0 8px #00e5ff;
  animation: blink 1.2s infinite;
}

.live-dot.warning {
  background: #ff5c1a;
  box-shadow: 0 0 8px #ff5c1a;
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}

.neon-badge.cyan {
  background: rgba(0, 229, 255, 0.15);
  color: #00e5ff;
  border: none;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.neon-badge.warning {
  background: rgba(255, 92, 26, 0.15);
  color: #ff5c1a;
  border: none;
  box-shadow: 0 0 10px rgba(255, 92, 26, 0.2);
}

/* Titles */
.menu-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #00e5ff 0%, #ffffff 50%, #ff2d95 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-top: 4px;
}

.menu-tagline {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #94a3b8;
  text-transform: uppercase;
}

/* =========================================
   FIGHTER SELECTOR PANEL (robot1.jpg in 3D)
   ========================================= */
.fighter-select-panel {
  width: 100%;
  background: rgba(12, 16, 32, 0.75);
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.select-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #00e5ff;
  text-align: left;
}

.fighter-tabs {
  display: block;
}

.char-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.char-page.hidden {
  display: none;
}

.char-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 2px;
}

.char-pager-btn {
  background: rgba(16, 24, 48, 0.85);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 8px;
  color: #00e5ff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  width: 30px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.char-pager-btn:hover {
  border-color: #00e5ff;
  background: rgba(0, 229, 255, 0.15);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

.char-pager-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
  border-color: rgba(0, 229, 255, 0.15);
}

.char-pager-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #7fdbff;
  min-width: 34px;
  text-align: center;
}

.char-tab-btn {
  background: rgba(16, 24, 48, 0.85);
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  color: #e2e8f0;
}

.char-tab-btn:hover {
  background: rgba(24, 36, 68, 0.95);
  border-color: rgba(0, 229, 255, 0.5);
  transform: translateY(-1px);
}

.char-tab-btn.active {
  background: rgba(0, 229, 255, 0.15);
  border-color: #00e5ff;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.3);
}

.tab-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: contain;
  background: rgba(10, 14, 28, 0.9);
  border: none;
}

.char-tab-btn.active .tab-thumb {
  border-color: #00e5ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.tab-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tab-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.char-tab-btn.active .tab-name {
  color: #00e5ff;
}

.tab-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #94a3b8;
}

.tab-status-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

.char-tab-btn.active .tab-status-badge {
  background: #00e5ff;
  color: #0a0a14;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
}

/* =========================================
   ARENA (MAP) SELECTOR
   ========================================= */
.map-select-panel {
  width: 100%;
  background: rgba(12, 16, 32, 0.75);
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.map-tab-btn {
  background: rgba(16, 24, 48, 0.85);
  border: none;
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  color: #e2e8f0;
}

.map-tab-btn:hover {
  background: rgba(24, 36, 68, 0.95);
  border-color: rgba(255, 45, 149, 0.5);
  transform: translateY(-1px);
}

.map-tab-btn.active {
  background: rgba(255, 45, 149, 0.14);
  border-color: #ff2d95;
  box-shadow: 0 0 14px rgba(255, 45, 149, 0.3);
}

.map-tab-btn.active .tab-name {
  color: #ff2d95;
}

.map-tab-btn.active .tab-status-badge {
  background: #ff2d95;
  color: #0a0a14;
  box-shadow: 0 0 6px rgba(255, 45, 149, 0.6);
}

.map-tab-btn.active .tab-thumb {
  border-color: #ff2d95;
  box-shadow: 0 0 8px rgba(255, 45, 149, 0.5);
}

.map-tab-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1px;
}

/* =========================================
   CPU DIFFICULTY SELECTOR
   ========================================= */
.diff-select-panel {
  width: 100%;
  background: rgba(12, 16, 32, 0.75);
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diff-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.diff-tab-btn {
  background: rgba(16, 24, 48, 0.85);
  border: none;
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  color: #e2e8f0;
}

.diff-tab-btn:hover {
  background: rgba(24, 36, 68, 0.95);
  border-color: rgba(255, 92, 26, 0.5);
  transform: translateY(-1px);
}

.diff-tab-btn.active {
  background: rgba(255, 92, 26, 0.14);
  border-color: #ff5c1a;
  box-shadow: 0 0 14px rgba(255, 92, 26, 0.3);
}

.diff-tab-btn.active .tab-name {
  color: #ff5c1a;
}

.diff-tab-btn.active .tab-status-badge {
  background: #ff5c1a;
  color: #0a0a14;
  box-shadow: 0 0 6px rgba(255, 92, 26, 0.6);
}

/* =========================================
   MENU FOOTER — $VIB testnet token info
   ========================================= */
.menu-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 229, 255, 0.18);
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
}
.footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.4px;
  flex-wrap: wrap;
}
.footer-label {
  color: #00e5ff;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.12);
  border: none;
}
.footer-addr,
.footer-link {
  color: #9fb0d8;
  text-decoration: none;
  word-break: break-all;
  transition: color 0.15s ease;
}
.footer-addr:hover,
.footer-link:hover {
  color: #00e5ff;
  text-decoration: underline;
}

/* =========================================
   VERSUS SHOWCASE
   ========================================= */
.start-card {
  max-width: 560px;
}

/* =========================================
   MATCH SIZE (BOT COUNT) SELECTOR
   ========================================= */
.bot-select-panel {
  width: 100%;
  background: rgba(12, 16, 32, 0.75);
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bot-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.bot-tab-btn {
  background: rgba(16, 24, 48, 0.85);
  border: none;
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  color: #e2e8f0;
}

.bot-tab-btn:hover {
  background: rgba(24, 36, 68, 0.95);
  border-color: rgba(0, 229, 255, 0.5);
  transform: translateY(-1px);
}

.bot-tab-btn.active {
  background: rgba(0, 229, 255, 0.14);
  border-color: #00e5ff;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.3);
}

.bot-tab-btn.active .tab-name {
  color: #00e5ff;
}

.bot-tab-btn.active .tab-status-badge {
  background: #00e5ff;
  color: #0a0a14;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
}

/* =========================================
   SURVIVORS STRIP (in-game HUD)
   One chip per fighter; eliminated fade + grey.
   ========================================= */
.survivors-strip {
  display: flex;
  flex-wrap: wrap; /* chips wrap to the next line instead of pushing HUD buttons off-screen */
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 100%;
  min-width: 0; /* allow shrinking inside the flex row */
  overflow: hidden;
}

.surv-chip {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  padding: 2px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid rgba(0, 229, 255, 0.55);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.25);
  transition: filter 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.surv-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 5px;
}

.surv-chip.you {
  border-color: #00e5ff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.55);
}

.surv-chip.you em {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-style: normal;
  font-size: 6px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #00e5ff;
  background: rgba(10, 10, 20, 0.92);
  padding: 0 3px;
  border-radius: 3px;
}

/* Eliminated: grey out + sink (stays visible so you can read the attrition) */
.surv-chip.out {
  filter: grayscale(1) brightness(0.5);
  opacity: 0.4;
  transform: scale(0.86);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.vs-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 6px 0;
  width: 100%;
}

.combatant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.avatar-frame {
  width: 74px;
  height: 74px;
  border-radius: 12px;
  padding: 3px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  position: relative;
}

.avatar-frame.cyan {
  border-color: #00e5ff;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.35);
}

.avatar-frame.magenta {
  border-color: #ff2d95;
  box-shadow: 0 0 16px rgba(255, 45, 149, 0.35);
}

.avatar-frame.large {
  width: 104px;
  height: 104px;
  border-radius: 16px;
  border-color: #00e5ff;
}

.showcase-avatar,
.win-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.combatant-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.combatant-name.cyan {
  color: #00e5ff;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.combatant-name.magenta {
  color: #ff2d95;
  text-shadow: 0 0 8px rgba(255, 45, 149, 0.4);
}

.combatant-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #64748b;
  letter-spacing: 0.5px;
}

/* Solo showcase: the selected fighter as a spinning 3D model, frameless */
.showcase-solo {
  flex: 1;
}

.showcase-solo #menu-p1-avatar-canvas {
  width: 150px;
  height: 150px;
  display: block;
  border: none;
  border-radius: 0;
  background: transparent;
}

/* =========================================
   ULTRA-FUTURISTIC CYBER BUTTONS
   ========================================= */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.cyber-btn {
  position: relative;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 14px 28px;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  /* Chamfered 45deg sci-fi corners */
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* Corner bracket accents */
.btn-corner {
  position: absolute;
  width: 6px;
  height: 6px;
  pointer-events: none;
}

.btn-corner.tl {
  top: 0;
  left: 0;
  border-top: 2px solid #00e5ff;
  border-left: 2px solid #00e5ff;
}

.btn-corner.tr {
  top: 0;
  right: 0;
  border-top: 2px solid #00e5ff;
  border-right: 2px solid #00e5ff;
}

.btn-corner.bl {
  bottom: 0;
  left: 0;
  border-bottom: 2px solid #00e5ff;
  border-left: 2px solid #00e5ff;
}

.btn-corner.br {
  bottom: 0;
  right: 0;
  border-bottom: 2px solid #00e5ff;
  border-right: 2px solid #00e5ff;
}

/* Primary Futuristic Button */
.cyber-btn-primary {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.28) 0%, rgba(14, 24, 48, 0.95) 100%),
              repeating-linear-gradient(0deg, rgba(0, 229, 255, 0.04) 0px, rgba(0, 229, 255, 0.04) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1px #00e5ff,
              0 6px 20px rgba(0, 0, 0, 0.6),
              0 0 18px rgba(0, 229, 255, 0.35),
              inset 0 0 14px rgba(0, 229, 255, 0.18);
  color: #ffffff;
}

.cyber-btn-primary:hover {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.45) 0%, rgba(18, 32, 64, 0.98) 100%),
              repeating-linear-gradient(0deg, rgba(0, 229, 255, 0.06) 0px, rgba(0, 229, 255, 0.06) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1.5px #ffffff,
              0 8px 30px rgba(0, 0, 0, 0.7),
              0 0 28px rgba(0, 229, 255, 0.65),
              inset 0 0 18px rgba(0, 229, 255, 0.35);
  transform: translateY(-2px);
  color: #ffffff;
}

/* Secondary Futuristic Button */
.cyber-btn-secondary {
  background: linear-gradient(135deg, rgba(20, 28, 54, 0.85) 0%, rgba(10, 14, 28, 0.95) 100%),
              repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2),
              0 4px 16px rgba(0, 0, 0, 0.5);
  color: #cbd5e1;
}

.cyber-btn-secondary:hover {
  background: linear-gradient(135deg, rgba(26, 36, 72, 0.95) 0%, rgba(16, 22, 44, 0.98) 100%);
  box-shadow: 0 0 0 1px #00e5ff,
              0 6px 20px rgba(0, 0, 0, 0.6),
              0 0 16px rgba(0, 229, 255, 0.3);
  color: #ffffff;
  transform: translateY(-2px);
}

.cyber-btn:active {
  transform: scale(0.96) translateY(0);
}

/* Solana wallet connect button (green accent) */
/* Profile · Staking Demo button (yellow accent, same cyber-btn style) */
.cyber-btn-profile {
  background: linear-gradient(135deg, rgba(80, 62, 8, 0.9) 0%, rgba(38, 30, 6, 0.95) 100%);
  box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.55), 0 6px 20px rgba(0, 0, 0, 0.6),
              0 0 18px rgba(255, 215, 0, 0.25);
  color: #ffe27a;
}

.cyber-btn-profile:hover {
  background: linear-gradient(135deg, rgba(112, 88, 12, 0.95) 0%, rgba(52, 42, 8, 0.98) 100%);
  box-shadow: 0 0 0 1.5px #ffd700, 0 8px 30px rgba(0, 0, 0, 0.7),
              0 0 30px rgba(255, 215, 0, 0.6);
  transform: translateY(-2px);
  color: #fff3b0;
}

.cyber-btn-wallet {
  background: linear-gradient(135deg, rgba(20, 40, 32, 0.9) 0%, rgba(10, 18, 14, 0.95) 100%);
  box-shadow: 0 0 0 1px rgba(20, 241, 149, 0.4), 0 6px 20px rgba(0, 0, 0, 0.6);
}

.cyber-btn-wallet:hover {
  box-shadow: 0 0 0 1px #14f195, 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 16px rgba(20, 241, 149, 0.35);
}

.cyber-btn-wallet:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Connected wallet chip in the HUD */
.wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #14f195;
  background: rgba(10, 20, 16, 0.85);
  border: 1px solid rgba(20, 241, 149, 0.5);
  border-radius: 8px;
  padding: 5px 10px;
  box-shadow: 0 0 10px rgba(20, 241, 149, 0.2);
  white-space: nowrap;
}

.wallet-chip.hidden {
  display: none;
}

/* Toast notifications */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(10, 14, 28, 0.92);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(0, 229, 255, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 500;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Pulsing glow — LIGHT: animate opacity of a duplicate shadow layer instead of
   re-computing box-shadow every frame (the old box-shadow keyframes forced a
   repaint each frame on macOS and could make the button feel "dead" to clicks).
   We keep the pulse but drive it with a transform-free opacity on ::before. */
.btn-pulse {
  position: relative;
}
.btn-pulse::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.65), 0 0 6px rgba(0, 229, 255, 0.6);
  opacity: 0.5;
  animation: pulseGlow 2.5s ease-in-out infinite;
  will-change: opacity;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 0.8; }
}

.btn-icon {
  font-size: 13px;
}

.key-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #00e5ff;
}

/* =========================================
   CONTROLS GUIDE
   ========================================= */
.menu-controls-guide {
  width: 100%;
  background: rgba(10, 14, 28, 0.7);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 4px;
}

.guide-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-align: left;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 12px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 7px;
  text-align: left;
}

.guide-desc {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
}

/* =========================================
   WIN & PAUSE MODAL SPECIFICS
   ========================================= */
.pause-card {
  max-width: 440px;
}

.win-card {
  max-width: 460px;
}

.win-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.win-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  margin-top: -6px;
}

.score-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: #00e5ff;
  letter-spacing: 1px;
}

/* =========================================
   IN-GAME HUD (Top bar, status, controls)
   ========================================= */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  z-index: 50;
  transition: opacity 0.25s ease;
}

.ui-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.top-bar {
  display: flex;
  flex-wrap: wrap; /* let sections wrap on narrow screens instead of overflowing */
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

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

.title {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #00e5ff 0%, #ffffff 50%, #ff2d95 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.15);
  color: #00e5ff;
  border: none;
  -webkit-text-fill-color: #00e5ff;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  align-items: center;
  background: rgba(10, 14, 28, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 229, 255, 0.28);
  border-radius: 14px;
  padding: 8px 20px;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 229, 255, 0.12);
}

.team {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-avatar {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: contain;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid;
}

.p1-team .team-avatar {
  border-color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.p2-team .team-avatar {
  border-color: #ff2d95;
  box-shadow: 0 0 10px rgba(255, 45, 149, 0.5);
}

.team-info {
  display: flex;
  flex-direction: column;
}

.team-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.p1-team .team-name {
  color: #00e5ff;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.p2-team .team-name {
  color: #ff2d95;
  text-shadow: 0 0 8px rgba(255, 45, 149, 0.4);
}

.team-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-divider {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 900;
  color: #475569;
}

/* Quick Action HUD buttons */
.quick-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(10, 14, 28, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.icon-btn:hover {
  background: rgba(22, 30, 58, 0.95);
  border-color: #00e5ff;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.96) translateY(0);
}

/* =========================================
   TOUCH CONTROLS (mobile only)
   ========================================= */
.touch-ui {
  display: none;
}

.touch-device .touch-ui {
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

/* Left joystick */
.touch-joystick {
  position: absolute;
  left: calc(20px + env(safe-area-inset-left));
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-joystick .joy-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 24, 48, 0.55) 0%, rgba(10, 14, 28, 0.35) 70%);
  border: 2px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.15), inset 0 0 24px rgba(0, 229, 255, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.touch-joystick .joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(0, 229, 255, 0.85) 0%, rgba(0, 120, 160, 0.8) 100%);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.6);
  transition: box-shadow 0.15s ease;
}

.touch-joystick.active .joy-knob {
  box-shadow: 0 0 26px rgba(0, 229, 255, 0.95);
}

/* Right action cluster */
.touch-actions {
  position: absolute;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

.touch-utility {
  display: flex;
  gap: 10px;
}

.touch-grid {
  display: grid;
  grid-template-columns: repeat(2, 76px);
  grid-auto-rows: 76px;
  gap: 12px;
}

.touch-btn {
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: 'Orbitron', sans-serif;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(14, 20, 40, 0.72);
  color: #e2e8f0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
}

.touch-btn .touch-main {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.touch-btn .touch-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
}

.touch-btn .touch-icon {
  font-size: 15px;
  line-height: 1;
}

.touch-btn.pressed {
  transform: scale(0.9);
  background: rgba(30, 42, 80, 0.95);
}

.touch-btn.cyan {
  border-color: rgba(0, 229, 255, 0.7);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.25), inset 0 0 12px rgba(0, 229, 255, 0.12);
}

.touch-btn.cyan.pressed {
  background: rgba(0, 229, 255, 0.25);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.6);
}

.touch-btn.magenta {
  border-color: rgba(255, 45, 149, 0.7);
  box-shadow: 0 0 14px rgba(255, 45, 149, 0.25), inset 0 0 12px rgba(255, 45, 149, 0.12);
}

.touch-btn.magenta.pressed {
  background: rgba(255, 45, 149, 0.25);
  box-shadow: 0 0 24px rgba(255, 45, 149, 0.6);
}

.touch-btn.warning {
  border-color: rgba(255, 92, 26, 0.7);
  box-shadow: 0 0 14px rgba(255, 92, 26, 0.25), inset 0 0 12px rgba(255, 92, 26, 0.12);
}

.touch-btn.warning.pressed {
  background: rgba(255, 92, 26, 0.25);
  box-shadow: 0 0 24px rgba(255, 92, 26, 0.6);
}

.touch-btn.violet {
  border-color: rgba(167, 139, 250, 0.7);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.25), inset 0 0 12px rgba(167, 139, 250, 0.12);
}

.touch-btn.violet.pressed {
  background: rgba(167, 139, 250, 0.25);
  box-shadow: 0 0 24px rgba(167, 139, 250, 0.6);
}

/* Wide DASH button spanning the whole grid row (thumb-friendly target) */
.touch-btn.touch-btn-dash {
  grid-column: 1 / -1;
  border-radius: 22px;
}

.touch-btn-small {
  width: 46px;
  height: 46px;
  font-size: 8px;
}

.touch-btn-small .touch-label {
  font-size: 7px;
}

/* On touch devices the keyboard hint bar is redundant (buttons carry labels) */
.touch-device .bottom-bar {
  display: none;
}

/* Portrait phones: tighter layout so the clusters never overlap */
@media (max-width: 560px), (max-height: 480px) {
  .touch-joystick {
    width: 108px;
    height: 108px;
    left: calc(14px + env(safe-area-inset-left));
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .touch-joystick .joy-knob {
    width: 48px;
    height: 48px;
  }
  .touch-grid {
    grid-template-columns: repeat(2, 62px);
    grid-auto-rows: 62px;
    gap: 10px;
  }
  .touch-btn .touch-main {
    font-size: 11px;
  }
  .touch-actions {
    right: calc(14px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    gap: 8px;
  }
}

/* Landscape phones: pull clusters toward the corners away from the HUD */
@media (orientation: landscape) and (max-height: 500px) {
  .touch-joystick {
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: calc(12px + env(safe-area-inset-left));
    transform: scale(0.85);
    transform-origin: bottom left;
  }
  .touch-actions {
    bottom: calc(10px + env(safe-area-inset-bottom));
    right: calc(12px + env(safe-area-inset-right));
    transform: scale(0.85);
    transform-origin: bottom right;
  }
}

/* Island Shrink & Weapon Status Panel */
.island-status {
  position: absolute;
  top: 90px;
  left: 24px;
  pointer-events: auto;
  background: rgba(10, 14, 28, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 229, 255, 0.22);
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(0, 229, 255, 0.1);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 700;
}

.status-value {
  color: #f8fafc;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff5c1a, #ff2200);
  width: 100%;
  transition: width 0.05s linear;
}

/* Weapon Cooldown Blocks */
.ability-block {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ability-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #cbd5e1;
}

.key-badge {
  display: inline-block;
  background: rgba(20, 28, 54, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #00e5ff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.key-badge.mini {
  padding: 1px 5px;
  font-size: 9px;
  border-radius: 3px;
}

.status-value.ready {
  color: #00e5ff;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
  font-weight: 800;
}

.status-value.charging {
  color: #ff5c1a;
}

.status-value.locked {
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.ability-block.flash {
  animation: ability-flash 0.7s ease-out;
}

.item-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-slot-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.6));
}

.item-slot-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.5px;
}

.item-slot-icon.spent {
  filter: grayscale(1) brightness(0.55);
}

.item-fuel-bar {
  display: flex;
  gap: 3px;
  margin-top: 5px;
  height: 6px;
}

.item-fuel-bar[hidden] {
  display: none;
}

.item-fuel-seg {
  flex: 1;
  height: 6px;
  border-radius: 2px;
  background: #2a3148;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform-origin: center bottom;
}

.item-fuel-seg.lit {
  background: #00e5ff;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.9);
}

.item-fuel-seg.pop {
  animation: fuel-pop 0.18s ease-out;
}

@keyframes fuel-pop {
  0% {
    transform: scaleY(2.4);
    filter: brightness(2.4);
    background: #fff6d0;
  }
  100% {
    transform: scaleY(1);
    filter: brightness(1);
  }
}

@keyframes ability-flash {
  0% {
    background: rgba(0, 229, 255, 0.28);
    border-radius: 6px;
  }
  100% {
    background: transparent;
  }
}

.push-fill {
  background: linear-gradient(90deg, #0284c7, #00e5ff);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

.push-fill.ready {
  background: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.8);
}

.spear-fill {
  background: linear-gradient(90deg, #059669, #10b981);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.spear-fill.ready {
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
}

.grenade-fill {
  background: linear-gradient(90deg, #ea580c, #ff5c1a);
  box-shadow: 0 0 6px rgba(255, 92, 26, 0.4);
}

.grenade-fill.ready {
  background: #ff5c1a;
  box-shadow: 0 0 10px rgba(255, 92, 26, 0.8);
}

.dash-fill {
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  box-shadow: 0 0 6px rgba(167, 139, 250, 0.4);
}

.dash-fill.ready {
  background: #a78bfa;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.8);
}

/* Bottom Hint & Controls */
.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: auto;
}

.controls-hint {
  background: rgba(10, 14, 28, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.hint-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.hint-sep {
  color: #475569;
  font-size: 12px;
}

/* Mobile & Small Screen Responsiveness */
@media (max-width: 860px) {
  .ui-overlay {
    padding: 12px;
  }
  .title {
    font-size: 18px;
  }
  .island-status {
    top: 76px;
    left: 12px;
    width: 175px;
    padding: 10px 12px;
  }
  .controls-hint {
    padding: 8px 12px;
    font-size: 10px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .menu-card {
    padding: 22px 20px;
  }
  .menu-title {
    font-size: 28px;
  }
  .guide-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== ONLINE 1V1 PANEL (PeerJS / WebRTC) ===== */
.cyber-btn-online {
  background: linear-gradient(135deg, rgba(180, 107, 255, 0.28) 0%, rgba(24, 16, 48, 0.95) 100%),
              repeating-linear-gradient(0deg, rgba(180, 107, 255, 0.04) 0px, rgba(180, 107, 255, 0.04) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1px #b46bff,
              0 6px 20px rgba(0, 0, 0, 0.6),
              0 0 18px rgba(180, 107, 255, 0.35),
              inset 0 0 14px rgba(180, 107, 255, 0.18);
}
.cyber-btn-online:hover {
  background: linear-gradient(135deg, rgba(180, 107, 255, 0.45) 0%, rgba(30, 20, 60, 0.98) 100%),
              repeating-linear-gradient(0deg, rgba(180, 107, 255, 0.06) 0px, rgba(180, 107, 255, 0.06) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1.5px #ffffff,
              0 8px 30px rgba(0, 0, 0, 0.7),
              0 0 28px rgba(180, 107, 255, 0.65),
              inset 0 0 18px rgba(180, 107, 255, 0.35);
  transform: translateY(-2px);
}

.online-card {
  max-width: 440px;
  gap: 14px;
}

.online-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.room-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #94a3b8;
  text-transform: uppercase;
}
.room-code-value {
  font-size: 20px;
  letter-spacing: 6px;
  color: #00e5ff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
}

.online-divider {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: #475569;
}

.online-join-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

.online-input {
  flex: 1;
  min-width: 0;
  background: rgba(6, 10, 22, 0.9);
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  color: #00e5ff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  outline: none;
}
.online-input::placeholder {
  color: #334155;
  letter-spacing: 2px;
  font-size: 11px;
}
.online-input:focus {
  border-color: #00e5ff;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
}

.online-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #00e5ff;
  text-transform: uppercase;
  min-height: 16px;
  text-align: center;
}
.online-status.error {
  color: #ff5c1a;
}
.online-status.ok {
  color: #14f195;
}

/* ===== 3D MENU TITLE + FALLING "OO" LOGO ===== */
/* Every word paints its own iridescent gradient that "flows" through the
   letters, with a stacked dark extrusion underneath for a block-letter 3D
   look. The "OO" additionally trembles like a warning tile, tumbles away
   like a dropped floor tile, then rises back — looping. */
.title-3d {
  position: relative;
  background: none; /* words paint their own gradients */
  transform: perspective(650px) rotateX(15deg) rotateY(-8deg);
  transform-origin: 50% 100%;
  animation: titleFloat 5s ease-in-out infinite;
}

@keyframes titleFloat {
  0%, 100% {
    transform: perspective(650px) rotateX(15deg) rotateY(-8deg) translateY(0);
  }
  50% {
    transform: perspective(650px) rotateX(15deg) rotateY(-3deg) translateY(-6px);
  }
}

.t3d-word,
.t3d-oo {
  background-size: 220% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  /* Extruded depth: dark steps + a neon cyan under-edge + contact shadow */
  filter: drop-shadow(0 1px 0 rgba(3, 16, 24, 0.95))
          drop-shadow(0 2px 0 rgba(3, 16, 24, 0.9))
          drop-shadow(0 3px 0 rgba(2, 10, 16, 0.85))
          drop-shadow(0 4px 0 rgba(0, 229, 255, 0.55))
          drop-shadow(0 6px 12px rgba(0, 0, 0, 0.65));
  animation: wordFlow 3.6s ease-in-out infinite alternate;
}

.t3d-a { background-image: linear-gradient(100deg, #00e5ff 0%, #66f3ff 30%, #ffffff 55%, #ffa6d0 82%, #ff4ba0 100%); }
.t3d-b { background-image: linear-gradient(100deg, #ffc9e2 0%, #ffffff 40%, #ff9ecb 78%, #ff4ba0 100%); }
.t3d-c { background-image: linear-gradient(100deg, #ff9ecb 0%, #ff5fb0 45%, #ff2d95 100%); }

@keyframes wordFlow {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

.t3d-oo {
  display: inline-block;
  transform-origin: 50% 80%;
  background-image: linear-gradient(100deg, #ffb3d4 0%, #ff6fb8 55%, #ff2d95 100%);
  /* Tile-fall transform + the same gradient flow on top */
  animation:
    ooTileFall 5.6s ease-in-out infinite,
    wordFlow 3.6s ease-in-out infinite alternate;
  will-change: transform, opacity;
}

/* Second O lags behind the first, so the letters drop one after another */
.t3d-o2 {
  animation-delay: 0.7s, 0.35s;
}

@keyframes ooTileFall {
  0%   { transform: perspective(400px) translateY(0) rotateX(0); opacity: 1; }
  /* tremble like a tile about to fall */
  30%  { transform: perspective(400px) translate(0, 0) rotate(0); opacity: 1; }
  32%  { transform: perspective(400px) translate(-1.5px, 1px) rotate(-2.5deg); }
  34%  { transform: perspective(400px) translate(1.5px, -1px) rotate(2.5deg); }
  36%  { transform: perspective(400px) translate(-1.5px, 1px) rotate(-2.5deg); }
  38%  { transform: perspective(400px) translate(1.5px, -1px) rotate(2.5deg); }
  40%  { transform: perspective(400px) translate(0, 0) rotate(0); }
  /* tumble away into the void like a dropped floor tile */
  47%  { transform: perspective(400px) translateY(6px) rotateX(40deg); opacity: 1; }
  54%  { transform: perspective(400px) translateY(64px) rotateX(150deg) rotate(18deg); opacity: 0; }
  62%  { transform: perspective(400px) translateY(64px) rotateX(150deg) rotate(18deg); opacity: 0; }
  /* rise back into place with a settle bounce */
  67%  { transform: perspective(400px) translateY(-26px) rotateX(-40deg); opacity: 0; }
  74%  { transform: perspective(400px) translateY(0) rotateX(0); opacity: 1; }
  77%  { transform: perspective(400px) translateY(-4px); opacity: 1; }
  80%  { transform: perspective(400px) translateY(0); opacity: 1; }
  100% { transform: perspective(400px) translateY(0) rotateX(0); opacity: 1; }
}

/* =========================================
   START MENU — wide desktop layout
   (left: identity + actions + guide,
    right: fighter/map/difficulty selectors)
   ========================================= */
/* Two-column start menu. The threshold was 1024px — but between 768–1023px the
   single-column layout stacked all panels into ~1275px of content, pushing the
   INITIALIZE BATTLE / ONLINE buttons below the fold (they sat at y≈900 while
   the window was 720 tall → looked "unclickable"). Switch to two columns from
   768px so the whole card fits one screen and every button stays visible. */
@media (min-width: 768px) {
  /* FULLSCREEN menu: the card fills the viewport instead of a centred box.
     Removes the max-width card look — menu spreads across the whole screen. */
  #start-menu {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  #start-menu .start-card {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow-y: auto;
    padding: clamp(16px, 2.5vh, 30px) clamp(20px, 3vw, 56px);
    grid-template-columns: minmax(300px, 1.15fr) minmax(330px, 1fr);
    column-gap: clamp(24px, 3vw, 56px);
    row-gap: clamp(12px, 1.8vh, 22px);
  }
  .start-card {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(300px, 1.15fr) minmax(330px, 1fr);
    grid-template-areas:
      "header   fighters"
      "showcase fighters"
      "actions  maps"
      "guide    difbots";
    column-gap: 22px;
    row-gap: 13px;
    align-items: start;
    padding: 22px 26px;
  }
  .start-card .menu-header { grid-area: header; align-self: center; }

  /* VS showcase: the two fighter boxes 30% bigger (74 -> 96). */
  .start-card .avatar-frame {
    width: 96px;
    height: 96px;
    border-radius: 14px;
  }
  .start-card .showcase-avatar {
    width: 150px;
    height: 150px;
  }
  .start-card .combatant-name { font-size: 15px; }

  /* Fighters panel: kill the dead space at the bottom by letting the tabs
     (grid) stretch to fill the panel instead of hugging their content. */
  .start-card .fighter-select-panel { display: flex; flex-direction: column; }
  .start-card .fighter-tabs { flex: 1 1 auto; display: flex; flex-direction: column; }
  .start-card .char-page { flex: 1 1 auto; align-content: stretch; grid-auto-rows: 1fr; }
  .start-card .fighter-select-panel,
  .start-card .map-select-panel {
    align-self: stretch; /* fill the full row height — no dead space below */
  }
  .start-card .fighter-select-panel { grid-area: fighters; margin-top: 0; }
  .start-card .map-select-panel { grid-area: maps; margin-top: 0; }
  /* CPU DIFFICULTY + MATCH SIZE live in ONE flex column, stacked directly
     under each other in the right column — MATCH SIZE can never fall below
     the fold because the group shares difficulty's grid row. */
  .start-card .difficulty-group {
    grid-area: difbots;
    display: flex;
    flex-direction: column;
    gap: 11px;
    align-self: start; /* don't stretch — keeps the group tight so MATCH SIZE clears the fold */
    margin-top: 0;
    min-width: 0;
  }
  .start-card .difficulty-group .diff-select-panel,
  .start-card .difficulty-group .bot-select-panel { margin-top: 0; }
  .start-card .vs-showcase { grid-area: showcase; margin: 0; }
  .start-card .menu-actions { grid-area: actions; }
  .start-card .menu-controls-guide { grid-area: guide; margin-top: 0; }

  /* Balance the right column: map/difficulty tabs size to CONTENT (prevents the
     panels inflating and pushing MATCH SIZE below the fold on 720px windows).
     NOTE: .fighter-tabs is NOT here on purpose — its panel is tall and would
     show dead space, so the fighter tabs stretch to fill it instead (below). */
  .start-card .map-tabs,
  .start-card .diff-tabs {
    flex: 0 0 auto;
    grid-auto-rows: auto;
    align-content: start;
  }
  .start-card .fighter-tabs {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }
  .start-card .char-page {
    flex: 1 1 auto;
    align-content: stretch;
    grid-auto-rows: 1fr;
  }
  .start-card .map-thumb {
    width: 46px;
    height: 46px;
  }

  /* Short windows (≤ 780px tall): the right column's content
     (fighters + maps + difficulty + match) exceeds the viewport and MATCH SIZE
     falls below the fold. Fit it by laying the 6 fighter cards / 4 map cards in
     THREE columns (2 rows instead of 3) and tightening gaps — content only,
     component sizes stay recognisable. */
  @media (max-height: 780px) {
    .start-card .char-page,
    .start-card .map-tabs {
      grid-template-columns: repeat(3, 1fr);
      gap: 7px;
    }
    .start-card .difficulty-group { gap: 9px; }
    .start-card .char-tab-btn,
    .start-card .map-tab-btn {
      padding: 6px 7px;
      gap: 7px;
    }
    .start-card .char-tab-btn .tab-thumb,
    .start-card .map-tab-btn .map-thumb {
      width: 34px;
      height: 34px;
    }
    .start-card .tab-name { font-size: 10px; }
    .start-card .tab-sub { font-size: 8px; }
  }

  .start-card .menu-title {
    font-size: clamp(30px, 4.2vw, 54px);
    letter-spacing: clamp(2px, 0.4vw, 4px);
  }

  /* Actions as a 2x2 grid: INITIALIZE spans the full row */
  .start-card .menu-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
  }
  .start-card .menu-actions .cyber-btn-primary { grid-column: 1 / -1; }

  /* =================== VARIANT D (borderless refresh) ===================
     Applied only to the desktop two-column layout. Removes hard borders in
     favour of soft glow / subtle fills; selector rows act like a list. */
  /* Card: drop the cyan border, keep depth with a glow-shadow instead. */
  #start-menu .menu-card.start-card,
  .start-card.start-card,
  .start-card {
    border: none !important;
    border-top: none !important;
    box-shadow: none;
    background: transparent;
  }
  /* Panels stay dark glass so the labels read; the planet shows between them. */
  .start-card .fighter-select-panel,
  .start-card .map-select-panel,
  .start-card .difficulty-group .diff-select-panel,
  .start-card .difficulty-group .bot-select-panel,
  .start-card .menu-controls-guide {
    border: none;
    background: rgba(8, 12, 24, 0.72);
  }
  /* Selector rows read like a list: active = cyan left rail + fill. */
  .start-card .char-tab-btn,
  .start-card .map-tab-btn,
  .start-card .diff-tab-btn,
  .start-card .bot-tab-btn {
    border-radius: 0;
    border: none;
    border-left: 3px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.16s ease, border-color 0.16s ease;
  }
  .start-card .char-tab-btn:hover,
  .start-card .map-tab-btn:hover,
  .start-card .diff-tab-btn:hover,
  .start-card .bot-tab-btn:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .start-card .char-tab-btn.active {
    border-left-color: #00e5ff; /* SELECT PLAYER — cyan (matches its accent) */
    background: rgba(0, 229, 255, 0.12);
    box-shadow: none;
  }
  .start-card .map-tab-btn.active {
    border-left-color: #ff2d95; /* SELECT ARENA — magenta */
    background: rgba(255, 45, 149, 0.12);
    box-shadow: none;
  }
  .start-card .diff-tab-btn.active {
    border-left-color: #ff5c1a; /* CPU DIFFICULTY — orange */
    background: rgba(255, 92, 26, 0.12);
    box-shadow: none;
  }
  .start-card .bot-tab-btn.active {
    border-left-color: #ffd700; /* MATCH SIZE — yellow */
    background: rgba(255, 215, 0, 0.12);
    box-shadow: none;
  }
  /* NOTE: do NOT clip-path .cyber-btn — it breaks click hit-testing on macOS. */
  /* Footer sits under the guide within its grid cell. */
  .start-card .menu-footer { grid-area: guide; }
}

@media (prefers-reduced-motion: reduce) {
  .title-3d,
  .t3d-oo,
  .t3d-word,
  .menu-aurora,
  .menu-scanlines,
  .start-card::before {
    animation: none;
  }
  /* Panels should appear immediately, without the entrance slide. */
  #start-menu .menu-header,
  #start-menu .fighter-select-panel,
  #start-menu .map-select-panel,
  #start-menu .diff-select-panel,
  #start-menu .bot-select-panel,
  #start-menu .vs-showcase,
  #start-menu .menu-actions,
  #start-menu .menu-controls-guide {
    animation: none;
  }
}

/* ===== PHONE LAYOUT FIXES (menus + HUD) ===== */
/* On touch devices the HUD pause/restart/sound live in the touch layer and
   the pause menu, so the desktop quick-action row is hidden to keep the
   top bar on one line. */
.touch-device .quick-actions {
  display: none;
}

/* Score moves to the LEFT side; the cooldown panel tucks into the very
   top-right corner so the arena stays as visible as possible. */
.touch-device .top-bar {
  justify-content: flex-start;
}
.touch-device .scoreboard {
  margin-left: 0;
  margin-right: 0;
}

/* Ability/cooldown panel (PUSH / SPEAR / GRENADE): 20% smaller and docked
   to the RIGHT edge instead of the left on phones. */
.touch-device .island-status {
  left: auto;
  right: 12px;
  top: 8px;
  width: 140px; /* 175px * 0.8 */
  padding: 8px 10px;
  border-radius: 12px;
}
.touch-device .island-status .status-row {
  font-size: 9.5px;
}
.touch-device .island-status .ability-label {
  font-size: 8px;
}
.touch-device .island-status .key-badge.mini {
  font-size: 7.5px;
  padding: 1px 4px;
}
.touch-device .island-status .progress-track {
  height: 3px;
}

/* Landscape phones have little height: squeeze the docked panel further so
   it never collides with the touch action buttons (which gained a DASH row). */
@media (max-height: 500px) {
  .touch-device .island-status {
    transform: scale(0.6);
    transform-origin: top right;
  }
}

@media (max-width: 560px) {
  .menu-card {
    padding: 16px 14px;
  }
  .menu-title {
    font-size: 24px;
    letter-spacing: 1.5px;
  }
  .title-badge {
    display: none;
  }

  /* Selector tab rows: shrink to fit instead of clipping */
  .char-page,
  .map-tabs,
  .diff-tabs {
    gap: 6px;
  }
  .char-tab-btn,
  .map-tab-btn,
  .diff-tab-btn {
    padding: 6px;
    gap: 5px;
    min-width: 0;
  }
  .tab-thumb {
    width: 28px;
    height: 28px;
  }
  .tab-info,
  .map-tab-info {
    min-width: 0;
    overflow: hidden;
  }
  .tab-name {
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tab-sub {
    font-size: 7.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tab-status-badge {
    display: none; /* the neon border already marks the active tab */
  }
  .diff-tab-btn {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  /* HUD top bar: one compact row — brand left, scoreboard slightly left
     of the edge so it clears the cooldown panel docked below-right */
  .top-bar {
    flex-wrap: nowrap;
    align-items: center;
  }
  .title {
    font-size: 16px;
  }
  .scoreboard {
    margin-left: auto;
    margin-right: 10px;
    padding: 5px 8px;
    gap: 8px;
  }
  .team {
    gap: 5px;
  }
  .team-avatar {
    width: 24px;
    height: 24px;
  }
  .team-name {
    font-size: 9px;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .team-score {
    font-size: 16px;
  }
  .score-divider {
    font-size: 11px;
  }

  /* Cooldown panel: tuck it higher, right under the one-row top bar */
  .touch-device .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .touch-device .team-name {
    max-width: 40px;
  }
}
/* =========================================
   PROFILE / STAKING DEMO OVERLAY
   ========================================= */
.profile-overlay {
  pointer-events: auto;
  position: fixed;
  inset: 0;
  height: auto;
  z-index: 110; /* above the start/win menu screens (z 100) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  background: #000000;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(14px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
}

/* Closed profile must leave the layout. Opacity-only hiding kept a full-screen
   layer (and a zero-size canvas if we also used display:none too late). */
.profile-overlay.hidden {
  display: none;
}

.profile-overlay::before {
  content: none;
}

.profile-card {
  width: min(1200px, 100%);
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  color: #e2e8f0;
}

.profile-panel {
  background: #000000;
  border: 1px solid rgba(0, 229, 255, 0.32);
  border-radius: 16px;
  box-shadow: none;
  padding: 16px 18px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-heading {
  min-width: 0;
}

.profile-header h2 {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(16px, 2.4vw, 22px);
  letter-spacing: 1.6px;
  color: #00e5ff;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.6);
}

.profile-kicker {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
  color: #7a8299;
}

.profile-demo-tag {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.55);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.profile-close {
  margin-left: auto;
  flex: 0 0 auto;
  background: rgba(255, 45, 149, 0.12);
  color: #ff2d95;
  border: 1px solid rgba(255, 45, 149, 0.45);
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 16px;
  cursor: pointer;
}

.profile-close:focus-visible,
.profile-actions .cyber-btn:focus-visible {
  outline: 2px solid #00e5ff;
  outline-offset: 2px;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

/* --- LEFT column --- */
.profile-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.profile-avatar-frame {
  width: 132px;
  height: 132px;
  margin: 0 auto;
  border-radius: 16px;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profile-stats .stat {
  background: #000000;
  border: 1px solid rgba(0, 229, 255, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
}

.profile-stats label {
  display: block;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: #7a8299;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  line-height: 1.15;
  color: #00e5ff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
  word-break: break-word;
}

.stat-hold-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-tier {
  flex: 0 0 auto;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.45);
  border-radius: 999px;
  padding: 2px 7px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.35);
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.profile-actions .cyber-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 12px;
  letter-spacing: 0.6px;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  text-align: center;
}

.profile-actions .cyber-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Stake amount — same neon glass language as the profile stats. */
.stake-slider {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 8px;
  background: #000000;
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 12px;
  box-shadow: none;
}

.stake-slider-head,
.stake-slider-scale {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.stake-slider-kicker {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #7a8299;
}

.stake-slider-value {
  font-size: 16px;
  color: #00e5ff;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.stake-slider-scale {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #586075;
}

.stake-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.stake-slider input[type="range"]:focus-visible {
  outline: 2px solid #00e5ff;
  outline-offset: 2px;
}

.stake-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #00e5ff var(--stake-pct, 0%), rgba(122, 130, 153, 0.35) var(--stake-pct, 0%));
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}

.stake-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 4px;
  border: 2px solid #ffffff;
  background: #00e5ff;
  box-shadow: 0 0 12px #00e5ff, 0 0 0 1px rgba(0, 229, 255, 0.4);
  cursor: pointer;
}

.stake-slider input[type="range"]::-moz-range-track {
  height: 6px;
  border: none;
  border-radius: 999px;
  background: rgba(122, 130, 153, 0.35);
}

.stake-slider input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: #00e5ff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}

.stake-slider input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid #ffffff;
  background: #00e5ff;
  box-shadow: 0 0 12px #00e5ff;
  cursor: pointer;
}

.stake-slider input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* --- RIGHT: embedded 3D vault viewport --- */
.profile-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 12px;
}

.profile-coins-title,
.profile-cards-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
  align-self: flex-start;
}

.profile-vault {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

/* Vault control bar is injected under the canvas by stakingVault.js. */
.staking-vault-hud {
  width: 100%;
  max-width: min(100%, 720px);
  box-sizing: border-box;
}

.staking-vault-hud button,
.staking-vault-hud select {
  min-height: 44px;
  max-width: 100%;
  white-space: normal;
  font-family: inherit;
}

.staking-vault-hud input[type="range"] {
  min-height: 44px;
  max-width: 100%;
}

/* Square viewport so the plasma sphere fills the view instead of sitting
   in a wide 16:9 letterbox. No border: the animation is the black field.
   Height comes only from aspect-ratio — a min-height that fights the ratio
   stretches the page. The vault reads this client box. */
.staking-canvas {
  width: 100%;
  max-width: min(100%, 720px);
  min-width: 0;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  border: none;
  border-radius: 0;
  background: #000000;
  box-shadow: none;
}

/* Tall desktop: leave room under the square for the open-safe bar. */
@media (min-width: 900px) and (min-height: 700px) {
  .staking-canvas {
    width: min(100%, 640px, calc(100dvh - 340px));
    min-height: 0;
    max-height: none;
  }
}

.profile-coins-sub {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #7a8299;
}

/* --- BOTTOM: stock cards --- */
.profile-bottom {
  padding-bottom: 18px;
}

.profile-cards-title {
  color: #7a8299;
  text-shadow: none;
  margin-bottom: 10px;
}

.profile-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.profile-empty {
  grid-column: 1 / -1;
  color: #586075;
  font-size: 13px;
  text-align: center;
  padding: 18px;
  border: 1px dashed rgba(122, 130, 153, 0.35);
  border-radius: 12px;
}

.stock-card {
  --stock-color: #00e5ff;
  background: #000000;
  border: 1px solid var(--stock-color);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 0 14px color-mix(in srgb, var(--stock-color) 35%, transparent);
}

.stock-tier {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--stock-color);
  margin-bottom: 4px;
}

.stock-ticker {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px color-mix(in srgb, var(--stock-color) 60%, transparent);
}

.stock-name {
  font-size: 11px;
  color: #7a8299;
  margin: 2px 0 8px;
  min-height: 26px;
}

.stock-value {
  font-size: 14px;
  color: var(--stock-color);
}

.stock-meta {
  font-size: 10px;
  color: #586075;
  margin-top: 4px;
}

/* --- MOBILE + short landscape: avatar+stats → vault → cards. --- */
@media (max-width: 800px), (max-height: 520px) {
  .profile-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .profile-left {
    flex-direction: column;
    align-items: stretch;
  }
  .profile-avatar-frame {
    width: 108px;
    height: 108px;
  }
  .profile-actions {
    margin-top: 0;
  }
  .profile-actions .cyber-btn,
  .profile-close {
    min-height: 48px;
    min-width: 44px;
  }
  .staking-canvas {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    max-height: none;
  }
  .profile-header {
    flex-wrap: wrap;
  }
  .profile-demo-tag {
    order: 3;
  }
}

/* Short landscape: a full-bleed square is taller than the screen. Keep it
   large, but cap it so the reactor and the cards are both reachable. */
@media (max-height: 520px) {
  .staking-canvas {
    width: min(100%, 460px);
    max-width: 100%;
    min-height: 0;
    max-height: none;
  }
}

/* =========================================================================
   VIBER RACE — menu button, setup panel, race HUD, countdown
   ========================================================================= */
.cyber-btn-race {
  background: linear-gradient(135deg, rgba(255, 45, 149, 0.3) 0%, rgba(40, 10, 34, 0.95) 100%),
              repeating-linear-gradient(0deg, rgba(255, 45, 149, 0.05) 0px, rgba(255, 45, 149, 0.05) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1px #ff2d95,
              0 6px 20px rgba(0, 0, 0, 0.6),
              0 0 18px rgba(255, 45, 149, 0.35),
              inset 0 0 14px rgba(255, 45, 149, 0.18);
  color: #ffffff;
}
.cyber-btn-race:hover {
  background: linear-gradient(135deg, rgba(255, 45, 149, 0.48) 0%, rgba(56, 14, 46, 0.98) 100%),
              repeating-linear-gradient(0deg, rgba(255, 45, 149, 0.07) 0px, rgba(255, 45, 149, 0.07) 2px, transparent 2px, transparent 4px);
  box-shadow: 0 0 0 1.5px #ffffff,
              0 8px 30px rgba(0, 0, 0, 0.7),
              0 0 28px rgba(255, 45, 149, 0.65),
              inset 0 0 18px rgba(255, 45, 149, 0.35);
  transform: translateY(-2px);
}
.cyber-btn-race .btn-corner { border-color: #ff2d95; }
.cyber-btn-race.btn-pulse::before {
  box-shadow: 0 0 22px rgba(255, 45, 149, 0.65), 0 0 6px rgba(255, 45, 149, 0.6);
}

/* Desktop 2-col action grid: INITIALIZE BATTLE + VIBER RACE share the top row */
@media (min-width: 861px) {
  .start-card .menu-actions #btn-menu-play.cyber-btn-primary { grid-column: 1; }
  .start-card .menu-actions #btn-menu-race { grid-column: 2; }
}

.neon-badge.magenta {
  background: rgba(255, 45, 149, 0.15);
  color: #ff2d95;
  box-shadow: 0 0 10px rgba(255, 45, 149, 0.2);
}
.neon-badge.magenta .live-dot {
  background: #ff2d95;
  box-shadow: 0 0 8px #ff2d95;
}

.race-card {
  max-width: 620px;
  gap: 0;
  max-height: 92vh;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85),
              0 0 40px rgba(255, 106, 0, 0.18),
              0 0 80px rgba(123, 47, 247, 0.12);
}
.race-card .menu-title {
  background: linear-gradient(135deg, #ff9a3c 0%, #fff2dd 48%, #b06bff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.race-card .neon-badge.magenta {
  background: rgba(255, 106, 0, 0.14);
  color: #ff9a3c;
  box-shadow: 0 0 10px rgba(255, 106, 0, 0.2);
}
.race-card .neon-badge.magenta .live-dot {
  background: #ff6a00;
  box-shadow: 0 0 8px #ff6a00;
}
.race-scroll {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 106, 0, 0.45) transparent;
}
.race-scroll::-webkit-scrollbar { width: 6px; }
.race-scroll::-webkit-scrollbar-track { background: transparent; }
.race-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 106, 0, 0.45);
  border-radius: 999px;
}

/* Wide screens: two independent columns (map + racers / difficulty + theme)
   so each column packs tightly without leaving dead space. */
.race-columns {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.race-col { display: contents; }

@media (min-width: 700px) {
  .race-card { max-width: 720px; }
  .race-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
  }
  .race-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
  }
  .race-col .race-map-grid,
  .race-col .race-tabs,
  .race-col .race-tabs.race-tabs-2 {
    grid-template-columns: 1fr;
  }
}

/* Shorter laptop viewports: trim decorative copy so the whole setup and the
   CTA fit without cutting a panel in half. */
@media (max-height: 820px) {
  .race-card {
    max-height: 96vh;
    padding-top: 18px;
    padding-bottom: 18px;
  }
  .race-scroll { gap: 10px; }
  .race-card .menu-tagline,
  .race-card .race-rules { display: none; }
  .race-select-panel { padding: 8px 10px; gap: 7px; }
}
.race-select-panel {
  width: 100%;
  background: rgba(12, 16, 32, 0.75);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.race-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.race-tabs.race-tabs-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.race-size-btn,
.race-diff-btn {
  background: rgba(16, 24, 48, 0.85);
  border: none;
  border-left: 3px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  transition: background 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  color: #e2e8f0;
}
.race-size-btn:hover,
.race-diff-btn:hover {
  background: rgba(24, 36, 68, 0.95);
  transform: translateY(-1px);
}
.race-size-btn.active,
.race-diff-btn.active {
  background: rgba(255, 45, 149, 0.14);
  border-left-color: #ff2d95;
  box-shadow: 0 0 14px rgba(255, 45, 149, 0.25);
}
.race-size-btn.active .tab-name,
.race-diff-btn.active .tab-name { color: #ff2d95; }
.race-size-btn.active .tab-status-badge,
.race-diff-btn.active .tab-status-badge {
  background: #ff2d95;
  color: #0a0a14;
  box-shadow: 0 0 6px rgba(255, 45, 149, 0.6);
}

/* Race map selector + theme toggle (Halloween orange accent) */
.race-map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.race-map-btn,
.race-theme-btn {
  background: rgba(16, 24, 48, 0.85);
  border: none;
  border-left: 3px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  color: #e2e8f0;
}
.race-map-btn:hover,
.race-theme-btn:hover {
  background: rgba(24, 36, 68, 0.95);
  transform: translateY(-1px);
}
.race-map-btn.active,
.race-theme-btn.active {
  background: rgba(255, 106, 0, 0.14);
  border-left-color: #ff6a00;
  box-shadow: 0 0 14px rgba(255, 106, 0, 0.25);
}
.race-map-btn.active .tab-name,
.race-theme-btn.active .tab-name {
  color: #ff9a3c;
}
.race-map-btn.active .tab-status-badge,
.race-theme-btn.active .tab-status-badge {
  background: #ff6a00;
  color: #0a0612;
  box-shadow: 0 0 6px rgba(255, 106, 0, 0.6);
}
.race-map-icon {
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}
.race-map-btn .map-tab-info,
.race-theme-btn .map-tab-info {
  flex: 1 1 auto;
  min-width: 0;
}
.race-map-btn .tab-name,
.race-theme-btn .tab-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.race-map-btn .tab-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.18;
}
.race-size-btn,
.race-diff-btn,
.race-map-btn,
.race-theme-btn {
  min-width: 0;
}
.race-map-btn .tab-status-badge,
.race-theme-btn .tab-status-badge {
  flex: 0 0 auto;
}

/* Race setup adapts down to phones: one map per row, stacked difficulty. */
@media (max-width: 560px) {
  .race-card {
    padding: 20px 16px;
    gap: 12px;
  }
  .race-select-panel { padding: 9px 10px; }
  .race-map-grid { grid-template-columns: 1fr; }
  .race-tabs { grid-template-columns: 1fr; }
  .race-tabs.race-tabs-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .race-map-btn,
  .race-theme-btn { padding: 9px 11px; }
}

/* The optional auth chip would cover the focused race setup on small screens. */
body:has(#race-menu:not(.hidden)) .vib-privy-badge {
  display: none;
}

@media (max-width: 720px) {
  /* Keep the optional auth chip accessible on phones without letting it sit on
     top of the start-menu wordmark. */
  body:has(#start-menu:not(.hidden)) #start-menu .menu-card {
    padding-top: 58px;
  }
}

/* Keep the primary actions reachable while the setup content scrolls. */
.race-card .menu-actions {
  width: 100%;
  flex: 0 0 auto;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: transparent;
}

/* Spooky race tint on the HUD panels */
body.halloween-race .island-status {
  border-color: rgba(255, 106, 0, 0.4);
  box-shadow: 0 0 18px rgba(123, 47, 247, 0.25), inset 0 0 14px rgba(255, 106, 0, 0.08);
}
body.halloween-race .race-place-label,
body.halloween-race .title-badge {
  color: #ff9a3c;
}
.race-rules {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #94a3b8;
}
.race-rules > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Mode switching: battle-only vs race-only HUD pieces */
.race-only { display: none !important; }
body.race-mode .race-only { display: flex !important; }
body.race-mode .race-status.race-only { display: flex !important; }
body.race-mode .battle-only { display: none !important; }
body.race-mode .scoreboard .team,
body.race-mode .scoreboard .score-divider { display: none; }
body.race-mode .survivors-strip {
  margin-left: 0;
  padding-left: 0;
  border-left: none;
}
body.race-mode #touch-push,
body.race-mode #touch-spear,
body.race-mode #touch-grenade { display: none; }
body.race-mode .island-status { border-color: rgba(255, 45, 149, 0.28); }

.race-status {
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.race-place-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: 'Orbitron', sans-serif;
}
.race-place-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ff2d95;
}
.race-place-value {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 14px rgba(255, 45, 149, 0.7);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.race-place-value.bump { transform: scale(1.25); }
.race-place-value.first {
  color: #ffd700;
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.8);
}
.race-place-total {
  font-size: 14px;
  font-weight: 800;
  color: #94a3b8;
}
.race-batt { color: #00e5ff; }
.race-batt.full { text-shadow: 0 0 8px rgba(0, 229, 255, 0.9); }

.race-map { color: #c9e4ff; font-size: 11px; line-height: 1.2; text-align: right; max-width: 155px; }
.race-light { font-weight: 700; letter-spacing: 1px; }
.race-light.green { color: #39ff14; text-shadow: 0 0 8px rgba(57, 255, 20, 0.8); }
.race-light.red { color: #ff2d2d; text-shadow: 0 0 10px rgba(255, 45, 45, 0.9); animation: blink 0.5s infinite; }
.race-light.meteor { color: #ff8c2a; text-shadow: 0 0 8px rgba(255, 140, 42, 0.8); }

.race-track {
  position: relative;
  height: 14px;
  margin-top: 2px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  overflow: visible;
}
.race-track-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.15), rgba(0, 229, 255, 0.45));
}
.race-track-dots {
  position: absolute;
  inset: 0 14px 0 0;
}
.race-dot {
  position: absolute;
  top: 3px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
  background: currentColor;
  opacity: 0.85;
}
.race-dot.you {
  top: 1px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border: 2px solid #ffffff;
  opacity: 1;
  z-index: 2;
}
.race-track-flag {
  position: absolute;
  right: 0;
  top: -3px;
  font-size: 13px;
  color: #ffffff;
}

/* Map 3: music / voice tag on-off clickers */
.race-audio-controls {
  display: none;
  gap: 6px;
  margin-top: 8px;
}
.race-audio-controls.show {
  display: flex;
}
.race-audio-btn {
  flex: 1;
  background: rgba(16, 24, 48, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 6px 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.race-audio-btn:hover {
  border-color: rgba(0, 229, 255, 0.5);
  color: #c9e4ff;
}
.race-audio-btn.active {
  color: #39ff14;
  border-color: rgba(57, 255, 20, 0.6);
  background: rgba(57, 255, 20, 0.12);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.25);
}

.surv-chip.finished { box-shadow: 0 0 0 2px #ffd700, 0 0 10px rgba(255, 215, 0, 0.6); }
.surv-chip .race-rank {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 14px;
  height: 14px;
  padding: 0 2px;
  border-radius: 7px;
  background: #ffd700;
  color: #0a0a14;
  font: 800 9px/14px 'JetBrains Mono', monospace;
  text-align: center;
}

.race-countdown {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(64px, 14vw, 150px);
  font-weight: 900;
  letter-spacing: 6px;
  color: #ffffff;
  text-shadow: 0 0 24px rgba(255, 45, 149, 0.9), 0 0 60px rgba(0, 229, 255, 0.6);
  pointer-events: none;
  z-index: 60;
}
.race-countdown.hidden { display: none; }
.race-countdown.pop { animation: raceCountPop 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
.race-countdown.go {
  color: #39ff14;
  text-shadow: 0 0 24px rgba(57, 255, 20, 0.9), 0 0 60px rgba(0, 229, 255, 0.6);
}
@keyframes raceCountPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(0.96); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .race-countdown.pop { animation: none; }
}

/* =========================================================================
   HALLOWEEN — VIBER RACE menu button decoration
   The generated neon plaque (assets/halloween/button-frame.png) is applied as
   a 9-slice border so the pumpkin / bat corners stay intact around any button
   width, while the centre stretches invisibly behind the actual CTA.
   ========================================================================= */
.hw-btn-wrap {
  --hw-frame-x: 34px;
  --hw-frame-y: 30px;
  position: relative;
  display: flex;
  overflow: visible;
}
.hw-btn-wrap > .cyber-btn {
  flex: 1 1 auto;
  z-index: 1;
}
.hw-btn-wrap::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--hw-frame-y)) calc(-1 * var(--hw-frame-x));
  z-index: 0;
  pointer-events: none;
  border-style: solid;
  border-width: var(--hw-frame-y) var(--hw-frame-x);
  border-image-source: url("assets/halloween/button-frame.png");
  border-image-slice: 90 fill;
  border-image-width: var(--hw-frame-y) var(--hw-frame-x);
  border-image-repeat: stretch;
  transform-origin: center;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), filter 0.22s ease;
  filter: drop-shadow(0 0 10px rgba(255, 106, 0, 0.28)) drop-shadow(0 0 18px rgba(123, 47, 247, 0.22));
  will-change: transform;
}
.hw-btn-wrap:hover::before {
  transform: scale(1.035);
  filter: drop-shadow(0 0 16px rgba(255, 106, 0, 0.6)) drop-shadow(0 0 28px rgba(123, 47, 247, 0.45));
}

.cyber-btn-viber {
  position: relative;
  z-index: 1;
  background: transparent;
  color: #ffe9d0;
  font-size: 14px;
  letter-spacing: 2.2px;
  text-shadow: 0 0 14px rgba(255, 106, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.85);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), color 0.18s ease;
}
.cyber-btn-viber:hover {
  color: #ffffff;
  transform: translateY(-2px) scale(1.06);
}
.cyber-btn-viber .btn-icon {
  color: #ffb066;
  text-shadow: 0 0 12px rgba(255, 106, 0, 0.9);
}
.cyber-btn-viber .key-tag {
  border-color: rgba(255, 154, 60, 0.55);
  color: #ffd9b0;
  box-shadow: 0 0 10px rgba(255, 106, 0, 0.24), inset 0 0 8px rgba(255, 106, 0, 0.16);
}

@media (max-width: 640px) {
  .hw-btn-wrap { --hw-frame-x: 20px; --hw-frame-y: 24px; }
}

@media (min-width: 861px) {
  .start-card .menu-actions .hw-btn-wrap { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .cyber-btn-viber,
  .hw-btn-wrap::before { transition: none; }
  .cyber-btn-viber:hover { transform: translateY(-2px); }
  .hw-btn-wrap:hover::before { transform: none; }
}

/* =========================================================================
   HALLOWEEN — neon bloom toggle in the race setup
   ========================================================================= */
.race-glow-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 11px;
  background: rgba(16, 24, 48, 0.78);
  border: 1px solid rgba(123, 47, 247, 0.32);
  border-radius: 10px;
  color: #8f9ab4;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.race-glow-toggle:hover {
  border-color: rgba(255, 106, 0, 0.5);
  color: #d8e2f6;
}
.race-glow-toggle .glow-orb {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a2a55;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.6);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}
.race-glow-toggle .glow-state {
  margin-left: auto;
  color: #64748b;
  letter-spacing: 1.5px;
}
.race-glow-toggle.active {
  color: #ffcf9a;
  border-color: rgba(255, 106, 0, 0.55);
  box-shadow: 0 0 14px rgba(255, 106, 0, 0.18), inset 0 0 14px rgba(123, 47, 247, 0.16);
}
.race-glow-toggle.active .glow-orb {
  background: #ff6a00;
  box-shadow: 0 0 10px #ff6a00, 0 0 18px rgba(255, 106, 0, 0.5);
}
.race-glow-toggle.active .glow-state { color: #ff6a00; }

/* =========================================================================
   HALLOWEEN — cobweb HUD corners (mirrored top-right)
   ========================================================================= */
body.race-mode.halloween-race #in-game-hud::before,
body.race-mode.halloween-race #in-game-hud::after {
  content: "";
  position: absolute;
  top: 0;
  width: clamp(96px, 13vw, 176px);
  aspect-ratio: 1 / 1;
  background: url("assets/halloween/cobweb.png") top left / contain no-repeat;
  opacity: 0.5;
  pointer-events: none;
  z-index: -1;
  filter: drop-shadow(0 0 6px rgba(123, 47, 247, 0.55));
}
body.race-mode.halloween-race #in-game-hud::before { left: 0; }
body.race-mode.halloween-race #in-game-hud::after { right: 0; transform: scaleX(-1); }
