/* Shared game UI: one scroll owner per sheet; fixed chrome never covers content. */
:root {
  --ui-height:100dvh; --ui-top:0px;
  --ui-safe-top:env(safe-area-inset-top,0px); --ui-safe-bottom:env(safe-area-inset-bottom,0px);
  --ui-safe-left:env(safe-area-inset-left,0px); --ui-safe-right:env(safe-area-inset-right,0px);
  --ui-bar:64px; --ui-dock:80px; --ui-gap:16px;
  --ink:#f6fbff; --muted:#c0d4eb; --edge:#76a6cf; --edge-in:#5387ba; --edge-out:#06162c;
  --box1:#204770; --box2:#143453; --gold:#ffda66; --gold2:#efb32b;
  --ui-surface:#173b60; --ui-raised:#28567f; --ui-deep:#0b223d;
  --ui-font:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  --ui-display:'Pixelify',var(--ui-font);
}
html { overscroll-behavior:none; background:#092744; }
body { font:15px/1.5 var(--ui-font); -webkit-font-smoothing:antialiased; user-select:auto; }
body::before { content:''; position:fixed; inset:0; pointer-events:none; background:#092744; z-index:-1; }
button,input,select,textarea { font:inherit; }
button,[role=button],summary,a { -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
button,summary,[role=button] { user-select:none; }
a { color:#b9e5ff; text-underline-offset:3px; }
button:focus-visible,a:focus-visible,[role=button]:focus-visible,summary:focus-visible,.field:focus-visible {
  outline:3px solid #fff2b7; outline-offset:3px; box-shadow:0 0 0 6px #0b223d;
}
button:disabled { cursor:not-allowed; }
[hidden] { display:none!important; }
.scr,.save-writer-wait {
  top:var(--ui-top); bottom:auto; height:var(--ui-height); width:100%;
  padding:max(16px,var(--ui-safe-top)) max(16px,var(--ui-safe-right)) max(16px,var(--ui-safe-bottom)) max(16px,var(--ui-safe-left));
  min-width:0; min-height:0; overflow:hidden; isolation:isolate;
}
.scr.dim,.save-writer-wait { background:rgba(3,14,29,.88); backdrop-filter:blur(8px); }
body.ui-hub .scr:not(#scr-menu):not(#scr-settings):not(#scr-news):not(#scr-legal):not(#scr-profile):not(#scr-support):not(#scr-nick):not(#scr-arena-notice):not(#scr-arena-fix-notice):not(#scr-save-payment-notice) {
  padding-top:calc(var(--ui-safe-top) + var(--ui-bar) + 12px);
  padding-bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 12px);
}
/* Modal sheets sit above the resource bar. */
#scr-settings,#scr-news,#scr-legal,#scr-profile,#scr-support,#scr-nick,#scr-arena-notice,#scr-arena-fix-notice,#scr-save-payment-notice,#scr-arena-death,#scr-arena-feedback { z-index:60; }
.box {
  background:var(--ui-surface); border:2px solid #6494bb; border-radius:18px;
  box-shadow:0 6px 0 #06182c,0 18px 50px #020b1b66,inset 0 1px 0 #b5d9f533;
  padding:24px; text-shadow:none; max-width:100%;
}
.box h1,.box h2,.box h3 { font-family:var(--ui-display); letter-spacing:0; line-height:1.15; }
.box h2 { font-size:30px; } .box h3 { font-size:22px; }
.box p { overflow-wrap:anywhere; } .sub { font-size:14px; color:var(--muted); margin-bottom:16px; line-height:1.5; }
.note { font-size:13px; line-height:1.5; color:var(--muted); }
.box.ui-panel { display:flex; flex-direction:column; min-height:0; max-height:100%; padding:0!important; overflow:hidden; width:min(620px,100%); animation:ui-enter .18s ease-out; }
.box.ui-panel.wide { width:min(1080px,100%); }
.box.ui-panel.settings { width:min(760px,100%); }
.box.ui-panel.profile-box { width:min(660px,100%); }
.ui-panel-header { flex:0 0 auto; margin:0!important; padding:18px 24px; background:#244e76; border-bottom:1px solid #77acd144; min-width:0; }
h2.ui-panel-header { font-size:28px; }
.ui-panel-header h2 { margin:0; }
.ui-panel-header .sub { margin:4px 0 0; }
.ui-panel-header .row { flex-wrap:wrap; }
.ui-scroll { flex:1 1 auto; min-height:0; min-width:0; padding:20px 24px; overflow-y:auto; overflow-x:hidden; overscroll-behavior-y:contain; touch-action:pan-y; scrollbar-gutter:stable; scroll-padding:16px; -webkit-overflow-scrolling:touch; }
.ui-panel-footer { flex:0 0 auto; padding:16px 24px 20px; border-top:1px solid #77acd144; background:#102e4b; min-width:0; }
.ui-panel-footer>.row { margin-top:0!important; }
.ui-panel-footer .note { margin:8px 0 0; }
.ui-scroll> :first-child { margin-top:0; } .ui-scroll> :last-child { margin-bottom:0; }
.ui-panel .grid,.ui-panel .fr-list,.ui-panel .rk-list,.ui-panel .goals-body,.ui-panel .set-body,.ui-panel .news-body,.ui-panel .arena-slots { max-height:none; height:auto; overflow:visible; padding-right:0; }
.ui-panel :where(.split,.panel,.row,.grow,.txt,.upg-head,.arena-setup)>* { min-width:0; }
.ui-panel .row { gap:12px; flex-wrap:wrap; }
.ui-panel .row>.field.grow { flex-basis:170px; }
.ui-panel .grid { grid-template-columns:repeat(auto-fill,minmax(100px,1fr)); gap:10px; }
.ui-panel .split { grid-template-columns:minmax(0,1fr) minmax(240px,320px); gap:20px; align-items:start; }
.panel { background:#0d2a48; border:1px solid #648eb56b; border-radius:12px; padding:16px; }
/* Deliberate game buttons: depth communicates press; gold marks commitment. */
.btn,.menu-item {
  min-height:48px; padding:11px 18px; border:2px solid #87c3ed; border-bottom-color:#306997;
  border-radius:10px; background:linear-gradient(#439ad2,#2472ae); color:#fff;
  box-shadow:0 4px 0 #061a31,inset 0 2px 0 #c6eeff55; text-shadow:0 2px 0 #092e50;
  font-family:var(--ui-display); font-size:20px; line-height:1.15; font-weight:700; letter-spacing:0;
  transition:transform .1s ease,filter .1s ease; cursor:pointer; text-decoration:none;
  display:inline-flex; align-items:center; justify-content:center; gap:8px; text-align:center;
}
.btn.small { min-height:44px; padding:9px 14px; font-size:18px; }
.btn.gold,.menu-item.play { color:#392508; background:linear-gradient(#ffe785,#ffc342); border-color:#fff1b1; border-bottom-color:#c88a1f; box-shadow:0 5px 0 #8b5814,inset 0 2px 0 #fff6ce; text-shadow:0 1px 0 #fff1ba; }
.btn.ghost { color:#e8f5ff; background:#214b71; border-color:#5586af; border-bottom-color:#173a5c; text-shadow:none; }
.btn:hover,.menu-item:hover { filter:brightness(1.08); outline:revert; }
.btn:active,.menu-item:active { transform:translateY(3px); box-shadow:0 1px 0 #061a31,inset 0 1px 0 #c6eeff55; }
.btn:disabled,.btn[aria-disabled=true] { opacity:.55; filter:saturate(.45); transform:none; box-shadow:0 3px 0 #061a31; }
.btn svg,.btn .pxi { flex-shrink:0; }
.ui-icon-button { display:grid; place-items:center; padding:9px; width:44px; height:44px; flex:0 0 44px; background:#28567f; color:#fff; border:1px solid #73a6cc; border-radius:10px; cursor:pointer; box-shadow:0 3px 0 #061a31; }
.ui-icon-button svg { width:24px; height:24px; }
.field { min-height:48px; font-size:16px; color:#fff; padding:11px 12px; background:#071e36; border:1px solid #6b9fc4; border-radius:10px; line-height:1.4; max-width:100%; }
.field::placeholder { color:#a8c3dc; opacity:1; }
.field:focus { border-color:#bdeaff; }
textarea.field { resize:vertical; min-height:96px; }
label { font-size:14px; color:#d3e6f8; margin-top:12px; }
input[type=range] { min-height:44px; accent-color:#ffd364; }
input[type=radio],input[type=checkbox] { width:20px; height:20px; accent-color:#ffcf58; vertical-align:middle; flex-shrink:0; }
fieldset { border:1px solid #6b9fc466; border-radius:12px; padding:12px 16px; min-width:0; }
fieldset label { min-height:44px; display:flex; align-items:center; gap:10px; margin:0; }
/* Tabs and filters scroll horizontally only; they never own a vertical scroll. */
.tabs,.gen-tabs,.filters { display:flex; flex-wrap:wrap; gap:8px; padding:4px 0 8px; margin:0 0 12px; min-width:0; overflow:visible; }
.gen-tabs { flex-wrap:nowrap; overflow-x:auto; max-width:100%; overscroll-behavior-x:contain; touch-action:pan-x; scrollbar-width:thin; }
.tab,.gen-tab,.chip { min-height:44px; padding:9px 14px; border-radius:9px; border:1px solid #5e8fb7; background:#0d2c4a; color:#d8e9f9; font-size:14px; line-height:1.2; font-weight:650; white-space:nowrap; cursor:pointer; }
.tab { flex:1; }
.gen-tab { flex-shrink:0; }
.tab.on,.gen-tab.on,.chip.on { color:#342508; border-color:#ffe69c; background:#ffda72; box-shadow:0 2px 0 #8c621e; }
.chip svg,.chip .pxi { vertical-align:middle; }
/* Resource bar stays within safe areas. Utilities live behind a labeled menu. */
.topbar { inset:calc(var(--ui-top) + var(--ui-safe-top)) 0 auto; min-height:var(--ui-bar); padding:10px max(16px,var(--ui-safe-right)) 10px max(16px,var(--ui-safe-left)); background:#09233eea; border-bottom:1px solid #8bc0df44; backdrop-filter:blur(12px); display:flex; justify-content:center; gap:10px; z-index:40; width:100%; }
.pill { min-height:40px; max-width:100%; gap:6px; padding:6px 12px; border:1px solid #5583a9; border-radius:10px; background:#071a30; box-shadow:inset 0 2px 4px #0004; text-shadow:none; font-size:15px; white-space:nowrap; font-variant-numeric:tabular-nums; }
#tickets-pill { flex-shrink:1; flex-wrap:wrap; }
#user-pill { max-width:240px; cursor:pointer; overflow:hidden; text-overflow:ellipsis; }
#user-pill small { font-size:11px; }
#ui-tools-toggle { margin-left:8px; }
.ui-tools { position:fixed; z-index:85; top:calc(var(--ui-top) + var(--ui-safe-top) + var(--ui-bar) + 8px); right:max(16px,var(--ui-safe-right)); width:min(320px,calc(100% - 32px)); max-height:calc(var(--ui-height) - var(--ui-bar) - 32px); padding:16px; background:#173b60; border:2px solid #6d9ec4; border-radius:16px; box-shadow:0 15px 40px #0009; overflow-y:auto; overscroll-behavior:contain; }
.ui-tools-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.ui-tools-head b { font-family:var(--ui-display); font-size:24px; }
.ui-tool-action { display:flex; justify-content:flex-start; width:100%; margin-top:10px; gap:12px; }
.ui-tool-label { font-family:var(--ui-font); font-size:14px; }
#btn-logout { color:#ffd1d5; }
#btn-logout .ui-tool-label { display:none; }
.sound-panel { z-index:90; top:calc(var(--ui-top) + var(--ui-safe-top) + var(--ui-bar) + 8px); right:max(16px,var(--ui-safe-right)); width:min(340px,calc(100% - 32px)); max-height:calc(var(--ui-height) - var(--ui-bar) - 32px); overflow:auto; }
.game-dock { position:fixed; z-index:45; bottom:0; left:0; right:0; padding:0 max(12px,var(--ui-safe-right)) var(--ui-safe-bottom) max(12px,var(--ui-safe-left)); height:calc(var(--ui-dock) + var(--ui-safe-bottom)); display:flex; justify-content:center; background:linear-gradient(#31597b,#1b3857); border-top:2px solid #92b8d2; box-shadow:0 -5px 20px #0004; }
.game-dock button { appearance:none; flex:1; max-width:150px; min-width:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; color:#c6d9ed; border:0; border-left:1px solid #7c9ab933; background:transparent; cursor:pointer; font-size:12px; font-weight:700; position:relative; }
.game-dock button:last-child { border-right:1px solid #7c9ab933; }
.game-dock svg { width:27px; height:27px; filter:drop-shadow(0 2px 0 #061a31); }
.game-dock button.on { background:linear-gradient(#4e8cba,#285a82); color:#fff0b2; }
.game-dock button.on::before { content:''; position:absolute; top:0; left:20%; right:20%; height:4px; border-radius:0 0 4px 4px; background:#ffda72; }
.game-dock button[data-route=menu] svg { width:32px; height:32px; }
/* Main hub. The chosen Pokémon owns the stage; gold belongs to the run action. */
#scr-menu { padding:calc(var(--ui-safe-top) + var(--ui-bar) + 20px) max(24px,var(--ui-safe-right)) calc(var(--ui-safe-bottom) + var(--ui-dock) + 20px) max(24px,var(--ui-safe-left)); background-color:#104c78; background-image:linear-gradient(45deg,#0c345344 25%,transparent 25%,transparent 75%,#0c345344 75%),linear-gradient(45deg,#0c345344 25%,transparent 25%,transparent 75%,#0c345344 75%),radial-gradient(ellipse at 35% 38%,#3895bd66,transparent 65%); background-size:88px 88px,88px 88px,100% 100%; background-position:0 0,44px 44px,0 0; }
.hub-layout { width:min(1060px,100%); max-height:100%; min-height:0; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; touch-action:pan-y; display:grid; grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); align-items:center; gap:48px; padding:8px 6px 16px; scrollbar-width:thin; }
#scr-menu .menu-left { padding:0; min-width:0; }
#scr-menu .logo { margin:0 0 20px; }
#scr-menu .logo .t1 { font:700 clamp(40px,4.7vw,64px)/.95 var(--ui-display); color:#ffe481; letter-spacing:-1px; text-shadow:0 4px 0 #8c5717,0 7px 0 #082a46; }
#scr-menu .logo .t2 { font:700 12px/1.4 var(--ui-font); letter-spacing:3px; margin-top:12px; color:#def5ff; }
.partner-card { position:relative; isolation:isolate; width:100%; margin:0; padding:8px 12px 22px; border:0; background:none; }
.partner-card::before { content:''; position:absolute; z-index:-1; left:12%; right:12%; top:50%; height:55px; border-radius:50%; background:linear-gradient(#75b8b4,#236677); border:3px solid #89c6c7; box-shadow:0 10px 0 #103d56,0 16px 20px #031d3a77; }
#menu-partner { width:300px; max-width:100%; height:220px; object-fit:contain; margin:0 auto 8px; display:block; }
.partner-card .nm { font:700 30px/1.2 var(--ui-display); text-shadow:0 3px 0 #062740; }
.partner-card .lv { font:14px/1.5 var(--ui-font); color:#d5eaf8; margin-top:4px; text-shadow:none; }
#menu-shiny { margin-top:10px; justify-content:center; }
#scr-menu .menu-right { width:auto; padding:0; background:none; overflow:visible; gap:18px; }
#scr-menu .menu-right>:first-child { margin-top:0; } #scr-menu .menu-right>:last-child { margin-bottom:0; }
.hub-heading h1 { font:700 34px/1.1 var(--ui-display); margin:0 0 8px; text-shadow:0 2px 0 #082a46; }
.hub-heading p { margin:0; color:#d6ebfb; font-size:14px; }
.hub-actions { display:grid; gap:14px; }
#scr-menu .menu-item { width:100%; display:grid; grid-template-columns:38px minmax(0,1fr); column-gap:10px; text-align:left; padding:14px 20px; min-height:72px; font-size:24px; color:#fff; }
#scr-menu .menu-item::before { display:none; }
#scr-menu .menu-item .mi-ico { grid-row:1 / 3; display:flex; align-items:center; justify-content:center; }
#scr-menu .menu-item small { grid-column:2; font:12px/1.4 var(--ui-font); color:#e3f2ff; white-space:normal; margin-top:4px; }
#scr-menu .menu-item.play { min-height:86px; font-size:32px; color:#392508; }
#scr-menu .menu-item.play small { color:#604117; }
.hub-shortcuts { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
#scr-menu .hub-shortcuts .menu-item { display:flex; flex-direction:column; justify-content:center; padding:12px 6px; min-height:80px; gap:7px; font-size:19px; background:linear-gradient(#366a92,#255172); border-color:#6596b9; }
#scr-menu .hub-shortcuts .menu-item small { display:none; }
#scr-menu .hub-stats { padding:0!important; background:none; border:0; box-shadow:none; border-radius:0; }
#menu-stats { display:block!important; font-size:13px!important; color:#d3e8f8!important; text-align:center; }
.hub-info { min-height:44px; border:0; background:none; color:#c9e4f6; text-decoration:underline; text-underline-offset:4px; cursor:pointer; font-size:12px; }
.hub-extras { border-top:1px solid #82b5d355; padding-top:12px; }
.hub-extras summary { min-height:44px; font-size:13px; font-weight:600; cursor:pointer; display:list-item; }
.hub-extras .share-reward-card { margin:8px 0 12px; padding:16px!important; }
.hub-extras .menu-champion { width:100%; margin:8px 0; }
.hub-extras .share-reward-head b { font-size:16px; }
.share-reward-close,.champion-close { min-width:44px; min-height:44px; font-size:24px; }
/* Card systems stay readable, including reward, achievement and profile subviews. */
.cell { border:1px solid #628bad; border-radius:12px; background:linear-gradient(#325d82,#244967); padding:12px 6px 8px; min-height:120px; box-shadow:0 3px 0 #071c33; transition:transform .12s; }
.cell b { font-size:12px; line-height:1.35; } .cell .no { font-size:10px; color:#c7dded; }
.cell.on { border:2px solid #ffda72; background:#365d79; }
.cell.locked { opacity:.64; }
.cell:hover { background:#365f82; transform:translateY(-2px); }
#dex-detail { width:100%; max-width:100%; overflow-wrap:anywhere; }
.ui-dex-close,.ui-dex-shade { display:none; }
.ui-dex-sheet { min-width:0; position:sticky; top:0; }
.ui-dex-sheet .panel { margin:0; }
#dex-detail .btn { width:100%; margin-top:12px; }
.ui-panel .upg,.ui-panel .ach-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr)); gap:12px; }
.upg-head { gap:16px; padding-bottom:16px; margin-bottom:16px; border-bottom:1px solid #82b5d333; }
#upg-mon { min-width:0!important; width:100%!important; }
.upg-head .grow { flex:1; min-width:0; }
.upg-item { grid-template-columns:32px minmax(0,1fr) auto; gap:12px; padding:16px; }
.upg-item .btn { min-width:64px; }
.upg-btns { gap:10px; }
.bind-slots { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.ban-moves { gap:8px; }
.cards { width:min(640px,100%); gap:12px; margin:auto; }
.card { min-height:84px; padding:16px; gap:14px; border:1px solid #739fc1; border-radius:12px; background:#244c71; box-shadow:0 4px 0 #071c33; text-align:left; }
.card .txt { min-width:0; }
.card .nm { font:700 23px/1.15 var(--ui-display); }
.card .ds { font-size:14px; line-height:1.5; margin-top:6px; }
.card:hover { background:#315f85; transform:translateY(-1px); }
.card.evo,.card.bond { border-width:2px; }
#scr-test .q { font-family:var(--ui-display); font-size:28px; line-height:1.25; }
#scr-test .answers { gap:12px; } #scr-test .answer { min-height:56px; padding:14px; }
#scr-result .trait { font-family:var(--ui-display); font-size:42px; }
#res-stage { max-height:160px; width:auto; }
#scr-result .ui-panel-footer .btn { flex:1; }
#scr-login .ui-panel { width:min(460px,100%)!important; }
#scr-login .logo { margin:0 0 18px; }
#scr-login .logo .t1 { font:700 42px/1 var(--ui-display); text-shadow:0 3px 0 #8c5717,0 5px 0 #082a46; }
#scr-login .logo .t2 { font:700 11px/1.4 var(--ui-font); letter-spacing:3px; }
#scr-login .login-tag { font-size:14px; line-height:1.5; margin-bottom:20px; }
#scr-login .btn { width:100%; }
#scr-login .home-seo summary { min-height:44px; }
#scr-login .home-seo-copy { font-size:14px; line-height:1.6; }
#scr-login .home-seo h2 { font-size:24px; }
#login-err:empty,#nick-err:empty { min-height:0; margin:0; }
#login-recovery-note { margin-top:16px; }
#scr-pause .ui-panel-footer .row { display:grid; grid-template-columns:1fr 1fr; }
#btn-resume { grid-column:1/-1; min-height:56px; }
#pause-coop { border:1px solid #f3c55b; padding:12px; border-radius:8px; color:#ffe69c; background:#4b401e; }
.fr-row { padding:14px; gap:12px; min-width:0; border-color:#5381a7; background:#102e4c; }
.fr-row .row { gap:8px; }
.fr-row b { font-size:15px; }
.lob-cards { grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.lob-card { min-width:0; }
.lob-card canvas { max-width:100%; height:auto; }
.rk-row { grid-template-columns:42px minmax(0,1fr) auto; padding:12px; gap:10px; background:#102e4c; border:1px solid #507fa5; }
.rk-row .mons { display:none; }
.rk-row .who b { font-size:14px; }
.rk-row .time,.rk-collection-row .collection-score b { font:700 24px/1 var(--ui-display); }
.rk-collection-row { grid-template-columns:38px 36px minmax(0,1fr) auto; }
.rk-tools .field { width:auto; flex:1 1 200px; min-height:44px; font-size:16px; }
.rk-me { border:1px solid #d7b95a; background:#393e37; color:#ffe69c; padding:14px; }
.mission,.ach { padding:14px; gap:12px; background:#102e4c; border:1px solid #507fa5; border-radius:12px; }
.mission .btn { flex-shrink:0; }
.fav-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
.fav-slot { min-width:0; min-height:110px; }
.fav-slot canvas { max-width:100%; height:auto; }
#prof-body .prof-favs { gap:10px; }
#prof-body canvas { max-width:100%; }
/* Gacha: banner and choices first; rate disclosure remains available. */
#scr-gacha .banner { border:1px solid #9dbbd1; border-radius:14px; padding:20px; background:linear-gradient(135deg,#3a6d9d,#203e69); }
#scr-gacha .feat { min-height:100px; gap:12px; }
#scr-gacha .feat canvas { max-width:100px; height:auto; }
#scr-gacha .split { grid-template-columns:minmax(0,1.5fr) minmax(220px,1fr); }
#scr-gacha .split .row .btn { flex:1 1 120px; min-height:58px; font-size:18px; }
#pull-10b { background:linear-gradient(#59bed8,#30859d); border-color:#a6ecf8; color:#061e31; text-shadow:0 1px 0 #d0f7ff; box-shadow:0 4px 0 #13506b; }
.rates { font-size:14px; line-height:1.5; } .rates h3 { font-size:22px; }
#pull-fx { position:fixed; inset:var(--ui-top) 0 auto; height:var(--ui-height); padding:24px max(16px,var(--ui-safe-right)) max(20px,var(--ui-safe-bottom)) max(16px,var(--ui-safe-left)); display:flex; flex-direction:column; gap:20px; background:#06172bf5; z-index:100; overflow:hidden; }
.ui-pull-scroll { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; display:flex; flex-direction:column; align-items:center; gap:20px; padding:16px 4px; }
#slot { flex-shrink:0; min-height:170px; }
.pull-results { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); width:min(900px,100%); gap:14px; }
#pull-close { position:static; flex-shrink:0; align-self:center; min-width:min(280px,100%); min-height:54px; }
/* Arena subviews and feedback share the same sheet geometry. */
.arena-box .arena-head { align-items:flex-start; }
#arena-title-subtitle { display:block; margin-top:4px; font-size:13px!important; }
.arena-rules { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; font-size:13px; margin-bottom:20px; }
.arena-rules span { min-width:0; }
.arena-setup { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:20px; }
.arena-role-panel .stage { height:110px; width:auto; max-width:100%; }
.arena-slot { min-height:48px; padding:10px; }
.arena-feedback-form { min-width:0; }
.arena-feedback-form label,.arena-feedback-form legend { font-size:14px; }
.arena-feedback-form fieldset { margin-bottom:16px; }
#arena-feedback-form>.row:last-child { position:sticky; bottom:-20px; padding:14px 0; margin-bottom:-20px; background:#173b60; border-top:1px solid #75a5c844; }
.arena-canvas { max-width:100%; width:100%; height:auto; max-height:none; border-radius:10px; }
#arena-hud-scoreboard { top:calc(var(--ui-safe-top) + 8px); left:calc(var(--ui-safe-left) + 8px); width:min(240px,calc(100vw - 32px)); pointer-events:auto; max-height:36dvh; overflow:auto; opacity:.9; }
#arena-hud-scoreboard .arena-hud-row { min-height:25px; }
/* Auxiliary windows, notices, feedback and system messages. */
#invite-pop { position:fixed; z-index:92; right:max(16px,var(--ui-safe-right)); bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 16px); width:min(380px,calc(100% - 32px)); max-height:calc(var(--ui-height) - var(--ui-bar) - var(--ui-dock) - 40px); overflow:auto; }
#invite-pop .row { flex-wrap:wrap; gap:10px; }
.save-writer-wait { z-index:120; }
.save-writer-wait-box.ui-panel { display:block; padding:24px!important; max-height:100%; overflow-y:auto; }
.save-writer-wait-box button { min-height:48px; }
.toast,.ach-pop { z-index:130; max-width:min(520px,calc(100vw - 32px)); width:max-content; white-space:normal; overflow-wrap:anywhere; font:14px/1.5 var(--ui-font); color:#fff; border:1px solid #89afce; background:#0c2d4b; padding:14px 18px; border-radius:12px; box-shadow:0 8px 25px #0006; text-shadow:none; }
.toast { bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 16px); }
.ach-pop { top:auto; bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 16px); }
#ps-version-update { transform:none!important; bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 16px)!important; max-width:calc(100vw - 32px)!important; left:16px!important; right:16px!important; width:auto!important; }
.boot,.tapstart { padding:max(24px,var(--ui-safe-top)) max(20px,var(--ui-safe-right)) max(24px,var(--ui-safe-bottom)) max(20px,var(--ui-safe-left)); height:var(--ui-height); overflow-y:auto; background:#0b3556; }
.boot-in { max-width:520px; margin:auto; }
.boot-in h1,.boot-title { font-family:var(--ui-display); font-size:clamp(30px,6vw,52px); line-height:1.1; }
.boot-in p { font-size:15px; line-height:1.5; }
.credits-line,.instance-credit { display:none!important; }
.ui-about-links { border-top:1px solid #82b5d355; margin-top:24px; padding-top:20px; font-size:13px; color:var(--muted); }
.ui-about-links a { display:inline-block; padding:10px 2px; }
.ui-keyboard .game-dock { display:none; }
.ui-keyboard .scr { padding-bottom:12px!important; }
.ui-keyboard .topbar { display:none!important; }
@keyframes ui-enter { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
/* Phone portrait: compact stage, full-width sheets and a collection detail drawer. */
@media (max-width:700px) {
  :root { --ui-bar:62px; --ui-dock:74px; --ui-gap:12px; }
  .scr,.save-writer-wait { padding:12px max(12px,var(--ui-safe-right)) max(12px,var(--ui-safe-bottom)) max(12px,var(--ui-safe-left)); padding-top:calc(var(--ui-safe-top) + 12px); }
  .box.ui-panel { border-radius:16px; }
  .box.ui-panel .ui-panel-header { padding:14px 16px; }
  .box.ui-panel h2 { font-size:26px; }
  .ui-scroll { padding:16px; scrollbar-gutter:auto; }
  .ui-panel-footer { padding:12px 16px 16px; }
  .ui-panel-header>.row { gap:8px; }
  .ui-panel .split,#scr-gacha .split,.arena-setup { grid-template-columns:minmax(0,1fr); gap:16px; }
  .ui-panel .grid { grid-template-columns:repeat(auto-fill,minmax(88px,1fr)); gap:8px; }
  .topbar { gap:6px; padding-left:max(12px,var(--ui-safe-left)); padding-right:max(12px,var(--ui-safe-right)); justify-content:flex-start; }
  .pill { padding:5px 8px; font-size:13px; min-height:40px; }
  #user-pill { margin-left:auto; max-width:124px; min-width:0; flex-shrink:1; font-size:12px; line-height:1.3; }
  #user-pill small { font-size:9px; }
  #tickets-pill { gap:4px; font-size:12px; }
  #ui-tools-toggle { margin-left:0; }
  #scr-menu { padding:calc(var(--ui-safe-top) + var(--ui-bar) + 10px) max(16px,var(--ui-safe-right)) calc(var(--ui-safe-bottom) + var(--ui-dock) + 12px) max(16px,var(--ui-safe-left)); }
  .hub-layout { display:flex; flex-direction:column; justify-content:flex-start; gap:8px; width:min(480px,100%); padding:8px 3px 14px; }
  #scr-menu .menu-left { width:100%; flex:0 0 auto; }
  #scr-menu .logo { margin-bottom:4px; }
  #scr-menu .logo .t1 { font-size:40px; }
  #scr-menu .logo .t2 { font-size:10px; letter-spacing:2.5px; margin-top:8px; }
  .partner-card { padding:0 0 8px; }
  .partner-card::before { top:46%; height:36px; left:22%; right:22%; box-shadow:0 7px 0 #103d56,0 12px 15px #031d3a66; }
  #menu-partner { width:200px; height:130px; margin-bottom:0; }
  .partner-card .nm { font-size:25px; }
  .partner-card .lv { font-size:12px; margin-top:2px; }
  #menu-shiny { margin-top:6px; }
  #scr-menu .menu-right { width:100%; gap:12px; }
  .hub-heading { display:none; }
  .hub-actions { gap:12px; }
  #scr-menu .menu-item.play { min-height:72px; font-size:30px; }
  #scr-menu .menu-item { min-height:66px; padding:12px 16px; font-size:24px; }
  #scr-menu .menu-item small { font-size:11px; }
  #scr-menu .hub-shortcuts .menu-item { min-height:64px; flex-direction:row; gap:6px; font-size:17px; }
  #scr-menu .hub-shortcuts .mi-ico .pxi { width:20px!important; height:20px!important; }
  .hub-shortcuts { gap:8px; }
  #menu-stats { font-size:11px!important; }
  .hub-extras { padding-top:8px; }
  .game-dock { padding-left:0; padding-right:0; }
  .game-dock button { font-size:11px; }
  .game-dock svg { width:25px; height:25px; }
  .cell { min-height:116px; }
  .ui-dex-sheet { display:none; }
  .ui-dex-open .ui-dex-sheet { display:flex; flex-direction:column; position:fixed; z-index:75; top:auto; left:max(12px,var(--ui-safe-left)); right:max(12px,var(--ui-safe-right)); bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 10px); max-height:calc(var(--ui-height) - var(--ui-bar) - var(--ui-dock) - var(--ui-safe-top) - var(--ui-safe-bottom) - 32px); padding:12px; background:#173b60; border:2px solid #7eadd1; border-radius:16px; box-shadow:0 15px 50px #000b; }
  .ui-dex-close { display:flex; flex-shrink:0; min-height:44px; width:100%; margin-bottom:12px; }
  .ui-dex-open #dex-detail { min-height:0; overflow-y:auto; overscroll-behavior:contain; touch-action:pan-y; }
  .ui-dex-open .ui-dex-shade { display:block; position:fixed; inset:0; background:#021327b8; border:0; z-index:70; cursor:pointer; }
  .ui-dex-open .game-dock,.ui-dex-open .topbar { pointer-events:none; }
  .upg-head { align-items:flex-start; gap:12px; }
  .upg-head .stage { width:72px; height:64px; flex:0 0 72px; }
  .upg-head .sub { font-size:12px; }
  .upg-head .row { display:block; }
  .upg-head .row label { margin:0 0 6px; }
  .fr-row { flex-wrap:wrap; align-items:center; gap:10px; }
  .fr-row>.row { flex-basis:100%; }
  .fr-row .btn { flex:1; }
  .lob-cards { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .lob-card canvas { max-height:88px; width:auto; }
  .rk-row { gap:8px; padding:12px 8px; }
  .rk-row .who small { font-size:11px; }
  .rk-row .time { font-size:22px; }
  .rk-collection-row { grid-template-columns:26px 28px minmax(0,1fr) auto; }
  .rk-collection-row .collection-score small { font-size:9px; }
  .mission { flex-wrap:wrap; }
  .mission .m-txt { flex:1 1 150px; }
  .mission .btn { margin-left:auto; }
  .fav-slots,.prof-favs { gap:8px; }
  .fav-slot { min-height:100px; padding:10px 4px; }
  .fav-slot canvas { max-height:72px; width:auto; }
  .arena-rules { grid-template-columns:repeat(2,minmax(0,1fr)); font-size:12px; }
  #arena-description { font-size:12px; }
  .arena-feedback-form>.row .btn { flex:1 1 120px; }
  .pull-results { grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; }
  .card { padding:14px 12px; gap:12px; }
  .card .nm { font-size:21px; } .card .ds { font-size:13px; }
  .card .key { display:none; }
  .ui-panel-footer .btn { flex:1 1 auto; }
  #starter-info { flex-basis:100%; order:-1; font-size:13px; }
  #arena-hud-scoreboard { width:160px; max-height:180px; }
  .arena-hud-header,.arena-hud-name small,.arena-hud-hpbar { display:none; }
  .arena-hud-row { font-size:10px; grid-template-columns:18px minmax(0,1fr) auto; }
  .arena-hud-state { font-size:10px; }
}
/* Tiny phones remain functional; scrolling gains room by reducing decoration, never targets. */
@media (max-width:380px) {
  .pill { padding:5px 6px; font-size:12px; }
  #user-pill { max-width:90px; }
  #tickets-pill { max-width:115px; }
  .topbar { gap:4px; }
  #scr-menu .logo .t1 { font-size:34px; }
  #scr-menu .hub-shortcuts .menu-item { font-size:15px; flex-direction:column; }
  .ui-panel .grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .ui-scroll { padding:14px; }
  .ui-panel-header { padding:12px 14px!important; }
}
/* Short landscape: two columns for decoration, room for real 44px controls. */
@media (max-height:520px) and (min-width:701px) {
  :root { --ui-bar:56px; --ui-dock:60px; }
  .scr { padding:10px max(12px,var(--ui-safe-right)) max(10px,var(--ui-safe-bottom)) max(12px,var(--ui-safe-left)); }
  .ui-panel-header { padding:10px 16px; } .ui-panel-header h2 { font-size:24px; }
  .ui-scroll { padding:14px 16px; }
  .ui-panel-footer { padding:10px 16px 14px; }
  .game-dock button { flex-direction:row; gap:8px; }
  .game-dock svg,.game-dock button[data-route=menu] svg { width:24px; height:24px; }
  #scr-menu { padding-top:calc(var(--ui-safe-top) + var(--ui-bar) + 8px); padding-bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 8px); }
  .hub-layout { grid-template-columns:minmax(0,.9fr) minmax(0,1.3fr); gap:24px; align-items:start; }
  #scr-menu .logo { margin-bottom:0; }
  #scr-menu .logo .t1 { font-size:36px; }
  #scr-menu .logo .t2 { font-size:9px; letter-spacing:2px; margin-top:8px; }
  #menu-partner { width:180px; height:100px; margin-bottom:0; }
  .partner-card { padding:0; }
  .partner-card::before { height:28px; top:40%; }
  .partner-card .nm { font-size:22px; }
  .partner-card .lv { font-size:11px; }
  #scr-menu .menu-right { gap:10px; }
  .hub-heading { display:none; }
  .hub-actions { grid-template-columns:1fr 1fr; gap:12px; }
  #scr-menu .menu-item,#scr-menu .menu-item.play { min-height:76px; padding:10px; font-size:23px; grid-template-columns:26px minmax(0,1fr); gap:6px; }
  #scr-menu .menu-item small { font-size:10px; }
  #scr-menu .hub-shortcuts .menu-item { min-height:52px; font-size:17px; flex-direction:row; gap:8px; padding:10px; }
  #menu-stats { font-size:11px!important; }
  #scr-levelup .cards,#scr-item .cards,#scr-bond .cards { flex-direction:row; width:100%; align-items:stretch; }
  #scr-levelup .card,#scr-item .card,#scr-bond .card { flex:1 1 0; min-width:0; flex-direction:column; align-items:flex-start; padding:12px; }
  .card .nm { font-size:20px; } .card .ds { font-size:12px; }
  .card .key { display:none; }
  #scr-pause .ui-scroll { padding-top:10px; padding-bottom:10px; }
  #scr-pause .ui-panel { width:min(760px,100%)!important; }
  #scr-pause .ui-panel-footer .row { display:flex; }
  #btn-resume { min-height:48px; }
}
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { scroll-behavior:auto!important; animation-duration:.001ms!important; transition-duration:.001ms!important; animation-iteration-count:1!important; }
}
@media (hover:none) { .btn:hover,.menu-item:hover { filter:none; } .card:hover,.cell:hover { transform:none; } }
/* Explicit resets for the legacy short-height stylesheet's high-specificity rules. */
#scr-menu { justify-content:center; align-items:center; flex-direction:row; overflow:hidden; }
#scr-menu .menu-right .hub-stats { display:block; }
#scr-menu .menu-item small { display:block; }
#scr-menu .hub-shortcuts .menu-item small { display:none; }
#scr-dex .box.ui-panel { height:auto; max-height:100%; }
#scr-dex .ui-scroll .split { min-height:0; grid-template-columns:minmax(0,1fr) minmax(240px,320px); gap:20px; }
#scr-dex .ui-scroll .grid { flex:none; min-height:0; overflow:visible; grid-template-columns:repeat(auto-fill,minmax(90px,1fr)); gap:10px; }
#scr-dex .chip { min-height:44px; padding:9px 14px; font-size:14px; }
#scr-dex .filters { flex-wrap:wrap; overflow:visible; }
#scr-dex #dex-detail { display:block; overflow:visible; padding:16px; }
#scr-dex #dex-detail .btn { position:static; margin-top:12px; font-size:18px; padding:11px 14px; }
.ui-tool-action .ui-tool-label { display:inline!important; }
#btn-logout .ui-tool-label { display:none!important; }
@media (max-width:700px) {
  #scr-dex .ui-scroll .split { grid-template-columns:minmax(0,1fr); }
  #scr-dex .ui-scroll .grid { grid-template-columns:repeat(auto-fill,minmax(88px,1fr)); gap:8px; }
  .ui-dex-open #scr-dex #dex-detail { overflow-y:auto; min-height:0; }
}
@media (max-width:380px) { #scr-dex .ui-scroll .grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
/* Safe-area resets also cover ID-specific legacy rules on short viewports. */
:is(#scr-login,#scr-test,#scr-result,#scr-starters,#scr-news,#scr-support,#scr-settings,#scr-legal,#scr-nick,#scr-friends,#scr-lobby,#scr-arena-notice,#scr-arena-fix-notice,#scr-save-payment-notice,#scr-arena,#scr-arena-death,#scr-arena-feedback,#scr-rank,#scr-goals,#scr-profile,#scr-dex,#scr-upgrades,#scr-gacha,#scr-levelup,#scr-bond,#scr-item,#scr-pause,#scr-over) {
  padding:calc(var(--ui-safe-top) + 16px) max(16px,var(--ui-safe-right)) calc(var(--ui-safe-bottom) + 16px) max(16px,var(--ui-safe-left));
}
body.ui-hub :is(#scr-dex,#scr-gacha,#scr-goals,#scr-friends,#scr-upgrades,#scr-rank) {
  padding-top:calc(var(--ui-safe-top) + var(--ui-bar) + 12px);
  padding-bottom:calc(var(--ui-safe-bottom) + var(--ui-dock) + 12px);
}
body:has(#topbar:not(.hidden)) :is(#scr-lobby,#scr-arena) { padding-top:calc(var(--ui-safe-top) + var(--ui-bar) + 12px); }
body.ui-keyboard :is(#scr-login,#scr-nick,#scr-friends,#scr-arena-feedback) { padding-top:12px; padding-bottom:12px; }
#scr-bond #bond-cards { display:flex; flex-direction:column; width:100%; }
#scr-goals .fav-slots { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
#scr-goals .fav-slot { width:100%; min-width:0; }
#set-tabs .gen-tab { min-height:44px; padding:9px 14px; }
#sound-panel .ui-sound-close { width:100%; margin-bottom:12px; }
#scr-legal .ui-scroll :is(p,h3),.ui-about-links { -webkit-user-select:text; user-select:text; -webkit-touch-callout:default; }
@media(max-width:700px) {
  #scr-goals .mission { grid-template-columns:minmax(0,1fr) auto; gap:10px; }
  #scr-goals .mission>div:first-child { grid-column:1/-1; }
  #scr-goals .fav-slot { min-height:100px; }
}
@media(max-height:520px) and (min-width:701px) {
  #scr-bond #bond-cards { flex-direction:row; }
}
@media(max-width:700px) {
  .ui-dex-open .ui-dex-sheet { bottom:calc(var(--ui-safe-bottom) + 12px); max-height:calc(var(--ui-height) - var(--ui-bar) - var(--ui-safe-top) - var(--ui-safe-bottom) - 24px); }
}
/* Pokémon identity: Pokédex shell, party summary and type colors remain native to the game. */
#scr-menu .hub-actions .menu-item { grid-column:auto; }
.cell canvas { max-width:100%; height:auto; }
.partner-card .nm { display:table; margin:0 auto; padding:5px 20px; border:1px solid #9acbcf; border-radius:10px; background:#103c59; box-shadow:0 3px 0 #082a43; }
.partner-card .lv { margin-top:10px; }
#scr-dex .ui-panel-header { background:#96384b; border-bottom-color:#f29aab77; }
#scr-dex .box.ui-panel { border-color:#d67b8c; }
#scr-dex .ui-panel-header h2 { color:#fff; }
#scr-dex .gen-tab.on { color:#fff; background:#9c3c50; border-color:#f4b1be; box-shadow:0 2px 0 #5c2130; }
#dex-detail h3 { color:#ffe192; }
#dex-detail .stat { border-radius:4px; }
#dex-detail .move-icons { gap:8px; }
#menu-partner-info .type,#dex-detail .type { padding:3px 9px; border-radius:5px; font-size:11px; font-weight:750; border:1px solid #ffffff44; }
.btn.danger { background:#972d43; border-color:#f1a2b2; color:#fff; text-shadow:none; }
.save-writer-wait-box.ui-panel>button { position:sticky; bottom:0; }
@media(max-width:700px) {
  .ui-dex-open .ui-dex-sheet { border-color:#dc8697; background:#792c40; }
  .ui-dex-open .ui-dex-close { color:#fff; background:#a8485e; border-color:#eeadbb; }
  #scr-dex #dex-detail { border-color:#819fbd; background:#173b60; }
  .partner-card .nm { padding:3px 18px; }
}
/* Portrait combat uses its own canvas HUD. The Arena roster opens only when requested. */
.portrait-arena-toggle { display:none; }
@media (orientation:portrait) {
  body.ui-arena-active:not(.ui-arena-score-open) #arena-hud-scoreboard { display:none; }
  body.ui-arena-active .portrait-arena-toggle { display:flex; position:fixed; z-index:12; right:calc(var(--ui-safe-right) + 12px); bottom:calc(var(--ui-safe-bottom) + 104px); min-width:110px; min-height:44px; font-size:16px; }
  body.ui-arena-active #arena-hud-scoreboard { top:auto; left:auto; right:calc(var(--ui-safe-right) + 12px); bottom:calc(var(--ui-safe-bottom) + 160px); width:min(280px,calc(100vw - 24px)); max-height:45dvh; overflow-y:auto; overscroll-behavior:contain; }
}
