/* ===================================================================
   ELEMENTAL CLASH — MOBILE / TOUCH ADAPTATION LAYER
   Gated on body.touch (added by mobile.js for native/coarse devices)
   rather than @media (pointer:coarse) — some Android WebViews don't
   report pointer:coarse, so the class is the reliable signal.
   Desktop is untouched because body.touch is only present on devices.
   =================================================================== */

/* ---- safe-area variables (viewport-fit=cover) ---- */
:root{
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
}

/* ---- global touch hygiene ---- */
*{ -webkit-tap-highlight-color: transparent; }
html,body{ overscroll-behavior:none; }
body.touch{
  -webkit-touch-callout:none;
  -webkit-user-select:none; user-select:none;
  touch-action:manipulation;
}
body.touch input,
body.touch textarea,
body.touch [contenteditable]{
  -webkit-user-select:text; user-select:text; -webkit-touch-callout:default;
  font-size:16px;
}

/* ===== kill sticky hover + give a pressed state ===== */
body.touch .btn:hover, body.touch .mcard:hover, body.touch .node:hover,
body.touch .chip:hover, body.touch .hud-chip:hover, body.touch .trial-card:hover,
body.touch .bsel-card:hover, body.touch .bsel-back:hover, body.touch .icon-card:hover,
body.touch .shop-card:hover, body.touch .deck-card:hover, body.touch .card:hover,
body.touch .bpx-buybtn:hover, body.touch .bpx-claim:hover, body.touch .bpx-close:hover,
body.touch .rps-choice:hover, body.touch .lobby-row:hover{
  transform:none !important; filter:none !important;
}
body.touch .btn:active, body.touch .mcard:active, body.touch .chip:active,
body.touch .hud-chip:active, body.touch .trial-card:active, body.touch .bsel-card:active,
body.touch .bsel-back:active, body.touch .icon-card:active, body.touch .shop-card:active,
body.touch .bpx-buybtn:active, body.touch .bpx-claim:active, body.touch .bpx-close:active,
body.touch .rps-choice:active, body.touch .menu-card:active{
  transform:scale(.96) !important; filter:brightness(1.12) !important;
  transition:transform .05s ease, filter .05s ease;
}

/* ===== minimum tap targets ===== */
body.touch .btn, body.touch .chip, body.touch .hud-chip, body.touch .bsel-back,
body.touch .bpx-buybtn, body.touch .bpx-claim, body.touch .bpx-close,
body.touch .rps-choice, body.touch .icon-card, body.touch button,
body.touch .menu-back, body.touch .close, body.touch .x-close{
  min-height:48px;
}
body.touch .bpx-amt, body.touch .shop-price, body.touch .price{ font-size:16px; }

/* ===== drag surfaces don't scroll the page ===== */
body.touch.dragging{ touch-action:none; overflow:hidden; }
body.touch #screen-deck .deck-card,
body.touch #screen-duel .hand .card{ touch-action:none; }

/* ===== momentum scrolling ===== */
body.touch .overlay, body.touch .icon-grid, body.touch .deck-list, body.touch .shop-grid,
body.touch .lobby-list, body.touch .bpx-scroll, body.touch .leaderboard,
body.touch .inbox-list, body.touch .scrollable{
  -webkit-overflow-scrolling:touch; scrollbar-width:thin;
}

/* ===================================================================
   FULL-SCREEN UI. #overlay lives outside the scaled #stage, so it
   covers the whole device screen; big panels fill it edge-to-edge.
   =================================================================== */
body.touch .overlay{ padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); }

/* Battle Pass fills the whole screen */
body.touch .overlay > .bpx{
  width:100vw !important; height:100dvh !important;
  max-width:100vw !important; max-height:100dvh !important;
  border-radius:0 !important;
}
/* every content modal goes edge-to-edge in width; height grows to full, then scrolls */
body.touch .overlay > .modal:not(.off-modal){
  width:100vw !important; max-width:100vw !important;
  max-height:100dvh !important; height:auto !important;
  margin:0 !important; border-radius:0 !important; overflow:auto;
  box-sizing:border-box;
  padding-left:calc(20px + var(--sa-l)); padding-right:calc(20px + var(--sa-r));
}
/* short notices (offline / quick confirms) stay a tidy centered card */
body.touch .overlay > .off-modal{ width:min(92vw,460px) !important; max-width:460px !important; }

