/* ===== E.D.I.T.H. Arcade Mobile Handheld Console & Anti-Zoom Polish ===== */

/* 1. Zero Double-Tap / Off-Controller Zoom & Handheld Focus Shell */
:where(
  html.in-arcade,
  body.in-arcade,
  body.in-arcade #main,
  .edith-hall,
  .edith-cab-frame,
  .edith-cab-stage,
  .edith-cab-stage *
) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
html.in-arcade,
body.in-arcade,
.edith-cab-frame,
.edith-cab-stage {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.in-arcade main > h1,
body.in-arcade main > .spills {
  display: none !important;
}

/* Hide redundant always-on in-cabinet family score rows (now in topbar 🏆 modal) */
.cap-card .g4.mt,
.im2048-fam-row,
.wolv-fam-counts,
.cyc-fam-row,
.str-fam-row,
.sl-lb-sec,
.mag-lb-grid,
.spidey-fam-strip,
.inf-fam-row,
.gsol-fam-row,
.ssol-fam-row,
.jg-fam-row,
.xch-fam-row {
  display: none !important;
}

/* 2. On-Demand 🏆 Scores Modal */
.edith-m-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.edith-m-kicker {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sky);
}
.edith-m-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}
.edith-m-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 13px;
  background: var(--tile);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--txt);
}
.edith-m-score-row.is-lead {
  border-color: var(--sky);
  box-shadow: 0 0 14px color-mix(in srgb, var(--sky) 24%, transparent);
}
.edith-m-val {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  color: var(--wh);
  font-variant-numeric: tabular-nums;
}
.edith-m-val small {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--mut);
}
.edith-m-house {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}
.edith-m-sub {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mut);
  margin-bottom: 7px;
}
.edith-m-house-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.edith-m-house-chip {
  padding: 8px 6px;
  border-radius: 12px;
  background: var(--tile);
  border: 1px solid var(--line);
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--txt);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.edith-m-house-chip.is-lead { border-color: var(--sky); }
.edith-m-house-chip b { font-size: 13.5px; color: var(--wh); }
.edith-m-house-chip small { font-size: 10px; color: var(--mut); }
.edith-m-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* 2b. Auto-Responsive Device Fit (<= 1024px): hide redundant manual fullscreen/screen toggles */
@media (max-width: 1024px) {
  #edithFsBtn,
  #slFullBtn {
    display: none !important;
  }
}

