/* ============================================================
   ASTRIKE — MENU / BOOT / MATCH-LOADING styles (Agent I)
   Fully self-contained. Styles ONLY:
     - the #menu subtree
     - #boot (cinematic intro, driven by js/intro.js)
     - #match-loading
   plus the .menu3d-canvas class used by js/menu3d.js.
   Global reset is assumed (style.css). All keyframes are prefixed
   mn- / bt- / ml- to avoid clashing with other stylesheets.
   ============================================================ */

/* ============================= #menu ============================= */

#menu {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 20px;
  overflow: hidden;
  color: #dfe5ea;
}

/* --- animated background layer (fallback under the 3D canvas) --- */
#menu .menu-bg {
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(160deg, #0c1420 0%, #101a29 30%, #0d1522 55%, #131b2e 80%, #0a0f18 100%);
  background-size: 300% 300%;
  animation: mn-bg-shift 26s ease-in-out infinite alternate;
}
#menu .menu-bg::before { /* film grain */
  content: ''; position: absolute; inset: 0; opacity: 0.05; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}
#menu .menu-bg::after { /* scanlines + vignette */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(2, 5, 9, 0.55) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
}
@keyframes mn-bg-shift {
  from { background-position: 0% 20%; }
  to   { background-position: 100% 80%; }
}

/* --- 3D backdrop canvas (js/menu3d.js mounts it here or on <body>) --- */
#menu #menu3d-holder {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
}
.menu3d-canvas {
  position: fixed; inset: 0; z-index: 19;   /* fallback: direct child of <body>, under #menu (z 20) */
  display: block; pointer-events: none;
}
#menu3d-holder .menu3d-canvas {
  position: absolute; inset: 0; z-index: auto; /* mounted inside #menu: above bg, below content */
  width: 100%; height: 100%;
}

/* --- portrait rotate hint (non-blocking) --- */
#menu #menu-rotate {
  display: none;
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 3; align-items: center; gap: 8px;
  padding: 7px 16px;
  font-size: 11px; letter-spacing: 2.5px; font-weight: 700; color: #cfd6dd;
  background: rgba(12, 18, 26, 0.78);
  border: 1px solid rgba(88, 240, 138, 0.25);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  pointer-events: none;
}
#menu #menu-rotate .mr-ico { color: #58f08a; font-size: 14px; animation: mn-spin 2.4s ease-in-out infinite; }
@keyframes mn-spin { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(180deg); } }
@media (orientation: portrait) and (pointer: coarse) {
  #menu #menu-rotate { display: flex; }
}

/* --- header lockup --- */
#menu .menu-head { position: relative; z-index: 2; text-align: center; }
#menu .logo {
  font-size: clamp(34px, 7vw, 62px);
  font-weight: 900; letter-spacing: 10px; line-height: 1.1;
  margin: 0 10px;
  background: linear-gradient(100deg, #e8eef2 25%, #58f08a 48%, #d9ffe6 54%, #e8eef2 75%);
  background-size: 220% 100%; background-position: 110% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transition: letter-spacing 0.5s ease, filter 0.5s ease, background-position 1.2s ease;
  cursor: default;
}
#menu .logo span { color: transparent; } /* let the lockup gradient show through */
#menu .logo:hover {
  letter-spacing: 13px;
  filter: drop-shadow(0 0 18px rgba(88, 240, 138, 0.35));
  background-position: -10% 0;
}
#menu .studio-tag {
  font-size: 10px; letter-spacing: 6px; color: #7d8891;
  margin: 10px 0 4px;
}
#menu .tagline { font-size: 12.5px; letter-spacing: 1px; color: #8b96a0; }

/* --- footer --- */
#menu .menu-footer {
  position: absolute; bottom: 10px; left: 0; right: 0; z-index: 2;
  text-align: center;
  font-size: 10px; letter-spacing: 3px; color: #4a545e;
  pointer-events: none;
}

