/* A single portrait viewport keeps navigation and the current action within reach. */
html,body{height:100%;overflow:hidden}
#phone{height:100vh;height:100dvh;min-height:0;overflow:hidden}
#hud,#dock,#nav{flex-shrink:0}
#hud{padding-top:calc(7px + env(safe-area-inset-top));min-height:58px}
#scene{min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#716b53 transparent}
#scene.home{display:block}
.town{height:100%;min-height:375px;max-height:none}
#nav{position:static;padding-bottom:env(safe-area-inset-bottom)}
#nav button{min-height:49px}
[hidden],#nav[hidden],#dock[hidden]{display:none!important}
button,summary{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button:active:enabled{filter:brightness(1.22)}
button:not(.portrait):not(.bench-hero):not(.building){min-height:44px}
.building{min-height:46px}
.go-back{min-width:44px;background:#293b33;border:1px solid #8c7958;padding:0 5px;line-height:.75;font-size:26px}
.go-back small{display:block;font:11px/1.2 system-ui;color:#ecdcba}
#dock{display:flex;gap:9px;align-items:center;justify-content:space-between;padding:8px 14px;background:#25372f;border-top:1px solid #7c7154;box-shadow:0 -4px 12px #15211c66;z-index:2}
#dock:has(+ #nav[hidden]){padding-bottom:max(env(safe-area-inset-bottom),9px)}
#dock .red{flex:1;min-width:48%;font-size:16px}
#dock .soft{min-width:26%}
.stage-strip{display:flex;overflow-x:auto;gap:6px;margin:12px 0;position:relative;scrollbar-width:thin}
.stage-strip button{flex:0 0 60px;display:grid;line-height:1.3;place-content:center}
.stage-strip small,.altar small{font-size:11px}
.stage-strip .sel{box-shadow:inset 0 -2px #efcd83}
.stage-strip .done{color:#b4dbc3}
.formation-head,.opponent,.formation-stats,.bench-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
.formation-head{margin-bottom:10px}.formation-head .heading{margin:0}.formation-head h1{font-size:25px}
.opponent{align-items:flex-end;flex-direction:column;gap:0;font-size:12px}.opponent button{padding:2px 8px}
.formation-board{background:radial-gradient(ellipse at 40% 30%,#415344,#24372e);border:1px solid #9d865a;box-shadow:inset 0 0 0 3px #24372e;padding:9px 12px}
.board-labels{display:grid;grid-template-columns:2fr 1fr;text-align:center;font-size:12px;letter-spacing:.2em;color:#dfcda1}
.slots{margin:5px 0 9px;gap:6px}.slots button{aspect-ratio:1.8;background:#1c2e27;border:1px dashed #908c69;border-radius:5px}
.slots button:has(img){border-style:solid}.slots .chosen{border:2px solid #ffdc83;outline:none;box-shadow:0 0 0 2px #c4a76277}
.slots img{object-position:50% 32%}.slots span{font-size:12px;line-height:1.5;color:#fff1cf}
.seat-number,.rarity,.position{position:absolute;top:0;line-height:1.4;padding:0 4px;font:700 11px/1.5 system-ui}
.seat-number{left:0;color:#ffe5a1;background:#23372ddc}.chosen .seat-number{background:#f0ca77;color:#3d3423}
.formation-stats{font-size:12px}.formation-stats b{color:#f0d18e}.formation-stats span{color:#d0d4bc;text-align:right}
.bench-head{margin-top:11px}.bench-head h3{font-size:17px}.bench-head .inline{padding:1px 9px}
.bench-grid,.scout-grid,.draw-results{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
.bench-hero{position:relative;min-height:0;padding:0 0 3px;overflow:hidden;line-height:1.25;background:#23332d;border-color:#6e7360}
.bench-hero img,.scout-grid img{display:block;width:100%;aspect-ratio:1;object-fit:cover}
.bench-hero b,.scout-grid b,.bench-hero small,.scout-grid small{display:block;text-align:center;font-size:12px}
.bench-hero small{font-size:10px;color:#d1d5c2}.bench-hero.deployed{border-color:#d4b26e}
.rarity{left:0;color:#ffe2a1;background:#403324d9}.position{right:0;color:#fff0c5;background:#475c44}
.altar-tabs{display:grid;gap:6px}.altar-tabs{grid-template-columns:repeat(2,1fr);margin-bottom:10px}
.altar{min-height:clamp(145px,25dvh,215px);background-size:cover;background-position:center 32%;border:1px solid #958254;display:flex;align-items:flex-end;padding:18px}
.altar h2{font-size:30px;color:#f3d69c}.altar small{display:block;color:#efe4c6}
.meter{height:5px;background:#15271f;margin:7px 0 11px}.meter i{height:100%;display:block;background:#dbb36d}
.draw-actions,.result-buttons{display:flex;gap:8px;align-items:stretch;margin-top:14px;flex-wrap:wrap}
.draw-actions button,.result-buttons .red{flex:1}.draw-results .portrait{width:100%}.draw-results:has(.portrait:only-child){grid-template-columns:minmax(100px,42%);justify-content:center}
dialog{max-height:88dvh;overscroll-behavior:contain}dialog header{gap:8px}dialog header h2{flex:1}
.close{min-width:44px}
#dialog-note:not(:empty){position:sticky;bottom:0;background:#344837;color:#ffe3a2;padding:8px 12px;border-top:1px solid #86754d}
.cave-event{border-color:#b1935e}.cave-event .red{min-width:44%}
.cards>div>.portrait{width:100%}
#scene.battlepage{background:#1c2c25}
.battlepage .field{height:clamp(260px,65dvh,600px)}
.battlepage.settled .field{height:clamp(130px,27dvh,270px);filter:saturate(.8)}
.debrief{margin:-10px 12px 16px;position:relative;background:linear-gradient(160deg,#384535,#21352c 75%);border:3px double #b99b63;text-align:center;padding:17px 12px;color:#eee1ba}
.debrief h1{font-size:33px;color:#ffe1a1;letter-spacing:.12em}.debrief.defeat{border-color:#957769}.debrief.defeat h1{color:#edb9a5}
.reward-grid{display:flex;flex-wrap:wrap;justify-content:center;gap:5px;margin:8px 0}.reward-grid span{padding:3px 7px;border:1px solid #6c7057;background:#26392e;font-size:13px}
.debrief p{font-size:13px}.result-buttons{justify-content:center}.result-buttons .inline{flex-basis:100%}
.playback{padding-bottom:env(safe-area-inset-bottom)}.narrate{padding:3px 0;margin-bottom:0}
#toast{bottom:max(100px,16dvh);max-width:85vw;text-align:center;border-radius:4px}
@media(min-width:430px){.bench-grid{grid-template-columns:repeat(6,minmax(0,1fr))}}
@media(max-width:355px){#scene{padding-left:9px;padding-right:9px}.bench-grid,.draw-results{gap:4px}.formation-board{padding:8px}.bench-hero b{font-size:11px}.draw-results .cardtext b{font-size:12px}}
@media(max-height:650px){.battlepage .field{height:50dvh}.battlepage.settled .field{height:21dvh}.debrief{padding:9px}.formation-board .slots button{aspect-ratio:2.25}}

.fame,.pool-info,.pool-actions,.tavern-tools{display:flex;align-items:center;gap:8px}.fame{justify-content:space-between;margin-bottom:8px}.fame>div{flex:1}.fame .meter{margin:3px 0}
.tavern-pool{padding:9px 11px;margin:8px 0;border:1px solid #8b7758;background-position:center, right 35%;background-size:cover,65% auto;background-repeat:no-repeat;background-color:#1e3128;box-shadow:inset 0 0 0 2px #243329}
.pool-info{justify-content:space-between}.pool-info h2{color:#ffe4b2;font-size:21px}.pool-info small{padding:1px 6px;border-radius:10px;background:#17291fe6;color:#f5ead3}
.pool-actions{margin-top:6px}.pool-actions button{min-width:76px;padding:3px 8px;line-height:1.2}.pool-actions button span{display:block;font-size:12px}
.pool-clock{display:block;color:#d6dac8;margin-top:3px;font-size:12px}.tavern-tools{justify-content:space-between}
.scout-strip{display:flex;align-items:center;gap:5px;margin:0 0 8px}.scout-strip img{width:28px;aspect-ratio:1;border:1px solid #a88b65;border-radius:3px}
.slots button:has(img){touch-action:none;user-select:none;-webkit-user-select:none}
.slots img{pointer-events:none}.slots .lifting{opacity:.55}.slots .drop-target{outline:3px solid #ffdb80;outline-offset:-3px}
.drag-portrait{position:fixed;z-index:30;width:58px;height:58px;object-fit:cover;border:2px solid #edc675;border-radius:5px;box-shadow:0 5px 10px #131c16aa;transform:translate(-50%,-80%);pointer-events:none}
.formation-help{color:#c5cbb7;font-size:12px;margin-top:6px}
