/* ==========================================================================\
   SELECT SCREEN OVERHAUL\
   A compact, controller-first presentation layer. Core game/menu behavior\
   remains in js/hud.js; this file owns only the two selection screens.\
   ========================================================================== */

:root {
  --select-red: #ef3340;
  --select-red-dark: #9d111d;
  --select-gold: #ffd86a;
  --select-ink: #07080d;
  --select-panel: rgba(14, 17, 27, .94);
  --select-line: rgba(255, 255, 255, .16);
}

/* ---- main mode menu ---------------------------------------------------- */

/* Mode cards are directly tappable, so the gameplay touch pad only blocks
   content on this screen. Hiding it also leaves the bottom hint unobstructed. */
body.title-mode #touchControls { display: none !important; }

#titleScreen {
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(10px, 1.8vh, 20px) !important;
  padding: max(22px, env(safe-area-inset-top)) clamp(22px, 7vw, 104px) max(18px, env(safe-area-inset-bottom)) !important;
  overflow: hidden !important;
}

#titleScreen .titleBrand {
  min-width: 0;
  align-self: start;
}

#titleScreen .gameTitle {
  position: static !important;
  inset: auto !important;
  max-width: 100% !important;
  margin: 0;
  color: #fff;
  font: 950 italic clamp(44px, 5.2vw, 74px)/.92 Arial, sans-serif !important;
  letter-spacing: clamp(1px, .3vw, 4px) !important;
  white-space: nowrap;
  transform: skewX(-10deg);
  text-shadow: 0 0 26px rgba(255, 120, 60, .65), 0 6px 0 #000;
}

#titleScreen .gameTitle > div {
  margin-top: 7px !important;
  color: #ffce7a;
  font: 900 clamp(10px, 1.1vw, 15px)/1 Arial, sans-serif !important;
  letter-spacing: clamp(3px, .5vw, 7px) !important;
  text-shadow: 0 2px 0 #000;
}

#titleScreen .titleMenu {
  min-height: 0;
  width: min(calc(46vw + 46px), 606px);
  max-width: 100%;
  margin-left: -6px;
  padding: 6px 40px 6px 6px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  justify-content: safe center;
  align-self: stretch;
  gap: clamp(7px, 1.25vh, 13px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .34) transparent;
}

#titleScreen .titleButton {
  appearance: none;
  flex: 0 0 auto;
  width: 100% !important;
  min-height: clamp(62px, 9vh, 88px);
  padding: clamp(10px, 1.45vh, 16px) clamp(22px, 2.6vw, 34px) !important;
  box-sizing: border-box;
  border: 0;
  border-left: 10px solid rgba(255, 255, 255, .88);
  border-radius: 6px;
  color: #fff;
  background: var(--title-color);
  background: linear-gradient(100deg, var(--title-color) 0%, color-mix(in srgb, var(--title-color) 76%, #111 24%) 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .4);
  filter: brightness(.8) saturate(.8);
  text-align: left;
  cursor: pointer;
  transform: skewX(-10deg);
  transform-origin: 50% 50%;
  transition: transform .12s, box-shadow .12s, filter .12s;
}

#titleScreen .titleButton > span {
  display: block;
  color: #fff;
  font: 950 italic clamp(29px, 3.1vw, 42px)/.96 Arial, sans-serif !important;
  letter-spacing: clamp(1px, .24vw, 3px) !important;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .55);
}

#titleScreen .titleButton > small {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, .88);
  font: 800 clamp(9px, .95vw, 13px)/1.15 Arial, sans-serif !important;
  letter-spacing: clamp(.6px, .16vw, 2px) !important;
}

#titleScreen .titleButton.is-selected {
  z-index: 1;
  filter: brightness(1.18) saturate(1.15);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .55), 0 0 22px rgba(255, 255, 255, .22);
  transform: skewX(-10deg) translateX(clamp(8px, 1.5vw, 20px)) scale(1.025);
}

#titleScreen .titleButton:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

#titleScreen .titleHint {
  position: static !important;
  inset: auto !important;
  max-width: min(100%, 720px) !important;
  color: #cdd6e0;
  font: 800 clamp(10px, 1vw, 14px)/1.3 Arial, sans-serif !important;
  text-align: left !important;
}

#titleScreen .titleHint b { color: #fff; }

/* The old compact rule started at 500px, leaving the common 501-720px range
   exposed. Keep all mode counts compact through laptop-height viewports. */
@media (max-height: 780px) {
  #titleScreen {
    gap: 6px !important;
    padding: max(10px, env(safe-area-inset-top)) clamp(18px, 5vw, 68px) max(9px, env(safe-area-inset-bottom)) !important;
  }

  #titleScreen .gameTitle { font-size: clamp(34px, 7vh, 52px) !important; }
  #titleScreen .gameTitle > div { margin-top: 3px !important; font-size: 9px !important; letter-spacing: 3px !important; }
  #titleScreen .titleMenu { gap: 5px; padding-top: 4px; padding-bottom: 4px; }
  #titleScreen .titleButton { min-height: 0; padding: 6px 20px !important; }
  #titleScreen .titleButton > span { font-size: clamp(24px, 5vh, 32px) !important; }
  #titleScreen .titleButton > small { margin-top: 3px; font-size: 8px !important; letter-spacing: .8px !important; }
  #titleScreen .titleHint { font-size: 10px !important; }
}

@media (max-width: 640px) {
  #titleScreen {
    padding-right: max(12px, env(safe-area-inset-right)) !important;
    padding-left: max(12px, env(safe-area-inset-left)) !important;
  }

  #titleScreen .gameTitle {
    font-size: clamp(34px, 11vw, 52px) !important;
    letter-spacing: 1px !important;
  }

  #titleScreen .titleMenu {
    width: 100%;
    margin-left: 0;
    padding-right: 24px;
    padding-left: 4px;
  }

  #titleScreen .titleButton > span { font-size: clamp(25px, 8vw, 36px) !important; }
  #titleScreen .titleButton > small { white-space: normal; }
  #titleScreen .titleButton.is-selected { transform: skewX(-10deg) translateX(6px) scale(1.012); }
  #titleScreen .titleHint { max-width: 100% !important; text-align: center !important; }
}

