/* Compact paper controls leave room for the battlefield. */
#game{grid-template-rows:52px minmax(0,1fr) 100px}#game.dock-open{grid-template-rows:52px minmax(0,1fr) 244px}#game.tools-open{grid-template-rows:52px minmax(0,1fr) 148px}
#quickSelection{display:flex;gap:3px;padding:2px 5px;flex:0 0 46px;min-height:46px;box-sizing:border-box;order:-2}#quickSelection button{flex:1;min-width:0;min-height:42px;height:42px;padding:3px 2px;font-size:11px;line-height:1.15}
#panel nav{order:-1}#quickOrders{display:none;gap:3px;padding:2px 5px;flex:0 0 46px;min-height:46px;box-sizing:border-box}#game.tools-open #quickOrders{display:flex}#quickOrders button{flex:1;min-width:0;font-size:12px;height:42px;min-height:42px;padding:2px}#quickOrders select{flex:1.5;min-width:0;max-width:110px;font:12px monospace;color:#24221d;background:#eae5d9 url('paper-ui.png') center/cover;border:0;height:42px;padding:3px;clip-path:polygon(1% 3%,30% 0,61% 2%,99% 0,100% 49%,99% 98%,68% 100%,32% 97%,1% 100%,0 50%)}
#game.tools-open #panel .tactical-orders,#game.tools-open #panel .extra-orders,#game.tools-open #panel .orders{display:none!important}
#game.dock-open #cards{display:flex!important;padding:4px 0;gap:0;overflow:hidden;min-height:0;animation:deck-rise .16s ease-out}#cardPage{display:flex!important;align-items:stretch;gap:7px;overflow-x:auto!important;overflow-y:hidden!important;scroll-snap-type:x mandatory;scroll-padding-inline:8px;scrollbar-width:none;touch-action:pan-x;overscroll-behavior-x:contain;width:100%;height:100%;padding:2px 8px 6px;box-sizing:border-box;cursor:grab}#cardPage::-webkit-scrollbar{display:none}#cardPage:active{cursor:grabbing}#cardPage .card{flex:0 0 118px!important;min-width:118px!important;max-width:118px!important;scroll-snap-align:start;max-height:none;padding:5px;user-select:none}#cardPage .card .art{width:76px;height:55px}#cardPage .card b{font-size:12px;line-height:1.15}#cardPage .card .cost{font-size:11px}#cards::after{content:'';position:absolute;right:0;bottom:6px;width:9px;height:125px;background:linear-gradient(90deg,transparent,#ebe8dfaa);pointer-events:none}
#groupPopup{position:fixed;inset:auto;margin:0;box-sizing:border-box;width:min(320px,calc(100dvw - 16px));padding:10px;background:#eee9dc url('paper-ui.png') center/cover;border:1px solid #4e483d;box-shadow:3px 4px #29261e55;color:#222;font:14px monospace}#groupPopup[hidden]{display:none!important}#groupPopup>button{position:absolute;right:5px;top:4px;width:38px;height:38px;min-height:38px}#groupPopup>strong{display:block;min-height:32px;padding-right:38px}.group-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}.group-grid button{min-height:44px;min-width:0;font-size:12px;padding:4px}
#game.has-building:not(.dock-open):not(.tools-open){grid-template-rows:52px minmax(0,1fr) 54px}.has-building #quickSelection{display:none}.has-building.dock-open #quickSelection,.has-building.tools-open #quickSelection{display:flex}
.resources .resource-warning{background:#26231d;color:#fff;outline:2px solid #26231d}.resources small{white-space:nowrap;font-size:9px}.resources>div:focus-visible{outline:2px dashed #24221d;outline-offset:3px}
@keyframes deck-rise{from{transform:translateY(24px);opacity:.3}to{transform:translateY(0);opacity:1}}
@media(max-width:600px){#game{grid-template-rows:48px minmax(0,1fr) 100px}#game.dock-open{grid-template-rows:48px minmax(0,1fr) 232px}#game.tools-open{grid-template-rows:48px minmax(0,1fr) 146px}#game.has-building:not(.dock-open):not(.tools-open){grid-template-rows:48px minmax(0,1fr) 54px}#cardPage .card{flex-basis:110px!important;min-width:110px!important;max-width:110px!important}#cardPage .card .art{height:48px}header .resources{gap:9px}#panel nav button{font-size:12px}#addSelection{font-size:10px}#selectionStats{max-width:min(250px,calc(100% - 110px))}}
@media(max-height:430px){#game{grid-template-rows:44px minmax(0,1fr) 94px}#game.tools-open{grid-template-rows:44px minmax(0,1fr) 140px}#game.dock-open{grid-template-rows:44px minmax(0,1fr) 204px}#game.has-building:not(.dock-open):not(.tools-open){grid-template-rows:44px minmax(0,1fr) 50px}#cardPage .card .art{height:32px}#cardPage .card{padding:3px}#cardPage .card b{font-size:11px}#cardPage .card .cost{font-size:10px}#cardPage{gap:6px}#selectionStats{display:none!important}}
@media(prefers-reduced-motion:reduce){#game.dock-open #cards{animation:none}}

.resources strong{white-space:nowrap}#selectionStats.group-selected #statsValues,#selectionStats.group-selected #statsNote{display:none}#selectionStats.group-selected{padding:6px 8px;gap:2px}#selectionStats.group-selected #statsName{font-size:12px}#selectionStats.group-selected #statsHealthText{font-size:11px}
@media(max-width:360px){header .resources{gap:5px}.resources strong{font-size:12px}header .wordmark{max-width:58px!important}#quickSelection button{font-size:10px}}
.resources .resource-warning small{color:#fff9e8}
@media(max-width:360px){header{display:grid;grid-template-columns:54px minmax(0,1fr) 40px;gap:6px;padding:3px 5px}header .wordmark{width:54px;max-width:54px!important}header .hud-logo{width:54px;height:32px;max-width:100%}header .resources{min-width:0;justify-content:space-between;gap:4px}header .resources small{font-size:8px;letter-spacing:0}header .resources strong{font-size:12px}header button{width:40px}}

/* One context, one action row. Building tools share the deck instead of covering the map. */
#game{grid-template-rows:52px minmax(0,1fr) 144px}#game.dock-open{grid-template-rows:52px minmax(0,1fr) 292px}#game.army-context,#game.tools-open{grid-template-rows:52px minmax(0,1fr) 188px}#game.structure-context:not(.dock-open){grid-template-rows:52px minmax(0,1fr) 138px}
#commandContext{order:-3;display:flex;align-items:center;gap:8px;padding:2px 8px;min-height:44px;flex:0 0 44px;box-sizing:border-box;background:#d8d2c1aa}#commandContextText{font:12px monospace;flex:1;min-width:0;line-height:1.2}#quickRepair{font-size:11px;min-width:112px;min-height:40px;padding:4px}#game.army-context #quickOrders{display:flex}#game.has-building #quickSelection{display:none!important}#game #buildingActions{position:static!important;inset:auto!important;transform:none!important;order:0;display:flex;align-items:center;gap:4px;flex:0 0 44px;min-height:44px;width:auto!important;max-width:none!important;padding:2px 5px!important;box-shadow:none!important;background:transparent!important;border:0!important}#game #buildingActions[hidden]{display:none!important}#buildingActions #buildingName,#buildingBack,#buildingRally,#buildingDemolish{display:none!important}#buildingActions button{min-width:0;flex:1;font-size:11px;min-height:40px;padding:3px}#buildingQueue{max-width:90px}#buildingReclaim{max-width:150px}#buildingPower{max-width:130px}#panel nav{flex:0 0 44px;min-height:44px}#game.structure-context #cards{flex:1;min-height:0}.group-grid{display:flex;flex-direction:column;gap:10px}.group-row{display:grid;grid-template-columns:1fr 1.5fr;gap:3px}.group-row>span{grid-column:1/-1;font:11px monospace;padding:3px 0;line-height:1.3}.group-row button{min-height:42px}.has-building #selectionStats{display:none!important}#game.army-context #toggleOrders{visibility:hidden}
@media(max-width:600px){#game{grid-template-rows:48px minmax(0,1fr) 144px}#game.dock-open{grid-template-rows:48px minmax(0,1fr) 280px}#game.army-context,#game.tools-open{grid-template-rows:48px minmax(0,1fr) 188px}#game.structure-context:not(.dock-open){grid-template-rows:48px minmax(0,1fr) 138px}#commandContextText{font-size:11px}#quickRepair{min-width:100px;font-size:10px}}
@media(max-height:500px){#game,#game.army-context,#game.tools-open{grid-template-rows:44px minmax(0,1fr) 138px}#game.dock-open{grid-template-rows:44px minmax(0,1fr) 234px}#game.army-context #quickSelection{display:none}#game.structure-context:not(.dock-open){grid-template-rows:44px minmax(0,1fr) 132px}#commandContextText{font-size:11px}#cardPage .card .art{height:35px}}

#radioCaption{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);max-width:calc(100% - 24px);min-height:40px;padding:6px 15px;z-index:9;font:12px monospace;background:#ece8dced url(paper-ui.png) center/cover;color:#24231e;box-shadow:2px 3px #20221a55}#radioCaption[hidden]{display:none}
#game #buildingActions:not([hidden]){display:flex!important;flex-wrap:nowrap;height:44px;min-height:44px;flex:0 0 44px}#game #panel nav{height:44px;min-height:44px;flex:0 0 44px;padding:2px 5px}#game #panel{min-height:0;overflow:hidden}#game #cards{min-height:0!important;max-height:none!important;flex:1 1 0!important}#cardPage .card{justify-content:center;gap:3px;transform:none!important}#cardPage .card .art{width:100px;max-width:100%;height:70px;flex:1;min-height:20px;max-height:90px}#cardPage .card .art canvas{object-fit:contain}#cardPage .card b,#cardPage .card .cost{flex:0 0 auto}#game #buildingActions button[hidden]{display:none!important}
@media(max-height:500px){#cardPage .card .art{height:40px;max-height:50px}}
#game.dock-open,#game.army-context.dock-open{grid-template-rows:52px minmax(0,1fr) 280px}#game.dock-open #quickOrders,#game.dock-open #quickSelection{display:none!important}#game.dock-open #toggleOrders{visibility:visible}@media(max-width:600px){#game.dock-open,#game.army-context.dock-open{grid-template-rows:48px minmax(0,1fr) 264px}}@media(max-height:500px){#game.dock-open,#game.army-context.dock-open{grid-template-rows:44px minmax(0,1fr) 224px}}

/* Orders appear with an army selection; the redundant navigation toggle is unnecessary. */
#game #toggleOrders{display:none!important}
