:root {
  --bg: #080c18;
  --bg-elev: #0f162a;
  --bg-card: #131c34;
  --line: #263356;
  --line-bright: #3a4f82;
  --text: #f5f7fc;
  --muted: #9eb0d4;
  --gold: #ffd84a;
  --cyan: #48d0ff;
  --amber: #ff9a2e;
  --emerald: #5fd38a;
  --crimson: #ff5c6c;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-px: 'Press Start 2P', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

img.px, canvas#arenaCanvas, canvas#townCanvas, canvas#minigameCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden {
  display: none !important;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
}

/* ==================== SCREEN 1: WALKABLE HUB TOWN ==================== */
.hub-view.town-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(85% 55% at 50% 42%, #182a54 0%, #0a1022 65%, #070a14 100%);
  user-select: none;
  -webkit-user-select: none;
}

.hub-bar {
  flex: none;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 12, 24, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.hub-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 700;
  letter-spacing: -0.03em;
  flex: none;
}

.brand-glyph {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffd84a, #ff9a2e);
  color: #101422;
  font-size: 15px;
  box-shadow: 0 0 14px rgba(255, 216, 74, 0.35);
}

.brand-name b {
  color: var(--gold);
}

/* Active Partner Pill */
.partner-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  max-width: 190px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  border: 1px solid var(--line-bright);
  background: linear-gradient(180deg, #141f3c 0%, #0d1428 100%);
  text-align: left;
  transition: border-color 0.15s, transform 0.1s;
}

.partner-pill:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.partner-pill-pic {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0a1020;
  border: 1px solid var(--line-bright);
  object-fit: contain;
  flex: none;
}

.partner-pill-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.partner-pill-top {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11px;
  line-height: 1;
}

.partner-pill-top strong {
  font-family: var(--font-display);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.partner-pill-top em {
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  color: var(--gold);
  flex: none;
}

.mini-xp-track {
  display: block;
  width: 100%;
  min-width: 68px;
  height: 4px;
  border-radius: 999px;
  background: #1b2544;
  overflow: hidden;
}

.mini-xp-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.hub-bar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  display: grid;
  place-items: center;
  font-size: 16px;
  flex: none;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-bright);
  background: var(--bg-elev);
  font-size: 12px;
  font-weight: 700;
  max-width: 44vw;
}

.account-pill span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.account-pill.signed .acc-dot {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.account-pill.signed {
  border-color: rgba(95, 211, 138, 0.55);
  color: #dcffe9;
}

/* Town Canvas Viewport */
.town-viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  touch-action: none;
}

.town-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #0b1326;
  cursor: pointer;
  touch-action: none;
}

.town-hint-pill {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(9, 14, 28, 0.82);
  border: 1px solid rgba(72, 208, 255, 0.35);
  color: #cfe4ff;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.town-hint-pill span:first-child {
  color: var(--gold);
}

/* Hub Town Virtual Thumbstick */
.town-stick-wrap {
  position: absolute;
  left: max(12px, env(safe-area-inset-left, 0px));
  bottom: 14px;
  z-index: 12;
  display: none;
}

body.coarse .town-stick-wrap {
  display: block;
}

@media (max-width: 900px) {
  .town-stick-wrap {
    display: block;
  }
}

.vstick.town-vstick {
  width: 98px;
  height: 98px;
  opacity: 0.9;
}

.vstick.town-vstick .vstick-knob {
  width: 38px;
  height: 38px;
}

/* Dynamic Proximity Action Pill */
.town-action-pill {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid #fff0a8;
  background: linear-gradient(135deg, #ffd84a 0%, #ff9a2e 100%);
  color: #0e1320;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 28px rgba(255, 196, 56, 0.55), 0 0 0 4px rgba(255, 216, 74, 0.22);
  animation: pulseGold 0.7s ease-in-out infinite alternate;
  white-space: nowrap;
}

.tap-icon {
  font-size: 16px;
}

.tap-kbd {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(10, 14, 24, 0.2);
  border: 1px solid rgba(10, 14, 24, 0.35);
  font-size: 10px;
  font-weight: 800;
}

/* 4-Slot Quick-Warp Bottom Dock */
.town-dock {
  flex: none;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 12, 24, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: linear-gradient(180deg, #131d38 0%, #0c1224 100%);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}

.dock-btn:hover {
  border-color: var(--line-bright);
  transform: translateY(-1px);
}

.dock-btn:active {
  transform: scale(0.97);
}

.dock-btn.arena { border-color: rgba(255, 107, 74, 0.55); }
.dock-btn.mini { border-color: rgba(255, 216, 74, 0.55); }
.dock-btn.shrine { border-color: rgba(72, 208, 255, 0.55); }
.dock-btn.account { border-color: rgba(95, 211, 138, 0.55); }

.dock-btn.near {
  box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 216, 74, 0.4);
  background: linear-gradient(180deg, #212e54 0%, #111932 100%);
}

.dock-ic {
  font-size: 17px;
  line-height: 1;
}

.dock-txt {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.dock-txt em {
  font-style: normal;
  color: var(--cyan);
  font-size: 10px;
}

@media (max-width: 520px) {
  .brand-name {
    display: none;
  }

  .partner-pill {
    max-width: 148px;
  }

  .mini-xp-track {
    min-width: 48px;
  }

  .town-hint-pill {
    font-size: 10px;
    padding: 4px 10px;
  }

  .tap-kbd {
    display: none;
  }

  .town-action-pill {
    left: auto;
    right: 12px;
    transform: none;
    bottom: 24px;
    padding: 8px 13px;
    font-size: 12px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .hub-bar {
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .partner-pill, .icon-btn, .account-pill {
    min-height: 30px;
    height: 30px;
  }

  .partner-pill-pic {
    width: 22px;
    height: 22px;
  }

  .town-viewport {
    padding: 3px;
  }

  .town-hint-pill {
    top: 6px;
    font-size: 10px;
    padding: 3px 9px;
  }

  .vstick.town-vstick {
    width: 78px;
    height: 78px;
  }

  .vstick.town-vstick .vstick-knob {
    width: 30px;
    height: 30px;
  }

  .town-dock {
    padding-top: 5px;
    padding-bottom: max(5px, env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }

  .dock-btn {
    flex-direction: row;
    gap: 6px;
    min-height: 38px;
    padding: 4px 8px;
  }
}

/* ==================== SHARED MODAL OVERLAYS ==================== */
.pm-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  background: rgba(5, 8, 18, 0.8);
  backdrop-filter: blur(8px);
}

.pm-sheet {
  width: 100%;
  max-width: 960px;
  max-height: calc(100dvh - 20px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(180deg, #111932 0%, #0b1020 100%);
  border: 1.5px solid var(--line-bright);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.78);
  overflow: hidden;
}

.account-sheet { max-width: 820px; }
.mg-sheet { max-width: 880px; }
.shrine-sheet { max-width: 980px; }
.gate-sheet { max-width: 880px; }

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  background: rgba(9, 14, 28, 0.92);
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: clamp(18px, 3vw, 22px);
}

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  touch-action: pan-y;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 13px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.arena-note {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

/* Buttons */
.primary-cta {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffd84a 0%, #ffb02e 100%);
  color: #101422;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.03em;
  min-height: 44px;
  padding: 10px 20px;
  box-shadow: 0 6px 20px rgba(255, 216, 74, 0.3);
  transition: transform 0.1s, filter 0.15s;
}

.primary-cta:hover { filter: brightness(1.06); }
.primary-cta:active { transform: scale(0.98); }
.primary-cta.full { width: 100%; }
.primary-cta.sm { min-height: 36px; padding: 6px 13px; font-size: 12px; }

.sec-btn {
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  background: #141e38;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  min-height: 42px;
  padding: 8px 15px;
}

.sec-btn.sm { min-height: 34px; padding: 5px 11px; font-size: 12px; }
.sec-btn.danger { border-color: rgba(255, 92, 108, 0.55); color: #ffb8c0; background: rgba(255, 92, 108, 0.12); }
.sec-btn.full { width: 100%; }

.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  min-height: 40px;
  padding: 6px 12px;
}

.ghost-btn.sm { min-height: 30px; padding: 3px 10px; font-size: 12px; }

.dlg-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1122;
  font-size: 16px;
  flex: none;
}

.dlg-note {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.btn-row-2 {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
}

/* ==================== OVERLAY 1: TAMER HALL (MOCKED EMAIL LOGIN + LEADERBOARD) ==================== */
.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 720px) {
  .account-grid {
    grid-template-columns: 1fr;
  }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pm-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-bright);
  background: #080c18;
  color: var(--text);
}

.code-6-input {
  font-family: var(--font-px);
  font-size: 16px;
  letter-spacing: 5px;
  text-align: center;
  color: var(--gold);
}

.dev-inbox-box {
  padding: 11px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(95, 211, 138, 0.15) 0%, rgba(255, 216, 74, 0.14) 100%);
  border: 1.5px dashed rgba(255, 216, 74, 0.75);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dev-inbox-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff2b8;
}

.dev-inbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dev-inbox-code {
  font-family: var(--font-px);
  font-size: 18px;
  letter-spacing: 3px;
  color: var(--gold);
  background: rgba(8, 12, 24, 0.85);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 216, 74, 0.45);
}

.auth-error {
  margin: 2px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 92, 108, 0.14);
  border: 1px solid rgba(255, 92, 108, 0.5);
  color: #ffc2c8;
  font-size: 12px;
}

.auth-profile {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prof-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: #0a1020;
  border: 1px solid var(--line);
}

.prof-banner strong {
  font-family: var(--font-display);
  font-size: 18px;
}

.prof-email {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.rp-pill {
  font-weight: 800;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 216, 74, 0.18);
  color: var(--gold);
  flex: none;
}

.prof-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0a1020;
  border: 1px solid var(--line);
  font-size: 12px;
}

.lb-item.me { border-color: var(--gold); }
.lb-rank { font-family: var(--font-display); font-weight: 700; color: var(--muted); }
.lb-rank.top { color: var(--gold); }
.lb-rp { font-weight: 800; color: var(--gold); white-space: nowrap; }
.lb-rec { font-size: 11px; color: var(--muted); }

/* ==================== OVERLAY 2: MINI-GAME PLAZA ==================== */
.mg-partner-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 13px;
  background: #0a1020;
  border: 1px solid var(--line);
}