/* ---- shared motion ------------------------------------------------------ */

@keyframes select-grid-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes select-hand-idle {
  0%, 100% { transform: translate(-50%, -77%) rotate(-8deg) translateY(0); }
  50% { transform: translate(-50%, -77%) rotate(-5deg) translateY(-5px); }
}

@keyframes select-hand-lock {
  0% { transform: translate(-50%, -77%) rotate(-7deg) scale(1.2); }
  48% { transform: translate(-50%, -69%) rotate(3deg) scale(.86); }
  72% { transform: translate(-50%, -75%) rotate(-2deg) scale(1.06); }
  100% { transform: translate(-50%, -77%) rotate(0) scale(.98); }
}

@keyframes selected-edge-pulse {
  0%, 100% { opacity: .48; }
  50% { opacity: .9; }
}

/* ---- fighter select shell --------------------------------------------- */

#select {
  isolation: isolate;
  box-sizing: border-box;
  display: flex;
  min-height: 0;
  color: #fff;
  background:
    linear-gradient(112deg, rgba(0, 0, 0, .05) 0 66%, rgba(0, 0, 0, .46) 66.1% 100%),
    radial-gradient(circle at 84% 38%, rgba(255, 255, 255, .12), transparent 24%),
    linear-gradient(135deg, rgba(112, 9, 18, .88), rgba(20, 9, 16, .9) 38%, rgba(5, 7, 14, .96) 72%);
}

/* On a wide screen the right third is the live fighter showcase. Keep that
   lane genuinely transparent so the Three.js render remains bright and fully
   readable; compact/tall layouts use the opaque base treatment above. */
@media (min-width: 1100px) and (min-height: 540px) and (min-aspect-ratio: 3 / 2) {
  #select {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, .04) 0 69%, rgba(0, 0, 0, .12) 69.1% 100%),
      radial-gradient(circle at 84% 42%, rgba(255, 255, 255, .045), transparent 25%),
      linear-gradient(105deg, rgba(112, 9, 18, .9) 0, rgba(20, 9, 16, .9) 51%, rgba(7, 8, 14, .62) 66%, rgba(5, 7, 14, .08) 72% 100%);
  }
  body:not(.party-mode) #partyPlayers,
  body:not(.party-mode) #selInfo {
    width: min(70vw, 990px);
    margin-left: clamp(12px, 2.4vw, 40px);
    margin-right: auto;
  }
  body:not(.party-mode) #selInfo { align-self: flex-start; box-sizing: border-box; }
}

#select::before {
  content: '';
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: .42;
  background:
    repeating-linear-gradient(118deg, transparent 0 64px, rgba(255, 255, 255, .025) 65px 67px, transparent 68px 132px),
    linear-gradient(105deg, rgba(239, 51, 64, .92) 0 8px, transparent 8px);
  mask-image: linear-gradient(90deg, #000, rgba(0, 0, 0, .72) 72%, transparent);
}

#select::after {
  content: '';
  position: fixed;
  z-index: -1;
  right: -12vw;
  bottom: -42vh;
  width: 62vw;
  aspect-ratio: 1;
  border: clamp(28px, 6vw, 90px) solid rgba(255, 255, 255, .026);
  border-radius: 50%;
  transform: rotate(-16deg);
  pointer-events: none;
}

.selectHeader {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 90px;
  padding: max(14px, env(safe-area-inset-top)) clamp(18px, 3.2vw, 52px) 10px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: linear-gradient(90deg, rgba(4, 5, 10, .74), rgba(4, 5, 10, .28) 72%, transparent);
}

.selectHeadingLockup {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 13px;
  align-items: end;
}

.selectStep {
  grid-row: 1 / 3;
  align-self: stretch;
  display: grid;
  place-items: center;
  width: 52px;
  min-height: 58px;
  color: #fff;
  background: linear-gradient(145deg, #ff5963, var(--select-red-dark));
  border: 1px solid rgba(255, 255, 255, .6);
  clip-path: polygon(14% 0, 100% 0, 86% 100%, 0 100%);
  font: 950 italic 25px/1 Arial, sans-serif;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .36);
}

.selectEyebrow {
  align-self: end;
  color: var(--select-gold);
  font: 900 11px/1 Arial, sans-serif;
  letter-spacing: 4px;
}

#select .selectHeader h1 {
  grid-column: 2;
  margin: 4px 0 0;
  color: #fff;
  font: 950 italic clamp(29px, 3.6vw, 55px)/.88 Arial, sans-serif;
  letter-spacing: clamp(1px, .22vw, 4px);
  text-align: left;
  transform: skewX(-8deg);
  text-shadow: 0 4px 0 #000, 0 0 24px rgba(239, 51, 64, .34);
}

.selectHeaderMeta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  padding-bottom: 2px;
}

#selectPhase {
  color: #fff;
  font: 950 italic 13px/1 Arial, sans-serif;
  letter-spacing: 1.8px;
}

.selectNavLegend {
  color: #9da6b8;
  font: 800 10px/1 Arial, sans-serif;
  letter-spacing: 1.3px;
  white-space: nowrap;
}

.selectNavLegend b {
  display: inline-grid;
  min-width: 19px;
  min-height: 19px;
  margin: 0 2px 0 8px;
  padding: 0 4px;
  place-items: center;
  box-sizing: border-box;
  border-radius: 4px;
  color: #12131a;
  background: #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .45);
  font-size: 9px;
}

#partyFormatBar {
  z-index: 7;
  margin-top: 7px;
}

/* ---- roster ------------------------------------------------------------ */

