/* Only the current game entry pages opt in. Keep historical previews unchanged. */
:root{--game-width:100vw;--game-height:100vh;--safe-top:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--safe-right:env(safe-area-inset-right,0px);--play-width:calc(var(--game-width) - var(--safe-left) - var(--safe-right));--play-height:calc(var(--game-height) - var(--safe-top) - var(--safe-bottom))}
@supports(height:100dvh){:root{--game-height:100dvh}}
html.game-embedded{--safe-top:0px;--safe-bottom:0px;--safe-left:0px;--safe-right:0px}
.mobile-game,.mobile-game body{width:var(--game-width);height:var(--game-height);min-height:0;margin:0;overflow:hidden;overscroll-behavior:none}
.mobile-game body{box-sizing:border-box;padding:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left)}
.mobile-game #game-view{inset:auto!important;left:var(--safe-left)!important;top:var(--safe-top)!important;width:var(--play-width)!important;height:var(--play-height)!important;z-index:2147483000!important}
.mobile-game #game-view:is([data-game-page=lobby],[data-game-page=selection]){left:0!important;top:0!important;width:var(--game-width)!important;height:var(--game-height)!important}
.mobile-game:is([data-game-page=lobby],[data-game-page=selection]) body{padding:0}
.mobile-portrait:not(.game-embedded) body>main,.mobile-portrait:not(.game-embedded) #game-view{visibility:hidden}
#game-rotate[hidden],[data-game-fullscreen][hidden]{display:none!important}
#game-rotate{position:fixed;inset:0;z-index:2147483647;display:grid;place-items:center;background:#090810;color:#f5e5bd;text-align:center;padding:32px 24px;font:14px/1.8 Galmuri11,system-ui,sans-serif}
#game-rotate img{width:min(280px,75vw);height:auto;image-rendering:pixelated}
#game-rotate h1{font:20px/1.5 Galmuri11,system-ui,sans-serif;margin:24px 0 12px;color:#efd08b}
#game-rotate p{font:13px/1.8 Galmuri11,system-ui,sans-serif;color:#c5bdcf}
.rotate-phone{margin:24px auto 0;width:84px;height:46px;border:3px solid #d5b97d;border-radius:8px;font:36px/40px system-ui;color:#d5b97d}
.mobile-game[data-game-page=title] .title-screen{min-height:0;height:var(--play-height);padding:0}
.mobile-game[data-game-page=title] .scene{width:min(var(--play-width),calc(var(--play-height)*16/9))}
.mobile-game[data-game-page=title] .main-menu{width:28%;top:64%;gap:4px}
.mobile-game[data-game-page=title] .main-menu .menu-button{min-height:0;height:5.3cqw;font-size:clamp(12px,2cqw,20px)}
.mobile-game[data-game-page=title] .minor{padding:5px 8px;font-size:10px}
.mobile-game[data-game-page=lobby] .lobby{width:var(--game-width);height:var(--game-height);min-height:0;position:relative}
.mobile-game[data-game-page=lobby] #map-stage{width:min(var(--play-width),calc(var(--game-height)*1672/941));left:calc(var(--safe-left) + var(--play-width)/2)}
.mobile-game[data-game-page=lobby] .scene-controls{left:calc(var(--safe-left) + 8px);top:calc(var(--safe-top) + 8px);gap:5px;opacity:1}
.mobile-game[data-game-page=lobby] .scene-controls button,.mobile-game[data-game-page=lobby] .scene-controls a{width:34px;height:32px;font-size:20px}
.mobile-game[data-game-page=lobby] .game-brand{width:110px;bottom:calc(var(--safe-bottom) + 8px);right:calc(var(--safe-right) + 8px)}
.mobile-game[data-game-page=lobby] .dossier{left:auto;right:calc(var(--safe-right) + 8px);top:calc(var(--safe-top) + 8px);bottom:calc(var(--safe-bottom) + 8px);max-height:none;min-height:0;width:min(300px,48%);padding:16px;overflow:auto}
/* Roster: real responsive cards instead of a 1600px desktop screenshot. */
.mobile-game[data-game-page=selection] #app{width:var(--game-width);height:var(--game-height);padding:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);transform:none!important;display:flex;flex-direction:column;overflow:hidden}
.mobile-game[data-game-page=selection] header{height:38px;flex:0 0 38px;padding:0 12px}
.mobile-game[data-game-page=selection] header nav{font-size:10px;gap:10px}.mobile-game[data-game-page=selection] header nav span:not(.active){display:none}
.mobile-game[data-game-page=selection] .logo{width:90px;height:36px}.mobile-game[data-game-page=selection] .back{font-size:12px}
.mobile-game[data-game-page=selection] .body{padding:0 12px;display:flex;flex-direction:column;flex:1;min-height:0}
.mobile-game[data-game-page=selection] .body>.eyebrow,.mobile-game[data-game-page=selection] .sub{display:none}
.mobile-game[data-game-page=selection] h1{font-size:17px;margin:7px 0;line-height:1.4}
.mobile-game[data-game-page=selection] .classlayout{grid-template-columns:minmax(0,1fr) 30%;gap:10px;margin:0;flex:1;min-height:0}
.mobile-game[data-game-page=selection] .classgrid{width:auto;gap:7px;grid-template-rows:repeat(2,minmax(0,1fr))}
.mobile-game[data-game-page=selection] .classcard{height:auto;min-height:0;padding:8px;overflow:hidden}
.mobile-game[data-game-page=selection] .classcard h3{font-size:13px;left:8px;top:7px;margin:0}
.mobile-game[data-game-page=selection] .classcard .chosen{font-size:10px;top:8px;right:6px}.mobile-game[data-game-page=selection] .classcard .role{display:none}
.mobile-game[data-game-page=selection] .classcard .face{left:8px;top:30px;width:auto;height:calc(100% - 36px);max-height:90px;aspect-ratio:1}
.mobile-game[data-game-page=selection] .classcard .sprite{right:4px;top:30px;width:43%;height:calc(100% - 34px)}
.mobile-game[data-game-page=selection] .detail{height:auto;min-height:0;padding:9px;display:flex;flex-direction:column;overflow:auto}
.mobile-game[data-game-page=selection] .detail .eyebrow{font-size:9px;letter-spacing:1px}.mobile-game[data-game-page=selection] .detail h2{font-size:18px;margin:4px 0}.mobile-game[data-game-page=selection] .detail .tag{font-size:9px;padding:3px;align-self:flex-start}
.mobile-game[data-game-page=selection] .detail p{font-size:10px;margin:6px 0;line-height:1.5}.mobile-game[data-game-page=selection] .detail .notice{display:none}
.mobile-game[data-game-page=selection] .stat{font-size:10px;margin:4px 0;gap:6px}.mobile-game[data-game-page=selection] .stat span{width:36px}.mobile-game[data-game-page=selection] .bar{height:5px}
.mobile-game[data-game-page=selection] .detail .primary{font-size:12px;min-height:36px;padding:7px 4px;margin-top:auto}.mobile-game[data-game-page=selection] .detail .back-step{font-size:10px;margin:5px 0 0;padding:4px}
.mobile-game[data-game-page=selection] .partystrip{margin-top:7px;padding:5px;gap:5px}.mobile-game[data-game-page=selection] .slot{padding:6px 4px;font-size:11px;min-height:32px}.mobile-game[data-game-page=selection] .slot small{display:none}
.mobile-game[data-game-page=selection] .foot{position:static;height:24px;flex:0 0 24px;padding:5px 12px;font-size:10px}.mobile-game[data-game-page=selection] .foot span{display:none}
@media(orientation:landscape) and (max-height:540px){
 .mobile-game[data-game-page=selection] .classlayout{grid-template-columns:minmax(0,1fr) 36%}
 .mobile-game[data-game-page=selection] .detail{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:max-content;align-content:space-between;align-items:center;gap:4px 8px;padding:8px}
 .mobile-game[data-game-page=selection] .detail>.eyebrow{display:none}
 .mobile-game[data-game-page=selection] .detail h2{font-size:16px;line-height:1.2;margin:0}
 .mobile-game[data-game-page=selection] .detail .tag{justify-self:end;align-self:center;font-size:10px;line-height:1.2;padding:2px 3px;word-break:keep-all}
 .mobile-game[data-game-page=selection] .detail p{grid-column:1/-1;font-size:12px;line-height:1.35;margin:0;word-break:keep-all}
 .mobile-game[data-game-page=selection] .detail .stat{margin:0;font-size:10px;line-height:1.3;gap:4px}
 .mobile-game[data-game-page=selection] .stat span{width:32px}
 .mobile-game[data-game-page=selection] .detail .primary{grid-column:1/-1;min-height:32px;margin:0;padding:5px 2px;font-size:12px}
 .mobile-game[data-game-page=selection] .detail .back-step{grid-column:1/-1;margin:0;padding:2px;line-height:1.3}
}
@media(orientation:landscape) and (max-height:340px){
 .mobile-game[data-game-page=selection] header{height:28px;flex-basis:28px}
 .mobile-game[data-game-page=selection] .logo{height:26px}
 .mobile-game[data-game-page=selection] h1{font-size:15px;margin:3px 0}
 .mobile-game[data-game-page=selection] .partystrip{margin-top:4px;padding:3px}
 .mobile-game[data-game-page=selection] .foot{height:18px;flex-basis:18px;padding-block:2px}
 .mobile-game[data-game-page=selection] .detail{padding:5px 7px;row-gap:2px}
 .mobile-game[data-game-page=selection] .detail p{font-size:11px}
}
/* Landscape phones: keep authored arena geometry, put legible touch controls beside it. */
@media(min-aspect-ratio:9/5) and (max-height:600px){
 .mobile-game[data-game-page=battle] body{display:block}
 .mobile-game[data-game-page=battle] .screen{width:var(--play-width);height:var(--play-height);aspect-ratio:auto;max-width:none;display:grid;grid-template-columns:minmax(0,1fr) clamp(178px,25vw,250px);align-items:center;border:0;gap:0}
 .mobile-game[data-game-page=battle] .scene{width:min(100%,calc(var(--play-height)*16/7));height:auto;aspect-ratio:16/7;justify-self:center;container-type:inline-size;border:1px solid #8d784f}
 .mobile-game[data-game-page=battle] .hud{width:100%;height:100%;display:flex;flex-direction:column;gap:10px;padding:10px 6px 6px;border-top:0;border-left:1px solid #b89b61;overflow:hidden}
 .mobile-game[data-game-page=battle] .hud:before{display:none}
 .mobile-game[data-game-page=battle] .hud .party{width:100%;height:42%;flex:0 0 42%;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(2,minmax(0,1fr));gap:7px 5px}
 .mobile-game[data-game-page=battle] .hud .member{min-height:0;padding:6px 4px 3px;gap:4px;align-items:center}
 .mobile-game[data-game-page=battle] .hud .portrait{width:25%;height:auto;max-height:80%;aspect-ratio:12/17}
 .mobile-game[data-game-page=battle] .hud .role-badge{font-size:8px;min-width:22px;padding:0 3px;top:-5px}
 .mobile-game[data-game-page=battle] .hud .stats strong{font-size:10px;line-height:1.1;margin:0 0 2px}
 .mobile-game[data-game-page=battle] .hud .stat-line{font-size:8px;line-height:1.1;margin:1px 0}.mobile-game[data-game-page=battle] .hud .bar{height:3px}
 .mobile-game[data-game-page=battle] .hud .commands{flex:1;min-height:0;padding:0}
 .mobile-game[data-game-page=battle] .hud .command-grid{grid-template-rows:repeat(3,minmax(0,1fr));gap:5px}
 .mobile-game[data-game-page=battle] .hud .command-grid button{font-size:12px;padding:4px;min-height:32px;line-height:1.35;white-space:normal;overflow-wrap:anywhere}
 .mobile-game[data-game-page=battle] .hud #party-end-turn{position:relative;inset:auto;font:inherit;padding:4px;z-index:auto}
 .mobile-game[data-game-page=battle] #dungeon-menu-open,.mobile-game[data-game-page=battle] #party-configure{font-size:11px;padding:5px 7px;min-height:30px}
 .mobile-game[data-game-page=battle] .clear-panel{max-width:95%;min-width:0}.mobile-game[data-game-page=battle] .clear-buttons button{min-height:36px;font-size:12px}
 /* Three cards, their rerolls and the confirmation all remain on screen. */
 .mobile-game .skill-draft.loot-overlay{inset:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);padding:6px 12px;align-items:center}
 .mobile-game .skill-draft .loot-panel{width:min(1000px,100%);padding:0;max-height:100%;overflow:auto}
 .mobile-game .skill-draft h2{font-size:20px;margin:0 0 7px;line-height:1.3}
 .mobile-game .draft-cards{gap:12px;max-width:none}.mobile-game .draft-option{gap:6px}
 .mobile-game .draft-card{display:grid;grid-template-columns:46px minmax(0,1fr);grid-template-rows:46px minmax(0,1fr) auto;align-items:center;gap:4px 6px;height:clamp(118px,calc(var(--play-height) - 153px),330px);min-height:0;padding:12px 16px 10px}
 .mobile-game .draft-emblem{width:46px;height:46px;padding:2px;flex-basis:46px}
 .mobile-game .draft-card strong{font-size:13px;line-height:1.4;text-align:left}
 .mobile-game .draft-description{grid-column:1/-1;min-height:0;max-height:100%;overflow:auto;font-size:12px;line-height:1.5;align-self:stretch;text-align:left}
 .mobile-game .draft-card small{grid-column:1/-1;font-size:10px;margin:0;padding:0;min-height:0}
 .mobile-game .draft-card small .draft-emblem{width:16px;height:16px;flex-basis:16px}
 .mobile-game .draft-reroll{width:100%;font-size:11px;min-height:30px;padding:3px 6px;line-height:1.4}
 .mobile-game .draft-reroll .draft-emblem{width:18px;height:18px;flex-basis:18px}
 .mobile-game .skill-draft .loot-subtitle{font-size:11px;margin:6px 0 0;line-height:1.4}
 .mobile-game .skill-draft .loot-footer{margin:6px 0 0;gap:10px;flex-wrap:nowrap}
 .mobile-game .skill-draft #loot-skip,.mobile-game .skill-draft #loot-back{font-size:12px;min-height:34px;padding:6px 14px}
 .mobile-game .skill-draft .draft-key-help{display:none}
}