/* Content modals (Astral Calendar, match VICTORY/DEFEAT, settings, card choosers,
   etc.) are auto-scaled to fit the screen HEIGHT by mobile.js → installModalFit,
   so the whole panel — including its action buttons — is always visible with NO
   vertical scrollbar, on every device. (No fixed per-modal zoom anymore.) */

/* Settings keeps its centered-card shape (not full-width); height auto-fits via JS. */
body.touch .overlay > .modal.settings-modal{
  width:min(560px,94vw) !important; max-width:560px !important;
  height:auto !important; border-radius:18px !important;
  padding-left:26px !important; padding-right:26px !important;
}

/* 1-of-3 draw chooser (Oracle's Glimpse) & graveyard viewer: shrink the cards
   so the picker isn't oversized on a phone. */
body.touch .modal-card{ width:108px !important; height:192px !important; }
body.touch .modal-cards{ gap:12px !important; margin:12px 0 14px !important; }

/* currency HUD always sits on the right and ON TOP — never hidden behind the
   avatar / rank plate (the plate had a higher z-index and was covering it). */
body.touch .menu-hud{ z-index:30 !important; right:calc(14px + var(--sa-r)) !important; }
body.touch .rank-plate{ z-index:8 !important; }
/* map/Trials top bar: right-align the toolbar so the gold/gem chips are on the
   right and never hidden under the avatar/rank plate on the left. */
body.touch #screen-map .map-head{ justify-content:flex-end !important; padding-right:calc(8px + var(--sa-r)) !important; }

/* the small round "+" currency buttons are <button>s — keep them a fixed 1:1
   circle everywhere (the 48dp tap-target floor was stretching them tall). */
body.touch .hud-plus,
body.touch [id$="Plus"],
body.touch .bal-chip button{
  min-width:0 !important; min-height:0 !important;
  width:24px !important; height:24px !important; aspect-ratio:1 !important;
  flex:0 0 auto !important; padding:0 !important; line-height:1 !important; border-radius:50% !important;
}

/* =====================================================================
   BATTLE PASS on phones: the panel FILLS the screen (rule above), and the
   two tracks are sized from viewport HEIGHT so BOTH rows — premium (top)
   and free (bottom) — are fully visible with NO vertical scrolling.
   Cell + node share one width var so columns stay aligned; you still scroll
   left/right to move along the tiers.
   ===================================================================== */
