/* Touch layout: every desktop panel remains reachable through the four tabs. */
.mobile-tabs{display:none}
html,body{overscroll-behavior:none}
button,input,select{-webkit-tap-highlight-color:transparent}
#battlefield{touch-action:none}

@media(max-width:1024px),(max-width:1366px) and (pointer:coarse){
 :root{--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--mobile-head:50px;--mobile-panel:214px;--mobile-tabs:44px;--mobile-actions:48px;--mobile-bottom:calc(var(--mobile-panel) + var(--mobile-tabs) + var(--mobile-actions) + var(--safe-bottom))}
 html,body{width:100%;height:100%;height:100dvh;overflow:hidden}
 body{position:relative;isolation:isolate}
 button{min-height:44px;touch-action:manipulation}
 input,select{min-height:44px;font-size:16px;max-width:100%}
 .topbar{top:0;height:calc(var(--mobile-head) + var(--safe-top));padding:var(--safe-top) calc(8px + var(--safe-right)) 0 calc(10px + var(--safe-left));gap:6px;z-index:7}
 .brand{gap:5px;flex-shrink:0}
 .brand b{font-size:19px;letter-spacing:3px;white-space:nowrap}
 .brand small,.brand i,.brand .world-name{display:none}
 .brand .sigil{font-size:25px}
 .round-header{position:static;transform:none;gap:0;margin-left:auto;margin-right:5px}
 .round-number{font-size:20px;line-height:1}
 .round-number span,.phase-steps{display:none}
 .topbar nav{gap:0;flex-shrink:0}
 .topbar nav button{font-size:11px;min-width:44px;padding:7px 5px;white-space:nowrap}
 body #battlefield{top:calc(var(--mobile-head) + var(--safe-top));bottom:var(--mobile-bottom);left:var(--safe-left);right:var(--safe-right);min-height:0}
 .vignette{bottom:var(--mobile-bottom)}
 .player-board{height:calc(var(--mobile-panel) + var(--safe-bottom));padding:10px calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(12px + var(--safe-left));display:block;overflow:hidden;gap:0;box-shadow:none;z-index:5;background:linear-gradient(135deg,#192e34,#0c1c23)}
 .player-board>.character,.player-board>.board-section{display:none;height:100%;min-height:0}
 body[data-mobile-panel="hand"] .player-board>.board-section:not(.board-reflux),body[data-mobile-panel="reflux"] .player-board>.board-reflux{display:block}
 .board-section-head{font-size:10px;margin:0 0 8px;line-height:14px;letter-spacing:.3px}
 .hand{height:calc(100% - 24px);grid-template-columns:repeat(5,minmax(76px,1fr));gap:7px;overflow-x:auto;overflow-y:hidden;padding-bottom:4px;scroll-snap-type:x proximity;scrollbar-width:thin;scrollbar-color:#688c8d #14272d}
 .hand>.spell-card,.hand>.empty-slot{height:100%;min-height:0;scroll-snap-align:start}
 .spell-card:not(:disabled):hover,.spell-card.selected{transform:none}
 .card-name{font-size:12px;letter-spacing:0;line-height:1.4}
 .card-content{left:7px;right:5px;bottom:9px}
 .card-path{font-size:9px;letter-spacing:1px;margin-bottom:4px}
 .card-summary{display:none}
 .card-cost{top:8px;left:7px}
 .card-cost b{font-size:18px}
 .card-cooldown{top:11px;right:6px;font-size:9px}
 .reflux{grid-template-columns:repeat(5,minmax(58px,1fr));gap:6px;margin:0;overflow-x:auto}
 .reflux-slot{height:110px;min-height:44px}
 .reflux-slot .mini-name{font-size:10px;line-height:1.5;top:7px}
 .reflux-slot .mini-name span{font-size:9px!important}
 .reflux-slot .slot-num{font-size:21px}
 .reflux-arrow{margin-top:8px;font-size:10px;letter-spacing:0}
 .reflux-note{margin-top:5px;font-size:10px;line-height:1.5;color:#9ab4b7}
 .mobile-tabs{position:absolute;display:grid;grid-template-columns:repeat(4,1fr);z-index:6;left:0;right:0;bottom:calc(var(--mobile-panel) + var(--safe-bottom));height:var(--mobile-tabs);padding:0 var(--safe-right) 0 var(--safe-left);border-top:1px solid #607e8166;border-bottom:1px solid #607e8144;background:#0c1d24}
 .mobile-tabs button{min-height:44px;height:44px;background:none;border:0;border-right:1px solid #607e8122;font-size:12px;letter-spacing:2px;color:#99b4b5}
 .mobile-tabs button[aria-selected="true"]{background:linear-gradient(0deg,#55766a55,transparent);color:var(--gold);box-shadow:inset 0 -2px var(--gold)}
 .action-bar{left:var(--safe-left);right:var(--safe-right);bottom:calc(var(--mobile-panel) + var(--mobile-tabs) + var(--safe-bottom));height:var(--mobile-actions);transform:none;max-width:none;padding:2px 6px;gap:5px;overflow-x:auto;overflow-y:hidden;justify-content:flex-start;border-left:0;border-right:0;background:#0a1b23ed;scrollbar-width:none}
 .action-bar button{min-height:44px;flex:1 0 auto;padding:5px 10px;font-size:11px}
 .action-bar button small{display:none}
 .turn-prompt{top:calc(var(--mobile-head) + var(--safe-top) + 9px);bottom:auto;left:calc(12px + var(--safe-left));right:calc(12px + var(--safe-right));width:auto;transform:none}
 .turn-prompt h2{font-size:13px;letter-spacing:1px;margin:0 0 5px}
 .turn-prompt p{font-size:10px;line-height:1.5;max-width:95%;margin:auto;color:#c0d0cb}
 .camera-tools{left:calc(8px + var(--safe-left));right:auto;bottom:calc(var(--mobile-bottom) + 8px);flex-direction:row;gap:4px}
 .camera-tools button{width:44px;height:44px;min-height:44px;font-size:19px;background:#0e242acf;border:1px solid #759b9666}
 .camera-tools span{display:none}
 .initiative,.world-panel{display:none;position:absolute;top:auto;bottom:var(--safe-bottom);height:var(--mobile-panel);z-index:6;margin:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#688c8d transparent}
 body[data-mobile-panel="units"] .player-board>.character{display:flex;flex-direction:column;width:42%;padding-right:10px;overflow-y:auto}
 .character-title{font-size:18px;margin-bottom:6px;letter-spacing:2px}
 .character-sub{font-size:10px;line-height:1.5;display:block}
 .character-sub>span{display:block}
 .resource-row{gap:10px;margin:9px 0;flex-wrap:wrap}
 .resource{min-width:26px}
 .resource b{font-size:24px}
 .resource b small{font-size:10px}
 .resource label{font-size:10px}
 .weapon-strip{min-height:44px;padding-top:7px;gap:7px;margin-top:auto}
 .weapon-icon{width:30px;height:39px}
 .weapon-strip b{font-size:11px;line-height:1.4}
 .weapon-strip small{font-size:9px;line-height:1.4}
 body[data-mobile-panel="units"] .initiative{display:block;left:44%;right:var(--safe-right);width:auto;padding:8px 12px 8px 6px}
 .initiative>.eyebrow,.initiative-note{display:none}
 #unit-list{display:grid;grid-template-columns:1fr;gap:4px}
 .initiative .unit-row{min-height:44px;margin:0;padding:5px 7px;gap:7px}
 .unit-row.current:after{display:none}
 .unit-icon{width:16px;height:24px}
 .unit-icon:after{left:5px;top:6px;width:6px;height:6px}
 .unit-name{font-size:10px}
 .unit-meta{font-size:9px;gap:5px;margin-top:3px}
 .hearts{font-size:9px;letter-spacing:1px}
 .unit-energy{font-size:18px}
 .initiative #log-btn{font-size:11px;padding:5px 0;min-height:44px}
 body[data-mobile-panel="world"] .world-panel{display:grid;left:var(--safe-left);right:var(--safe-right);width:auto;grid-template-columns:1fr 1fr;gap:14px;padding:12px;align-items:start}
 .world-panel #team-status{grid-column:1}
 .world-panel .eyebrow{font-size:9px;letter-spacing:1px;margin-bottom:10px}
 .world-panel .eyebrow span{display:inline;font-size:10px}
 .team-line{font-size:10px;gap:4px;margin-bottom:10px;flex-wrap:wrap}
 .team-bonus{font-size:10px;line-height:1.7}
 .life-tokens{gap:3px}
 .life-token{height:17px;width:16px}
 .world-panel .event-panel{grid-column:2;grid-row:1 / span 2;border-top:0;border-left:1px solid #66878b44;padding:0 0 0 12px;margin:0}
 .event-panel h3{font-size:13px;line-height:1.5;margin:6px 0}
 .event-panel p{font-size:11px;line-height:1.7;margin:8px 0}
 .event-label{font-size:9px;gap:6px;flex-wrap:wrap;line-height:1.6}
 .world-panel .tile-panel{display:block;grid-column:1;padding:9px;margin:0;min-height:0}
 .tile-panel .tile-type{font-size:9px;letter-spacing:0;margin-bottom:5px}
 .tile-panel h3{font-size:12px}
 .tile-panel p{font-size:10px;line-height:1.7}
 #toast{position:fixed;top:calc(var(--mobile-head) + var(--safe-top) + 8px);max-width:calc(100vw - 28px);width:max-content;padding:10px 15px;font-size:12px;line-height:1.6;z-index:80}
 .card-tip{display:none!important}
 .modal-backdrop{padding:calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));overflow:auto;align-items:center}
 .modal,.modal.wide{width:100%;max-width:850px;max-height:calc(100vh - 20px - var(--safe-top) - var(--safe-bottom));max-height:calc(100dvh - 20px - var(--safe-top) - var(--safe-bottom));padding:24px 16px 18px;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#638380 #12282d;scroll-padding-top:52px}
 .modal-close{position:sticky;display:block;top:0;float:right;margin:-16px -8px 0 10px;width:44px;height:44px;min-height:44px;right:auto;z-index:3;background:#12272ef5;border:1px solid #69868166;border-radius:4px;color:#d6e0d7}
 .modal h2{font-size:23px;letter-spacing:2px;line-height:1.4;margin:7px 0 14px;overflow-wrap:anywhere}
 .modal>.eyebrow{font-size:8px;letter-spacing:1px;line-height:1.8;padding-right:42px}
 .modal p{font-size:12px;line-height:1.9;overflow-wrap:anywhere}
 .modal-footer{position:relative;gap:8px;margin-top:17px;display:flex;flex-wrap:wrap;clear:both}
 .modal-footer button{flex:1 1 auto;font-size:12px;padding:9px 13px;min-height:44px}
 .option-row{gap:7px;margin:13px 0}
 .option-row button{font-size:12px;padding:9px 13px;min-height:44px}
 .check-row,.enhance-row{font-size:12px;line-height:1.7;gap:8px;flex-wrap:wrap}
 .check-row{min-height:44px;margin:10px 0}
 .check-row input{width:20px;min-height:20px;height:20px;flex-shrink:0}
 .guide-grid{grid-template-columns:1fr;gap:8px;margin-top:16px}
 .guide-grid h3{font-size:14px;margin-bottom:5px}
 .guide-grid p{font-size:12px;line-height:1.8;margin-top:0}
 .choice-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-top:16px}
 .choice-grid .spell-card{height:210px}
 .choice-grid.weapons{grid-template-columns:1fr}
 .weapon-choice{grid-template-columns:74px 1fr;gap:13px;min-height:144px;padding:11px}
 .weapon-choice .weapon-art{height:124px}
 .weapon-choice h3{font-size:17px;margin:4px 0 8px}
 .weapon-choice p{font-size:11px;line-height:1.7;margin:0}
 .filter-row{gap:6px;margin:12px 0}
 .filter-row button{font-size:11px;min-height:44px;padding:7px 9px}
 .filter-row input{width:100%;min-width:0;font-size:16px;margin:0;padding:9px 11px}
 .codex-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
 .codex-grid .spell-card{height:224px}
 .codex-grid .card-name,.choice-grid .card-name{font-size:14px}
 .codex-grid .card-path,.choice-grid .card-path{font-size:10px}
 .card-detail-grid{grid-template-columns:105px minmax(0,1fr)!important;gap:14px!important}
 .card-detail-grid>div:first-child{height:160px!important}
 .card-detail-grid p{margin-top:0;line-height:1.8}
 .log-list{max-height:60vh;max-height:60dvh;margin-top:15px}
 .log-item{font-size:12px}
 .unit-detail{flex-wrap:wrap;gap:6px}
 .pills{gap:6px}
 .pill{font-size:11px;line-height:1.5}
 body.title-mode #battlefield{top:0;bottom:0;left:0;right:0;opacity:.65}
 body.title-mode .mobile-tabs,body.vfx-preview-mode .mobile-tabs{display:none}
 body.title-mode .topbar{visibility:hidden}
 .title-backdrop{padding:calc(22px + var(--safe-top)) calc(24px + var(--safe-right)) calc(22px + var(--safe-bottom)) calc(24px + var(--safe-left));background:linear-gradient(90deg,#071920ee,#071920bb 65%,#07192066);align-items:center;justify-content:center}
 .title-screen{width:100%;max-width:540px;max-height:calc(100vh - 44px - var(--safe-top) - var(--safe-bottom));max-height:calc(100dvh - 44px - var(--safe-top) - var(--safe-bottom));overflow:auto;padding:4px 0;scrollbar-width:none}
 .title-screen>.eyebrow{padding-right:0;font-size:8px;letter-spacing:1.6px}
 .title-screen h1{font-size:clamp(46px,13vw,70px);letter-spacing:10px;line-height:1.3;margin:20px 0 12px}
 .title-screen .english{font-size:11px;letter-spacing:6px}
 .title-screen .subtitle{font-size:17px;letter-spacing:3px;margin:25px 0 14px}
 .title-screen .intro{width:100%;font-size:12px;line-height:1.9;margin:0}
 .mode-select{gap:8px;margin-top:23px}
 .mode-select button{min-width:0;flex:1;padding:12px 10px;font-size:12px;line-height:1.4}
 .mode-select small{font-size:10px;line-height:1.6;letter-spacing:0}
 .title-screen .title-actions{gap:8px;margin-top:17px;flex-wrap:wrap}
 .title-screen .title-actions button{padding:12px 13px;font-size:12px;letter-spacing:1px;flex:1;white-space:nowrap}
 .title-screen .text-btn{font-size:12px;line-height:1.5;margin-top:8px}
 .title-screen .build-note{font-size:10px;line-height:1.7;margin-top:15px}
 .spell-announcement,.spell-announcement.ultimate{top:calc(var(--mobile-head) + var(--safe-top) + 64px);left:50%;width:min(360px,calc(100vw - 30px - var(--safe-left) - var(--safe-right)));min-width:0;padding:10px 14px}
 .spell-name{font-size:21px;letter-spacing:2px}
 .spell-kicker{font-size:8px;letter-spacing:2px}
 .spell-subtitle{font-size:10px;margin-top:5px}
 .spell-announcement.ultimate .spell-name{font-size:26px;letter-spacing:4px}
 .spell-announcement.ultimate .spell-kicker{font-size:8px;letter-spacing:2px}
 body.vfx-preview-mode{--preview-panel:260px}
 body.vfx-preview-mode #battlefield{top:var(--safe-top);left:var(--safe-left);right:var(--safe-right);bottom:calc(var(--preview-panel) + var(--safe-bottom));opacity:1}
 body.vfx-preview-mode .spell-announcement{left:50%;top:calc(15px + var(--safe-top));width:min(360px,85vw)}
 .vfx-preview-panel{top:auto;left:0;right:0;bottom:0;width:100%;height:calc(var(--preview-panel) + var(--safe-bottom));min-height:0;max-height:none;padding:14px calc(14px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(14px + var(--safe-left));overflow:auto;border-width:1px 0 0;display:grid;grid-template-columns:76px minmax(0,1fr);align-content:start;column-gap:13px;row-gap:5px}
 .vfx-preview-panel .preview-art{position:static;grid-column:1;grid-row:1 / span 4;width:76px;height:107px}
 .vfx-preview-panel .eyebrow,.vfx-preview-panel h2,.vfx-preview-panel .preview-status,.vfx-preview-panel>p{grid-column:2;margin:0}
 .vfx-preview-panel .eyebrow{grid-row:1;font-size:8px;line-height:1.5;letter-spacing:1px}
 .vfx-preview-panel h2{grid-row:2;font-size:20px;line-height:1.4;letter-spacing:2px}
 .vfx-preview-panel .preview-status{grid-row:3;font-size:10px;line-height:1.5;min-height:0;letter-spacing:0}
 .vfx-preview-panel>p{grid-row:4;font-size:11px;line-height:1.6}
 .vfx-preview-panel .option-row,.vfx-preview-panel .preview-nav,.vfx-preview-panel>small{grid-column:1 / -1;margin:0}
 .vfx-preview-panel .option-row{margin-top:6px}
 .vfx-preview-panel button{font-size:12px;padding:8px 10px;min-height:44px}
 .vfx-preview-panel .preview-nav{padding-top:6px;border:0}
 .vfx-preview-panel .preview-nav button{font-size:11px;padding:8px 10px;min-height:44px}
 .vfx-preview-panel>small{font-size:10px;line-height:1.5;color:#8ca7aa}
 .fallback{max-width:calc(100% - 32px);left:16px;right:16px;top:20%;font-size:13px}
}

/* Wide phones share one command row with the panel tabs, preserving board height. */
@media(max-width:1024px) and (orientation:landscape) and (max-height:600px),(max-width:1366px) and (pointer:coarse) and (orientation:landscape) and (max-height:600px){
 :root{--mobile-head:46px;--mobile-panel:112px;--mobile-tabs:44px;--mobile-actions:0px}
 .topbar{height:calc(46px + var(--safe-top))}
 .player-board{padding-top:6px;padding-bottom:calc(6px + var(--safe-bottom))}
 .board-section-head{margin-bottom:4px;font-size:9px;line-height:12px}
 .hand{height:calc(100% - 16px);gap:7px;padding-bottom:0;grid-template-columns:repeat(5,minmax(80px,1fr))}
 .hand .card-content{left:9px;bottom:6px;right:9px}
 .hand .card-name{font-size:12px}
 .hand .card-path{font-size:8px;margin-bottom:3px}
 .hand .card-cost{left:8px;top:5px}
 .hand .card-cost b{font-size:16px}
 .hand .card-cooldown{top:8px;right:8px}
 .hand .spell-card .card-shade{background:linear-gradient(180deg,#04151988,transparent 27%,#081820e8 64%,#0b1b21 100%)}
 .mobile-tabs{right:auto;width:calc(232px + var(--safe-left));padding-right:0;border-right:1px solid #607e8166}
 .mobile-tabs button{font-size:11px;letter-spacing:0}
 .action-bar{left:calc(232px + var(--safe-left));bottom:calc(var(--mobile-panel) + var(--safe-bottom));height:44px;padding:0 4px;gap:4px}
 .action-bar button{font-size:11px;padding:5px 9px}
 .turn-prompt{top:calc(var(--mobile-head) + var(--safe-top) + 6px);left:calc(160px + var(--safe-left));right:calc(150px + var(--safe-right))}
 .turn-prompt h2{font-size:12px;margin-bottom:3px}
 .turn-prompt p{font-size:9px;line-height:1.4}
 .camera-tools{bottom:calc(var(--mobile-bottom) + 6px);left:calc(8px + var(--safe-left));gap:3px}
 .camera-tools button{background:#0e242a99}
 .reflux{gap:8px}
 .reflux-slot{height:64px}
 .reflux-slot .mini-name{font-size:10px;top:5px;line-height:1.3}
 .reflux-slot .mini-name span{font-size:8px!important}
 .reflux-slot.occupied .slot-num{font-size:10px;padding:2px}
 .reflux-arrow{display:none}
 .reflux-note{font-size:9px;line-height:1.4;margin-top:3px}
 .reflux-note br{display:none}
 body[data-mobile-panel="units"] .player-board>.character{display:grid;grid-template-columns:1fr 1fr;width:40%;padding-right:12px;column-gap:12px;align-content:start;overflow:auto}
 .character-title{font-size:15px;grid-column:1;margin:0 0 3px}
 .character-sub{font-size:9px;grid-column:1}
 .resource-row{grid-column:2;grid-row:1 / span 2;gap:9px;margin:2px 0;flex-wrap:nowrap}
 .resource b{font-size:21px}
 .resource label{font-size:9px;white-space:nowrap}
 .weapon-strip{grid-column:1 / -1;padding-top:4px;margin-top:4px;min-height:39px}
 .weapon-icon{width:24px;height:32px}
 .weapon-strip b{display:inline;font-size:10px;margin-right:8px}
 .weapon-strip small{font-size:9px}
 body[data-mobile-panel="units"] .initiative{left:41%;padding:6px 10px 6px 6px;display:flex;gap:8px}
 #unit-list{grid-template-columns:1fr 1fr;flex:1}
 .initiative .unit-row{padding:4px 7px;min-height:44px}
 .initiative #log-btn{width:44px;min-height:44px;align-self:center;line-height:1.7;text-align:center}
 .initiative #log-btn span{display:none}
 body[data-mobile-panel="world"] .world-panel{grid-template-columns:1fr 1.2fr 1fr;gap:15px;padding:8px 12px}
 .world-panel #team-status{grid-column:1;grid-row:1}
 .world-panel .event-panel{grid-column:2;grid-row:1;padding-left:12px}
 .world-panel .tile-panel{grid-column:3;grid-row:1}
 .world-panel .eyebrow{margin-bottom:5px;font-size:8px}
 .team-line{font-size:10px;margin-bottom:5px}
 .team-bonus{font-size:9px;margin-top:0;margin-bottom:4px}
 .event-panel p{font-size:10px;line-height:1.5;margin:4px 0}
 .event-panel h3{font-size:12px;margin:3px 0}
 .event-progress{margin-top:5px}
 .tile-panel p{font-size:10px;line-height:1.5}
 .spell-announcement,.spell-announcement.ultimate{top:calc(80px + var(--safe-top));width:300px;padding:6px 12px}
 .spell-name{font-size:19px}
 .spell-announcement.ultimate .spell-name{font-size:23px}
 .spell-kicker,.spell-announcement.ultimate .spell-kicker{font-size:7px;margin-bottom:3px}
 .spell-subtitle{font-size:9px;margin-top:3px}
 .modal-backdrop{padding:calc(7px + var(--safe-top)) calc(10px + var(--safe-right)) calc(7px + var(--safe-bottom)) calc(10px + var(--safe-left))}
 .modal,.modal.wide{max-height:calc(100vh - 14px - var(--safe-top) - var(--safe-bottom));max-height:calc(100dvh - 14px - var(--safe-top) - var(--safe-bottom));padding-top:20px}
 .modal h2{font-size:21px;margin-bottom:10px}
 .choice-grid{grid-template-columns:repeat(5,minmax(0,1fr))}
 .choice-grid .spell-card{height:176px}
 .choice-grid.weapons{grid-template-columns:1fr 1fr}
 .weapon-choice{grid-template-columns:67px 1fr}
 .weapon-choice .weapon-art{height:107px}
 .weapon-choice h3{font-size:15px}
 .codex-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
 .codex-grid .spell-card{height:205px}
 .guide-grid{grid-template-columns:1fr 1fr;gap:8px 22px}
 .card-detail-grid{grid-template-columns:110px minmax(0,1fr)!important}
 .title-backdrop{padding-top:calc(14px + var(--safe-top));padding-bottom:calc(14px + var(--safe-bottom));justify-content:flex-start}
 .title-screen{max-width:640px;max-height:calc(100dvh - 28px - var(--safe-top) - var(--safe-bottom));padding:0 7px 0 0;display:grid;grid-template-columns:1fr 1fr;column-gap:25px;align-content:start}
 .title-screen>.eyebrow,.title-screen h1,.title-screen .english,.title-screen .subtitle,.title-screen .intro{grid-column:1}
 .title-screen>.eyebrow{grid-row:1;font-size:8px;margin:0}
 .title-screen h1{grid-row:2;font-size:48px;line-height:1.2;margin:14px 0 9px}
 .title-screen .english{grid-row:3;font-size:10px;letter-spacing:5px}
 .title-screen .subtitle{grid-row:4;font-size:15px;letter-spacing:2px;margin:15px 0 8px}
 .title-screen .intro{grid-row:5;font-size:11px;line-height:1.7}
 .title-screen .mode-select{grid-column:2;grid-row:1 / span 3;flex-direction:column;gap:7px;margin:0;align-self:center}
 .title-screen .mode-select button{padding:9px 12px}
 .title-screen .mode-select small{margin-top:3px;line-height:1.4}
 .title-screen .title-actions{grid-column:2;grid-row:4 / span 2;align-self:start;flex-direction:column;margin-top:10px;gap:7px}
 .title-screen .title-actions button{padding:9px 12px}
 .title-screen .text-btn{grid-column:2;grid-row:6;margin-top:6px}
 .title-screen .build-note{grid-column:1;grid-row:6;font-size:9px;margin-top:9px;align-self:center}
 body.vfx-preview-mode{--preview-panel:240px}
 body.vfx-preview-mode #battlefield{top:var(--safe-top);bottom:var(--safe-bottom);left:var(--safe-left);right:calc(var(--preview-panel) + var(--safe-right))}
 body.vfx-preview-mode .spell-announcement{top:calc(16px + var(--safe-top));left:calc((100% - var(--preview-panel) - var(--safe-right) + var(--safe-left))/2);width:min(330px,calc(100vw - 290px))}
 .vfx-preview-panel{left:auto;right:0;top:0;bottom:0;width:calc(var(--preview-panel) + var(--safe-right));height:auto;max-height:100vh;max-height:100dvh;grid-template-columns:1fr;padding:calc(11px + var(--safe-top)) calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) 12px;border-width:0 0 0 1px;gap:5px}
 .vfx-preview-panel .eyebrow,.vfx-preview-panel h2,.vfx-preview-panel .preview-status,.vfx-preview-panel>p,.vfx-preview-panel .option-row,.vfx-preview-panel .preview-nav,.vfx-preview-panel>small{grid-column:1;grid-row:auto}
 .vfx-preview-panel .preview-art{display:none}
 .vfx-preview-panel h2{font-size:20px}
 .vfx-preview-panel .eyebrow{font-size:7px}
 .vfx-preview-panel .option-row{margin-top:5px}
 .vfx-preview-panel button{font-size:11px;padding:7px;white-space:normal}
 .vfx-preview-panel .preview-nav{padding-top:0}
 .vfx-preview-panel .preview-nav button{font-size:10px;padding:7px}
 .vfx-preview-panel>small{font-size:9px}
}

/* Larger tablets get larger card illustrations without altering desktop layout. */
@media(min-width:600px) and (max-width:1024px) and (orientation:portrait){
 :root{--mobile-panel:250px}
 .hand{gap:12px}
 .hand .card-name{font-size:16px}
 .hand .card-path{font-size:10px}
 .hand .card-content{left:10px;bottom:12px}
 .hand .card-summary{display:block;font-size:10px}
 .reflux-slot{height:146px}
 .reflux-slot .mini-name{font-size:13px;top:10px}
 .reflux-note{font-size:12px}
 .initiative .unit-row{min-height:49px;padding:7px 10px}
 .unit-name{font-size:13px}
 .unit-meta{font-size:11px}
 .character-title{font-size:23px}
 .character-sub{font-size:12px}
 .resource-row{gap:25px;margin:16px 0}
 .resource b{font-size:32px}
 .weapon-strip b{font-size:13px}
 .weapon-strip small{font-size:11px}
 .world-panel .event-panel p,.tile-panel p{font-size:12px}
 .team-line{font-size:12px}
 .codex-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
 .choice-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
 .choice-grid.weapons{grid-template-columns:1fr 1fr}
 .guide-grid{grid-template-columns:1fr 1fr;gap:16px}
 .title-screen h1{font-size:76px}
 .title-screen .intro{font-size:14px}
 .title-screen .subtitle{font-size:23px}
 .title-screen .mode-select button{padding:17px;font-size:15px}
 .title-screen .title-actions button{padding:16px;font-size:14px}
}

/* Short landscape screens use their width for the HUD, keeping the board tall. */
@media(min-width:560px) and (max-width:1024px) and (orientation:landscape) and (max-height:600px),(min-width:560px) and (max-width:1366px) and (pointer:coarse) and (orientation:landscape) and (max-height:600px){
 :root{--mobile-sidebar:clamp(280px,35.5vw,310px);--sidebar-actions:52px}
 body:not(.title-mode):not(.vfx-preview-mode) #battlefield{top:calc(var(--mobile-head) + var(--safe-top) + 42px);bottom:var(--safe-bottom);left:var(--safe-left);right:calc(var(--mobile-sidebar) + var(--safe-right));border-right:1px solid #75968b33}
 body:not(.title-mode):not(.vfx-preview-mode) .vignette{top:calc(var(--mobile-head) + var(--safe-top));bottom:var(--safe-bottom);right:calc(var(--mobile-sidebar) + var(--safe-right))}
 .turn-prompt{top:calc(var(--mobile-head) + var(--safe-top) + 5px);left:calc(10px + var(--safe-left));right:calc(var(--mobile-sidebar) + var(--safe-right) + 10px);height:34px;overflow:hidden;text-align:left}
 .turn-prompt h2{font-size:12px;line-height:16px;letter-spacing:.5px;margin:0 0 2px}
 .turn-prompt p{font-size:9px;line-height:13px;max-width:100%;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 .battlefield-unit-label{font-size:9px!important;padding:3px 5px!important;letter-spacing:0!important}
 .camera-tools{bottom:calc(7px + var(--safe-bottom));left:calc(8px + var(--safe-left));gap:4px}
 .camera-tools button{width:44px;height:44px;font-size:18px;background:#0d2329bb}
 .mobile-tabs{left:auto;right:var(--safe-right);top:calc(var(--mobile-head) + var(--safe-top));bottom:auto;width:var(--mobile-sidebar);height:44px;padding:0;border-right:0;border-left:1px solid #63857c55;background:#0d2027}
 .mobile-tabs button{font-size:12px;letter-spacing:1px}
 .player-board{top:calc(var(--mobile-head) + var(--safe-top) + 44px);bottom:calc(var(--sidebar-actions) + var(--safe-bottom));left:auto;right:var(--safe-right);width:var(--mobile-sidebar);height:auto;padding:8px 10px;border-top:0;border-left:1px solid #63857c55;box-shadow:-12px 0 35px #06111822}
 .board-section-head{font-size:9px;line-height:14px;margin-bottom:6px;letter-spacing:0}
 .board-section-head>span:last-child>span{margin-left:4px!important}
 .hand{height:calc(100% - 20px);grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(2,minmax(60px,1fr));grid-auto-rows:minmax(60px,1fr);gap:6px;overflow:auto;padding:0;scroll-snap-type:none}
 .hand>.spell-card,.hand>.empty-slot{height:100%;min-height:60px}
 .hand .card-content{left:6px;right:4px;bottom:5px}
 .hand .card-name{font-size:11px;line-height:1.35}
 .hand .card-path{font-size:8px;letter-spacing:1px;margin-bottom:2px}
 .hand .card-cost{top:4px;left:5px}
 .hand .card-cost b{font-size:16px}
 .hand .card-cost span{font-size:10px}
 .hand .card-cooldown{top:7px;right:5px;font-size:8px}
 .hand .spell-card.is-ultimate:after{top:4px;font-size:15px}
 .hand .empty-slot{font-size:25px;gap:4px}
 .hand .empty-slot small{font-size:8px}
 .action-bar{left:auto;right:var(--safe-right);bottom:var(--safe-bottom);top:auto;width:var(--mobile-sidebar);height:var(--sidebar-actions);padding:4px 6px;gap:4px;border-left:1px solid #63857c55;border-top:1px solid #63857c44;background:#0c1f26}
 .action-bar button{font-size:10px;padding:5px 8px;flex:1 0 auto;min-height:44px}
 .reflux{grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;overflow:visible}
 .reflux-slot{height:100px}
 .reflux-slot .mini-name{font-size:9px;line-height:1.4;left:3px;right:3px;top:6px;overflow-wrap:anywhere}
 .reflux-slot .mini-name span{font-size:8px!important}
 .reflux-slot.occupied .slot-num{font-size:10px;padding:4px 1px}
 .reflux-arrow{display:block;font-size:9px;line-height:1.5;margin-top:10px;letter-spacing:0}
 .reflux-note{font-size:10px;line-height:1.6;margin-top:7px;color:#a6bebb}
 .reflux-note br{display:initial}
 body[data-mobile-panel="reflux"] .player-board>.board-reflux{overflow:auto}
 body[data-mobile-panel="units"] .player-board>.character{width:100%;height:96px;display:grid;grid-template-columns:1fr 1fr;padding-right:0;column-gap:9px;overflow:auto}
 .character-title{font-size:16px;grid-column:1;margin-bottom:3px}
 .character-sub{font-size:9px;line-height:1.5;grid-column:1}
 .resource-row{grid-column:2;grid-row:1 / span 2;gap:10px;margin:0;flex-wrap:nowrap;align-self:center}
 .resource b{font-size:23px}
 .resource b small{font-size:9px}
 .resource label{font-size:9px;white-space:nowrap}
 .weapon-strip{grid-column:1 / -1;min-height:40px;padding-top:4px;margin-top:4px;gap:7px}
 .weapon-icon{width:26px;height:34px}
 .weapon-strip b{font-size:11px;display:block;margin:0 0 2px}
 .weapon-strip small{font-size:9px;line-height:1.4}
 body[data-mobile-panel="units"] .initiative{left:auto;right:var(--safe-right);top:calc(var(--mobile-head) + var(--safe-top) + 148px);bottom:calc(var(--sidebar-actions) + var(--safe-bottom));width:var(--mobile-sidebar);height:auto;padding:0 10px 6px;display:block;overflow:auto}
 #unit-list{grid-template-columns:1fr 1fr;gap:5px}
 .initiative .unit-row{padding:5px;min-height:44px;gap:5px}
 .initiative .unit-icon{width:12px;height:22px}
 .initiative .unit-icon:after{left:4px;width:5px}
 .initiative .unit-name{font-size:10px;white-space:nowrap}
 .initiative .unit-meta{font-size:8px;gap:3px}
 .initiative .unit-energy{font-size:16px}
 .initiative #log-btn{width:100%;min-height:44px;margin-top:2px;padding:5px 0;text-align:left;font-size:11px}
 .initiative #log-btn span{display:inline;float:right}
 body[data-mobile-panel="world"] .world-panel{left:auto;right:var(--safe-right);top:calc(var(--mobile-head) + var(--safe-top) + 44px);bottom:calc(var(--sidebar-actions) + var(--safe-bottom));height:auto;width:var(--mobile-sidebar);display:block;padding:10px 12px;overflow:auto}
 .world-panel #team-status{margin-bottom:10px}
 .world-panel .eyebrow{font-size:8px;line-height:1.5;margin-bottom:7px}
 .world-panel .team-line{font-size:10px;margin-bottom:7px}
 .world-panel .team-bonus{font-size:9px;line-height:1.6}
 .world-panel .event-panel{border-left:0;border-top:1px solid rgba(var(--path-rgb),.4);padding:9px 0 0;margin:0}
 .world-panel .event-panel h3{font-size:13px;margin:5px 0}
 .world-panel .event-panel p{font-size:10px;line-height:1.6;margin:5px 0 7px}
 .world-panel .event-label{font-size:9px;line-height:1.5}
 .world-panel .event-progress{margin-top:5px}
 .world-panel .tile-panel{display:block;margin-top:12px;padding:9px;min-height:0}
 .world-panel .tile-panel h3{font-size:12px}
 .world-panel .tile-panel p{font-size:10px;line-height:1.6}
 body:not(.title-mode):not(.vfx-preview-mode) .spell-announcement{left:calc((100% - var(--mobile-sidebar) - var(--safe-right) + var(--safe-left))/2);top:calc(var(--mobile-head) + var(--safe-top) + 48px);width:min(290px,calc(100vw - var(--mobile-sidebar) - 32px));padding:7px 12px}
}

/* Atlas cells retain their original proportions in every mobile panel. Border
   decoration is inset so it does not change the artwork's content-box ratio. */
@media(max-width:1024px),(max-width:1366px) and (pointer:coarse){
 :root{--mobile-card-ratio:5748 / 7848;--mobile-weapon-ratio:821.2 / 1121;--mobile-event-ratio:821 / 1121.333333}
 .spell-card,.spell-card[data-path],.empty-slot,.reflux-slot,.weapon-icon,.vfx-preview-panel .preview-art{border:0;box-shadow:inset 0 0 0 1px #57707188}
 .spell-card[data-path]{box-shadow:inset 0 0 0 1px rgba(var(--path-rgb),.48),inset 0 -3px var(--path-color)}
 .hand{display:flex;align-items:flex-start;padding-bottom:0;overflow-x:auto;overflow-y:hidden}
 .hand>.spell-card,.hand>.empty-slot{flex:0 0 auto;width:auto;min-width:0;max-width:none;height:100%;min-height:0;aspect-ratio:var(--mobile-card-ratio)}
 .choice-grid:not(.weapons),.codex-grid{align-items:start}
 .choice-grid .spell-card,.codex-grid .spell-card{width:100%;height:auto;min-height:0;aspect-ratio:var(--mobile-card-ratio)}
 .codex-grid .spell-card[data-detail^="weapon:"]{aspect-ratio:var(--mobile-weapon-ratio)}
 .codex-grid .spell-card[data-detail^="event:"]{aspect-ratio:var(--mobile-event-ratio)}
 .reflux{align-items:start}
 .reflux-slot{width:100%;max-width:106px;height:auto;min-height:0;aspect-ratio:var(--mobile-card-ratio);justify-self:center}
 .weapon-icon{height:auto;aspect-ratio:var(--mobile-weapon-ratio)}
 .weapon-choice .weapon-art{width:100%;height:auto;aspect-ratio:var(--mobile-weapon-ratio);align-self:start}
 .card-detail-grid>div:first-child{height:auto!important;aspect-ratio:var(--mobile-card-ratio);align-self:start}
 .card-detail-grid>div:first-child[style*="weapons.webp"]{aspect-ratio:var(--mobile-weapon-ratio)}
 .card-detail-grid>div:first-child[style*="events.webp"]{aspect-ratio:var(--mobile-event-ratio)}
 .vfx-preview-panel .preview-art{height:auto;aspect-ratio:var(--mobile-card-ratio);align-self:start}
}

/* The landscape sidebar keeps its three columns. Extra rows scroll vertically
   instead of stretching five cards to fill two equally tall grid tracks. */
@media(max-width:559px) and (orientation:landscape) and (max-height:600px){
 .reflux-slot{max-width:calc(64px * 5748 / 7848)}
}
@media(min-width:560px) and (max-width:1024px) and (orientation:landscape) and (max-height:600px),(min-width:560px) and (max-width:1366px) and (pointer:coarse) and (orientation:landscape) and (max-height:600px){
 .hand{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:none;grid-auto-rows:max-content;align-content:start;align-items:start;overflow:auto}
 .hand>.spell-card,.hand>.empty-slot{width:100%;height:auto;min-height:0;aspect-ratio:var(--mobile-card-ratio)}
}

/* Keep the public-market entry reachable on narrow phones. */
@media(max-width:1024px),(max-width:1366px) and (pointer:coarse){
 #online-status{top:calc(var(--mobile-head) + var(--safe-top) + 64px);font-size:10px;padding:5px 8px;max-width:calc(100% - 24px)}
}
@media(max-width:380px){
 .topbar .brand .sigil{display:none}
 .topbar nav button{font-size:10px;padding-left:4px;padding-right:4px}
}