#roster {
  position: relative;
  z-index: 4;
  flex: 1 1 auto;
  width: min(70vw, 990px);
  min-height: 0;
  margin: 0 auto 0 clamp(12px, 2.4vw, 40px);
  padding: clamp(14px, 2vh, 22px) clamp(12px, 1.5vw, 24px) 26px;
  display: grid;
  grid-template-columns: repeat(6, minmax(86px, 1fr));
  grid-auto-rows: minmax(108px, 1fr);
  gap: clamp(6px, .75vw, 11px);
  /* `center` places overflow above scrollTop=0 on compact screens, making the
     first roster rows impossible to reach. Start alignment keeps every card in
     the scroll range while the shell itself still centers the grid. */
  align-content: start;
  justify-content: stretch;
  overflow: auto;
  box-sizing: border-box;
  animation: select-grid-in .36s cubic-bezier(.18, .8, .22, 1) both;
}

.char {
  --fighter: #fff;
  position: relative;
  isolation: isolate;
  min-width: 0;
  width: 100%;
  min-height: 108px;
  padding: 0;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 4px;
  background: linear-gradient(145deg, rgba(41, 44, 55, .96), rgba(10, 11, 17, .98));
  box-shadow: 0 7px 16px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .09);
  cursor: pointer;
  transform: none;
  transition: transform .14s cubic-bezier(.2, .8, .2, 1), border-color .14s, filter .14s, box-shadow .14s;
}

.char::before {
  content: '';
  position: absolute;
  z-index: 4;
  inset: -3px;
  border: 3px solid transparent;
  border-radius: 6px;
  pointer-events: none;
  transition: border-color .12s, box-shadow .12s;
}

.char::after {
  content: '';
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--fighter);
  box-shadow: 0 0 12px color-mix(in srgb, var(--fighter) 72%, transparent);
  pointer-events: none;
}

.char:hover,
.char:focus-visible {
  z-index: 8;
  filter: brightness(1.13) saturate(1.08);
  transform: translateY(-3px) scale(1.025);
  outline: none;
}

.char:is(.cur1, .cur2, .cur3, .cur4) {
  z-index: 7;
  transform: translateY(-4px) scale(1.035);
  filter: brightness(1.14) saturate(1.12);
  border-color: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .58), 0 0 0 2px rgba(255, 255, 255, .28);
}

.char:is(.cur1, .cur2, .cur3, .cur4)::before {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--fighter), 0 0 16px color-mix(in srgb, var(--fighter) 60%, transparent);
  animation: selected-edge-pulse 1.35s ease-in-out infinite;
}

.char .swatch {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background-color: #171923;
  background-position: center 24%;
  background-size: cover;
  overflow: hidden;
  box-shadow: none !important;
  filter: contrast(1.04) saturate(.95);
}

.char .swatch::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 34%, rgba(5, 6, 10, .12) 52%, rgba(5, 6, 10, .94) 100%),
    linear-gradient(115deg, color-mix(in srgb, var(--fighter) 20%, transparent), transparent 50%);
  pointer-events: none;
}

.char .portraitFallback {
  z-index: 0;
  align-items: center;
  padding: 0 10px 22px;
  font-size: 12px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--fighter) 65%, #fff), #11131c 78%);
}

.char .portrait-instant .portraitFallback,
.char .portrait-ready .portraitFallback { opacity: 0; }

.char .portrait-loading::before,
.char .portrait-loading::after {
  opacity: .72;
  transform: translateX(50%);
}

.charNumber {
  position: absolute;
  z-index: 5;
  top: 5px;
  left: 6px;
  color: rgba(255, 255, 255, .72);
  font: 900 italic 10px/1 Arial, sans-serif;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
}

.charCaption {
  position: absolute;
  z-index: 4;
  left: 7px;
  right: 7px;
  bottom: 8px;
  min-width: 0;
  pointer-events: none;
  text-align: left;
  transform: skewX(-5deg);
}

.char .cname {
  overflow: hidden;
  color: #fff;
  font: 950 italic clamp(11px, 1vw, 15px)/.96 'Arial Narrow', Arial, sans-serif;
  letter-spacing: .15px;
  text-overflow: clip;
  text-shadow: 0 2px 2px #000, 0 0 8px #000;
  white-space: normal;
  overflow-wrap: anywhere;
}

.char .ctitle {
  display: none;
}

.char .bars,
.char .v2badge {
  display: none !important;
}

.char .tag {
  z-index: 12;
  top: -13px;
  min-width: 28px;
  padding: 4px 8px;
  box-sizing: border-box;
  border: 2px solid #fff;
  border-radius: 3px;
  font: 950 italic 10px/1 Arial, sans-serif;
  letter-spacing: .5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
}