body.touch .overlay > .bpx{
  padding:8px 12px 6px !important;
  /* one card-cell's height, derived so (2 cells + the node band) fit the body */
  --bpc-h: clamp(52px, calc((100vh - 150px) / 2.7), 150px);
  --bpc-w: calc(var(--bpc-h) * 0.68);
}
/* trim header + footer to free vertical room */
body.touch .bpx-head{ gap:10px !important; padding:0 4px 6px !important; }
body.touch .bpx-title{ font-size:22px !important; letter-spacing:1px !important; }
body.touch .bpx-season{ font-size:8px !important; letter-spacing:3px !important; margin-top:2px !important; }
body.touch .bpx-tierbadge{ width:54px !important; height:54px !important; }
body.touch .bpx-tb-tx b{ font-size:15px !important; }
body.touch .bpx-tb-tx small{ font-size:7px !important; }
body.touch .bpx-buybtn{ padding:6px 11px !important; font-size:11px !important; }
body.touch .bpx-buybtn i{ font-size:11px !important; padding:2px 7px !important; }
body.touch .bpx-foot{ padding:5px 4px 0 !important; gap:10px !important; }
body.touch .bpx-hint{ font-size:10px !important; line-height:1.3 !important; }
body.touch .bpx-close{ width:120px !important; height:44px !important; }
/* the two tracks: cells + nodes share the width var; height fits the screen */
body.touch .bpx-cell{ width:var(--bpc-w) !important; height:var(--bpc-h) !important; }
body.touch .bpx-cell.framed{ background-size:100% 100% !important; }
body.touch .bpx-node{ width:var(--bpc-w) !important; }
body.touch .bpx-band{ gap:9px !important; padding:0 8px !important; }
body.touch .bpx-band.nodes{ padding-top:3px !important; padding-bottom:3px !important; }
body.touch .bpx-disc{ width:calc(var(--bpc-w) * 0.8) !important; height:calc(var(--bpc-w) * 0.8) !important; }
body.touch .bpx-node.star .bpx-disc{ width:var(--bpc-w) !important; height:var(--bpc-w) !important; }
body.touch .bpx-num{ font-size:calc(var(--bpc-w) * 0.32) !important; }
body.touch .bpx-line{ height:5px !important; }
/* reward art scales with the (smaller) cells so it never spills over */
body.touch .bpx-cell .bpx-rw.card img{ height:calc(var(--bpc-h) * 0.56) !important; width:auto !important; object-fit:contain !important; }
body.touch .bpx-cell .bpx-rw.icon img{ height:calc(var(--bpc-h) * 0.40) !important; width:auto !important; }
body.touch .bpx-cell .bpx-gem, body.touch .bpx-cell .bpx-coin{ width:calc(var(--bpc-h) * 0.30) !important; height:calc(var(--bpc-h) * 0.30) !important; }
body.touch .bpx-amt{ font-size:calc(var(--bpc-h) * 0.11) !important; }
/* small in-cell badges shrink too */
body.touch .bpx-badge, body.touch .bpx-stars, body.touch .bpx-spell{ font-size:8px !important; padding:1px 5px !important; }
body.touch .bpx-freebadge{ width:54px !important; height:18px !important; }
body.touch .bpx-claim{ font-size:9px !important; padding:3px 8px !important; }
body.touch .bpx-labels{ width:24px !important; }
body.touch .bpx-rowlabel{ font-size:11px !important; letter-spacing:3px !important; }
body.touch .bpx-scroll{ margin-left:24px !important; justify-content:center !important; }

/* =====================================================================
   DECK FORGE — mobile-friendly redesign (bigger tap targets, bigger
   cards, sticky filters, thumb-zone pager, touch-visible remove).
   ===================================================================== */
body.touch #screen-deck{ padding:8px 10px !important; }
/* header: bigger, wraps; larger deck tabs + Done */
body.touch #screen-deck .deck-header{ gap:8px !important; margin-bottom:8px !important; flex-wrap:wrap !important; }
body.touch #screen-deck .deck-h-title{ font-size:17px !important; }
body.touch #screen-deck .deck-tabs{ gap:6px !important; }
body.touch #screen-deck .deck-tabs > *{ min-height:46px !important; padding:6px 12px !important; }
body.touch #screen-deck .deck-header .btn{ min-height:46px !important; padding:8px 18px !important; }
/* keep deck strip + collection side-by-side (landscape) but rebalance widths */
body.touch #screen-deck .deck-main{ grid-template-columns:minmax(210px,32%) 1fr !important; gap:12px !important; }
body.touch #screen-deck .deck-pane{ padding:10px !important; max-height:none !important; }
/* your-deck strip: fewer, bigger cards */
body.touch #screen-deck .slot-grid{ grid-template-columns:repeat(4,1fr) !important; gap:8px !important; }
/* collection grid: fewer, bigger, easily-tappable cards */
body.touch #screen-deck .trunk-grid{ grid-template-columns:repeat(auto-fill,minmax(96px,1fr)) !important; gap:10px !important; }
/* filters: bigger chips, wrap, and stick to the top while scrolling cards */
body.touch #screen-deck .filter-bar{ gap:8px 10px !important; padding:8px 10px !important; position:sticky !important; top:0 !important; z-index:6 !important; }
body.touch #screen-deck .filter-bar button,
body.touch #screen-deck .filter-bar select,
body.touch #screen-deck .filter-bar .star-select,
body.touch #screen-deck .filter-clear{ min-height:40px !important; padding:6px 12px !important; }
/* pager: big prev/next in the thumb zone */
body.touch #screen-deck .pager{ gap:14px !important; margin-top:8px !important; }
body.touch #screen-deck .pg-btn{ min-height:48px !important; min-width:104px !important; font-size:15px !important; padding:10px 18px !important; }
/* namebar controls bigger + wrap */
body.touch #screen-deck .deck-namebar{ flex-wrap:wrap !important; gap:8px !important; }
body.touch #screen-deck .set-active,
body.touch #screen-deck .deck-clear,
body.touch #screen-deck .deck-sort{ min-height:40px !important; }
/* touch has no hover — show a persistent ✕ on filled deck slots so removing is obvious */
body.touch #screen-deck .slot.filled::after{ content:'✕' !important; position:absolute !important; top:2px !important; right:2px !important;
  width:18px !important; height:18px !important; display:grid !important; place-items:center !important; border-radius:50% !important;
  background:rgba(160,32,52,.92) !important; color:#fff !important; font-size:11px !important; z-index:3 !important; pointer-events:none !important; }