/* ====================== screens & panels ====================== */

#menu .screen {
  position: relative; z-index: 2;
  animation: mn-screen-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes mn-screen-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
#menu .panel {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: min(410px, 92vw);
  padding: 20px 26px 24px;
  background: linear-gradient(150deg, rgba(16, 24, 34, 0.72), rgba(10, 15, 22, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.07);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  filter: drop-shadow(0 14px 34px rgba(0, 0, 0, 0.45));
  position: relative;
}
#menu .panel::before { /* top accent hairline */
  content: ''; position: absolute; top: 0; left: 12%; right: 30%; height: 1px;
  background: linear-gradient(90deg, rgba(88, 240, 138, 0.55), transparent);
}
#menu .panel-main { background: linear-gradient(150deg, rgba(16, 24, 34, 0.5), rgba(10, 15, 22, 0.38)); }
#menu .panel-wide { width: min(600px, 94vw); }
#menu .panel-help { width: min(680px, 94vw); }
#menu .panel-lobby { width: min(520px, 94vw); }

#menu h2 {
  font-size: 19px; letter-spacing: 5px; font-weight: 800; color: #e8eef2;
  margin: 2px 0 6px;
}
#menu h2::after {
  content: ''; display: block; width: 44px; height: 2px; margin: 8px auto 0;
  background: linear-gradient(90deg, transparent, #58f08a, transparent);
}

/* ============================ buttons ============================ */

#menu .mbtn {
  position: relative; overflow: hidden;
  pointer-events: all; cursor: pointer;
  display: inline-block;
  font-family: inherit; font-weight: 700; letter-spacing: 3px;
  color: #dfe5ea;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025));
  border: none;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s, transform 0.08s, filter 0.25s;
}
#menu .mbtn::after { /* sheen sweep on hover */
  content: ''; position: absolute; top: -10%; bottom: -10%; left: -70%; width: 45%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-18deg);
  transition: left 0.5s ease;
  pointer-events: none;
}
#menu .mbtn:hover::after { left: 130%; }
#menu .mbtn:hover { color: #ffffff; filter: drop-shadow(0 0 10px rgba(88, 240, 138, 0.18)); }
#menu .mbtn:active { transform: translateY(1px) scale(0.985); }
#menu .mbtn:focus-visible { box-shadow: inset 0 0 0 2px rgba(88, 240, 138, 0.65); }
#menu .mbtn:disabled { opacity: 0.45; cursor: default; filter: none; }
#menu .mbtn:disabled::after { display: none; }

#menu .mbtn.big { width: 340px; max-width: 100%; padding: 14px 0; font-size: 15px; }
#menu .mbtn.small { width: 165px; padding: 10px 0; font-size: 12px; }

#menu .mbtn.accent {
  color: #58f08a;
  background: linear-gradient(135deg, rgba(88, 240, 138, 0.14), rgba(88, 240, 138, 0.04));
  filter: drop-shadow(0 0 14px rgba(88, 240, 138, 0.22));
}
#menu .mbtn.accent:hover {
  color: #06130b;
  background: linear-gradient(135deg, #6ff5a0, #45d97a);
  filter: drop-shadow(0 0 20px rgba(88, 240, 138, 0.5));
}

#menu .backbtn {
  pointer-events: all; cursor: pointer;
  align-self: flex-start;
  background: none; border: none;
  color: #7d8891; font-size: 12px; letter-spacing: 2px; font-weight: 700;
  padding: 4px 6px; margin-bottom: 2px;
  transition: color 0.15s, transform 0.15s;
}
#menu .backbtn:hover { color: #ffffff; transform: translateX(-3px); }

#menu .row-pair { display: flex; gap: 10px; }

/* ====================== inputs & options ====================== */

#menu .opt {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  pointer-events: all;
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 9px 14px;
}
#menu .opt > span { font-size: 11px; letter-spacing: 1.5px; color: #97a2ac; font-weight: 700; flex-shrink: 0; }