.char .tagP1 { left: -5px; background: var(--port1, #d8383e); }
.char .tagP2 { right: -5px; background: var(--port2, #3a6fd8); }
.char .tagP3 { left: -5px; bottom: -13px; }
.char .tagP4 { right: -5px; bottom: -13px; }

.char .ready {
  z-index: 11;
  left: 50%;
  bottom: 4px;
  width: calc(100% - 10px);
  padding: 4px 2px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 2px;
  color: #081009;
  background: linear-gradient(90deg, #5ee47d, #baff85);
  box-shadow: 0 0 18px rgba(74, 238, 112, .7);
  font: 950 italic 10px/1 Arial, sans-serif;
  letter-spacing: 2px;
}

/* ---- floating glove cursors ------------------------------------------- */

.selectHandLayer {
  position: fixed;
  z-index: 21;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.selectHand {
  --hand-color: #ff5b62;
  position: fixed;
  left: -200px;
  top: -200px;
  width: var(--hand-width, clamp(52px, 4.5vw, 65px));
  aspect-ratio: 271 / 512;
  opacity: 0;
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, .7));
  transform-origin: 50% 65%;
  transition: left .16s cubic-bezier(.16, .86, .22, 1), top .16s cubic-bezier(.16, .86, .22, 1), opacity .1s;
  animation: select-hand-idle 1.05s ease-in-out infinite;
  will-change: auto;
}

.selectHand.is-visible { opacity: .8; will-change: left, top, transform; }
.selectHand.is-visible.is-active,
.selectHand.is-visible.is-locked { opacity: 1; }
.selectHand.is-locked { animation: select-hand-lock .28s cubic-bezier(.18, .82, .24, 1) both; }
.selectHand.is-locked .handPoint { opacity: 1; }

.selectHand svg,
.selectHandSprite {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  overflow: visible;
  user-select: none;
}

.selectHand .handPoint,
.selectHand .handGrab {
  transition: opacity .08s;
}

.selectHand .handGrab { opacity: 0; }
.selectHand .gloveOutline { fill: #171922; stroke: #06070a; stroke-width: 6; stroke-linejoin: round; }
.selectHand .gloveBody { fill: url(#selectGloveFill); stroke: rgba(255, 255, 255, .7); stroke-width: 1.4; }
.selectHand .glovePiece { stroke: #08090d; stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.selectHand .gloveShade { fill: none; stroke: rgba(87, 93, 111, .58); stroke-width: 4; stroke-linecap: round; }
.selectHand .gloveCuff { fill: var(--hand-color); stroke: #fff; stroke-width: 3; }

.handBadge {
  position: absolute;
  z-index: 3;
  right: -2px;
  top: 4px;
  display: grid;
  place-items: center;
  min-width: 27px;
  height: 21px;
  padding: 0 5px;
  box-sizing: border-box;
  border: 2px solid #fff;
  border-radius: 4px;
  color: #fff;
  background: var(--hand-color);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .48);
  font: 950 italic 10px/1 Arial, sans-serif;
  letter-spacing: .5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.selectHand[data-slot="2"] .handBadge { color: #221900; text-shadow: none; }
.selectHand[data-slot="1"] .selectHandSprite { filter: hue-rotate(218deg) saturate(1.08); }
.selectHand[data-slot="2"] .selectHandSprite { filter: hue-rotate(48deg) saturate(1.05); }
.selectHand[data-slot="3"] .selectHandSprite { filter: hue-rotate(118deg) saturate(1.05); }

/* ---- right-side fighter preview plate -------------------------------- */

#fighterPreviewLabel {
  display: block;
  position: fixed;
  z-index: 5;
  top: clamp(96px, 14vh, 132px);
  right: clamp(18px, 3vw, 48px);
  bottom: auto;
  width: min(26vw, 360px);
  padding: 9px 15px 8px 20px;
  box-sizing: border-box;
  border-left: 5px solid var(--select-red);
  border-bottom: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  background: linear-gradient(90deg, rgba(5, 6, 11, .9), rgba(5, 6, 11, .35));
  overflow: hidden;
  font: 950 italic clamp(20px, 2.1vw, 32px)/.95 Arial, sans-serif;
  letter-spacing: 1.2px;
  text-align: left;
  text-shadow: 0 3px 0 #000;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform: skewX(-5deg);
}

#fighterPreviewLabel::before {
  content: 'NOW HOVERING';
  display: block;
  margin-bottom: 5px;
  color: var(--select-gold);
  font: 900 8px/1 Arial, sans-serif;
  letter-spacing: 2.5px;
  text-shadow: none;
}

#fighterPreviewLabel small {
  display: block;
  margin-top: 6px;
  color: #bac4d6;
  font: 800 11px/1.4 'Segoe UI', Arial, sans-serif;
  letter-spacing: .8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: none;
  transform: skewX(5deg);
}

/* ---- footer / setup ---------------------------------------------------- */

#selInfo {
  position: relative;
  z-index: 23;
  flex: 0 0 auto;
  padding: 0 clamp(12px, 2.4vw, 36px) max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, .16);
  color: #c7cfdd;
  background: linear-gradient(180deg, rgba(7, 8, 13, .84), rgba(2, 3, 7, .98));
  box-shadow: 0 -12px 32px rgba(0, 0, 0, .35);
  font-size: 11px;
  line-height: 1.3;
}

.selectCommandBar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 30px);
  min-height: 35px;
  margin: 0 calc(clamp(12px, 2.4vw, 36px) * -1) 7px;
  padding: 4px 16px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
}

.selectCommandBar > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.selectCommandBar kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 50%;
  color: #14151a;
  background: #f5f7fb;
  box-shadow: 0 2px 0 #747a88;
  font: 950 9px/1 Arial, sans-serif;
}

.selectCommandBar kbd:not(.keyA):not(.keyB) { border-radius: 5px; }
.selectCommandBar .keyA { color: #05210c; background: #76e990; }
.selectCommandBar .keyB { color: #29090a; background: #ff777d; }
.selectCommandBar strong { color: #dce2ec; font-size: 8px; letter-spacing: 1.2px; }
.selectCommandBar strong { font-size: 10px; }

.singlesSetup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 39px;
}

.cpuSetupBlock {
  display: flex;
  align-items: center;
  gap: 7px;
}

.setupLabel {
  color: #98a3b5;
  font: 900 10px/1 Arial, sans-serif;
  letter-spacing: 1.5px;
  white-space: nowrap;
}

.cpuControls {
  min-height: 32px;
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .045);
}

.cpuControls button {
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
  background: #20232d;
  cursor: pointer;
}

.cpuControls #cpulvl { min-width: 66px; color: var(--select-gold); font-size: 12px; }
#p1cpu { width: auto; min-width: 69px; padding: 0 10px; border-radius: 14px; font-size: 9px; }
.selectSetupCopy { max-width: 620px; margin: 0; color: #aab3c1; font-size: 11px; line-height: 1.35; text-align: left; }

#costumeControls { margin: 0 auto 4px; }
.costumeChip { min-height: 34px; border-radius: 4px; background: rgba(255, 255, 255, .05); }
.costumeChip button { width: 30px; height: 30px; border-radius: 3px; }

#padStatus:empty,
#wizPrompt:empty { display: none; }

#padStatus {
  max-height: 28px;
  margin-top: 3px;
  overflow: hidden;
  color: #8393a9 !important;
  font-size: 9px !important;
  line-height: 1.35 !important;
}

.setupBtns {
  gap: 5px;
  margin-top: 4px;
}

#selInfo .setupBtns button {
  min-height: 28px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 4px;
  color: #aeb7c7;
  background: rgba(255, 255, 255, .045);
  font: 850 10px/1 Arial, sans-serif;
  letter-spacing: .7px;
}

#selInfo .setupBtns button:hover,
#selInfo .setupBtns button:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, .62);
  background: rgba(255, 255, 255, .11);
}

#rulesBtn { color: var(--select-gold) !important; border-color: rgba(255, 216, 106, .5) !important; }

/* Singles mirrors Ultimate's two-player dock: both choices remain visible even
   while the floating hand is working elsewhere in the roster. */
#partyPlayers {
  position: relative;
  z-index: 22;
  flex: 0 0 auto;
  width: min(920px, calc(100% - 28px));
  margin: 0 auto 7px;
  padding: 0;
  gap: 10px;
}