/* a clear "+" add hint on collection cards you can still add (not depleted) */
body.touch #screen-deck .trunk-card:not(.depleted)::after{ content:'+' !important; position:absolute !important; top:3px !important; right:3px !important;
  width:20px !important; height:20px !important; display:grid !important; place-items:center !important; border-radius:50% !important;
  background:rgba(60,150,90,.92) !important; color:#fff !important; font-size:15px !important; line-height:1 !important; z-index:3 !important; pointer-events:none !important; }
body.touch #screen-deck .trunk-card{ position:relative !important; }
/* make the 🔍 view button an easy tap target */
body.touch #screen-deck .card-view-btn{ width:34px !important; height:34px !important; top:4px !important; left:4px !important; }
/* clearer pressed feedback when adding/removing */
body.touch #screen-deck .trunk-card:active, body.touch #screen-deck .slot.filled:active{ transform:scale(.94) !important; filter:brightness(1.15) !important; }

/* =====================================================================
   Star filter dropdown — a compact custom dropdown (replaces the native
   <select>, which Android renders as an ugly full-screen list). Works the
   same on phone + desktop. Ungated so it applies everywhere.
   ===================================================================== */
.star-dd{ position:relative; display:inline-block; }
.star-dd-btn{ display:inline-flex; align-items:center; gap:8px; cursor:pointer;
  background:rgba(12,9,28,.92); color:#e9e0ff; border:1px solid rgba(255,215,120,.35);
  border-radius:9px; padding:6px 12px; font:inherit; font-size:14px; white-space:nowrap; }
.star-dd-caret{ font-style:normal; opacity:.7; font-size:11px; }
.star-dd-menu{ position:absolute; top:calc(100% + 4px); left:0; z-index:60;
  min-width:130px; max-height:min(52vh,320px); overflow:auto; display:none;
  background:#171033; border:1px solid rgba(255,215,120,.4); border-radius:10px;
  box-shadow:0 12px 32px rgba(0,0,0,.6); padding:5px; }
