/* Scoped pre-battle presentation. The regular loading/error view returns as
   soon as this section is hidden by the battle controller. */
#loading:has(#matchmaking:not([hidden])) > .load-box { visibility:hidden; }
.matchmaking[hidden] { display:none !important; }
.matchmaking {
  --mm-gold:#ffda79; --mm-copper:#cf9566;
  position:absolute; inset:0; z-index:3; isolation:isolate;
  display:grid; place-items:center; overflow:auto;
  padding:max(18px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));
  color:#fff8ed; text-align:center;
  background:linear-gradient(120deg,#191123ed,#301d32e8 50%,#191b2ced),url(loading.webp) center/cover;
}
.matchmaking::before {
  content:""; position:absolute; inset:0; z-index:-1; pointer-events:none;
  background:radial-gradient(ellipse at 18% 43%,#1389a62b,transparent 40%),radial-gradient(ellipse at 82% 43%,#e76d4024,transparent 40%),linear-gradient(125deg,transparent 49.85%,#ffd28e0b 50%,transparent 50.15%);
}
.mm-wrap { width:min(990px,100%); margin:auto; }
.mm-header { margin-bottom:clamp(12px,2.2vh,25px); }
.mm-kicker { color:#f4c98b; font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.16em; }
.mm-title { margin:5px 0 10px; font-size:clamp(26px,4.5vw,48px); font-style:italic; font-weight:950; letter-spacing:-.055em; line-height:1.05; text-shadow:0 3px #151022; }
.mm-meta { display:flex; justify-content:center; flex-wrap:wrap; gap:6px 10px; font-size:11px; font-weight:750; }
.mm-map { color:#f4d6aa; }
.mm-mode { padding-left:11px; border-left:1px solid #e9ba7c66; color:#c8d4e3; }
.mm-board { position:relative; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:34px; }
.mm-team { --side:#7de9ff; --shade:#1d526a; min-width:0; padding:12px; border:1px solid #a18caa5c; border-top:3px solid var(--side); border-radius:13px; background:linear-gradient(150deg,#2a2138ee,#191424e8); box-shadow:inset 0 1px #ffffff16,0 7px 0 #0c0a1455,0 20px 36px #09051344; }
.mm-team-red { --side:#ff9a85; --shade:#723948; }
.mm-team-header { display:flex; align-items:center; gap:8px; margin:0 2px 11px; color:var(--side); }
.mm-team-header h3 { margin:0; font-size:clamp(12px,1.6vw,17px); font-weight:850; text-align:left; }
.mm-team-count { margin-left:auto; font-size:12px; font-variant-numeric:tabular-nums; white-space:nowrap; color:#fff0d6; }
.mm-crest { display:block; flex:0 0 15px; height:18px; background:var(--side); clip-path:polygon(0 8%,50% 0,100% 8%,94% 64%,50% 100%,6% 64%); }
.mm-team-red .mm-crest { clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%); }
.mm-roster { display:grid; gap:8px; margin:0; padding:0; list-style:none; }
.mm-pilot { position:relative; display:grid; grid-template-columns:90px minmax(0,1fr) auto; align-items:center; min-height:78px; padding:3px 12px 3px 3px; border:1px solid #9c8ca53d; border-radius:8px; background:linear-gradient(110deg,#3c2b414d,#211a30aa); overflow:hidden; text-align:left; }
.mm-pilot::after { content:""; position:absolute; width:30%; inset:-30% auto -30% -50%; transform:skew(-20deg); background:linear-gradient(90deg,transparent,#ffedc814,transparent); animation:mm-scan 2.4s linear infinite; pointer-events:none; }
.mm-pilot.is-ready { border-color:#b39c9166; background:linear-gradient(115deg,var(--shade),#282034 77%); }
.mm-pilot.is-ready::after { display:none; }
.mm-pilot.is-you { border-color:var(--mm-gold); box-shadow:inset 3px 0 var(--mm-gold); }
.mm-portrait { position:relative; height:70px; display:grid; place-items:center; }
.mm-portrait::before { content:""; position:absolute; width:63px; height:25px; bottom:5px; border:1px solid #cdd8e82a; border-radius:50%; background:radial-gradient(ellipse,#bed6ff18,transparent 70%); }
.mm-portrait img { position:relative; width:100%; height:100%; object-fit:contain; opacity:0; transform:translateY(6px); transition:opacity .3s,transform .3s ease-out; filter:drop-shadow(0 4px 3px #080a1f88); }
.mm-slot-number { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); color:#8f839f; font-size:27px; font-weight:900; font-style:italic; opacity:.65; }
.mm-pilot.is-ready img { opacity:1; transform:translateY(0); }
.mm-pilot.is-ready .mm-slot-number { opacity:0; }
.mm-identity { min-width:0; display:grid; gap:4px; }
.mm-pilot-name { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:14px; font-weight:850; color:#a99cb5; }
.mm-pilot-model { font-size:11px; color:#a99ab5; }
.mm-pilot.is-ready .mm-pilot-name { color:#fff7e8; }
.mm-pilot.is-ready .mm-pilot-model { color:var(--side); }
.mm-pilot-badge { padding:3px 5px; margin-left:5px; border:1px solid #aa8a6744; border-radius:4px; color:#c7b4a6; font-size:9px; font-weight:850; letter-spacing:.05em; }
.mm-pilot.is-you .mm-pilot-badge { background:var(--mm-gold); border-color:var(--mm-gold); color:#2a1b26; }
.mm-versus { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%) rotate(-7deg); z-index:1; color:#ffdb81; font-size:24px; font-weight:950; font-style:italic; text-shadow:0 3px #211327,2px 0 #211327,-2px 0 #211327; }
.mm-footer { position:relative; display:grid; justify-items:center; margin-top:clamp(15px,2.7vh,28px); min-height:109px; }
.mm-status { display:grid; gap:5px; }
.mm-phase { color:#ffe4aa; font-size:16px; font-weight:850; }
.mm-total { font-size:11px; color:#c9b7c8; font-variant-numeric:tabular-nums; }
.mm-progress { display:block; width:min(270px,75%); height:7px; margin:12px 0 0; background:#191323; border:1px solid #80635c; border-radius:20px; box-shadow:0 0 15px #ffb45112; }
.mm-progress::-webkit-progress-bar { background:#191323; }
.mm-progress::-webkit-progress-value { background:linear-gradient(90deg,#d98849,#ffe5a0); transition:width .28s ease; }
.mm-progress::-moz-progress-bar { background:linear-gradient(90deg,#d98849,#ffe5a0); }
.mm-countdown { display:none; width:58px; height:58px; place-items:center; margin-top:9px; border:2px solid #ffc975; border-radius:50%; box-shadow:0 0 0 5px #f4b75b12,0 0 30px #ffb6431c; background:#342232; }
.mm-number { color:#ffe7a6; font-size:31px; font-weight:950; font-style:italic; line-height:1; }
.mm-note { margin:12px 0 0; color:#bba8bc; font-size:10px; line-height:1.35; }
.matchmaking[data-phase="countdown"] .mm-progress,.matchmaking[data-phase="ready"] .mm-progress { display:none; }
.matchmaking[data-phase="countdown"] .mm-countdown,.matchmaking[data-phase="ready"] .mm-countdown { display:grid; }
.matchmaking[data-phase="ready"] .mm-number { font-size:22px; }
@keyframes mm-scan { to { left:140%; } }
@media(max-width:600px) {
  .matchmaking { padding-inline:10px; }
  .mm-board { gap:13px; }
  .mm-team { padding:7px 5px; border-radius:9px; }
  .mm-team-header { gap:4px; margin:0 2px 8px; flex-wrap:wrap; }
  .mm-team-header h3 { font-size:11px; }
  .mm-crest { flex-basis:10px; height:12px; }
  .mm-team-count { font-size:10px; }
  .mm-roster { gap:6px; }
  .mm-pilot { grid-template-columns:52px minmax(0,1fr); min-height:68px; padding:3px 4px 3px 0; border-radius:6px; }
  .mm-portrait { height:51px; }
  .mm-portrait::before { width:43px; height:15px; }
  .mm-pilot-name { font-size:10px; }
  .mm-pilot-model { font-size:10px; }
  .mm-pilot-badge { position:absolute; right:4px; bottom:3px; margin:0; font-size:7px; padding:0 3px; }
  .mm-identity { gap:3px; padding-bottom:10px; }
  .mm-versus { font-size:16px; }
  .mm-kicker { font-size:9px; letter-spacing:.08em; }
  .mm-title { font-size:29px; }
  .mm-meta { font-size:10px; }
  .mm-phase { font-size:14px; }
  .mm-note { max-width:32ch; font-size:9px; }
}
@media(max-height:540px) {
  .matchmaking { padding-block:max(7px,env(safe-area-inset-top)); }
  .mm-wrap { width:min(860px,100%); }
  .mm-header { margin-bottom:8px; }
  .mm-kicker { font-size:8px; }
  .mm-title { font-size:25px; margin:2px 0 5px; }
  .mm-meta { font-size:9px; }
  .mm-team { padding:6px; }
  .mm-team-header { margin-bottom:5px; }
  .mm-team-header h3 { font-size:12px; }
  .mm-pilot { min-height:42px; grid-template-columns:57px minmax(0,1fr) auto; padding-block:0; }
  .mm-portrait { height:41px; }
  .mm-pilot-name { font-size:11px; }
  .mm-pilot-model { font-size:9px; }
  .mm-roster { gap:4px; }
  .mm-footer { margin-top:9px; min-height:58px; }
  .mm-status { gap:2px; }
  .mm-phase { font-size:12px; }
  .mm-total { font-size:9px; }
  .mm-countdown { position:absolute; left:calc(50% + 145px); top:0; width:38px; height:38px; margin:0; box-shadow:0 0 0 3px #f4b75b12; }
  .mm-number { font-size:23px; }
  .mm-progress { margin-top:6px; height:5px; }
  .mm-note { margin-top:5px; font-size:8px; max-width:none; }
}
@media(prefers-reduced-motion:reduce) {
  .mm-pilot::after { animation:none; }
  .mm-portrait img,.mm-progress::-webkit-progress-value { transition:none; }
}