body:not(.party-mode) #partyPlayers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body:not(.party-mode) #partyPlayers .partyPlayer:nth-child(n + 3) { display: none; }
body:not(.party-mode) .singlesSetup { display: none; }

#partyPlayers .partyPlayer {
  grid-template-columns: 58px minmax(0, 1fr) auto;
  min-height: 66px;
  padding: 5px 8px 5px 5px;
  border-radius: 5px;
}

#partyPlayers .partyPort {
  position: relative;
  width: 54px;
  height: 54px;
  border: 2px solid var(--port);
  border-radius: 4px;
  background-color: #11131b;
  background-position: center 24%;
  background-size: cover;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 255, 255, .2);
  color: transparent;
  font-size: 0;
}

#partyPlayers .partyPort::after {
  content: attr(data-label);
  position: absolute;
  left: 3px;
  bottom: 3px;
  min-width: 25px;
  padding: 3px 4px;
  border: 1px solid #fff;
  border-radius: 2px;
  color: #fff;
  background: var(--port);
  font: 950 italic 9px/1 Arial, sans-serif;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .65);
}

#partyPlayers .partyPlayer[data-player-slot="2"] .partyPort::after { color: #211900; text-shadow: none; }

#partyPlayers .partyFighter { font-size: 15px; letter-spacing: .7px; }
#partyPlayers .partyState { font-size: 10px; line-height: 1.2; letter-spacing: .8px; }
#partyPlayers .partyPlayer button { min-width: 38px; height: 34px; font-size: 10px; }
#partyPlayers .partyPlayer .partyControls { width: 34px; font-size: 15px; }
#partyPlayers .partyPlayer.is-ready::before { top: 6px; font-size: 9px; letter-spacing: 1.5px; }
#partyPlayers .partyPlayer.is-open { opacity: .9; border-style: dashed; }

.cpuDifficultyDock {
  display: grid;
  grid-template-columns: minmax(92px, 130px) auto;
  align-items: center;
  gap: 2px 8px;
  min-width: 138px;
  padding: 4px 7px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 4px;
  background: rgba(0, 0, 0, .3);
}

.cpuDifficultyDock[hidden] { display: none; }
.cpuDifficultyDock span { grid-column: 1; color: #d7ddea; font: 900 11px/1 Arial, sans-serif; letter-spacing: 1.1px; }
.cpuDifficultyDock output { grid-column: 2; grid-row: 1 / 3; min-width: 39px; color: var(--select-gold); font: 950 italic 15px/1 Arial, sans-serif; text-align: center; }

.cpuDifficultyDock input[type="range"] {
  grid-column: 1;
  width: 100%;
  height: 30px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: none;
  cursor: ew-resize;
  background: transparent;
}

.cpuDifficultyDock input[type="range"]::-webkit-slider-runnable-track {
  height: 7px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 2px;
  background: linear-gradient(90deg, #ef3340 0 var(--cpu-progress, 25%), #282c37 var(--cpu-progress, 25%) 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .55);
}

.cpuDifficultyDock input[type="range"]::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: -9px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ef3340;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .55);
}

.cpuDifficultyDock input[type="range"]::-moz-range-track { height: 7px; border: 1px solid rgba(255, 255, 255, .45); border-radius: 2px; background: #282c37; }
.cpuDifficultyDock input[type="range"]::-moz-range-progress { height: 7px; background: #ef3340; }
.cpuDifficultyDock input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; background: #ef3340; }
.cpuDifficultyDock input[type="range"]:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---- party select compatibility --------------------------------------- */

body.party-mode #roster {
  width: min(94vw, 1100px);
  margin-inline: auto;
  grid-template-columns: repeat(7, minmax(82px, 1fr));
  grid-auto-rows: minmax(96px, 1fr);
  padding-block: 11px 16px;
}

body.party-mode .char { min-height: 96px; }
body.party-mode .char:is(.cur1, .cur2, .cur3, .cur4) { transform: translateY(-3px) scale(1.025); }
body.party-mode .char:is(.cur1, .cur2, .cur3, .cur4) .swatch { box-shadow: none !important; }
body.party-mode #fighterPreviewLabel { display: none; }
body.party-mode .selectHeader { min-height: 73px; padding-top: 9px; }
body.party-mode #select .selectHeader h1 { font-size: clamp(26px, 3vw, 42px); }
body.party-mode #partyPlayers { margin-bottom: 5px; }

/* ---- stage select shell ------------------------------------------------ */

#stageSelect {
  --stage-accent: #ffd86a;
  isolation: isolate;
  box-sizing: border-box;
  justify-content: flex-start !important;
  padding: 0 !important;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 80% 16%, rgba(239, 51, 64, .24), transparent 30%),
    linear-gradient(145deg, rgba(39, 8, 14, .97), rgba(7, 8, 15, .985) 52%, rgba(8, 13, 24, .985));
}

#stageSelect::before {
  content: '';
  position: fixed;
  z-index: -1;
  inset: 0;
  opacity: .35;
  background: repeating-linear-gradient(120deg, transparent 0 70px, rgba(255, 255, 255, .035) 71px 73px, transparent 74px 144px);
  pointer-events: none;
}

.stageHeader {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(200px, 33vw);
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 82px;
  padding: max(12px, env(safe-area-inset-top)) clamp(16px, 3vw, 44px) 10px;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  background: linear-gradient(90deg, rgba(4, 5, 10, .82), rgba(4, 5, 10, .25));
}