.star-dd.open .star-dd-menu{ display:block; }
.star-dd-opt{ display:block; width:100%; text-align:left; cursor:pointer; font:inherit; font-size:14px;
  background:none; border:none; color:#e9e0ff; padding:9px 12px; border-radius:7px; }
.star-dd-opt:hover{ background:rgba(255,255,255,.08); }
.star-dd-opt.sel{ background:linear-gradient(90deg,rgba(200,166,78,.28),rgba(200,166,78,.08)); color:#ffe6a6; }
/* bigger tap targets on touch */
body.touch .star-dd-btn{ min-height:40px !important; font-size:15px !important; }
body.touch .star-dd-opt{ padding:12px 14px !important; font-size:15px !important; }
body.touch .star-dd-menu{ min-width:150px !important; }

/* Main-menu panels: on the full-screen (wider) stage the cards are wider than
   their art, so object-fit:cover was CROPPING the images (e.g. the ACHIEVEMENTS
   label baked at the bottom). Show the FULL image on a framed panel instead. */
body.touch .mcard{ background:linear-gradient(160deg,#241b54,#0f0a26) !important; box-shadow:inset 0 0 0 1px rgba(255,255,255,.06), 0 6px 18px rgba(0,0,0,.5) !important; }
body.touch .mcard-art{ object-fit:contain !important; object-position:center !important; }
/* the live Battle Pass card keeps its background filled behind its overlay */
body.touch .mcard.bp-menu .mcard-art{ object-fit:cover !important; }

/* LAN / Same-Wi-Fi play needs the local WebSocket server, which the published
   game doesn't run — hide (and thereby disable) every LAN entry point everywhere. */
#wLanBtn,
#wLan,
#olLan{ display:none !important; }

/* ===================================================================
   match-select (vs Ellie) was sized for desktop and overflowed the
   phone — shrink ~40% so the header + cards + Back button all fit.
   =================================================================== */
body.touch #bsel-root .battle-select{
  transform: scale(.6); transform-origin:center center;
}
body.touch #bsel-root, body.touch #rps-root{ padding-bottom:var(--sa-b); }
body.touch #rps-root .rps-choice{ min-width:56px; min-height:56px; }

/* ===================================================================
   shop card decorations (spinning conic ring, foil sweep, particles)
   glitch on some Android GPUs — they were rendering as a rainbow
   square over the art. Disable the heavy overlays on touch; the
   rarity glow (box-shadow) and badges remain.
   =================================================================== */
body.touch .ringspin{ display:none !important; }
body.touch .shop-card .foil{ mix-blend-mode:normal !important; opacity:.25 !important; }
body.touch .shop-card .aurora,
body.touch .shop-card .comet,
body.touch .shop-card .mote,
body.touch .shop-card .spark{ display:none !important; }
/* CARD BAZAAR flicker: the idle float (transform) + glow-pulse (box-shadow) +
   will-change:transform inside an overflow:hidden rounded card makes the whole
   card blink/repaint every frame on Android GPUs. Make the cards static. */
body.touch .shop-card,
body.touch .shop-card .cbody,
body.touch .shop-card .art,
body.touch .shop-card .rar-badge{ animation:none !important; will-change:auto !important; }
body.touch .shop-card{ transform:none !important; }

/* ===================================================================
   safe-area padding on top/bottom bars
   =================================================================== */
.menu-hud{ padding-top:calc(8px + var(--sa-t)); padding-left:calc(8px + var(--sa-l)); padding-right:calc(8px + var(--sa-r)); }
body.touch .duel-actions, body.touch .turn-actions{ padding-bottom:calc(6px + var(--sa-b)); }

/* media never bigger than the viewport and never blocks taps after it ends */
/* All cinematic videos fill ~90%+ of the screen. `width/height:auto` USED to make a
   low-resolution clip render at its small natural pixel size (a 540p low-graphics clip
   showed at half size on a 1080p screen) — these rules now force every clip to scale UP
   to the screen box, with object-fit:contain preserving the aspect ratio.
   Bare <video> is NOT capped so full-cover backgrounds (the duel field) still fill. */
.summon-cine-vid, .vfx-video{ width:96vw !important; height:90vh !important; object-fit:contain !important; }
/* Character reaction clips are sized precisely by JS (fitVideo in ellie.js) so the
   rounded frame + glow hug the picture; only cap them here. */
#ellie-vid video{ max-width:96vw !important; max-height:92vh !important; }
.cine-overlay.done, .vfx-overlay.done{ pointer-events:none; }

/* fill the letterbox around the fixed-canvas stage — no empty bars */
body.touch #stage-host{ background: radial-gradient(circle at 50% 36%, #1a1140 0%, #0c0818 62%, #07040f 100%); }

/* ===== low graphics / reduced motion — drop expensive GPU effects ===== */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001s !important; animation-iteration-count:1 !important; transition-duration:.05s !important; }
}
body.gfx-low *{ backdrop-filter:none !important; -webkit-backdrop-filter:none !important; }
body.gfx-low .bpx-buybtn.glow, body.gfx-low .bpx-claim, body.gfx-low .bpx-claimall,
body.gfx-low .menu-chip.glow, body.gfx-low .play-online{ animation:none !important; }
body.gfx-low .bpx, body.gfx-low .modal{ filter:none !important; }
body.gfx-low #stars{ opacity:.5; }

/* ===== portrait "rotate" prompt (landscape-locked game) ===== */
#rotate-prompt{
  position:fixed; inset:0; z-index:99999; display:none;
  flex-direction:column; align-items:center; justify-content:center; gap:18px;
  background:#0a0714; color:#efe9df; text-align:center; padding:24px;
  font-family:'Cinzel',Georgia,serif;
}
body.portrait #rotate-prompt{ display:flex; }
#rotate-prompt .rp-phone{ width:64px; height:104px; border:3px solid #e9c469; border-radius:12px; animation:rpRotate 1.8s ease-in-out infinite; }
#rotate-prompt h3{ margin:0; font-size:22px; color:#ffe9a8; letter-spacing:1px; }
#rotate-prompt p{ margin:0; font-size:15px; color:#bcae90; max-width:300px; }
@keyframes rpRotate{ 0%,40%{ transform:rotate(0); } 60%,100%{ transform:rotate(90deg); } }

