:root{font-family:"Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,system-ui,sans-serif;color:#263332;background:#fbfffd;font-synthesis:none}*{box-sizing:border-box}body{margin:0;line-height:1.8}.scene-page{width:min(1120px,calc(100% - 32px));margin:24px auto 40px}.scene-intro{margin-bottom:24px}.series-label{margin:0 0 6px;color:#47715f;font-size:.86rem;font-weight:700}.scene-intro h1{font-size:clamp(1.5rem,3vw,2rem);line-height:1.5;margin:0 0 12px}.scene-intro p:last-child{margin:0;color:#596d65}.scene-card,.info-section{background:#fff;border:1px solid #dceae3;border-radius:16px;overflow:hidden}.scene-toolbar{padding:16px;display:flex;flex-wrap:wrap;gap:14px 24px;justify-content:space-between}.scene-buttons,.scene-settings{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.scene-page button,.scene-page select{font:inherit;font-size:.9rem;border:1px solid #bad1c4;border-radius:8px;background:#fff;color:#263d32;min-height:44px;padding:8px 13px}.scene-page button{cursor:pointer;font-weight:700}.scene-page button:hover:enabled{background:#edf7f1}.scene-page button.primary-button{background:#2f8060;border-color:#2f8060;color:white}.scene-page button:disabled,.scene-page select:disabled,.scene-page input:disabled{opacity:.5;cursor:default}.scene-page :focus-visible{outline:3px solid #bc750e;outline-offset:3px}.scene-settings label{display:flex;align-items:center;gap:8px;font-size:.875rem}.scene-settings input{width:116px;accent-color:#2f8060;min-height:40px}.scene-status{margin:0;padding:10px 16px;background:#edf7f1;border-top:1px solid #e0eee6;font-size:.9rem;min-height:46px}.scene-viewport{width:100%;height:clamp(320px,52vh,580px);background:#ced9c7}#scene{display:block;width:100%;height:100%;touch-action:none}.camera-help{margin:0;padding:12px 16px;color:#5c6e65;font-size:.85rem}.info-section{padding:20px 24px;margin-top:20px}.info-section h2{font-size:1.15rem;margin:0 0 12px}.info-section p{margin:10px 0 0}.measure-heading{display:flex;align-items:center;flex-wrap:wrap;gap:12px;justify-content:space-between;margin-bottom:14px}.measure-heading h2{margin:0}.scene-metrics{padding:14px 16px;background:#f3f8f5;border-radius:10px;overflow-wrap:anywhere;font-variant-numeric:tabular-nums;white-space:pre-line}.measure-note{font-size:.85rem;color:#5c6e65}@media(max-width:640px){.scene-page{width:calc(100% - 24px);margin-top:18px}.scene-intro{margin-bottom:18px}.scene-intro h1{font-size:1.5rem}.scene-toolbar{padding:12px;gap:10px}.scene-buttons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%;gap:6px}.scene-page button{padding:8px;font-size:.85rem}.scene-settings{width:100%;justify-content:space-between;gap:8px}.scene-settings label{font-size:.8rem;gap:5px}.scene-page select{padding:6px;font-size:.8rem}.scene-settings input{width:88px}.scene-viewport{height:360px;height:clamp(300px,36svh,420px)}.scene-status{padding:9px 12px}.camera-help{padding:10px 12px}.info-section{padding:16px}.scene-metrics{padding:12px;font-size:.85rem}}

.scene-viewport{position:relative}#selection-box{position:absolute;pointer-events:none;border:1px solid #73eeee;background:rgba(95,225,225,.12);z-index:2}

.selection-details{padding:10px 16px;border-top:1px solid #e0eee6;background:#f6faf5}.selection-details p{margin:3px 0;font-size:.86rem}.selection-details #wood-stock{font-weight:700;color:#315940}.selection-details .resource-rules{font-size:.78rem;color:#5c6e65}

.warehouse-control{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;margin:8px 0}.warehouse-control button{flex-shrink:0}.warehouse-control p{flex:1;min-width:180px;font-size:.8rem}


/* A battlefield and a permanent command deck share one normal page frame. */
.scene-viewport{height:min(720px,calc(100svh - 24px));min-height:0;display:grid;grid-template-rows:minmax(0,1fr) 220px;isolation:isolate;overflow:hidden}
#queue-route{position:absolute;inset:0;width:100%;height:100%;z-index:1;overflow:hidden;pointer-events:none}#queue-route *{pointer-events:none}#queue-route[hidden]{display:none}#queue-route polyline{stroke:#fff2ad;stroke-width:1.5;vector-effect:non-scaling-stroke}#queue-route circle{fill:#233e35;stroke:#fff2ad;stroke-width:1}#queue-route text{fill:#fff8d8;font:700 12px system-ui,sans-serif}
#battlefield{position:relative;min-width:0;min-height:0;overflow:hidden;background:#ced9c7}#scene{position:absolute;inset:0;width:100%;height:100%;touch-action:none}
.game-overlay{position:absolute;z-index:3;touch-action:pan-y;overscroll-behavior:contain}.game-hud{top:8px;left:8px;right:8px;display:flex;justify-content:space-between;align-items:flex-start;gap:8px;pointer-events:none}.game-hud>*{pointer-events:auto}.hud-summary,.hud-play{display:flex;align-items:center;gap:6px;background:rgba(246,250,245,.96);border:1px solid #bad1c4;border-radius:8px;padding:4px}.hud-summary p{margin:0 6px;font-size:.9rem;font-weight:700;line-height:1.5;font-variant-numeric:tabular-nums}.scene-page .game-hud button,.scene-page .command-deck button{min-width:44px;min-height:44px;line-height:1.3;font-size:.875rem;padding:7px 10px}
.command-deck{position:relative;z-index:3;display:grid;grid-template-columns:230px minmax(0,1fr);grid-template-rows:minmax(0,1fr) 44px;gap:8px 12px;padding:10px;background:#f6faf5;border-top:3px solid #789c85;min-width:0;min-height:0;touch-action:pan-y;overscroll-behavior:contain}.selected-summary{border-right:1px solid #bad1c4;padding-right:12px;min-width:0;overflow:hidden}.scene-page #hud-selection{width:100%;text-align:left;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.selected-summary p{font-size:.875rem;line-height:1.6;margin:7px 0;overflow-wrap:anywhere}.command-options{display:grid;grid-template-rows:44px minmax(0,1fr);gap:7px;min-width:0;min-height:0}.command-tabs{display:flex;gap:6px;min-width:0}.command-tabs button{flex:1}.command-content{min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;padding:0 3px 1px 0}.game-panel{position:static;min-width:0;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none}.game-panel[hidden],.warehouse-control [hidden],#command-feedback[hidden]{display:none}.panel-heading{display:none}.game-panel .warehouse-control{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:6px;margin:0;align-items:start}.game-panel .warehouse-control button{min-width:0;width:100%;white-space:normal;text-align:left}.game-panel .warehouse-control p{min-width:0;margin:0;font-size:.85rem;grid-column:1 / -1}.game-panel .selection-details{padding:0;border:0;overflow-wrap:anywhere}.game-panel .selection-details p{font-size:.875rem;line-height:1.6}.game-panel .scene-buttons{display:flex;gap:6px;flex-wrap:wrap}.game-panel .scene-settings{display:flex;flex-wrap:wrap;gap:8px 14px;margin-top:8px}.game-panel .scene-settings input{min-height:44px}.game-controls{grid-column:1 / -1;display:flex;gap:6px;align-items:stretch;justify-content:flex-end;min-width:0}.game-controls button{min-width:70px!important}.game-controls #game-cancel{margin-left:8px}.scene-page button[aria-pressed="true"],.scene-page button[aria-expanded="true"]{background:#2f8060;color:#fff;border-color:#2f8060}#command-feedback{position:static;margin:6px 0 0;padding:4px 6px;background:#fff9e8;border:1px solid #b99b53;border-radius:6px;font-size:.85rem;line-height:1.4;overflow-wrap:anywhere;pointer-events:none}.selected-summary:has(#command-feedback:not([hidden])) #selection-summary{display:none}.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;min-height:0!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important}.game-guide{padding:12px 16px;border-top:1px solid #dceae3}.game-guide summary,.info-section summary{font-weight:700;cursor:pointer;min-height:44px;display:list-item;line-height:44px}.game-guide .resource-rules{font-size:.875rem;color:#5c6e65;line-height:1.8}.info-section>summary{font-size:1.05rem}.scene-metrics{margin-top:12px}
@media(max-width:640px){.scene-page{width:calc(100% - 16px)}.scene-viewport{height:min(740px,calc(100svh - 24px));grid-template-rows:minmax(0,1fr) 230px}.game-hud{top:6px;left:6px;right:6px;gap:4px}.hud-summary{padding:4px;max-width:calc(100% - 110px)}.hud-summary p{font-size:.85rem;margin:0 2px}.hud-play{gap:3px;padding:3px}.scene-page .hud-play button{padding:7px 6px}.command-deck{grid-template-columns:minmax(0,1fr);grid-template-rows:44px minmax(0,1fr) 44px;gap:6px;padding:8px}.selected-summary{border:0;padding:0;display:grid;grid-template-columns:120px minmax(0,1fr);gap:8px;align-items:center}.selected-summary p{margin:0;font-size:.85rem;line-height:1.4;max-height:42px;overflow:hidden}.scene-page #hud-selection{font-size:.85rem;padding:6px}.command-options{gap:5px}.command-tabs{gap:4px}.scene-page .command-tabs button{padding:6px 4px}.game-panel .warehouse-control{grid-template-columns:repeat(2,minmax(0,1fr));gap:5px}.scene-page .game-panel .warehouse-control button{font-size:.85rem;padding:6px}.game-controls{gap:4px;grid-column:1}.game-controls button{flex:1;min-width:44px!important;padding:6px 3px!important}.game-controls #game-cancel{margin-left:2px}.game-panel .scene-settings{display:grid;width:100%;gap:6px}.game-panel .scene-settings label{justify-content:space-between;font-size:.875rem}.game-panel .scene-settings input{width:150px}.scene-intro{margin-bottom:14px}}
@media(max-height:500px) and (min-width:641px){.scene-viewport{height:calc(100svh - 24px);grid-template-rows:minmax(0,1fr) 194px}.command-deck{grid-template-columns:180px minmax(0,1fr);grid-template-rows:minmax(0,1fr) 44px;padding:6px 8px;gap:5px 10px}.selected-summary{padding-right:8px}.selected-summary p{font-size:.85rem;line-height:1.4;margin:4px 0}.command-options{gap:4px}.game-panel .warehouse-control{grid-template-columns:repeat(auto-fit,minmax(155px,1fr))}.game-hud{top:6px;left:6px;right:6px}.hud-summary p{font-size:.85rem}.hud-summary,.hud-play{padding:3px}.game-controls button{padding:6px!important}.command-tabs{gap:5px}}

@media(max-width:640px){.selected-summary #command-feedback{margin:0;max-height:44px;overflow:hidden;font-size:.85rem;line-height:1.25;padding:3px 5px}}
@media(max-height:500px) and (min-width:641px){.selected-summary #command-feedback{margin:4px 0 0;max-height:44px;overflow:hidden;padding:3px 5px;line-height:1.25}}

/* Expand the battlefield and command deck together, without locking the page. */
#game-frame.is-expanded{width:100%;height:100vh;height:100dvh;max-height:none;margin:0;border:0;border-radius:0;background:#ced9c7}
#game-frame.is-expanded{position:fixed;inset:0;z-index:10000}
#fullscreen-toggle{min-width:44px;min-height:44px;white-space:nowrap}
@media(max-width:640px){.hud-summary{max-width:calc(100% - 172px)}.hud-summary p{font-size:.8rem}.hud-play{flex-shrink:0}.scene-page #fullscreen-toggle{padding:7px 5px}}

#visibility-mode{max-width:100%}.visibility-help{margin:0;font-size:.8rem;line-height:1.5;color:#596d65;flex-basis:100%}

/* The overview stays left of selection and commands. */
.command-deck{grid-template-columns:148px 200px minmax(0,1fr)}
.minimap-panel{grid-column:1;grid-row:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-width:0;min-height:0;margin:0;padding:2px 4px;border-right:1px solid #bad1c4;pointer-events:none}
#minimap{display:block;width:min(100%,140px);height:auto;aspect-ratio:180 / 152;background:transparent;border:1px solid transparent}
.minimap-legend{display:flex;justify-content:center;gap:12px;margin:0;font-size:.75rem;line-height:18px;white-space:nowrap}
.minimap-legend span::before{content:"";display:inline-block;width:7px;height:7px;margin-right:4px;border-radius:50%;vertical-align:middle}.minimap-ally::before{background:#32d1cc}.minimap-enemy::before{background:#ed6258}
.selected-summary{grid-column:2;grid-row:1}.command-options{grid-column:3;grid-row:1}.game-controls{grid-column:1 / -1;grid-row:2}
@media(max-width:640px){.command-deck{grid-template-columns:96px minmax(0,1fr);grid-template-rows:44px minmax(0,1fr) 44px;gap:6px 8px}.minimap-panel{grid-column:1;grid-row:1 / 3;padding:2px 4px}.selected-summary{grid-column:2;grid-row:1;grid-template-columns:100px minmax(0,1fr);gap:5px}.command-options{grid-column:2;grid-row:2}.game-controls{grid-column:1 / -1;grid-row:3}.minimap-legend{gap:8px;font-size:.7rem}.scene-page .command-tabs button{min-width:44px;padding:6px 2px}.game-panel .warehouse-control{grid-template-columns:minmax(0,1fr)}.game-panel .scene-settings label{flex-wrap:wrap}.game-panel .scene-settings input{max-width:100%}}
@media(max-height:500px) and (min-width:641px){.command-deck{grid-template-columns:104px 155px minmax(0,1fr)}.minimap-panel{padding:0 4px;gap:2px}#minimap{max-width:84px}.minimap-legend{font-size:.7rem;line-height:16px;gap:8px}}

#minimap{pointer-events:auto;cursor:pointer;touch-action:none}

/* One selected ally uses the existing summary space, without moving controls. */
#selection-preview{display:block;width:64px;height:76px;max-width:100%;border:2px solid #789c85;border-radius:6px;background:#f6faf5;pointer-events:none}#selection-preview[hidden]{display:none}
.selected-summary.has-preview{display:grid;grid-template-columns:64px minmax(0,1fr);grid-template-rows:44px minmax(0,1fr);gap:6px}.has-preview #hud-selection{grid-column:1 / -1;grid-row:1}.has-preview #selection-preview{grid-column:1;grid-row:2;align-self:center}.has-preview #selection-summary{grid-column:2;grid-row:2;margin:0;align-self:center}.has-preview #command-feedback{grid-column:1 / -1;grid-row:2}.selected-summary:has(#command-feedback:not([hidden])) #selection-preview{display:none}
@media(max-width:640px){.selected-summary.has-preview{grid-template-columns:44px 88px minmax(0,1fr);grid-template-rows:44px;gap:4px}.has-preview #selection-preview{grid-column:1;grid-row:1;width:44px;height:44px}.has-preview #hud-selection{grid-column:2;grid-row:1}.has-preview #selection-summary,.has-preview #command-feedback{grid-column:3;grid-row:1}.has-preview:has(#command-feedback:not([hidden])) #hud-selection{grid-column:1 / 3}}
@media(max-height:500px) and (min-width:641px){.selected-summary.has-preview{grid-template-columns:44px minmax(0,1fr);gap:5px}.has-preview #selection-preview{width:44px;height:44px}.has-preview #selection-summary{font-size:.75rem;line-height:1.2}}

/* Type filters occupy the existing summary, with bounded scrolling. */
.selected-summary.has-filters{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:44px minmax(0,1fr);gap:6px}.has-filters #hud-selection{grid-column:1;grid-row:1}.has-filters #selection-summary{display:none}.has-filters #selection-filters{grid-column:1;grid-row:2}.has-filters #command-feedback{grid-column:1;grid-row:2}
.selection-filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;min-width:0;min-height:0;align-content:start;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;scrollbar-width:thin}.selection-filters[hidden]{display:none}.scene-page .selection-filters button{min-width:0;min-height:44px;padding:4px;font-size:.75rem;line-height:1.15;white-space:normal;overflow-wrap:anywhere}.has-filters:has(#command-feedback:not([hidden])) #selection-filters{visibility:hidden}
@media(max-width:640px){.selected-summary.has-filters{grid-template-columns:44px minmax(0,1fr);grid-template-rows:44px;gap:4px}.has-filters #hud-selection{grid-column:1;grid-row:1}.scene-page .has-filters #hud-selection{padding:4px;font-size:.75rem;line-height:1.15;white-space:normal}.has-filters #selection-filters,.has-filters #command-feedback{grid-column:2;grid-row:1}.selection-filters{display:flex;align-items:start;overflow-x:auto;overflow-y:hidden;touch-action:pan-x;scrollbar-width:none}.selection-filters::-webkit-scrollbar{display:none}.scene-page .selection-filters button{flex:0 0 64px;height:44px}}
@media(max-height:500px) and (min-width:641px){.selected-summary.has-filters{gap:5px}.selection-filters{grid-template-columns:repeat(3,minmax(0,1fr));gap:3px}.scene-page .selection-filters button{padding:3px;font-size:.7rem;line-height:1.1}}

/* Five session groups use the existing command-content scroll area. */
.command-tabs{overflow-x:auto;scrollbar-width:none}.command-tabs::-webkit-scrollbar{display:none}.scene-page .command-tabs button{flex:1 0 44px}
.unit-group-list{display:grid;gap:6px}.unit-group-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px}.scene-page .unit-group-row button{min-width:0;min-height:44px;font-size:.8rem;line-height:1.2;padding:6px;white-space:normal;overflow-wrap:anywhere;text-align:center}

.formation-control{display:grid;grid-template-columns:2.5em minmax(0,1fr);align-items:center;gap:5px;margin:0 0 5px;min-width:0}.formation-control>span{font-weight:700}.formation-buttons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;min-width:0}.scene-page .formation-buttons button{min-width:0;min-height:44px;padding:6px 3px}

#move-queue{min-height:44px}#move-queue[aria-pressed="true"]{outline:2px solid currentColor}#move-queue-info{align-self:center;font-size:.85rem}

/* Resource totals wrap within the existing HUD at narrow widths. */
.hud-summary.materials-summary{flex-direction:column;align-items:flex-start;gap:0;min-width:0}.hud-summary.materials-summary p{max-width:100%;overflow-wrap:anywhere}.hud-summary #hud-materials{font-size:.8rem}#material-stock{overflow-wrap:anywhere}

.resource-cost-help{grid-column:1/-1;margin:4px 0;line-height:1.5;overflow-wrap:anywhere;font-size:.85rem}#resource-budget,#resource-shortage{overflow-wrap:anywhere;line-height:1.6}

/* Resource selection stays inside the existing HUD. */
.materials-summary{align-items:flex-start}.resource-worker-buttons{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px}.scene-page .game-hud .resource-worker-button{display:flex;flex-direction:column;gap:2px;min-height:44px;padding:4px 6px;font-size:.75rem;white-space:nowrap}.resource-workers{font-weight:400}.scene-page .resource-worker-button:disabled{opacity:1;color:#506458;background:#edf2ec;cursor:default}.materials-summary #hud-resources{white-space:nowrap;font-size:.8rem}
@media(max-width:1000px){.materials-summary{flex-direction:column;gap:1px}.resource-worker-buttons{grid-template-columns:repeat(3,minmax(0,1fr))}.scene-page .game-hud .resource-worker-button{font-size:.7rem;padding:3px}.materials-summary #hud-resources{font-size:.75rem}}
@media(max-width:420px){.resource-worker-buttons{grid-template-columns:repeat(2,minmax(0,1fr))}.scene-page .game-hud .resource-worker-button{font-size:.65rem}.materials-summary{max-width:calc(100% - 112px)}}

.scene-page .game-hud .resource-stock,.scene-page .game-hud .resource-workers{min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}

/* The existing command-content scroll area keeps the list and production buttons reachable. */
.production-facility-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:5px;margin:0 0 8px;min-width:0}
.scene-page .production-facility-list button{min-width:0;min-height:44px;text-align:left;white-space:normal;overflow-wrap:anywhere;font-size:.85rem;padding:6px}
.production-list-help{font-size:.8rem;line-height:1.4;margin:0 0 5px}
@media(max-width:640px){.production-facility-list{grid-template-columns:minmax(0,1fr)}}

.scene-page .production-facility-list button[aria-pressed="true"]{background:#245b3d;color:#fff;border-color:#163e29}
.production-controls{margin-bottom:8px!important}

.scene-page #production-multi{min-height:44px}.scene-page #production-multi[aria-pressed="true"]{background:#245b3d;color:#fff;border-color:#163e29}

/* Base status and explicit defeat stay inside the existing battlefield. */
.base-hp{position:absolute;left:8px;bottom:8px;z-index:3;margin:0;padding:5px 9px;border:1px solid #bad1c4;border-radius:6px;background:rgba(246,250,245,.96);font-size:.85rem;font-weight:700;font-variant-numeric:tabular-nums;pointer-events:none}
.defeat-panel{position:absolute;inset:0;z-index:8;display:grid;place-items:center;padding:12px;background:rgba(25,36,30,.72);text-align:center}.defeat-panel[hidden]{display:none}.defeat-panel>div{max-width:100%;padding:16px 22px;border-radius:10px;background:#f6faf5;color:#263d32}.defeat-panel strong{font-size:1.5rem}.defeat-panel p{margin:8px 0 12px;font-size:.95rem}

.scene-page .sfx-settings { display: grid; gap: 4px; width: 100%; max-width: 320px; }
.scene-page .sfx-settings label { justify-content: space-between; min-height: 44px; cursor: pointer; }
.scene-page .sfx-settings label span { display: flex; align-items: center; gap: 6px; }
.scene-page .sfx-settings input[type=range] { width: clamp(88px, 26vw, 150px); max-width: 100%; }
.scene-page .sfx-settings input[type=checkbox] { width: 22px; height: 22px; min-height: 0; margin: 0 6px; }
.scene-page .sfx-settings output { min-width: 4ch; text-align: right; }
.scene-page .game-comment-section { margin: 24px 0; }
.scene-page .game-comment-note { color: #465e51; font-size: .92rem; }