#menu select, #menu input {
  pointer-events: all;
  font-family: inherit;
  background: #121924; color: #dfe5ea;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 7px 10px; font-size: 13.5px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#menu select:focus, #menu input:focus {
  border-color: rgba(88, 240, 138, 0.65);
  box-shadow: 0 0 0 2px rgba(88, 240, 138, 0.12);
}
#menu select option { background: #121924; }

#menu input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 170px; height: 4px; padding: 0;
  background: rgba(255, 255, 255, 0.14);
  border: none; border-radius: 2px; cursor: pointer;
}
#menu input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  background: #58f08a;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
  box-shadow: 0 0 8px rgba(88, 240, 138, 0.6);
  border: none;
}
#menu input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 2px;
  background: #58f08a; box-shadow: 0 0 8px rgba(88, 240, 138, 0.6);
}
#menu input[type="range"]::-moz-range-track { height: 4px; background: rgba(255, 255, 255, 0.12); }
#menu input[type="range"]:focus { box-shadow: none; }

#menu .opt b {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 13px; color: #58f08a; min-width: 44px; text-align: right;
  font-variant-numeric: tabular-nums;
}

#menu .name-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
#menu .name-row label { font-size: 10px; letter-spacing: 3px; color: #7d8891; font-weight: 700; }
#menu .name-row input { width: 180px; }

#menu .code-input {
  width: 220px; text-align: center;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 24px; letter-spacing: 8px; font-weight: 800;
  text-transform: uppercase;
}

#menu .hint { font-size: 12px; color: #8b96a0; max-width: 340px; text-align: center; line-height: 1.65; }
#menu #create-status, #menu #join-error {
  color: #e0b13c; font-size: 12.5px; min-height: 18px; letter-spacing: 0.5px; text-align: center;
}

/* ============================ lobby ============================ */

#menu #lobby-code-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(88, 240, 138, 0.05);
  border: 1px solid rgba(88, 240, 138, 0.18);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
#menu #lobby-code-row .lcr-label { font-size: 9px; letter-spacing: 3px; color: #7d8891; font-weight: 700; }
#menu #lobby-code {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 26px; letter-spacing: 8px; color: #58f08a;
  text-shadow: 0 0 14px rgba(88, 240, 138, 0.4);
}
#menu #btn-copy-code {
  pointer-events: all; cursor: pointer;
  font-family: inherit; font-size: 10px; font-weight: 800; letter-spacing: 2px;
  color: #dfe5ea; background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 5px 12px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: background 0.15s, color 0.15s;
}
#menu #btn-copy-code:hover { background: #58f08a; color: #06130b; }
#menu #copy-hint { font-size: 10.5px; color: #58f08a; letter-spacing: 1px; min-width: 44px; }

#menu #lobby-count { font-size: 11.5px; color: #8b96a0; letter-spacing: 1.5px; }
#menu #lobby-players {
  display: flex; flex-direction: column; gap: 5px;
  width: 100%; min-height: 40px; max-height: 168px; overflow-y: auto;
  touch-action: pan-y;
}
#menu .lobby-player {
  display: flex; align-items: center;
  background: rgba(255, 255, 255, 0.045);
  border-left: 2px solid rgba(255, 255, 255, 0.14);
  padding: 6px 12px; font-size: 13.5px; letter-spacing: 0.5px;
  animation: mn-screen-in 0.25s ease-out both;
}
#menu .tag {
  display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: 1px;
  padding: 2px 7px; margin-right: 9px;
  background: #3a424a; color: #fff;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}
#menu .tag.CT { background: #3d6a96; }
#menu .tag.T { background: #a06a2c; }

#menu #lobby-options { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
#menu #lobby-options .opt { width: auto; flex: 1 1 150px; }
#menu #opt-bots-note { font-size: 10.5px; color: #58f08a; width: 100%; text-align: center; letter-spacing: 1px; min-height: 13px; }