.mg-partner-strip img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: #131e3a;
  border: 1px solid var(--line-bright);
  flex: none;
}

.mg-partner-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mg-partner-info strong {
  font-family: var(--font-display);
  font-size: 14px;
}

.caught-counter-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(72, 208, 255, 0.15);
  border: 1px solid rgba(72, 208, 255, 0.45);
  color: var(--cyan);
  flex: none;
}

.mg-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 680px) {
  .mg-cards {
    grid-template-columns: 1fr;
  }
}

.mg-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 9px;
  padding: 12px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: linear-gradient(180deg, #141e3c 0%, #0d1426 100%);
  text-align: left;
}

.mg-card.featured {
  border-color: rgba(255, 216, 74, 0.65);
  background: linear-gradient(180deg, #1e243e 0%, #0f1428 100%);
}

.mg-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mg-card-ic {
  font-size: 20px;
}

.mg-card-dur {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: #0a1020;
  border: 1px solid var(--line-bright);
  color: var(--gold);
}

.mg-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
}

.mg-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.mg-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.mg-best {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
}

.wild-picker {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  margin-bottom: 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 225, 255, 0.35) transparent;
}

.wild-picker::-webkit-scrollbar { height: 5px; }
.wild-picker::-webkit-scrollbar-track { background: transparent; }
.wild-picker::-webkit-scrollbar-thumb { background: rgba(88, 225, 255, 0.32); border-radius: 999px; }

.wild-card {
  position: relative;
  flex: 0 0 90px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #0b1122;
  text-align: center;
  transition: transform 0.12s, border-color 0.15s;
}

.wild-card:hover {
  border-color: var(--el-col, var(--line-bright));
  transform: translateY(-1px);
}

.wild-card[aria-selected="true"] {
  border-color: var(--gold);
  background: #1a2444;
  box-shadow: 0 0 0 1px var(--gold), 0 6px 16px rgba(255, 216, 74, 0.22);
}

.wild-el-dot {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--el-col, var(--cyan));
  opacity: 0.88;
}

.wild-card img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.wild-card strong {
  font-family: var(--font-display);
  font-size: 10.5px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wild-tag {
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 5px;
  letter-spacing: 0.04em;
}

.wild-tag.new {
  background: var(--gold);
  color: #101422;
}

.wild-tag.owned {
  background: rgba(95, 211, 138, 0.16);
  color: var(--emerald);
  border: 1px solid rgba(95, 211, 138, 0.45);
}

/* Full-Focus Mini-Game Stage */
.mg-play-stage {
  width: 100%;
  height: 100%;
  max-width: 1040px;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, #101934 0%, #090e1c 100%);
  border: 1.5px solid var(--line-bright);
  overflow: hidden;
  touch-action: none;
}

.mg-hud-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mg-hud-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mg-hud-left strong {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--gold);
}

.mg-hud-status {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mg-hud-metrics {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.mg-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: #0a1020;
  border: 1px solid var(--line-bright);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mg-pill.time b { color: var(--cyan); }
.mg-pill.score b { color: var(--gold); }

.mg-prog-wrap {
  flex: none;
}

.mg-prog-track {
  height: 8px;
  border-radius: 999px;
  background: #0a1020;
  border: 1px solid var(--line);
  overflow: hidden;
}

.mg-prog-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--emerald));
  transition: width 0.1s linear;
}