.stageStep {
  display: grid;
  place-items: center;
  width: 50px;
  height: 56px;
  color: #191108;
  background: linear-gradient(145deg, #fff2a1, #e5a632);
  clip-path: polygon(14% 0, 100% 0, 86% 100%, 0 100%);
  font: 950 italic 24px/1 Arial, sans-serif;
  box-shadow: 0 7px 18px rgba(0, 0, 0, .4);
}

.stageTitleLockup { min-width: 0; }
.stageEyebrow { color: var(--select-gold); font: 900 11px/1 Arial, sans-serif; letter-spacing: 3.2px; }

#stageSelect .stageTitle {
  margin: 4px 0 0;
  color: #fff;
  font: 950 italic clamp(28px, 3.6vw, 51px)/.88 Arial, sans-serif;
  letter-spacing: 2px;
  transform: skewX(-8deg);
  text-shadow: 0 4px 0 #000, 0 0 20px rgba(239, 51, 64, .32);
}

.stageCurrent {
  min-width: 0;
  padding: 9px 12px 9px 16px;
  border-left: 4px solid var(--stage-accent);
  background: linear-gradient(90deg, rgba(255, 255, 255, .08), transparent);
}

.stageCurrent small {
  display: block;
  color: #929daf;
  font: 900 10px/1 Arial, sans-serif;
  letter-spacing: 2px;
}

.stageCurrent b,
.stageCurrent span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stageCurrent b { margin-top: 4px; color: #fff; font: 950 italic 17px/1 Arial, sans-serif; letter-spacing: .8px; }
.stageCurrent span { margin-top: 3px; color: var(--stage-accent); font: 800 11px/1 Arial, sans-serif; letter-spacing: .8px; }

#stageSelect .partyMatchup { flex: 0 0 auto; margin: 7px auto 0; }

.stageGridShell {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: 10px clamp(16px, 3.3vw, 52px) 8px;
  box-sizing: border-box;
}

.stageGridLabel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-height: 25px;
  color: #8791a2;
  font: 850 10px/1 Arial, sans-serif;
  letter-spacing: 1.6px;
}

.stageGridLabel strong { color: #e8edf5; font-size: 11px; }

#stageRow {
  flex: 1 1 auto;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  grid-auto-rows: minmax(132px, 1fr);
  gap: clamp(8px, 1vw, 15px) !important;
  width: 100%;
  max-width: 1320px;
  max-height: none;
  min-height: 0;
  margin: 0 auto;
  padding: 4px 5px 12px;
  overflow: auto;
  box-sizing: border-box;
  scroll-snap-type: none;
  animation: select-grid-in .3s ease-out both;
}

#stageRow > .stageCard {
  --stage-card-color: #ffd86a;
  position: relative;
  isolation: isolate;
  width: auto;
  min-width: 0;
  min-height: 132px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 5px;
  background: #0b0c12;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .52), inset 0 1px 0 rgba(255, 255, 255, .08);
  cursor: pointer;
  transform: none;
  transition: transform .14s cubic-bezier(.2, .8, .2, 1), border-color .14s, filter .14s, box-shadow .14s;
  scroll-snap-align: none;
}

#stageRow > .stageCard::before {
  content: '';
  position: absolute;
  z-index: 4;
  inset: -1px;
  border: 4px solid transparent;
  pointer-events: none;
}

#stageRow > .stageCard::after {
  content: '';
  position: absolute;
  z-index: 5;
  left: -32%;
  top: -80%;
  width: 35%;
  height: 260%;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .38), transparent);
  transform: rotate(22deg);
  transition: left .42s ease, opacity .12s;
  pointer-events: none;
}

#stageRow > .stageCard:hover,
#stageRow > .stageCard:focus-visible {
  z-index: 3;
  filter: brightness(1.12) saturate(1.08);
  transform: translateY(-3px) scale(1.015);
  outline: none;
}

#stageRow > .stageCard.is-selected {
  z-index: 4;
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--stage-accent), 0 12px 28px rgba(0, 0, 0, .66), 0 0 22px color-mix(in srgb, var(--stage-accent) 45%, transparent);
  transform: translateY(-5px) scale(1.02);
  filter: brightness(1.13) saturate(1.1);
}

#stageRow > .stageCard.is-selected::before { border-color: rgba(255, 255, 255, .72); }
#stageRow > .stageCard.is-selected::after { left: 120%; opacity: .8; }

.stageThumb {
  position: absolute;
  z-index: 0;
  inset: 0;
  height: auto !important;
  background-position: center;
  background-size: cover;
  filter: saturate(.9) contrast(1.05);
  transition: transform .35s ease, filter .15s;
}

.stageCard:hover .stageThumb,
.stageCard.is-selected .stageThumb { transform: scale(1.045); filter: saturate(1.08) contrast(1.06); }

.stageThumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 5, 9, .02) 20%, rgba(4, 5, 9, .18) 48%, rgba(4, 5, 9, .97) 100%);
}

.stageInfo {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 12px 10px;
  box-sizing: border-box;
  text-align: left;
  background: none !important;
  transform: skewX(-4deg);
}

.stageIndex {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 18px;
  margin-right: 6px;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, .62);
  color: #11131a;
  background: var(--stage-accent);
  font: 950 10px/1 Arial, sans-serif;
  vertical-align: 3px;
}

.stageName {
  display: inline;
  color: #fff;
  font: 950 italic clamp(15px, 1.45vw, 21px)/1 Arial, sans-serif;
  letter-spacing: .7px;
  text-shadow: 0 2px 2px #000;
}