#menu #lobby-waiting {
  color: #e0b13c; font-size: 12.5px; letter-spacing: 1.5px;
  animation: mn-pulse 1.4s ease-in-out infinite;
}
@keyframes mn-pulse { 50% { opacity: 0.35; } }

/* =========================== settings =========================== */

#menu .set-section {
  display: flex; flex-direction: column; gap: 9px;
  width: 100%;
  padding: 10px 12px 12px;
  background: rgba(255, 255, 255, 0.022);
  border-left: 2px solid rgba(88, 240, 138, 0.35);
}
#menu .set-label {
  font-size: 9.5px; letter-spacing: 4px; font-weight: 800; color: #58f08a;
  margin-bottom: 2px;
}

/* ============================= help ============================= */

#menu .help-cols { display: flex; gap: 34px; text-align: left; width: 100%; justify-content: center; }
#menu .help-cols > div { flex: 1 1 0; max-width: 300px; }
#menu .help-cols h3 { font-size: 11.5px; letter-spacing: 3.5px; color: #58f08a; margin: 14px 0 6px; }
#menu .help-cols h3:first-child { margin-top: 0; }
#menu .help-cols p { font-size: 12.5px; line-height: 1.9; color: #b8c0c8; }
#menu kbd {
  display: inline-block;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 10px; font-weight: 700; color: #e8eef2;
  background: #1a222d;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  padding: 1px 6px; margin: 0 2px 2px 0;
  clip-path: polygon(3px 0, 100% 0, 100% calc(100% - 3px), calc(100% - 3px) 100%, 0 100%, 0 3px);
}

/* ============================= #boot ============================= */

#boot {
  position: absolute; inset: 0; z-index: 100;
  background: #04060a;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  transition: opacity 0.7s;
}
#boot.boot-out { opacity: 0; pointer-events: none; }
#boot-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
#boot-dust { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.85; }
#boot.boot-p3 #boot-dust { opacity: 0; transition: opacity 1s; }

/* --- phase 1 : studio card (auto-plays on load) --- */
#boot .boot-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 34px 52px 30px;
  overflow: hidden;
}
#boot .boot-line {
  width: min(440px, 66vw); height: 1px;
  background: linear-gradient(90deg, transparent, rgba(88, 240, 138, 0.9) 30%, rgba(226, 240, 232, 0.9) 55%, transparent);
  transform: scaleX(0); transform-origin: left center;
  animation: bt-line 0.95s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s both;
}
@keyframes bt-line { to { transform: scaleX(1); } }

#boot .boot-wordmark { display: flex; gap: clamp(7px, 1.4vw, 13px); margin: 30px 0 12px; }
#boot .bw-l {
  font-size: clamp(38px, 7.5vw, 70px);
  font-weight: 200; letter-spacing: 0.04em; color: #dfe8e4;
  opacity: 0;
  animation: bt-letter 0.75s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
#boot .bw-l:nth-child(1) { animation-delay: 0.35s; }
#boot .bw-l:nth-child(2) { animation-delay: 0.44s; }
#boot .bw-l:nth-child(3) { animation-delay: 0.53s; }
#boot .bw-l:nth-child(4) { animation-delay: 0.62s; }
#boot .bw-l:nth-child(5) { animation-delay: 0.71s; }
#boot .bw-l:nth-child(6) { animation-delay: 0.80s; color: #58f08a; }
@keyframes bt-letter {
  0%   { opacity: 0; transform: translateY(16px); clip-path: inset(0 0 100% 0); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}
#boot .boot-studios {
  font-size: 11px; letter-spacing: 8px; color: #626d75; font-weight: 400;
  opacity: 0;
  animation: bt-studios 0.9s ease-out 1.45s both;
}
@keyframes bt-studios {
  from { opacity: 0; letter-spacing: 4px; }
  to   { opacity: 1; letter-spacing: 15px; }
}
#boot .boot-sheen {
  position: absolute; top: -20%; bottom: -20%; left: -80%; width: 45%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.13), transparent);
  transform: skewX(-18deg);
  animation: bt-sheen 0.7s ease-in-out 1.5s both;
  pointer-events: none;
}
@keyframes bt-sheen { from { left: -80%; } to { left: 180%; } }