.mg-canvas-wrap {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.mg-canvas {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  border: 2px solid var(--line-bright);
  background: #090e1c;
  display: block;
  touch-action: none;
}

.mg-controls {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0 2px;
}

.mg-stick-zone, .mg-action-zone {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.mg-action-zone {
  flex-direction: column;
  gap: 6px;
}

.mg-action-btn {
  width: min(340px, 92%);
  min-height: 58px;
  border-radius: 16px;
  border: 2px solid #fff09e;
  background: linear-gradient(135deg, #ffd84a 0%, #ff9a2e 100%);
  color: #101422;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 8px 26px rgba(255, 194, 48, 0.45);
  touch-action: none;
}

.mg-action-btn:active {
  transform: scale(0.96);
}

.vstick.mg-vstick {
  width: 106px;
  height: 106px;
  flex: none;
}

.vstick.mg-vstick .vstick-knob {
  width: 40px;
  height: 40px;
}

.mg-ctrl-tip {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.mg-ctrl-tip kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: #0a1020;
  border: 1px solid var(--line-bright);
  color: var(--text);
}

/* Mini-Game & Battle Result Banners */
.mg-result-card {
  max-width: 470px;
}

.mg-rank-badge {
  align-self: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-px);
  font-size: 28px;
  background: radial-gradient(circle, #ffe97a 0%, #ff9a2e 100%);
  color: #101422;
  border: 3px solid #fff8cf;
  box-shadow: 0 0 28px rgba(255, 216, 74, 0.65);
}

.mg-rank-badge.rank-A { background: radial-gradient(circle, #8cf4ff 0%, #3290ff 100%); border-color: #d8fbff; box-shadow: 0 0 24px rgba(72, 208, 255, 0.55); }
.mg-rank-badge.rank-B { background: radial-gradient(circle, #9ef8c8 0%, #3ab870 100%); border-color: #dcffe9; box-shadow: 0 0 20px rgba(95, 211, 138, 0.5); }
.mg-rank-badge.rank-C { background: radial-gradient(circle, #c8d4f0 0%, #6878a0 100%); border-color: #eef4ff; box-shadow: none; }

.levelup-banner {
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255, 216, 74, 0.24), rgba(255, 154, 46, 0.24));
  border: 1.5px solid var(--gold);
  color: #fff6c2;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.caught-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(72, 208, 255, 0.18), rgba(95, 211, 138, 0.2));
  border: 1.5px solid var(--emerald);
  text-align: left;
}

.caught-banner img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex: none;
}

.caught-banner-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.caught-banner-info strong {
  font-family: var(--font-display);
  font-size: 14px;
  color: #dcffe9;
}

.caught-banner-info small {
  font-size: 11px;
  color: var(--muted);
}

.res-xp-box {
  padding: 9px 11px;
  border-radius: 11px;
  background: #0a1020;
  border: 1px solid var(--line);
  text-align: left;
}

/* ==================== OVERLAY 3: PARTNER SHRINE ==================== */
.shrine-toolbar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.shrine-filter-bar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}

.shrine-filter-bar::-webkit-scrollbar { display: none; }

.el-filter-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #0d1428;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}

.el-filter-chip em {
  font-style: normal;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}

.el-filter-chip:hover {
  border-color: var(--el-col, var(--line-bright));
  color: var(--text);
}

.el-filter-chip[aria-pressed="true"] {
  border-color: var(--el-col, var(--gold));
  background: color-mix(in srgb, var(--el-col, #ffd84a) 22%, #111a34);
  color: #ffffff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--el-col, #ffd84a) 45%, transparent);
}

.roster-strip {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 225, 255, 0.35) transparent;
}

.roster-strip::-webkit-scrollbar { height: 5px; }
.roster-strip::-webkit-scrollbar-track { background: transparent; }
.roster-strip::-webkit-scrollbar-thumb { background: rgba(88, 225, 255, 0.32); border-radius: 999px; }

.roster-card {
  position: relative;
  flex: 0 0 92px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 5px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: linear-gradient(180deg, #131c36 0%, #0d1324 100%);
  text-align: center;
  transition: transform 0.12s, border-color 0.15s;
}

.roster-card:hover { border-color: var(--line-bright); transform: translateY(-1px); }

.roster-card[aria-selected="true"] {
  border-color: var(--el-col, var(--gold));
  background: linear-gradient(180deg, color-mix(in srgb, var(--el-col, #ffd84a) 18%, #141e3a), #0e1427);
  box-shadow: 0 0 0 1px var(--el-col, var(--gold));
}

.roster-card.locked .roster-img-wrap img {
  filter: grayscale(1) brightness(0.45);
}

.roster-lv {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 9px;
  font-weight: 800;
  color: var(--cyan);
}

.roster-active-star {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  color: var(--gold);
}

.roster-img-wrap {
  width: min(56px, 13vw);
  height: min(56px, 13vw);
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: radial-gradient(circle, color-mix(in srgb, var(--el-col, #48d0ff) 22%, transparent) 0%, transparent 72%);
}

.roster-img-wrap img { width: 100%; height: 100%; object-fit: contain; }

.roster-name {
  font-family: var(--font-display);
  font-size: clamp(11px, 2vw, 13px);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.roster-el {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--el-col, #48d0ff) 24%, #0c1222);
  color: var(--el-col, var(--text));
  border: 1px solid color-mix(in srgb, var(--el-col, #48d0ff) 45%, transparent);
}

.showcase-grid {
  display: grid;
  grid-template-columns: minmax(250px, 0.88fr) minmax(0, 1.32fr);
  gap: 12px;
  align-items: stretch;
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 22%, color-mix(in srgb, var(--el-col, #ff7a3c) 24%, transparent), transparent 65%),
    linear-gradient(180deg, #131d38 0%, #0d1426 100%);
  border-color: color-mix(in srgb, var(--el-col, #ff7a3c) 45%, var(--line));
}

.hero-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: 144px;
}

.hero-glow {
  position: absolute;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--el-col, #ff7a3c) 35%, transparent), transparent 70%);
  filter: blur(8px);
}

.hero-portrait {
  position: relative;
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.55));
}

.hero-portrait.locked {
  filter: grayscale(1) brightness(0.42) drop-shadow(0 10px 14px rgba(0, 0, 0, 0.55));
}

.locked-overlay-tag {
  position: absolute;
  bottom: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(12, 16, 30, 0.92);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
}

.hero-identity h1 {
  margin: 5px 0 3px;
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
}

.hero-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.el-pill, .role-pill, .style-pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
}

.el-pill { background: var(--el-col, var(--amber)); color: #090d18; }
.role-pill { background: #1a2648; border: 1px solid var(--line-bright); color: var(--text); }
.style-pill { border: 1px solid rgba(255, 216, 74, 0.55); background: rgba(255, 216, 74, 0.16); color: #ffe57a; }
.style-pill.melee { border-color: rgba(255, 114, 72, 0.65); background: rgba(255, 114, 72, 0.18); color: #ff9c78; }
.style-pill.duelist { border-color: rgba(88, 225, 255, 0.65); background: rgba(88, 225, 255, 0.16); color: #9cf2ff; }
.style-pill.grapple { border-color: rgba(202, 138, 255, 0.65); background: rgba(202, 138, 255, 0.18); color: #e2b8ff; }
.style-pill.armor { border-color: rgba(255, 194, 72, 0.72); background: rgba(255, 174, 43, 0.2); color: #ffd97a; }
.style-pill.zoner { border-color: rgba(126, 245, 168, 0.6); background: rgba(126, 245, 168, 0.15); color: #9df8be; }

.hero-passive {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.evo-preview-badge {
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255, 216, 74, 0.16), rgba(255, 154, 46, 0.14));
  border: 1px solid rgba(255, 216, 74, 0.55);
  color: #ffe88a;
  font-size: 11px;
  font-weight: 700;
}

.mastery-box {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(8, 12, 24, 0.55);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.mastery-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  margin-bottom: 5px;
}

.mastery-head strong { color: var(--gold); }
.mastery-head span { color: var(--muted); }

.bond-hearts {
  color: #ff8ab8 !important;
  letter-spacing: 2px;
  font-size: 12px;
}

.shrine-sub-stats {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}

.xp-track {
  height: 6px;
  border-radius: 999px;
  background: #1b2544;
  overflow: hidden;
}

.xp-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.showcase-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.budget-badge, .combo-chip {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #192442;
  border: 1px solid var(--line-bright);
  color: var(--gold);
}

.combo-chip { color: var(--amber); }

.stat-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
}

.stat-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 7px;
  font-size: 11px;
}

.stat-row span { color: var(--muted); font-weight: 600; }

.stat-row i {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: #1b2544;
  overflow: hidden;
}

.stat-row i > s {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--el-col, var(--gold)));
}

.stat-row em {
  font-style: normal;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-row em b {
  color: var(--emerald);
  font-weight: 800;
}

.kit-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.kit-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 3px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0d1426;
  font-size: 11px;
  font-weight: 700;
}

.kit-tab small { font-size: 9px; font-weight: 700; color: var(--muted); }
.kit-tab[aria-selected="true"] { border-color: var(--gold); background: #1b2444; color: var(--gold); }
.kit-tab[aria-selected="true"] small { color: var(--cyan); }

.kit-detail {
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0a1020;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kit-detail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kit-detail-top strong { font-family: var(--font-display); font-size: 14px; }
.kit-meta-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.kit-meta-pills span { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: #16203d; color: var(--cyan); }
.kit-desc { margin: 0; font-size: 12px; line-height: 1.4; color: #dbe4f8; }
.kit-combo-tip { font-size: 11px; line-height: 1.4; padding: 6px 8px; border-radius: 8px; background: rgba(255, 154, 46, 0.12); border-left: 3px solid var(--amber); color: #ffe3ba; }

/* ==================== OVERLAY 4: ARENA GATE MODAL ==================== */
.gate-loadout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 13px;
  background: #0a1020;
  border: 1px solid var(--line);
}

.gate-loadout img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 10px;
  background: #141e3a;
  border: 1px solid var(--line-bright);
  flex: none;
}

.gate-loadout-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gate-loadout-info strong {
  font-family: var(--font-display);
  font-size: 15px;
}

.gate-loadout-info small {
  font-size: 11px;
  color: var(--gold);
}

.gate-map-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.arena-strip {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(114, 154, 240, 0.45) transparent;
}

.arena-strip::-webkit-scrollbar { height: 5px; }
.arena-strip::-webkit-scrollbar-track { background: transparent; }
.arena-strip::-webkit-scrollbar-thumb { background: rgba(114, 154, 240, 0.42); border-radius: 999px; }

.arena-chip {
  flex: 0 0 118px;
  scroll-snap-align: start;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 4px;
  padding: 5px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--bg-elev);
  text-align: center;
  transition: border-color 0.14s, transform 0.12s, background 0.14s;
}

.arena-chip:hover { border-color: var(--line-bright); transform: translateY(-1px); }

.arena-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  overflow: hidden;
  background: #0d1428;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.arena-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.arena-random-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--gold);
  background: radial-gradient(circle at 30% 25%, #2a3e78 0%, #141c38 62%, #0c1226 100%);
}

.arena-new-tag {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 1px 4px;
  border-radius: 4px;
  background: linear-gradient(135deg, #ffd84a 0%, #ff9a2e 100%);
  color: #101422;
  font-size: 7.5px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.25;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.arena-fx-tag {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(8, 13, 28, 0.86);
  border: 1px solid rgba(72, 240, 255, 0.55);
  color: #9af8ff;
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.arena-chip strong { font-size: 10.5px; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arena-chip small { font-size: 8.5px; color: var(--muted); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arena-chip.is-new { border-color: rgba(72, 240, 255, 0.36); }
.arena-chip[aria-checked="true"] { border-color: var(--gold); background: #1a2546; box-shadow: 0 0 0 1px rgba(255, 216, 74, 0.45), 0 4px 14px rgba(255, 216, 74, 0.14); }
.arena-chip[aria-checked="true"] strong { color: var(--gold); }

.stage-fx-pill {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(14, 22, 44, 0.88);
  border: 1px solid var(--line-bright);
  font-size: 11px;
  line-height: 1.35;
}

.stage-fx-pill.unique {
  border-color: rgba(72, 240, 255, 0.55);
  background: linear-gradient(90deg, rgba(22, 46, 78, 0.92) 0%, rgba(28, 22, 62, 0.92) 100%);
  box-shadow: 0 0 14px rgba(72, 240, 255, 0.14);
}

.sfx-badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 216, 74, 0.14);
  border: 1px solid rgba(255, 216, 74, 0.45);
  color: var(--gold);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.stage-fx-pill.unique .sfx-badge {
  background: rgba(72, 240, 255, 0.16);
  border-color: rgba(72, 240, 255, 0.65);
  color: #88f8ff;
}

.sfx-text {
  color: #dce6ff;
  font-size: 11px;
  font-weight: 500;
  min-width: 0;
}

@media (max-width: 780px) {
  .showcase-grid { grid-template-columns: 1fr; }
  .stat-bars { grid-template-columns: 1fr; }
  .arena-strip {
    display: flex;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .arena-strip::-webkit-scrollbar { display: none; }
  .arena-chip { flex: 0 0 106px; }
  .stage-fx-pill { flex-wrap: wrap; gap: 5px; padding: 6px 8px; }
  .wild-picker { gap: 6px; }
  .wild-card { flex: 0 0 78px; padding: 6px 4px; }
  .wild-card img { width: 38px; height: 38px; }
  .roster-card { flex: 0 0 80px; padding: 6px 4px; }
  .roster-img-wrap { width: 46px; height: 46px; }
  .opp-chip { flex: 0 0 64px; }
}

/* ==================== SCREEN 2: ARENA (LOCKED 100DVH) ==================== */
html.pm-battle-lock,
html.pm-battle-lock body {
  overflow: hidden;
  overscroll-behavior: none;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.arena-view {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(70% 80% at 30% 0%, #1a2c56 0%, #080c18 72%);
  z-index: 40;
}

.arena-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(276px, 24vw, 326px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "hud hud"
    "field moves";
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  touch-action: none;
}

.arena-stage button,
.arena-stage canvas,
.arena-stage .vstick,
.arena-stage .canvas-touch-zone {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Top Battle HUD */
.battle-hud {
  grid-area: hud;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 5px 10px;
  align-items: center;
  min-width: 0;
}

.hud-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 13px;
  background: rgba(16, 23, 44, 0.92);
  border: 1.5px solid color-mix(in srgb, var(--el-col, #48d0ff) 40%, var(--line));
  min-width: 0;
  overflow: hidden;
}

.hud-card.evo-active {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 216, 74, 0.35);
}

.hud-card.rival { flex-direction: row-reverse; text-align: right; }

.hud-pic {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: radial-gradient(#243260, #0c1222);
  border: 1.5px solid var(--el-col, var(--line-bright));
  object-fit: contain;
}

.hud-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hud-top-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hud-card.rival .hud-top-row { flex-direction: row-reverse; }
.hud-top-row strong { font-family: var(--font-display); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-lv { font-size: 10px; font-weight: 700; color: var(--gold); flex: none; }
.hud-type { margin-left: auto; font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--el-col, #3b4f8c); color: #090d18; flex: none; }
.hud-card.rival .hud-type { margin-left: 0; margin-right: auto; }

.hud-hp-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hud-card.rival .hud-hp-row { flex-direction: row-reverse; }
.hud-hp-bar { flex: 1; min-width: 24px; height: 8px; border-radius: 999px; background: #0a0f1e; overflow: hidden; display: flex; }
.hud-card.rival .hud-hp-bar { justify-content: flex-end; }
.hud-hp-bar i { display: block; height: 100%; background: var(--emerald); transition: width 0.14s linear; }
.hud-hp-num { font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; flex: none; }
.hud-card.rival .hud-hp-num { text-align: left; }

.hud-sub-row { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.hud-card.rival .hud-sub-row { flex-direction: row-reverse; }
.hud-en-bar { flex: 1; height: 4px; border-radius: 999px; background: #0a0f1e; overflow: hidden; display: flex; }
.hud-card.rival .hud-en-bar { justify-content: flex-end; }
.hud-en-bar i { display: block; height: 100%; background: var(--cyan); }

/* Desktop HUD DIGI Gauge */
.hud-evo-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-card.rival .hud-evo-row {
  flex-direction: row-reverse;
}

.hud-evo-lbl {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--gold);
  flex: none;
}

.hud-evo-bar {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: #14192d;
  overflow: hidden;
  display: flex;
}

.hud-card.rival .hud-evo-bar {
  justify-content: flex-end;
}

.hud-evo-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff9a2e, #ffd84a);
  transition: width 0.12s linear;
}

.hud-combo-badge {
  font-family: var(--font-px);
  font-size: 8px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 216, 74, 0.18);
  color: var(--gold);
  border: 1px solid rgba(255, 216, 74, 0.6);
  flex: none;
}

.hud-st { font-size: 9px; font-weight: 800; color: var(--amber); letter-spacing: 0.04em; flex: none; }
.hud-team { display: flex; gap: 4px; }
.hud-team:empty { display: none; }

.tm-dot {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--line-bright);
  background: #0c1326;
  padding: 1px;
  overflow: hidden;
}

.tm-dot.on { border-color: var(--cyan); }
.tm-dot.out { opacity: 0.35; filter: grayscale(1); }
.tm-dot img { width: 100%; height: 100%; object-fit: contain; }
.tm-dot i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--emerald); }

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-clock { font-family: var(--font-px); font-size: 13px; padding: 6px 12px; border-radius: 999px; background: #0d1428; border: 1.5px solid var(--line-bright); color: #fff; }
.hud-mode-tag { font-size: 9px; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); }
.hud-stage-tag {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: 100%;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(72, 240, 255, 0.48);
  background: rgba(14, 28, 52, 0.9);
  color: #8cf8ff;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-desk-tools { display: flex; gap: 5px; }

.tool-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-bright);
  background: #101830;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.tool-pill.on { border-color: var(--emerald); color: var(--emerald); background: rgba(95, 211, 138, 0.12); }
.tool-pill.danger { border-color: rgba(255, 92, 108, 0.5); color: #ffb8c0; }

/* Arena Field & Canvas */
.arena-field {
  grid-area: field;
  position: relative;
  container-type: size;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.arena-field canvas {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 14px;
  border: 2px solid var(--line);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65);
  background: #0a0f1f;
}

.canvas-touch-zone { position: absolute; inset: 0; cursor: crosshair; }

.countdown-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 24, 0.45);
  pointer-events: none;
}

.countdown-banner span { font-family: var(--font-px); font-size: clamp(34px, 8vw, 64px); color: var(--gold); text-shadow: 0 4px 0 #090d18; }
.countdown-banner small { margin-top: 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; color: #fff; }

/* Mobile Portrait Vital + DIGI + Combo Bar */
.mobile-vital-bar {
  grid-area: vital;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 11px;
  background: rgba(15, 22, 42, 0.94);
  border: 1px solid var(--line);
}

.vital-gauge { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; }
.vg-lbl { font-size: 8.5px; font-weight: 800; color: var(--muted); }
.vg-lbl.gold { color: var(--gold); }
.vg-track { flex: 1; height: 6px; border-radius: 999px; background: #090e1c; overflow: hidden; }
.vg-track.hp i { display: block; height: 100%; background: var(--emerald); }
.vg-track.en i { display: block; height: 100%; background: linear-gradient(90deg, #2d8fff, var(--cyan)); }
.vg-track.evo i { display: block; height: 100%; background: linear-gradient(90deg, #ff9a2e, #ffd84a); }
.vital-gauge em { font-style: normal; font-size: 9px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 20px; text-align: right; }

.vital-combo { display: flex; align-items: center; gap: 5px; padding-left: 5px; border-left: 1px solid var(--line); }
.chain-pips { display: flex; gap: 3px; }
.chain-pips i { display: block; width: 7px; height: 7px; border-radius: 50%; background: #222e52; border: 1px solid var(--line-bright); }
.chain-pips i.lit { background: var(--gold); border-color: #fff; box-shadow: 0 0 6px var(--gold); }
.combo-flag { font-family: var(--font-px); font-size: 7.5px; color: var(--muted); white-space: nowrap; }
.combo-flag.hot { color: var(--gold); }
.combo-flag.link { color: var(--amber); }
.combo-flag.cancel { color: var(--cyan); }

/* Left Touch Deck (Virtual Joystick) */
.touch-left-deck {
  grid-area: stick;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 16px;
  background: rgba(15, 22, 42, 0.88);
  border: 1px solid var(--line);
}

.vstick {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 44%, #1a274f 0%, #0d142c 68%, #070b18 100%);
  border: 2px solid #394f86;
  box-shadow: inset 0 4px 12px #000b, 0 8px 20px #0007;
}

.vstick.active {
  border-color: var(--cyan);
  box-shadow: inset 0 4px 12px #000b, 0 0 0 3px rgba(72, 208, 255, 0.25), 0 0 22px rgba(72, 208, 255, 0.35);
}

.vstick-ring { position: absolute; inset: 13px; border-radius: 50%; border: 1px dashed rgba(72, 208, 255, 0.28); pointer-events: none; }

.vstick-dir {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from -36deg, transparent 0deg, rgba(72, 208, 255, 0.9) 36deg, transparent 72deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  opacity: 0;
  pointer-events: none;
}

.vstick-arrows { position: absolute; inset: 7px; pointer-events: none; font-size: 8px; color: #6b80b4; }
.vstick-arrows span { position: absolute; }
.vstick-arrows .u { top: 0; left: 50%; transform: translateX(-50%); }
.vstick-arrows .d { bottom: 0; left: 50%; transform: translateX(-50%); }
.vstick-arrows .l { left: 1px; top: 50%; transform: translateY(-50%); }
.vstick-arrows .r { right: 1px; top: 50%; transform: translateY(-50%); }

.vstick-knob {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #b6f5ff 0%, #48b8f0 46%, #1d4e8a 100%);
  border: 2px solid #daf8ff;
  box-shadow: 0 5px 12px #000a, 0 0 14px rgba(72, 208, 255, 0.45);
  pointer-events: none;
  will-change: transform;
}

.left-pills { display: flex; gap: 6px; width: 100%; max-width: 144px; }
.deck-pill { flex: 1; min-height: 40px; border-radius: 999px; border: 1.5px solid var(--line-bright); background: #101830; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.04em; }
.deck-pill.on { border-color: var(--emerald); color: var(--emerald); background: rgba(95, 211, 138, 0.14); }
.deck-pill.danger { border-color: rgba(255, 92, 108, 0.5); color: #ffb8c0; background: rgba(255, 92, 108, 0.12); }

/* Right Ability Deck + DIGIVOLVE Trigger Pill */
.ability-deck {
  grid-area: moves;
  align-self: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  border-radius: 16px;
  background: rgba(15, 22, 42, 0.9);
  border: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
}

.ability-top-bar { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; padding: 0 2px; }
.en-readout { color: var(--cyan); }
.combo-readout { font-family: var(--font-px); font-size: 9px; color: var(--gold); }

/* Glowing DIGIVOLVE Trigger Button */
.evo-trigger-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 11px;
  border: 1.5px solid rgba(255, 216, 74, 0.42);
  background: #0b1122;
  color: #ffe88a;
  text-align: center;
  transition: transform 0.08s, box-shadow 0.15s, border-color 0.15s;
}

.evo-trigger-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(255, 154, 46, 0.42), rgba(255, 216, 74, 0.55));
  pointer-events: none;
  transition: width 0.1s linear;
}

.evo-trigger-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.evo-key {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(8, 12, 24, 0.72);
  border: 1px solid rgba(255, 216, 74, 0.45);
  color: var(--gold);
  font-size: 9px;
}

.evo-trigger-btn.ready {
  border-color: #fff2a6;
  background: linear-gradient(95deg, #5e3808 0%, #3a2308 50%, #5e3808 100%);
  color: #fffbe0;
  box-shadow: 0 0 0 2px #ffd84a, 0 0 24px rgba(255, 216, 74, 0.9);
  animation: pulseGold 0.6s ease-in-out infinite alternate;
}

.evo-trigger-btn.ready .evo-trigger-fill {
  background: linear-gradient(90deg, #ff9a2e, #ffd84a);
  opacity: 0.42;
}

.evo-trigger-btn.active {
  border-color: #ff9a2e;
  background: #231407;
  color: #fffbe0;
  box-shadow: 0 0 18px rgba(255, 154, 46, 0.65);
}

.evo-trigger-btn.active .evo-trigger-fill {
  background: linear-gradient(90deg, #ff6b2b, #ffd84a);
  opacity: 0.68;
}

.evo-trigger-btn.pressed {
  transform: scale(0.96);
}

.ability-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.ab-btn {
  --btn-col: var(--cyan);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-height: 64px;
  padding: 7px 9px 9px;
  border-radius: 12px;
  border: 2px solid color-mix(in srgb, var(--btn-col) 65%, #1d2846);
  background: linear-gradient(180deg, color-mix(in srgb, var(--btn-col) 15%, #131c36) 0%, #090e1c 100%);
  text-align: left;
  transition: transform 0.08s, box-shadow 0.12s, border-color 0.12s;
}

.ab-btn.basic { --btn-col: #ffd84a; }
.ab-btn.special { --btn-col: #ff9a2e; }
.ab-btn.dash { --btn-col: #48d0ff; }
.ab-btn.guard { --btn-col: #5fd38a; }
.ab-btn.mega { --btn-col: #ffd84a; grid-column: 1 / -1; min-height: 52px; }

.ab-btn.pressed { transform: scale(0.95); box-shadow: 0 0 0 2px #fff, 0 0 18px var(--btn-col); }
.ab-btn.cool { opacity: 0.56; filter: saturate(0.6); }

.ab-top { display: flex; justify-content: space-between; align-items: center; width: 100%; font-size: 10px; font-weight: 800; }
.ab-num { width: 17px; height: 17px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); display: grid; place-items: center; color: #fff; }
.ab-key { font-size: 9px; color: var(--muted); padding: 1px 5px; border-radius: 4px; background: rgba(8, 12, 24, 0.7); border: 1px solid var(--line); }
.ab-name { font-family: var(--font-display); font-size: 13px; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ab-sub { display: flex; align-items: center; justify-content: space-between; gap: 5px; width: 100%; font-size: 10px; }
.ab-cost { color: var(--muted); font-weight: 700; }
.ab-pips { display: flex; gap: 3px; }
.ab-pips i { display: block; width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.ab-pips i.lit { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.ab-tag { font-size: 9px; font-weight: 800; letter-spacing: 0.04em; padding: 1px 5px; border-radius: 4px; background: rgba(8, 12, 24, 0.65); color: var(--muted); }
.ab-ult-track { flex: 1; height: 7px; border-radius: 999px; background: #141c36; border: 1px solid rgba(255, 216, 74, 0.22); overflow: hidden; }
.ab-ult-track i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ff3858 0%, #ff8a24 52%, #ffd84a 100%); box-shadow: 0 0 10px rgba(255, 168, 48, 0.75); transition: width 0.12s ease-out; }
.ab-cd { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--btn-col); }

.ab-btn.special.link-ready { opacity: 1; filter: none; border-color: #ffb838; background: linear-gradient(180deg, #4b2a09 0%, #1d1208 100%); box-shadow: 0 0 0 2px #ffb838, 0 0 22px rgba(255, 162, 40, 0.75); animation: pulseAmber 0.45s ease-in-out infinite alternate; }
.ab-btn.special.link-ready .ab-tag { background: #ffb838; color: #140c02; }
.ab-btn.dash.cancel-ready { opacity: 1; filter: none; border-color: #48e8ff; background: linear-gradient(180deg, #0b3a4f 0%, #071928 100%); box-shadow: 0 0 0 2px #48e8ff, 0 0 22px rgba(72, 232, 255, 0.75); animation: pulseCyan 0.45s ease-in-out infinite alternate; }
.ab-btn.dash.cancel-ready .ab-tag { background: #48e8ff; color: #041520; }
.ab-btn.guard.parry-ready { border-color: #5fd38a; box-shadow: 0 0 0 2px #5fd38a, 0 0 18px rgba(95, 211, 138, 0.65); }
.ab-btn.guard.parry-ready .ab-tag { background: #5fd38a; color: #071b10; }
.ab-btn.mega.ult-charging { opacity: 0.82; filter: saturate(0.95); border-color: rgba(255, 154, 46, 0.7); }
.ab-btn.mega.ult-charging .ab-ult-track i { box-shadow: 0 0 12px rgba(255, 120, 48, 0.9); }
.ab-btn.mega.ult-ready { opacity: 1; filter: none; border-color: #ffe875; background: linear-gradient(95deg, #691026 0%, #9b2218 46%, #5f2d08 100%); box-shadow: 0 0 0 2px #ffd84a, 0 0 24px rgba(255, 56, 88, 0.85), 0 0 38px rgba(255, 216, 74, 0.7); animation: pulseCrimsonGold 0.6s ease-in-out infinite alternate; }
.ab-btn.mega.ult-ready .ab-name { color: #fff7d6; text-shadow: 0 1px 6px rgba(255, 64, 88, 0.65); }
.ab-btn.mega.ult-ready .ab-ult-track { border-color: #ffe875; background: #2c0b16; }
.ab-btn.mega.ult-ready .ab-ult-track i { background: linear-gradient(90deg, #ff4d6d, #ffd84a, #fff6bf); box-shadow: 0 0 14px rgba(255, 232, 117, 1); }
.ab-btn.mega.ult-ready .ab-tag { background: linear-gradient(90deg, #ffd84a, #fff099); color: #1a080c; box-shadow: 0 0 10px rgba(255, 216, 74, 0.9); }

@keyframes pulseAmber { to { box-shadow: 0 0 0 3px #ffd26a, 0 0 28px rgba(255, 162, 40, 0.95); } }
@keyframes pulseCyan { to { box-shadow: 0 0 0 3px #90f4ff, 0 0 28px rgba(72, 232, 255, 0.95); } }
@keyframes pulseGold { to { box-shadow: 0 0 0 3px #fff099, 0 0 30px rgba(255, 216, 74, 1); } }
@keyframes pulseCrimsonGold { to { box-shadow: 0 0 0 3px #fff29c, 0 0 32px rgba(255, 56, 88, 1), 0 0 48px rgba(255, 216, 74, 0.95); } }

.switch-row { display: flex; gap: 6px; }
.switch-btn { flex: 1; display: flex; align-items: center; gap: 5px; min-height: 34px; padding: 3px 7px; border-radius: 9px; border: 1px solid var(--line-bright); background: #101830; font-size: 10px; font-weight: 700; }
.switch-btn img { width: 22px; height: 22px; object-fit: contain; }

.desk-hints { display: flex; flex-wrap: wrap; gap: 6px; font-size: 10px; color: var(--muted); justify-content: center; }
.desk-hints kbd { padding: 1px 4px; border-radius: 4px; background: #090e1c; border: 1px solid var(--line-bright); color: var(--text); font-family: var(--font-ui); font-size: 9px; }

/* ==================== MOBILE PORTRAIT ARENA (390x844) ==================== */
@media (orientation: portrait), (max-width: 699px) {
  .arena-stage {
    grid-template-columns: minmax(132px, 40vw) minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "hud hud"
      "field field"
      "vital vital"
      "stick moves";
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top, 0px)) max(6px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    align-content: start;
  }

  .battle-hud { gap: 4px 5px; }
  .hud-card { padding: 4px 6px; gap: 5px; border-radius: 10px; }
  .hud-pic { width: 28px; height: 28px; }
  .hud-top-row strong { font-size: 10.5px; }
  .hud-type, .hud-mode-tag, .hud-desk-tools { display: none; }
  .hud-hp-num { font-size: 9px; min-width: 0; }
  .hud-clock { font-size: 10px; padding: 4px 8px; }
  .hud-stage-tag { font-size: 8.5px; padding: 2px 9px; max-width: 100%; }
  .hud-combo-badge { font-size: 7px; padding: 1px 4px; }
  .hud-st { font-size: 8px; max-width: 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud-evo-row { display: none; }

  .arena-field { container-type: normal; width: 100%; aspect-ratio: 16 / 9; }
  .arena-field canvas { width: 100%; height: 100%; border-radius: 10px; }

  .mobile-vital-bar { display: flex; }
  .touch-left-deck { display: flex; align-self: stretch; justify-content: center; }

  .ability-deck { align-self: stretch; justify-content: center; padding: 7px; gap: 6px; }
  .ability-top-bar, .desk-hints, .ab-key, .evo-key { display: none; }
  .evo-trigger-btn { min-height: 36px; padding: 5px 8px; }
  .evo-trigger-content { font-size: 11px; }
  .ability-grid { gap: 6px; }
  .ab-btn { min-height: 66px; padding: 6px 7px 7px; border-radius: 11px; }
  .ab-name { font-size: 11px; }
  .ab-btn.mega { min-height: 50px; }
}

/* ==================== MOBILE LANDSCAPE ARENA (844x390) ==================== */
@media (orientation: landscape) and (max-height: 560px) {
  .arena-stage {
    grid-template-columns: clamp(124px, 15.5vw, 148px) minmax(0, 1fr) clamp(172px, 23vw, 212px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "hud hud hud"
      "stick field moves";
    gap: 5px;
    padding: max(4px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(5px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }

  .battle-hud { gap: 6px; }
  .hud-card { padding: 3px 7px; gap: 6px; min-height: 38px; max-height: 44px; border-radius: 9px; }
  .hud-pic { width: 26px; height: 26px; }
  .hud-meta { gap: 2px; }
  .hud-top-row strong { font-size: 10.5px; }
  .hud-hp-bar { height: 5px; }
  .hud-en-bar { height: 3px; }
  .hud-evo-bar { height: 3px; }
  .hud-clock { font-size: 10px; padding: 3px 9px; }
  .hud-mode-tag, .hud-stage-tag, .hud-desk-tools, .mobile-vital-bar, .desk-hints, .ab-top, .ab-key, .evo-key { display: none; }

  .touch-left-deck { display: flex; padding: 5px 4px; gap: 6px; }
  .vstick { width: clamp(86px, 24dvh, 102px); height: clamp(86px, 24dvh, 102px); }
  .vstick-knob { width: 36px; height: 36px; }
  .deck-pill { min-height: 34px; font-size: 10px; }

  .ability-deck { padding: 5px; gap: 4px; justify-content: center; }
  .ability-top-bar { font-size: 9.5px; }
  .evo-trigger-btn { min-height: 28px; padding: 3px 6px; border-radius: 8px; }
  .evo-trigger-content { font-size: 10px; }
  .ability-grid { gap: 4px; }
  .ab-btn { min-height: clamp(40px, 13.5dvh, 54px); padding: 4px 6px 6px; border-radius: 9px; gap: 2px; }
  .ab-name { font-size: 10.5px; }
  .ab-sub { font-size: 8.5px; }
  .ab-btn.mega { min-height: clamp(36px, 11.5dvh, 46px); }
}

body.coarse .touch-left-deck { display: flex; }

@media (min-width: 700px) and (min-height: 561px) {
  body.coarse .arena-stage {
    grid-template-columns: clamp(142px, 18vw, 174px) minmax(0, 1fr) clamp(210px, 25vw, 260px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "hud hud hud"
      "stick field moves";
  }
  body.coarse .hud-desk-tools,
  body.coarse .desk-hints { display: none; }
}

/* ==================== ARENA GATE CARDS & ONLINE ROOMS ==================== */
.staging-tabs { display: none; grid-template-columns: 1fr 1fr; gap: 6px; }
.st-tab { min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #0a1020; font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--muted); }
.st-tab.active { border-color: var(--gold); background: #1a2444; color: var(--gold); }

.staging-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.staging-card { display: flex; flex-direction: column; gap: 9px; padding: 13px; border-radius: 14px; background: #0b1122; border: 1px solid var(--line); min-width: 0; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-top h3 { margin: 2px 0 0; font-family: var(--font-display); font-size: 18px; }
.status-pill, .acct-chip { font-size: 10px; font-weight: 800; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-bright); background: #141e38; color: var(--cyan); white-space: nowrap; }
.status-pill.ok { border-color: rgba(95, 211, 138, 0.5); color: var(--emerald); background: rgba(95, 211, 138, 0.12); }

.field-lbl { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 2px; }
.seg-group { display: grid; gap: 6px; }
.seg-group.two { grid-template-columns: 1fr 1fr; }
.seg-group.three { grid-template-columns: repeat(3, 1fr); }
.seg-group button { min-height: 38px; border-radius: 9px; border: 1px solid var(--line); background: #101830; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg-group button[aria-pressed="true"] { border-color: var(--gold); background: #1c2748; color: var(--gold); }

.cpu-team-box { padding: 8px; border-radius: 10px; background: #0e1529; border: 1px solid var(--line); }
.team-lbl { font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.cpu-team-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.team-slot-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border-radius: 9px; border: 1px solid var(--line-bright); background: #141e38; font-size: 10px; font-weight: 700; }
.team-slot-btn img { width: 32px; height: 32px; object-fit: contain; }

.cpu-opp-box {
  flex-shrink: 0;
  padding: 8px;
  border-radius: 10px;
  background: #0e1529;
  border: 1px solid var(--line);
  min-width: 0;
}

.cpu-opp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.cpu-opp-head .field-lbl { margin: 0; }

.cpu-opp-val {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cpu-opp-strip {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 1px 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(88, 225, 255, 0.35) transparent;
}

.cpu-opp-strip::-webkit-scrollbar { height: 4px; }
.cpu-opp-strip::-webkit-scrollbar-track { background: transparent; }
.cpu-opp-strip::-webkit-scrollbar-thumb { background: rgba(88, 225, 255, 0.32); border-radius: 999px; }

.opp-chip {
  flex: 0 0 68px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #0b1020;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}

.opp-chip img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.opp-chip .opp-dice {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.opp-chip strong {
  font-size: 9.5px;
  font-weight: 700;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-chip[aria-checked="true"] {
  border-color: var(--el-col, var(--gold));
  background: color-mix(in srgb, var(--el-col, #ffd84a) 18%, #162244);
  box-shadow: 0 0 0 1px var(--el-col, var(--gold));
}

.opp-chip[aria-checked="true"] strong {
  color: #ffffff;
}

.online-actions { display: flex; flex-direction: column; gap: 9px; }
.room-divider { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.room-divider::before, .room-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.room-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.join-box { display: flex; gap: 6px; }
.code-input { width: 100%; min-width: 0; min-height: 42px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line-bright); background: #080c18; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; }
.online-hint { margin: 0; font-size: 11px; line-height: 1.45; color: var(--muted); }

.online-room-box { display: flex; flex-direction: column; gap: 9px; padding: 12px; border-radius: 12px; background: #101830; border: 1px solid var(--cyan); text-align: center; }
.room-status-head { display: flex; justify-content: space-between; align-items: center; }
.room-badge { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; color: var(--cyan); }
.copy-code-btn { border: 1px solid var(--line-bright); background: #182446; border-radius: 6px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.room-code-big { font-family: var(--font-px); font-size: 22px; letter-spacing: 4px; color: var(--gold); }
.room-msg { margin: 0; font-size: 12px; color: var(--muted); }
.room-players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.room-player { padding: 8px; border-radius: 9px; background: #0a1020; border: 1px solid var(--line); font-size: 11px; }
.room-player strong { display: block; font-size: 12px; }
.room-player small { color: var(--muted); }

@media (max-width: 740px), (max-height: 540px) {
  .staging-tabs { display: grid; }
  .staging-panels { grid-template-columns: 1fr; }
  .staging-card.mob-hidden { display: none; }
}

/* ==================== POST-MATCH RESULTS OVERLAY ==================== */
.results-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(8, 12, 24, 0.84);
  backdrop-filter: blur(8px);
}

.results-card {
  width: 100%;
  max-width: 450px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  touch-action: pan-y;
  padding: 18px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #162040 0%, #0d1326 100%);
  border: 1.5px solid var(--line-bright);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.78);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.res-reason { align-self: center; font-size: 10px; font-weight: 800; letter-spacing: 0.14em; padding: 3px 10px; border-radius: 999px; background: #1a2648; color: var(--cyan); }
.res-title { margin: 0; font-family: var(--font-display); font-size: clamp(24px, 6vw, 34px); color: var(--gold); }
.res-title.loss { color: var(--crimson); }
.res-title.draw { color: var(--cyan); }
.res-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.res-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.res-stat { padding: 9px 5px; border-radius: 11px; background: #0a1020; border: 1px solid var(--line); }
.res-stat small { display: block; font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.res-stat strong { font-family: var(--font-display); font-size: 15px; color: var(--text); }
.res-stat strong.up { color: var(--emerald); }
.res-stat strong.dn { color: var(--crimson); }
.res-stat strong.xp { color: var(--gold); }
.res-wait { margin: 0; font-size: 12px; color: var(--cyan); }
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 2px; }
.res-actions .ghost-btn { grid-column: 1 / -1; }

/* ==================== TOAST ==================== */
.pm-toast {
  position: fixed;
  left: 50%;
  bottom: max(74px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 120;
  max-width: min(92vw, 440px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #141e3a;
  border: 1px solid var(--line-bright);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.pm-toast.err {
  border-color: var(--crimson);
  color: #ffc2c8;
}