/* ===== offline / network banner ===== */
#net-banner{
  position:fixed; left:50%; transform:translateX(-50%);
  top:calc(8px + var(--sa-t)); z-index:99998; display:none;
  background:linear-gradient(180deg,#7a1c1c,#4a0f0f); color:#ffd9d9;
  border:1px solid #c45b5b; border-radius:22px; padding:8px 18px;
  font-family:'Cinzel',Georgia,serif; font-size:13px; letter-spacing:.5px;
  box-shadow:0 6px 18px rgba(0,0,0,.5);
}
/* shown transiently for ~5s by online.js when connection drops, then auto-hides */
#net-banner.show{ display:block; animation:netIn .25s ease; }
/* "checking connection…" grace state — neutral blue, not an alarming red */
#net-banner.checking{ background:linear-gradient(180deg,#1c3a5a,#0f2238); border-color:#4a78a8; color:#cfe6ff; }
@keyframes netIn{ from{ opacity:0; transform:translateX(-50%) translateY(-8px); } to{ opacity:1; transform:translateX(-50%) translateY(0); } }

/* ===== purchase processing veil ===== */
#buy-processing{ position:fixed; inset:0; z-index:99997; display:none; align-items:center; justify-content:center; background:rgba(6,2,12,.5); }
body.buying #buy-processing{ display:flex; }
#buy-processing .spin{ width:46px; height:46px; border-radius:50%; border:4px solid rgba(233,196,105,.25); border-top-color:#e9c469; animation:spin 1s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* Shared responsive viewport: the same art is sized to the usable browser area. */
html,body{width:100%;height:100%;-webkit-text-size-adjust:100%;text-size-adjust:100%;}
#app{inset:auto;left:var(--ec-vx,0px);top:var(--ec-vy,0px);width:var(--ec-vw,100%);height:var(--ec-vh,100%);}
#stage-host{inset:0;}
#ellie-vid,#preview,.summon-cine{box-sizing:border-box;inset:auto!important;left:var(--ec-vx,0px)!important;top:var(--ec-vy,0px)!important;width:var(--ec-vw,100vw)!important;height:var(--ec-vh,100dvh)!important;padding:var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l);}
#ellie-vid video{max-width:70%!important;max-height:66%!important;object-fit:contain;}
.summon-cine-vid,.vfx-video{width:90%!important;height:82%!important;max-width:100%;max-height:100%;object-fit:contain!important;}
/* Reserve the bottom hand lane; cards never begin below the canvas. */
#screen-duel .hand-dock{bottom:18px;height:0;left:330px;right:250px;}
#screen-duel .handcard{width:98px;height:174px;bottom:0;}
#screen-duel .handcard:hover,#screen-duel .handcard.chosen{bottom:12px;}
#screen-duel .player-bar.you{bottom:16px;}
#screen-duel .hint{bottom:204px;max-width:80%;}
#screen-duel #cancelAction{bottom:204px;}
#screen-duel .player-bar.foe{top:20px;}
#screen-duel .bar-piles{padding-top:12px;}
#screen-duel .handcard{touch-action:manipulation;}
/* Limit menu panel geometry to the artwork's original design proportions. */
.menu-grid{width:min(100%,1440px);left:50%!important;right:auto!important;transform:translateX(-50%);}
.menu-titleblock{max-width:600px;}
body.ec-compact .menu-hud{right:14px!important;padding:8px!important;}
body.ec-compact .menu-corner{min-height:58px;min-width:58px;}
body.ec-compact #screen-duel .endbtn{min-height:76px;min-width:180px;}
/* Scroll content rather than shrinking modal text and controls into unreadable sizes. */
#overlay{box-sizing:border-box;padding:calc(8px + var(--sa-t)) calc(8px + var(--sa-r)) calc(8px + var(--sa-b)) calc(8px + var(--sa-l));overflow:hidden;}
#overlay>.modal{box-sizing:border-box;max-width:100%;max-height:100%;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;}
body.touch #overlay>.modal:not(.off-modal){width:100%!important;max-width:100%!important;}
#preview{gap:20px;padding:calc(12px + var(--sa-t)) calc(12px + var(--sa-r)) calc(12px + var(--sa-b)) calc(12px + var(--sa-l));}
#preview img{height:auto;max-height:90%;max-width:44%;object-fit:contain;flex:0 1 auto;}
#preview .pv-text{max-width:min(40%,360px);max-height:90%;margin:0;overflow:auto;}
body.touch #overlay>.bpx{width:100%!important;height:100%!important;max-width:100%!important;max-height:100%!important;--bpc-h:clamp(52px,calc((var(--ec-vh,100vh) - 150px - var(--sa-t) - var(--sa-b))/2.7),150px);}
/* Portrait web layout: keep the board's five lanes, with a full hand below. */
body.ec-portrait .menu-grid{display:grid;grid-template-columns:1fr 1fr;grid-template-rows:180px 180px 130px 150px 150px;gap:18px;width:780px!important;height:862px;top:390px!important;bottom:auto!important;}
body.ec-portrait .menu-grid>.mcard{position:relative!important;inset:auto!important;width:100%!important;height:100%!important;min-width:0;}
body.ec-portrait .menu-grid #deck{grid-column:1;grid-row:1;}
body.ec-portrait .menu-grid #pvp{grid-column:1;grid-row:2;}
body.ec-portrait .menu-grid #play{grid-column:2;grid-row:1/span 2;}
body.ec-portrait .menu-grid #tutBtn{grid-column:1;grid-row:3;}
body.ec-portrait .menu-grid #tutPortal{grid-column:2;grid-row:3;}
body.ec-portrait .menu-grid #achBtn{grid-column:1;grid-row:4;}
body.ec-portrait .menu-grid #shop{grid-column:2;grid-row:4;}
body.ec-portrait .menu-grid #bpBtn{grid-column:1/span 2;grid-row:5;}
body.ec-portrait .menu-titleblock{top:160px!important;left:50%!important;width:780px!important;transform:translateX(-50%)!important;}
body.ec-portrait .title-main{font-size:64px!important;line-height:1.03;}
body.ec-portrait .menu-crest{display:none;}
body.ec-portrait .menu-hud{top:110px!important;right:50%!important;transform:translateX(50%);white-space:nowrap;}
body.ec-portrait #rankBanner{top:12px!important;left:24px!important;}
body.ec-portrait .menu-corner{bottom:30px!important;}
body.ec-portrait #screen-duel .field-row.foe{top:220px;}
body.ec-portrait #screen-duel .field-row.you{top:650px;}
body.ec-portrait #screen-duel .center-band,body.ec-portrait #screen-duel .directzone{top:522px;}
body.ec-portrait #screen-duel .foe-hand{top:128px;}
body.ec-portrait #screen-duel .hand-dock{left:80px;right:80px;bottom:134px;}
body.ec-portrait #screen-duel .handcard{width:120px;height:213px;}
body.ec-portrait #screen-duel .logbox{top:980px;left:24px;width:852px;height:122px;overflow:auto;}
body.ec-portrait #screen-duel .corner-quit{top:926px;right:24px;min-height:62px;}
body.ec-portrait #screen-duel .hint,body.ec-portrait #screen-duel #cancelAction{bottom:390px;}
body.ec-portrait #screen-duel .player-bar.you{bottom:24px;}
body.ec-portrait #screen-duel .endbtn{min-height:88px;}
body.ec-portrait #screen-deck,body.ec-portrait #screen-shop,body.ec-portrait #screen-world,body.ec-portrait #screen-online,body.ec-portrait #screen-map,body.ec-portrait #screen-login{overflow:auto;overscroll-behavior:contain;}
@media(max-width:600px) and (orientation:portrait){
 #preview{flex-direction:column;}
 #preview img{max-height:58%;max-width:76%;width:auto;}
 #preview .pv-text{max-width:94%;max-height:34%;font-size:16px;}
 #preview .pv-text h3{font-size:22px;}
 #preview .pv-text p{font-size:16px;}
}

