/* The battlefield stays full size; controls appear only when requested. */
:root { --edge: 8px; }
#map-safe-area { position: absolute; inset: var(--safe-top) var(--safe-right) var(--dock-bottom) var(--safe-left); pointer-events: none; }
.settings-toggle { position: absolute; top: var(--safe-top); left: var(--safe-left); z-index: 18; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #d7c9a8; border-radius: 9px; color: var(--ink); background: #f8f3e4ed; box-shadow: 0 3px 14px #273f351a; }
.settings-toggle:hover, .settings-toggle[aria-expanded=true] { background: #e5e5ce; }
.settings-toggle svg { width: 22px; height: 22px; }
#portrait-hint { display: none; }
.sr-only { position: absolute!important; width: 1px!important; height: 1px!important; padding: 0!important; margin: -1px!important; overflow: hidden!important; clip-path: inset(50%); white-space: nowrap; border: 0!important; }

#game-menu { position: absolute; z-index: 17; left: calc(var(--safe-left) + 52px); right: auto; top: var(--safe-top); bottom: auto; width: 300px; max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 52px); max-height: calc(var(--app-height,100dvh) - var(--safe-top) - var(--dock-bottom)); padding: 14px; display: block; border: 1px solid #d8cbaa; border-radius: 10px; background: #f8f3e6f7; box-shadow: 0 8px 30px #233c3326; overflow-y: auto; scrollbar-width: thin; }
#game-menu #hud-bar { position: static; display: block; width: auto; height: auto; min-height: 0; max-width: none; margin: 0; padding: 0 0 12px; background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none; }
#game-menu .brand { display: inline-flex; padding: 0; margin: 0; border: 0; font: 500 19px var(--serif); letter-spacing: 2px; }
#game-menu .brand strong { font: inherit; }
.menu-battle { display: block; font-size: 10px; color: #8b8268; margin-top: 4px; }
#game-menu .hud-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding: 0; margin: 15px 0 12px; border: 0; }
#game-menu .hud-stat { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
#game-menu .hud-stat>span { font-size: 10px; }
#game-menu .hud-stat>strong { font-size: 19px; font-weight: 500; line-height: 1.2; }
#game-menu .hud-stat small { font-size: 10px; }
#game-menu .turn-clock { display: block; width: 100%; padding: 0; margin: 0; }
#game-menu .turn-clock>div:first-child { display: flex; justify-content: space-between; }
#game-menu .clock-sub { margin: 0; }
#game-menu .clock-sub b { font-size: 16px; }
#game-menu .turn-track { margin-top: 7px; }
.menu-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
#game-menu button { position: relative; display: flex; align-items: center; justify-content: flex-start; gap: 7px; width: auto; min-width: 0; min-height: 42px; height: auto; margin: 0; padding: 8px 9px; font-size: 12px; line-height: 1.3; letter-spacing: 0; color: var(--ink); background: #e9e6d782; border: 1px solid transparent; border-radius: 5px; text-align: left; white-space: nowrap; }
#game-menu button:hover { background: #e1e4d1; border-color: #c4c9ae; }
#game-menu button svg { width: 16px; height: 16px; }
#game-menu #speed-button:before { content: '速度'; font-size: 11px; color: #7e846a; }
#supplies-dot { position: absolute; right: 8px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: #aa8545; }
#game-menu #map-controls { display: grid; grid-template-columns: 42px minmax(0,1fr) 42px; gap: 5px; position: static; width: auto; margin: 11px 0; padding: 11px 0; transform: none; border: 0; border-top: 1px solid #d9d1bc; border-bottom: 1px solid #d9d1bc; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; }
#game-menu #map-controls button { justify-content: center; }
#game-menu #find-hq { grid-column: 1/3; }
#game-menu #hide-ui { grid-column: 3; font-size: 0; }
#game-menu #hide-ui svg { width: 18px; height: 18px; }
#game-menu .menu-secondary button { background: transparent; font-size: 11px; }
.audio-settings{margin:0 0 10px;padding:0 0 10px;border-bottom:1px solid #d9d1bc}
.audio-settings h3{margin:0 0 6px;color:#7d8069;font-size:10px;font-weight:500;letter-spacing:1px}
.audio-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px;align-items:center;margin-top:5px}
#game-menu .audio-row button{gap:5px;font-size:11px;padding:7px;min-height:40px}
#game-menu .audio-row button small{margin-left:auto;font-size:10px;color:#55754c}
#game-menu .audio-row button[aria-pressed=false]{color:#8b8775;background:#e6e1d580}
#game-menu .audio-row button[aria-pressed=false] small{color:#8b8775}
.audio-volume{display:flex;align-items:center;gap:6px;min-width:0}
.audio-volume input{min-width:0;width:100%;height:34px;margin:0;accent-color:#54724e;touch-action:pan-x}
.audio-volume output{flex:0 0 28px;color:#7a826b;font-size:9px;text-align:right;font-variant-numeric:tabular-nums}
#game-menu .menu-hint { padding: 8px 1px 0; margin: 6px 0 0; font-size: 10px; line-height: 1.8; color: #858770; border: 0; }

#dispatch-panel { position: absolute; z-index: 7; left: 0; top: 0; right: auto; bottom: auto; width: 300px; min-height: 0; max-width: calc(100vw - 16px); padding: 6px 7px 6px 10px; transform: none; color: var(--ink); background: #faf5e7f5; border: 1px solid #c2b38c; border-radius: 9px; box-shadow: 0 5px 20px #23392c29; backdrop-filter: blur(10px); }
#selection-content { display: grid; grid-template-columns: minmax(0,1fr) auto 30px; grid-template-rows: auto auto; gap: 0 8px; align-items: center; }
#dispatch-panel .selected-summary { grid-column: 1; grid-row: 1; display: block; border: 0; margin: 0; padding: 0; min-width: 0; }
#selected-name { font: 600 14px var(--serif); line-height: 17px; letter-spacing: 1px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#selected-type { display: block; color: #8c7c55; font-size: 9px; line-height: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#selected-hq { display: none; }
#friendly-controls { display: contents; }
#dispatch-panel .dispatch-label { grid-column: 2; grid-row: 1; display: flex; align-items: baseline; justify-content: flex-end; gap: 9px; color: #67745c; font-size: 10px; white-space: nowrap; }
#dispatch-panel .dispatch-label label { color: #586e4e; }
#dispatch-panel .dispatch-label strong { color: #344d36; font-size: 20px; font-weight: 600; line-height: 24px; }
#dispatch-panel .dispatch-label small { font-size: 9px; color: #8a8b73; margin-left: 2px; }
#dispatch-panel .remaining-label { font-size: 10px; color: #7a8067; }
#dispatch-panel .remaining-label b { font-size: 11px; color: #526849; }
#dispatch-panel .remaining-label.empty, #dispatch-panel .remaining-label.empty b { color: #ad6042; }
#dispatch-panel .slider-row { grid-column: 1/3; grid-row: 2; display: flex; align-items: center; gap: 8px; height: 36px; margin: 0; padding: 0; }
#dispatch-panel .step-button { display: grid; place-items: center; width: 30px; min-width: 30px; height: 36px; padding: 0; border: 0; border-radius: 5px; background: #eae8d7; color: #54694e; font-size: 19px; }
#dispatch-panel .step-button:hover { background: #dce1cb; }
#dispatch-panel .auto-route-button { flex: 0 0 68px; min-width: 68px; height: 36px; padding: 0 3px; margin: 0; border: 1px solid #b8c2a3; border-radius: 5px; color: #506b45; background: #e5e9d4; font-size: 10px; line-height: 1.2; white-space: nowrap; }
#dispatch-panel .auto-route-button:hover { background: #d6dfc1; }
#dispatch-panel .auto-route-button[data-state=active] { color: #3e6039; background: #dce7c9; border-color: #8ea77e; }
#dispatch-panel .auto-route-button[data-state=paused] { color: #985e3a; background: #f0e3cb; border-color: #c8a97b; }
#dispatch-panel .auto-route-button[data-state=selecting] { color: #fff8e8; background: #546d48; border-color: #546d48; }
#battle-map.choosing-route { cursor: crosshair; }
.auto-route-prompt { position: absolute; z-index: 10; left: 50%; bottom: calc(var(--dock-bottom) + 5px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 16px); padding: 4px 5px 4px 12px; border: 1px solid #9eae86; border-radius: 8px; color: #415c39; background: #f7f4e6f5; box-shadow: 0 3px 14px #273f3520; font-size: 11px; }
#auto-route-prompt-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cancel-auto-route-pick { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 5px; color: #60734e; background: #e8e9d8; }
#cancel-auto-route-pick svg { width: 14px; height: 14px; }
#troop-slider { flex: 1; min-width: 0; width: 100%; height: 36px; margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0; accent-color: #54724e; touch-action: none; }
#troop-slider::-webkit-slider-runnable-track { height: 5px; border: 0; border-radius: 5px; background: linear-gradient(to right,#64845b var(--fill),#d4d4bb var(--fill)); }
#troop-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 23px; height: 23px; margin-top: -9px; background: #54724e; border: 3px solid #f8f1dc; border-radius: 50%; box-shadow: 0 0 0 1px #6e8660; }
#troop-slider::-moz-range-track { height: 5px; background: #d4d4bb; border: 0; border-radius: 5px; }
#troop-slider::-moz-range-progress { height: 5px; background: #64845b; }
#troop-slider::-moz-range-thumb { width: 18px; height: 18px; background: #54724e; border: 3px solid #f8f1dc; border-radius: 50%; }
#clear-selection { grid-column: 3; grid-row: 1/3; position: static; align-self: stretch; display: grid; place-items: center; width: 30px; height: auto; min-height: 38px; padding: 0; margin: 0; background: none; color: #7a806a; border: 0; border-radius: 5px; }
#clear-selection:hover { background: #e6e4d4; }
#clear-selection svg { width: 14px; height: 14px; }
#enemy-controls { grid-column: 2; grid-row: 1/3; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 32px 0 0; min-height: 42px; position: relative; font-size: 10px; color: #68735c; }
#enemy-controls>span { display: inline; }
#enemy-controls strong { color: #344d36; }
#enemy-controls #selected-owner { display: inline; padding: 0; border: 0; font-size: 9px; color: #8a8069; }
#enemy-controls .dock-button { position: absolute; right: 0; top: 0; bottom: 0; min-width: 26px; padding: 0; border: 0; color: #5b7251; background: none; }
#enemy-controls .dock-button svg { width: 15px; height: 15px; }

#intel-drawer { left: calc(var(--safe-left) + 52px); right: auto; top: var(--safe-top); bottom: var(--dock-bottom); width: 340px; max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 52px); z-index: 16; border-radius: 9px; }
#intel-drawer .drawer-heading { position: static; display: flex; justify-content: space-between; padding: 15px 18px 5px; }
#intel-drawer .drawer-heading .eyebrow { display: block; }
#intel-drawer .drawer-tabs { padding: 0 18px; gap: 24px; }
#intel-drawer .drawer-body { padding: 16px 18px; }
#intel-drawer #set-hq { margin: 0 0 18px; background: #e2e6d1; color: #536e47; border-color: #b9c4a4; }
#drawer-routes .ratios { display: flex; gap: 6px; margin: 10px 0 15px; }
#drawer-routes .ratios button { flex: 1; height: 36px; color: #5e7150; background: #e9e8d8; border: 1px solid #d0cfb6; }
#drawer-routes .ratios button.active { background: #536d49; color: #fff6df; }
.auto-routes-section { margin-top: 22px; padding-top: 16px; border-top: 1px solid #d9d1bc; }
.auto-route-list { padding: 0; margin: 7px 0 0; list-style: none; }
.auto-route-entry { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 9px 0; border-bottom: 1px solid #ded9c5; }
.auto-route-entry>div { min-width: 0; }
.auto-route-entry strong { display: block; font-size: 11px; font-weight: 500; color: #4c6543; overflow-wrap: anywhere; }
.auto-route-entry span { display: block; margin-top: 4px; color: #81906d; font-size: 10px; line-height: 1.5; }
.auto-route-entry.paused span { color: #a57345; }
.auto-route-entry button { flex: 0 0 44px; min-height: 34px; padding: 4px 6px; border: 1px solid #cec8ae; border-radius: 5px; color: #71765c; background: #eeecdd; font-size: 11px; }
.siege-info { margin: 0 0 18px; padding: 12px; border: 1px solid #d5bca0; border-radius: 6px; background: #f2e7d780; color: #855c3e; }
.siege-info p { margin: 9px 0; font-size: 11px; line-height: 1.7; }
.siege-info ol { margin: 8px 0; padding: 0; list-style: none; }
.siege-info li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 11px; }
.siege-info .siege-note { margin-bottom: 0; color: #9b886c; font-size: 10px; }
#speed-menu { z-index: 19; max-height: calc(var(--app-height,100dvh) - var(--safe-top) - var(--dock-bottom)); }
#map-notice { top: auto; bottom: calc(var(--dock-bottom) + 3px); max-width: min(320px,calc(100vw - 30px)); padding: 7px 12px; font-size: 10px; pointer-events: none; }
.toast-stack { bottom: calc(var(--dock-bottom) + 10px); pointer-events: none; }
.restore-ui { top: var(--safe-top); right: var(--safe-right); bottom: auto; z-index: 18; }

@media(max-width:600px) and (orientation:portrait) {
  #game-menu, #intel-drawer { left: var(--safe-left); top: calc(var(--safe-top) + 52px); max-width: calc(100vw - var(--safe-left) - var(--safe-right)); }
  #game-menu { max-height: calc(var(--app-height,100dvh) - var(--safe-top) - var(--dock-bottom) - 52px); }
  #dispatch-panel { width: 288px; }
}