/* --- phase 2 : title slam (triggered by .boot-p2) --- */
#boot.boot-p2 .boot-card { animation: bt-card-out 0.45s ease-in both; }
@keyframes bt-card-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(-14px) scale(0.97); }
}
#boot .boot-presents {
  display: none;
  position: absolute; top: 37%; left: 0; right: 0;
  text-align: center;
  font-size: 11px; letter-spacing: 10px; color: #66727a; font-weight: 400;
}
#boot.boot-p2 .boot-presents { display: block; animation: bt-presents 1.25s ease both 0.1s; }
@keyframes bt-presents {
  0%   { opacity: 0; letter-spacing: 5px; }
  22%  { opacity: 0.95; }
  65%  { opacity: 0.95; letter-spacing: 11px; }
  100% { opacity: 0; letter-spacing: 12px; }
}

#boot .boot-title-wrap {
  display: none;
  position: absolute; top: 50%; left: 0; right: 0;
  transform: translateY(-50%);
  text-align: center;
  pointer-events: none;
}
#boot.boot-p2 .boot-title-wrap { display: block; animation: bt-shake 0.38s linear 1.02s; }
@keyframes bt-shake {
  0%, 100% { transform: translateY(-50%); }
  15% { transform: translateY(calc(-50% - 7px)) translateX(-5px); }
  30% { transform: translateY(calc(-50% + 6px)) translateX(4px); }
  45% { transform: translateY(calc(-50% - 4px)) translateX(-3px); }
  60% { transform: translateY(calc(-50% + 3px)) translateX(2px); }
  75% { transform: translateY(calc(-50% - 1px)) translateX(-1px); }
}
#boot .boot-title {
  display: inline-block; position: relative;
  font-size: clamp(52px, 11vw, 118px);
  font-weight: 900; letter-spacing: 0.13em;
  margin-right: -0.13em; /* balance trailing letter-spacing so glyphs center */
  opacity: 0;
  background: linear-gradient(105deg, #e8eef2 34%, #58f08a 46%, #d6ffe2 51%, #e8eef2 62%);
  background-size: 260% 100%; background-position: 120% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1px rgba(88, 240, 138, 0.14);
}
#boot .boot-title span { color: transparent; }
#boot.boot-p2 .boot-title {
  animation:
    bt-slam 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.55s both,
    bt-tsheen 0.8s ease-out 1.15s both;
}
@keyframes bt-slam {
  0%   { opacity: 0; transform: scale(1.6); }
  55%  { opacity: 1; }
  78%  { transform: scale(0.985); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes bt-tsheen {
  from { background-position: 120% 0; }
  to   { background-position: -40% 0; }
}
/* RGB-split glitch tick */
#boot .boot-title::before,
#boot .boot-title::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  opacity: 0; mix-blend-mode: screen;
  background: none; -webkit-text-stroke: 0;
  pointer-events: none;
}
#boot .boot-title::before { color: #ff3b5c; animation: bt-glitch-a 0.32s steps(3, end) 1.08s; }
#boot .boot-title::after  { color: #37c8ff; animation: bt-glitch-b 0.32s steps(3, end) 1.08s; }
@keyframes bt-glitch-a {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20% { opacity: 0.85; transform: translate(-5px, 1px); }
  45% { opacity: 0.6; transform: translate(4px, -2px); }
  70% { opacity: 0.9; transform: translate(-2px, 0); }
}
@keyframes bt-glitch-b {
  0%, 100% { opacity: 0; transform: translate(0, 0); }
  20% { opacity: 0.85; transform: translate(5px, -1px); }
  45% { opacity: 0.6; transform: translate(-4px, 2px); }
  70% { opacity: 0.9; transform: translate(2px, 1px); }
}
/* expanding shockwave ring */
#boot .boot-shock {
  position: absolute; top: 50%; left: 50%;
  width: 360px; height: 360px; margin: -180px 0 0 -180px;
  border-radius: 50%;
  border: 2px solid rgba(88, 240, 138, 0.75);
  box-shadow: 0 0 34px rgba(88, 240, 138, 0.35), inset 0 0 34px rgba(88, 240, 138, 0.2);
  opacity: 0; pointer-events: none;
}
#boot.boot-p2 .boot-shock { animation: bt-shock 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) 1.02s both; }
@keyframes bt-shock {
  0%   { opacity: 0.85; transform: scale(0.12); }
  100% { opacity: 0; transform: scale(2.6); }
}
/* version chip */
#boot .boot-chip {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  padding: 7px 16px;
  font-size: 9.5px; letter-spacing: 4px; color: #6d7880; font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 21, 0.6);
  white-space: nowrap;
  opacity: 0;
}
#boot.boot-p2 .boot-chip { animation: bt-chip 0.8s ease-out 1.4s both; }
@keyframes bt-chip {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- phase 3 : loading (triggered by .boot-p3) --- */
#boot .boot-load {
  position: relative;
  display: none;
  flex-direction: column; align-items: center; gap: 13px;
}
#boot.boot-p3 .boot-load { display: flex; animation: bt-load-in 0.55s ease-out both; }
@keyframes bt-load-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
#boot .boot-bar {
  width: min(380px, 70vw); height: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden; position: relative;
}
#boot #boot-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #58f08a, #b8ffce);
  box-shadow: 0 0 10px rgba(88, 240, 138, 0.55);
  transition: width 0.12s linear;
}
#boot #boot-step {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 10px; letter-spacing: 4px; color: #5f6b72;
  min-height: 13px;
}
#boot #boot-enter {
  display: none;
  margin-top: 12px;
  font-size: 15px; letter-spacing: 6px; font-weight: 800; color: #58f08a;
  text-shadow: 0 0 16px rgba(88, 240, 138, 0.45);
}
#boot.boot-p3.ready #boot-enter { display: block; animation: bt-enter 1.3s ease-in-out infinite; }
@keyframes bt-enter {
  0%, 100% { opacity: 1; letter-spacing: 6px; }
  50%      { opacity: 0.35; letter-spacing: 7px; }
}