/* 3. Mobile Handheld Console Shell & All-Cabinet Fit (<= 640px) */
@media (max-width: 640px) {
  body.in-arcade main {
    padding: calc(6px + env(safe-area-inset-top, 0px)) 8px calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body.in-arcade-game .hdr,
  body.in-arcade-game .bn {
    display: none !important;
  }
  body.in-arcade-game main {
    padding: calc(4px + env(safe-area-inset-top, 0px)) 6px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Compact Hall Hero so Cabinets Start Near the Top */
  .edith-hall { gap: 8px; }
  .edith-hero { padding: 9px 11px; border-radius: 16px; }
  .edith-kicker,
  .edith-hall-sub,
  .edith-stat-pill { display: none !important; }
  .edith-hud-orb { width: 34px; height: 34px; }
  .edith-hall-title { font-size: 15.5px; }
  .edith-rnd-btn,
  .edith-hero-actions .edith-tb-btn { min-height: 32px; padding: 0 10px; font-size: 11.5px; }

  /* Compact Universal Cabinet Topbar */
  .edith-cab-frame { gap: 6px; }
  .edith-cab-topbar { padding: 5px 8px; border-radius: 12px; gap: 6px; flex-wrap: nowrap; }
  .edith-cab-topbar-l { flex: 1 1 auto; min-width: 0; }
  .edith-cab-topbar-r { flex-shrink: 0; }
  .edith-tb-btn { min-height: 30px; padding: 0 9px; font-size: 11.5px; border-radius: 9px; flex-shrink: 0; }
  .edith-tb-badge { font-size: 12px; max-width: 100%; min-width: 0; flex: 0 1 auto; }
  .edith-tb-badge img { width: 19px; height: 19px; flex-shrink: 0; }
  .edith-tb-badge span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Strip verbose in-cabinet clutter & banter on phones */
  .wolv-comic-strip,
  .cyc-comms,
  .str-banter,
  .im2048-banter,
  .mag-comms,
  .gambit-banter,
  .spidey-banter,
  .qs-comic-strip,
  .inf-banter,
  .inf-ladder,
  .spidey-hint,
  .mag-deck-hint,
  .wolv-host-eyebrow,
  .wolv-sub-title,
  .cyc-host-tag,
  .str-host-tag,
  .spidey-kicker,
  .spidey-sub,
  .qs-eyebrow,
  .inf-kicker,
  .gsol-banter,
  .ssol-banter,
  .gsol-hint-row,
  .ssol-hint-row,
  .gsol-eyebrow,
  .ssol-eyebrow,
  .jg-banter,
  .jg-key-hint,
  .jg-eyebrow,
  .xch-eyebrow {
    display: none !important;
  }

  /* Tighten inner cabinet wrappers */
  .wolv-cab, .cyc-cab, .str-cab, .vnm-cab, .mag-cab, .gambit-cab,
  .spidey-cab, .qs-cab, .nc-cab, .inf-cab, .im2048-cab,
  .gsol-cab, .ssol-cab, .jg-cab, .xch-cab {
    padding: 6px 7px 8px !important;
    border-radius: 15px !important;
  }
  .wolv-top-bar, .cyc-hdr, .str-hdr, .mag-hdr, .gambit-top-bar,
  .spidey-top, .qs-top-bar, .nc-hdr, .inf-hdr, .im2048-hdr,
  .gsol-top, .ssol-top, .jg-top-bar, .xch-top {
    padding-bottom: 4px !important;
    margin-bottom: 3px !important;
  }

  /* Captain America zoomed mobile camera & Loadout drawer */
  .cap-card.p { padding: 2px 0 4px !important; background: transparent !important; border: 0 !important; box-shadow: none !important; }
  .cap-hdr, .cap-telemetry, .cap-rig-hint { display: none !important; }
  .cap-bar { display: none !important; gap: 4px; margin-bottom: 5px; }
  .cap-card.loadout-open .cap-bar { display: flex !important; }
  .cap-canvas { aspect-ratio: 500 / 270 !important; border-radius: 14px !important; }
  .cap-rig { margin-top: 6px !important; padding: 7px 7px 7px !important; border-radius: 16px !important; }
  .cap-ctrl-btn { min-height: 64px !important; }
  .cap-shield-btn { min-width: 82px !important; }

  /* Clamp tall canvases/stages proportionally so Stage + Controller fit in 390x664 */
  .cyc-hud, .str-scores, .qs-hud-strip, .nc-hud, .inf-scores, .gambit-hud, .spidey-hud {
    margin-top: 4px !important;
    gap: 4px !important;
  }
  .cyc-stat, .str-sc-tile, .qs-stat, .nc-stat, .inf-sc-tile, .gambit-stat, .spidey-stat {
    padding: 3px 5px !important;
  }
  .cyc-canvas {
    width: auto !important;
    max-width: 100%;
    max-height: calc(100dvh - 330px);
    max-height: calc(100vh - 330px);
    margin: 0 auto;
  }
  .str-stage-wrap {
    width: fit-content;
    max-width: 100%;
    margin: 4px auto 0 !important;
  }
  .str-canvas-frame {
    width: min(88vw, calc(100dvh - 415px)) !important;
    width: min(88vw, calc(100vh - 415px)) !important;
    max-width: 100%;
    margin: 0 auto;
  }
  .str-deck { margin-top: 5px !important; padding: 6px !important; }
  .str-deck-hdr { display: none !important; }
  .str-dpad { grid-template-rows: repeat(3, 38px) !important; }
  .qs-canvas {
    width: auto !important;
    max-width: 100%;
    max-height: calc(100dvh - 358px);
    max-height: calc(100vh - 358px);
    margin: 0 auto;
  }
  .nc-canvas {
    width: auto !important;
    max-width: 100%;
    max-height: calc(100dvh - 342px);
    max-height: calc(100vh - 342px);
    margin: 0 auto;
  }
  .inf-canvas-frame {
    width: auto !important;
    max-width: min(100%, calc((100dvh - 365px) * 360 / 480));
    max-width: min(100%, calc((100vh - 365px) * 360 / 480));
    margin: 0 auto;
  }
  .inf-deck { margin-top: 5px !important; gap: 4px !important; }
  .inf-ctrl-btn { min-height: 46px !important; }
  .mag-canvas {
    width: 100%;
    max-height: calc(100dvh - 305px);
    max-height: calc(100vh - 305px);
  }
  .spidey-bar { margin-top: 4px !important; }
  .spidey-canvas {
    min-height: 176px;
    max-height: calc(100dvh - 360px);
    aspect-ratio: 640 / 380;
  }
  .im2048-grid {
    max-width: min(296px, calc(100dvh - 310px)) !important;
    margin: 6px auto !important;
    gap: 6px !important;
    padding: 7px !important;
  }
  .wolv-grid-stage {
    max-width: min(214px, calc(100dvh - 360px)) !important;
    margin: 4px auto !important;
  }

  /* Gambit / Jean Grey compact deck fit */
  .gambit-charge-row, .jg-charge-row { margin-top: 4px !important; }
  .gambit-stage, .jg-stage { padding: 5px; margin-top: 5px; }
  .gambit-grid, .jg-grid { gap: 4px; }
  .gambit-grid.cols-4 .gambit-card, .jg-grid.cols-4 .jg-card { aspect-ratio: 3 / 3.15; }
  .gambit-grid.cols-5 .gambit-card, .jg-grid.cols-5 .jg-card { aspect-ratio: 5 / 4.9; }

  /* Wordle compact fit + touch keys */
  .wordle-board { max-width: 242px !important; margin: 6px auto !important; gap: 5px !important; }
  .wordle-row { gap: 5px !important; }
  .wordle-cell { font-size: 18px !important; border-radius: 9px !important; }
  .wkb-rows { margin-top: 8px !important; gap: 5px !important; }
  .wkb-key { height: 44px !important; touch-action: manipulation; }

  /* Upgrade thumb D-pads & action buttons to comfortable 42-46px touch targets */
  .mag-dpad-btn,
  .qs-dpad-btn,
  .nc-pad-btn,
  .im2048-dir-btn,
  .wolv-pad-btn {
    min-width: 44px !important;
    min-height: 42px !important;
    font-size: 16px !important;
  }
  .str-pad-btn {
    min-width: 44px !important;
    min-height: 38px !important;
    font-size: 16px !important;
  }
  .spidey-swing-btn,
  .spidey-tingle-btn,
  .spidey-rst-btn {
    min-height: 54px !important;
  }
  .cyc-touch-track { height: 46px !important; }
  .cyc-btn-row button { min-height: 44px !important; }
}