/* Keep baked-in labels visible and preserve source image proportions. */
body.ec-compact .mcard-art{object-fit:contain!important;object-position:center!important;}
body.ec-compact .mcard.bp-menu .mcard-art{object-fit:cover!important;}
body.ec-compact #screen-duel .endbtn{min-height:calc(44px / var(--ec-stage-scale,1));font-size:max(17px,calc(12px / var(--ec-stage-scale,1)));}
body.ec-portrait .menu-grid{grid-template-rows:180px 180px 200px 150px 150px;height:932px;}

.mcard-art{object-fit:contain;}
.mcard.bp-menu .mcard-art{object-fit:cover;}
#preview img{height:min(760px,calc(var(--ec-vh,100vh)*.86));width:auto;}
@media(max-width:600px) and (orientation:portrait){#preview img{height:min(760px,calc(var(--ec-vh,100vh)*.56));max-width:76%;width:auto;}}

/* Scaled-stage controls retain a physical tap size on compact viewports. */
body.ec-compact #stage .btn,body.ec-compact #stage .pg-btn,body.ec-compact #stage .filter-btn,body.ec-compact #stage .deck-tab,body.ec-compact #stage .deck-sort,body.ec-compact #stage .shop-tab{min-height:calc(44px / var(--ec-stage-scale,1));font-size:max(15px,calc(12px / var(--ec-stage-scale,1)));}
body.ec-portrait #screen-deck .deck-header{flex-wrap:wrap;gap:18px;}
body.ec-portrait #screen-deck .deck-h-title{font-size:36px!important;}
body.ec-portrait #screen-deck .deck-main{grid-template-columns:1fr!important;grid-template-rows:360px minmax(500px,1fr);}
body.ec-portrait #screen-deck .deck-pane{max-height:none!important;}
body.ec-portrait #screen-deck .trunk-grid{grid-template-columns:repeat(4,minmax(0,1fr))!important;}
body.ec-portrait #screen-deck .slot-grid{grid-template-columns:repeat(6,minmax(0,1fr))!important;}
body.ec-portrait #screen-deck .filter-bar{flex-wrap:wrap;}
body.ec-portrait #screen-duel .logbox{top:1030px;height:78px;}
body.ec-portrait #screen-duel .corner-quit{top:940px;}