/* --- fast-forward / reduced motion: cut all boot animation --- */
#boot.boot-skip *,
#boot.boot-skip *::before,
#boot.boot-skip *::after {
  animation-duration: 0.01s !important;
  animation-delay: 0s !important;
  transition-duration: 0.01s !important;
}
@media (prefers-reduced-motion: reduce) {
  #boot *, #boot *::before, #boot *::after {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
    transition-duration: 0.01s !important;
  }
  #menu .menu-bg { animation: none; }
  #menu .screen { animation-duration: 0.01s; }
}

/* ========================= #match-loading ========================= */

#match-loading {
  position: absolute; inset: 0; z-index: 90;
  display: none;              /* main.js toggles this to flex */
  flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, #131c28 0%, #070a0f 75%),
    #070a0f;
}
#match-loading .ml-wipe {
  position: absolute; inset: -30%;
  background: linear-gradient(115deg, transparent 38%, rgba(88, 240, 138, 0.06) 50%, transparent 62%);
  background-size: 300% 300%;
  animation: ml-wipe 2.3s linear infinite;
  pointer-events: none;
}
@keyframes ml-wipe {
  from { background-position: 120% 120%; }
  to   { background-position: -20% -20%; }
}
#match-loading .ml-inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 20px;
}
#match-loading .ml-studio {
  font-size: 10px; letter-spacing: 6px; color: #5f6b72;
  animation: mn-screen-in 0.8s ease-out both;
}
#match-loading #ml-title {
  font-size: clamp(38px, 8vw, 72px);
  font-weight: 900; letter-spacing: 0.12em; text-align: center;
  margin-right: -0.12em; /* balance trailing letter-spacing */
  background: linear-gradient(100deg, #e8eef2 30%, #58f08a 50%, #e8eef2 70%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: mn-screen-in 0.7s ease-out 0.1s both, ml-title-glow 3.2s ease-in-out 0.9s infinite alternate;
}
@keyframes ml-title-glow {
  from { filter: drop-shadow(0 0 6px rgba(88, 240, 138, 0.15)); }
  to   { filter: drop-shadow(0 0 20px rgba(88, 240, 138, 0.4)); }
}
#match-loading .ml-tagline {
  font-size: 10.5px; letter-spacing: 5px; color: #6d7880; font-weight: 700;
  animation: mn-screen-in 0.8s ease-out 0.25s both;
}
#match-loading .ml-bar {
  width: min(400px, 76vw); height: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden; position: relative;
  animation: mn-screen-in 0.8s ease-out 0.35s both;
}
#match-loading #ml-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #58f08a, #b8ffce);
  box-shadow: 0 0 14px rgba(88, 240, 138, 0.7);
  position: relative;
}
#match-loading #ml-bar-fill::after { /* traveling shimmer */
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: ml-shimmer 1.2s linear infinite;
}
@keyframes ml-shimmer { to { left: 130%; } }
#match-loading #ml-tip {
  max-width: min(480px, 86vw);
  text-align: center;
  font-size: 12.5px; color: #9aa5ae; line-height: 1.65;
  animation: mn-screen-in 0.8s ease-out 0.45s both;
}