.stageSubtitle {
  margin: 4px 0 0 32px;
  overflow: hidden;
  color: var(--stage-accent);
  font: 800 11px/1 Arial, sans-serif;
  letter-spacing: .8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stageBottom {
  position: relative;
  z-index: 8;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 42px);
  width: 100%;
  min-height: 68px;
  padding: 7px clamp(14px, 3vw, 42px) max(8px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  border-top: 1px solid rgba(255, 255, 255, .12);
  background: linear-gradient(180deg, rgba(8, 9, 15, .82), rgba(2, 3, 7, .98));
  box-shadow: 0 -10px 26px rgba(0, 0, 0, .26);
}

#stageSelect .rulesBar { flex: 0 1 auto; margin: 0; gap: 8px; }
#stageSelect .ruleChip { padding: 4px 6px 4px 11px; border-radius: 5px; background: rgba(255, 255, 255, .055); }
#stageSelect .ruleChip .ruleLbl { font-size: 9px; letter-spacing: 1.3px; }
#stageSelect .ruleChip .ruleLbl { font-size: 11px; }
#stageSelect .ruleChip b { min-width: 57px; font-size: 17px; }
#stageSelect .ruleStep { width: 29px; height: 29px; border-radius: 3px; font-size: 16px; }

#stageSelect .stageActions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 480px);
  margin: 0;
}

#stageSelect .stageActions span {
  color: #929bad;
  font: 850 10px/1.2 Arial, sans-serif;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
}

#stageSelect .stageActions button {
  min-width: 105px;
  min-height: 42px;
  padding: 7px 15px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 4px;
  font: 950 italic 14px/1 Arial, sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  transform: skewX(-6deg);
  transition: transform .1s, filter .1s, box-shadow .1s;
}

#stageSelect .stageActions button:hover,
#stageSelect .stageActions button:focus-visible { filter: brightness(1.16); transform: skewX(-6deg) translateY(-2px); outline: 2px solid #fff; outline-offset: 2px; }
#stageSelect #stageBack { color: #d8deea; background: #232734; border-color: rgba(255, 255, 255, .36); }
#stageSelect #stageFight { min-width: 132px; color: #220e09; background: linear-gradient(135deg, #ff745f, #ef3340); border-color: #fff; box-shadow: 0 6px 18px rgba(239, 51, 64, .35); }
#stageSelect #stageFight:disabled { filter: grayscale(.75); opacity: .5; cursor: not-allowed; }
#stageSelect.is-loading .stageCard,
#stageSelect.is-loading .ruleStep,
#stageSelect.is-loading #stageBack { pointer-events: none; filter: grayscale(.55) brightness(.72); }

/* ---- responsive fighter select ---------------------------------------- */

@media (max-width: 1099px) {
  #roster {
    width: calc(100% - 28px);
    margin-inline: auto;
    grid-template-columns: repeat(6, minmax(78px, 1fr));
  }

  #fighterPreviewLabel { display: none; }
}

@media (max-width: 820px) {
  .selectHeader { min-height: 74px; padding: max(9px, env(safe-area-inset-top)) 15px 8px; }
  .selectStep { width: 42px; min-height: 49px; font-size: 20px; }
  .selectEyebrow { font-size: 10px; letter-spacing: 2.5px; }
  #select .selectHeader h1 { font-size: clamp(25px, 6.2vw, 38px); }
  .selectHeaderMeta { display: none; }
  #roster { grid-template-columns: repeat(4, minmax(76px, 1fr)); grid-auto-rows: minmax(100px, 1fr); padding: 12px 9px 22px; }
  .char { min-height: 100px; }
  body.party-mode #roster { grid-template-columns: repeat(4, minmax(72px, 1fr)); }
  .selectCommandBar { gap: 9px; }
  .selectCommandBar strong { display: inline; font-size: 10px; letter-spacing: .6px; }
  .singlesSetup { gap: 8px; }
  .selectSetupCopy { display: none; }
  .setupBtns { max-height: 33px; overflow: auto; flex-wrap: nowrap; justify-content: flex-start; scrollbar-width: none; }
  .setupBtns::-webkit-scrollbar { display: none; }

  .stageHeader { grid-template-columns: auto minmax(0, 1fr); min-height: 70px; padding: max(9px, env(safe-area-inset-top)) 15px 8px; }
  .stageStep { width: 42px; height: 48px; font-size: 20px; }
  .stageCurrent { display: none; }
  #stageRow { grid-template-columns: repeat(2, minmax(140px, 1fr)); grid-auto-rows: minmax(128px, 1fr); }
  .stageBottom { gap: 8px; padding-inline: 10px; }
  #stageSelect .rulesBar { display: none; }
  #stageSelect .stageActions { width: min(100%, 500px); }
}

@media (max-width: 700px) {
  body:not(.party-mode) #partyPlayers { grid-template-columns: 1fr; width: calc(100% - 18px); gap: 5px; }
  body:not(.party-mode) #partyPlayers .partyPlayer { min-height: 58px; }
  body:not(.party-mode) #partyPlayers .partyPort { width: 48px; height: 48px; }
  body:not(.party-mode) #partyPlayers .partyPlayer { grid-template-columns: 52px minmax(0, 1fr) auto; }
}

/* Compact landscape still has two side-by-side player pods. Put the shared CPU
   rail on a full row so fighter names never collapse to a single letter. */
@media (max-width: 900px), (max-height: 590px) {
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty {
    grid-template-columns: 52px minmax(0, 1fr);
  }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPort { grid-column: 1; grid-row: 1; }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPlayerMain { grid-column: 2; grid-row: 1; }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPodActions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    width: 100%;
  }
}