/* =========================== responsive =========================== */

@media (max-width: 760px) {
  #menu .mbtn.big { width: min(90vw, 340px); }
  #menu .panel { padding: 16px 14px 20px; }
  #menu .panel-wide, #menu .panel-help, #menu .panel-lobby { width: 94vw; }
  #menu .opt { flex-wrap: wrap; }
  #menu input[type="range"] { width: min(46vw, 170px); }
  #menu .help-cols { flex-direction: column; gap: 6px; align-items: center; }
  #menu .help-cols > div { max-width: 94vw; }
  #menu #lobby-code { font-size: 20px; letter-spacing: 5px; }
  #match-loading .ml-bar { width: 84vw; }
}

@media (max-height: 600px) {
  #menu { gap: 8px; padding: 10px; }
  #menu .menu-head .tagline { display: none; }
  #menu .panel { gap: 8px; padding-top: 12px; padding-bottom: 14px; max-height: 94vh; overflow-y: auto; touch-action: pan-y; }
  #menu .mbtn.big { padding: 11px 0; }
  #menu .help-cols p { line-height: 1.6; }
  #boot .boot-card { padding: 22px 36px 20px; }
  #boot .boot-chip { bottom: 16px; }
}

/* ============================================================
   INTEGRATION FIX (LEAD): phase 3 layout — title settles up,
   loader sits below it instead of overlapping at center.
   ============================================================ */
#boot.boot-p3 .boot-title-wrap {
  animation: bt-title-settle 0.65s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes bt-title-settle {
  from { top: 50%; transform: translateY(-50%) scale(1); }
  to   { top: 33%; transform: translateY(-50%) scale(0.6); }
}
#boot.boot-p3 .boot-shock,
#boot.boot-p3 .boot-presents { display: none; }
#boot.boot-p3 .boot-load {
  position: absolute; left: 50%; top: 61%;
  animation: bt-load-in2 0.55s ease-out both;
}
@keyframes bt-load-in2 {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%); }
}
#boot.boot-p3.ready .boot-chip { opacity: 1; }