@media (max-width: 520px) {
  .selectHeader { min-height: 67px; }
  .selectStep { width: 38px; min-height: 44px; }
  #select .selectHeader h1 { font-size: clamp(22px, 7.5vw, 32px); letter-spacing: .5px; }
  #partyFormatBar { width: calc(100% - 12px); }
  .partyFormatLead { display: none; }
  .partyFormatBtn { min-height: 37px; padding: 5px 8px; }
  .partyFormatBtn span { font-size: 10px; }
  .partyFormatBtn small { display: none; }
  #roster,
  body.party-mode #roster {
    width: 100%;
    grid-template-columns: repeat(3, minmax(82px, 1fr));
    grid-auto-rows: minmax(98px, 1fr);
    gap: 6px;
    padding: 12px 9px 24px;
  }
  .char,
  body.party-mode .char { min-height: 98px; }
  .char .cname { font-size: 12px; }
  .selectHand { width: var(--hand-width, 52px); }
  #selInfo { padding-inline: 7px; }
  .selectCommandBar { justify-content: space-around; margin-inline: -7px; padding-inline: 5px; }
  .selectCommandBar > span:nth-child(3) { display: none; }
  .singlesSetup { min-height: 36px; }
  .setupLabel { display: none; }
  .cpuSetupBlock { gap: 4px; }
  .cpuControls #cpulvl { min-width: 56px; }
  #costumeControls { max-height: none; overflow: visible; flex-wrap: wrap; justify-content: center; gap: 5px; }
  .costumeChip { flex: 1 1 min(285px, 94vw); }
  .setupBtns { max-height: none; overflow: visible; flex-wrap: wrap; justify-content: center; }
  #selInfo .setupBtns button { min-height: 38px; font-size: 11px; }
  #padStatus { display: none; }
  #partyPlayers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body:not(.party-mode) #partyPlayers { grid-template-columns: 1fr; width: calc(100% - 14px); gap: 5px; }
  body:not(.party-mode) #partyPlayers .partyPlayer { min-height: 58px; }
  /* Give the draggable CPU rail its own row instead of squeezing the fighter
     name between a portrait and three controls on phone-width screens. */
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty {
    grid-template-columns: 52px minmax(0, 1fr);
  }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPort { grid-column: 1; grid-row: 1; }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPlayerMain { grid-column: 2; grid-row: 1; }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPodActions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    width: 100%;
  }
  .cpuDifficultyDock { grid-template-columns: minmax(82px, 1fr) auto; width: 100%; min-width: 0; }

  .stageGridShell { padding: 7px 9px 5px; }
  .stageGridLabel { padding-inline: 4px; }
  #stageRow { grid-template-columns: repeat(2, minmax(125px, 1fr)); gap: 8px !important; padding-bottom: 10px; }
  #stageRow > .stageCard { min-height: 120px; }
  .stageInfo { padding: 20px 8px 8px; }
  .stageIndex { display: none; }
  .stageName { font-size: 14px; }
  .stageSubtitle { margin-left: 0; font-size: 10px; }
  #stageSelect .stageActions { grid-template-columns: auto 1fr auto; min-width: 0; }
  #stageSelect .stageActions button { min-width: 84px; min-height: 42px; padding-inline: 9px; }
  #stageSelect #stageFight { min-width: 104px; }
  #stageSelect .stageActions span { font-size: 9px; }
}

/* The legacy party compact-height rule hides pod actions at 590px. Singles
   must retain the CPU slider at every height; the scrolling roster absorbs the
   reduced space without making the setting unreachable. */
@media (max-height: 590px) {
  body:not(.party-mode) .partyPodActions { display: flex; }
  body:not(.party-mode) #partyPlayers .partyPlayer.has-cpu-difficulty .partyPodActions { display: grid; }
  #stageSelect .rulesBar { display: none; }
  #stageSelect .stageBottom { justify-content: center; }
  #stageSelect .stageActions { grid-template-columns: auto auto; justify-content: center; width: auto; }
  #stageSelect .stageActions span { display: none; }
  #stageSelect #stageFight { grid-column: 2; }
}

/* Low-height desktop: protect gameplay setup controls without reverting to the
   old oversized two-row cards. */
@media (max-height: 720px) and (min-width: 821px) {
  .selectHeader { min-height: 67px; padding-top: 7px; padding-bottom: 6px; }
  .selectStep { min-height: 47px; width: 43px; font-size: 20px; }
  #select .selectHeader h1 { font-size: clamp(27px, 3.2vw, 40px); }
  #roster { grid-auto-rows: minmax(82px, 1fr); padding-block: 8px 14px; gap: 7px; }
  .char { min-height: 82px; }
  body.party-mode #roster { grid-auto-rows: minmax(76px, 1fr); }
  body.party-mode .char { min-height: 76px; }
  #fighterPreviewLabel { top: 76px; bottom: auto; }
  .selectCommandBar { min-height: 28px; margin-bottom: 3px; }
  .selectCommandBar kbd { min-width: 20px; height: 20px; }
  .singlesSetup { min-height: 32px; }
  .cpuControls { min-height: 27px; }
  .cpuControls button { width: 24px; height: 24px; }
  #p1cpu { width: auto; }
  #selInfo .setupBtns button { min-height: 24px; padding-block: 4px; }
  .stageHeader { min-height: 66px; padding-top: 7px; padding-bottom: 6px; }
  .stageStep { height: 45px; width: 42px; }
  #stageSelect .stageTitle { font-size: clamp(27px, 3vw, 40px); }
  .stageGridShell { padding-top: 6px; }
  #stageRow { grid-auto-rows: minmax(100px, 1fr); gap: 8px !important; }
  #stageRow > .stageCard { min-height: 100px; }
  .stageBottom { min-height: 58px; padding-block: 5px; }
}

@media (max-height: 500px) {
  .selectHeader { min-height: 55px; }
  #select .selectHeader h1 { font-size: 25px; }
  .selectStep { min-height: 38px; width: 35px; font-size: 17px; }
  #roster,
  body.party-mode #roster { grid-auto-rows: minmax(68px, 1fr); padding-block: 6px 10px; }
  .char,
  body.party-mode .char { min-height: 68px; }
  .charCaption { bottom: 5px; }
  .selectCommandBar { display: none; }
  .singlesSetup { min-height: 29px; }
  #padStatus { display: none; }
  .setupBtns { margin-top: 2px; }
  .stageHeader { min-height: 50px; }
  .stageStep { height: 36px; width: 34px; font-size: 16px; }
  #stageSelect .stageTitle { font-size: 25px; }
  .stageGridLabel { display: none; }
  #stageRow { grid-auto-rows: minmax(84px, 1fr); padding-top: 3px; }
  #stageRow > .stageCard { min-height: 84px; }
  .stageBottom { min-height: 47px; }
  #stageSelect .stageActions button { min-height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  #roster,
  #stageRow,
  .selectHand { animation: none !important; }
  .selectHand { transform: translate(-50%, -77%); }
  .char,
  .stageCard,
  .selectHand { transition-duration: .01ms !important; }
}
