.game-page { height: 100vh; height: 100dvh; min-width: 320px; display: grid; grid-template-rows: auto minmax(100px, 1fr) auto auto; overflow: hidden; }
.command-bar { display: grid; grid-template-columns: auto minmax(248px, 1fr) minmax(250px, 286px) auto auto auto auto auto; grid-template-areas: "brand resources groups empire clock sound help settings"; align-items: center; gap: 6px 12px; min-height: 78px; padding: 10px 16px; background: linear-gradient(#222d22, #19221b); border-bottom: 1px solid #746344; z-index: 4; }
.command-bar .brand { grid-area: brand; gap: 8px; }
.command-bar .brand > .icon { width: 30px; height: 36px; }
.command-bar .brand-wordmark { font-size: 8px; }
.command-bar .brand-wordmark strong { font-size: 18px; }
.resource-strip { grid-area: resources; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); min-width: 0; }
.resource { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 4px 6px; border-right: 1px solid var(--line); }
.resource .icon { color: var(--gold); width: 18px; height: 18px; }
.resource.wood .icon { color: #a3b18a; }
.resource.stone .icon { color: #a6b5aa; }
.resource div { display: flex; flex-direction: column; min-width: 0; }
.resource-label { color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.resource-value { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-variant-numeric: tabular-nums; font-weight: 550; line-height: 1.3; }
.empire-overview { grid-area: empire; display: flex; align-items: center; gap: 8px; min-width: 0; }
.age-numeral { width: 35px; height: 38px; display: grid; place-items: center; color: var(--gold); border: 1px solid #6d6347; font: 22px Georgia, serif; }
.empire-overview > div { display: flex; flex-direction: column; white-space: nowrap; }
#age { font: 15px Georgia, serif; }
#pop { color: var(--muted); font-size: 10px; margin-top: 3px; }
#pop.at-cap { color: #f0b296; }
.match-clock { grid-area: clock; display: grid; grid-template-columns: 15px auto; align-items: center; column-gap: 6px; min-width: 0; }
.match-clock .icon { width: 14px; height: 14px; color: var(--muted); }
#clock { font-size: 13px; font-variant-numeric: tabular-nums; }
#connection { grid-column: 1 / -1; margin-top: 3px; color: var(--gold); font-size: 9px; letter-spacing: .04em; }
#connection[data-state="live"] { color: var(--green); }
#connection[data-state="error"] { color: var(--red); }
.sound-settings { grid-area: sound; position: relative; }
.command-bar .sound-settings > summary, #help-toggle { width: 32px; height: 32px; padding: 6px; }
#help-toggle { grid-area: help; }
#settings-toggle { grid-area: settings; width: 32px; height: 32px; padding: 6px; }
.sound-settings > summary { list-style: none; cursor: pointer; }
.sound-settings > summary::-webkit-details-marker { display: none; }
.sound-settings[open] > summary { color: var(--gold); border-color: var(--gold-dark); }
.sound-panel { position: absolute; top: calc(100% + 10px); right: 0; width: 232px; max-width: calc(100vw - 24px); padding: 16px; border: 1px solid #756342; background: #1b261dfa; box-shadow: 0 10px 30px #0006; }
.sound-panel .eyebrow { margin-bottom: 12px; }
.sound-panel > button { width: 100%; margin-bottom: 16px; min-height: 36px; }
.sound-panel label { display: flex; justify-content: space-between; gap: 12px; margin: 0; font-size: 11px; }
.sound-panel output { color: var(--gold); font-variant-numeric: tabular-nums; }
.sound-panel input[type="range"] { min-height: 32px; padding: 6px 0; border: 0; background: transparent; accent-color: var(--gold); cursor: pointer; }
#sound-status { margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.battlefield { min-height: 0; min-width: 0; position: relative; overflow: hidden; background: #0e1916; }
#game { width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; }
#game[data-order="true"] { cursor: crosshair; }
#game[data-task="unavailable"] { cursor: not-allowed; }
#game:focus-visible { outline-offset: -3px; }
.task-cursor { position: absolute; top: 0; left: 0; z-index: 1; display: flex; align-items: center; gap: 7px; max-width: min(224px, calc(100% - 16px)); padding: 5px 8px; border: 1px solid var(--task-color); border-radius: 3px; background: #14231df2; color: #eee5c9; box-shadow: 0 2px 8px #0005; pointer-events: none; font-size: 11px; line-height: 1.35; }
.task-cursor .icon { width: 22px; height: 22px; color: var(--task-color); }
.battlefield-caption { position: absolute; top: 20px; left: 24px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; text-shadow: 0 1px 4px #000; }
.battlefield-caption .eyebrow { color: #d2c89f; font-size: 9px; }
#match-mode { color: #b9c1a9; font-size: 10px; }
.map-compass { position: absolute; right: 24px; top: 20px; display: flex; flex-direction: column; align-items: center; color: #b6bba0; pointer-events: none; opacity: .65; }
.map-compass span { font: 10px Georgia, serif; }
.map-compass .icon { width: 25px; height: 25px; }
.order-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: calc(100% - 28px); padding: 10px 16px; border: 1px solid #857044; background: #192219ed; color: #e2c98e; font-size: 11px; text-align: center; pointer-events: none; }
.match-notice { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 40px)); padding: 26px; text-align: center; border: 1px solid #5b6247; background: #172119f5; box-shadow: 0 16px 50px #0005; }
.match-notice > .icon { width: 34px; height: 34px; margin-bottom: 12px; color: var(--gold); }
.match-notice h1 { margin: 0 0 10px; font: 26px Georgia, serif; }
.match-notice p { margin: 0; color: var(--muted); font-size: 12px; }
.match-notice .button { margin-top: 18px; }
.result-panel { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); padding: 20px 40px; border-top: 1px solid var(--gold-dark); border-bottom: 1px solid var(--gold-dark); background: #152019ed; text-align: center; box-shadow: 0 16px 40px #0004; }
.result-panel h1 { margin: 6px 0; font: 40px Georgia, serif; color: var(--gold); }
.result-panel p { margin: 0; font-size: 12px; color: var(--muted); }
.result-panel .button { margin-top: 14px; }
.command-dock { display: grid; grid-template-columns: 194px 260px minmax(0, 1fr); gap: 22px; padding: 14px 22px; border-top: 1px solid #756342; background: linear-gradient(130deg, #222c21, #172119 55%); min-height: 224px; z-index: 2; }
.panel-caption { min-height: 25px; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--gold); font-size: 9px; font-weight: 600; letter-spacing: .12em; }
.panel-caption .icon-button { width: 24px; height: 24px; padding: 4px; border: 0; }
.panel-caption .icon-button .icon { width: 16px; height: 16px; }
.minimap-panel { padding-right: 18px; border-right: 1px solid var(--line); }
#minimap { display: block; width: 164px; height: 164px; background: #0e1916; border: 1px solid #687052; image-rendering: pixelated; cursor: crosshair; touch-action: none; }
.selection-panel { min-width: 0; padding-right: 20px; border-right: 1px solid var(--line); }
.selection-summary { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; }
.selection-portrait { display: grid; place-items: center; width: 68px; height: 68px; flex: 0 0 auto; border: 1px solid #596044; background: radial-gradient(#45503966, #121c14); }
.selection-portrait .sprite-thumb { --sprite-size: 64px; }
.selection-portrait > .icon { color: #768568; width: 32px; height: 32px; }
.selection-summary h2 { margin: 0 0 4px; font: 20px/1.15 Georgia, serif; }
#sel { color: var(--muted); font-size: 10px; }
#selection-details { min-height: 35px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
#selection-details .health-track { display: block; height: 4px; margin: 6px 0; background: #343d2e; }
.health-fill { display: block; height: 100%; background: var(--green); }
.construction-fill { display: block; height: 100%; background: var(--gold); }
#select-keep { min-height: 30px; margin-top: 8px; padding: 4px 0; color: var(--gold); background: transparent; border: 0; font-size: 10px; }
#select-keep kbd { margin-left: 8px; }
.orders-panel { min-width: 0; }
#command-mode { color: var(--muted); font-weight: 400; font-size: 9px; letter-spacing: 0; }
.control-groups { grid-area: groups; position: relative; min-width: 0; display: grid; gap: 2px; }
.control-groups-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; min-width: 0; height: 14px; }
.control-groups-roster-toggle { display: flex; align-items: flex-end; flex: 0 0 auto; min-width: 44px; height: 24px; padding: 0 2px; border: 0; background: transparent; color: var(--gold); font-size: 9px; line-height: 14px; }
.control-groups-roster-toggle:hover, .control-groups-roster-toggle[aria-expanded="true"] { color: #f1d69c; }
.control-group-feedback { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 8px; line-height: 14px; text-align: right; }
.control-group-feedback[data-announced="true"] { color: #e1c68f; }
.control-group-slots { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 2px; min-width: 0; }
.control-group-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; height: 28px; padding: 2px; border: 1px solid #45513b; border-radius: 2px; background: linear-gradient(#2e3929, #202c20); font-variant-numeric: tabular-nums; }
.control-group-button:hover:not(:disabled) { border-color: #b09a63; background: #35422e; }
.control-group-button.inspected:not(.active) { border-color: #8a9472; }
.control-group-button.active { border-color: var(--gold); background: #49442b; box-shadow: inset 0 -2px var(--gold); }
.control-group-button.empty { border-style: dashed; background: #1b251c; }
.control-group-button:disabled { opacity: 1; color: #8e9981; cursor: not-allowed; }
.control-group-number { color: var(--muted); font-size: 10px; line-height: 11px; font-weight: 600; }
.control-group-count { color: var(--text); font-size: 9px; line-height: 10px; }
.control-group-count::before { content: "×"; margin-right: 1px; color: var(--muted); }
.control-group-button.active .control-group-number, .control-group-button.active .control-group-count { color: #f1d69c; }
.control-group-button.empty .control-group-count { color: #8e9981; }
.control-group-preview { display: none; }
.control-group-roster { position: absolute; top: 100%; right: 0; z-index: 8; display: grid; gap: 8px; width: min(320px, 100%); max-height: min(320px, 55dvh); padding: 10px; overflow-y: auto; border: 1px solid #756342; background: #1b261dfa; color: var(--muted); box-shadow: 0 8px 24px #0006; font-size: 10px; line-height: 1.4; scrollbar-width: thin; scrollbar-color: #687052 transparent; overscroll-behavior-y: contain; }
.control-group-roster-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.control-group-roster-title { color: var(--gold); font-weight: 600; }
.control-group-roster-close { flex: 0 0 auto; width: 24px; height: 24px; padding: 0; border: 1px solid #45513b; background: #253023; color: var(--gold); font-size: 18px; line-height: 1; }
.control-group-roster-close:hover { border-color: var(--gold); }
.control-group-roster-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 6px 8px; min-width: 0; margin: 0; padding: 2px; list-style: none; }
.control-group-roster-list:focus-visible { outline: 1px solid var(--gold); outline-offset: -1px; }
.control-group-roster-list li { display: flex; align-items: center; gap: 4px; min-width: 0; }
.control-group-roster-list li > span:not(.sprite-thumb) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.control-group-roster-list .sprite-thumb { --sprite-size: 24px; margin-right: -2px; }
.control-group-roster-list strong { color: var(--text); font-size: 10px; font-variant-numeric: tabular-nums; }
.control-group-roster-empty { margin: 0; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 6px; max-height: 171px; overflow-y: auto; padding: 2px; scrollbar-width: thin; scrollbar-color: #687052 transparent; }
.action-card { position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 72px; padding: 7px 9px; border: 1px solid #45513b; border-radius: 2px; background: linear-gradient(#2e3929, #253023); text-align: left; }
.action-card:hover:not(:disabled) { background: #35422e; border-color: #b09a63; }
.action-card.active { border-color: var(--gold); background: #49442b; }
.action-card:disabled { opacity: 1; color: #a4aa94; background: #20291f; border-color: #35402f; }
.action-card:disabled > .icon, .action-card:disabled .sprite-thumb { opacity: .45; }
.action-card > .icon { width: 24px; height: 24px; color: var(--gold); }
.action-card .sprite-thumb { --sprite-size: 38px; margin-left: -5px; margin-right: -3px; }
.action-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.action-label { font-size: 10px; line-height: 1.25; font-weight: 600; }
.action-detail { color: #b3b9a0; font-size: 9px; line-height: 1.3; }
.action-card:disabled .action-detail { color: #959e86; }
.action-card.danger { border-color: #5e4435; background: #30291f; }
.action-card.danger > .icon { color: var(--red); }
.battlefield-footer { display: flex; align-items: center; gap: 14px; height: 27px; padding: 0 22px; border-top: 1px solid var(--line); background: #121c16; color: #a3ad92; font-size: 9px; z-index: 3; }
.footer-hint { margin-left: auto; }
#hash { font-family: ui-monospace, monospace; }
#chronicle { position: relative; }
#chronicle summary { display: flex; align-items: center; gap: 5px; cursor: pointer; color: #d0ba83; }
#log-count { color: #a2ad91; }
#log { position: absolute; bottom: 25px; left: 0; width: min(440px, 80vw); max-height: 220px; overflow-y: auto; padding: 12px 14px; border: 1px solid #596044; background: #172119fa; color: #c4c9b4; font: 10px/1.7 ui-monospace, monospace; box-shadow: 0 -8px 30px #0004; }
#log > div { border-bottom: 1px solid #a0b08012; padding: 3px 0; overflow-wrap: anywhere; }
.game-dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 26px; border: 1px solid #8b7850; background: #1b261d; color: var(--text); box-shadow: 0 20px 80px #0008; }
.game-dialog::backdrop { background: #060d0abb; backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.dialog-header h2 { margin: 5px 0 0; font: 28px Georgia, serif; }
.game-dialog p { color: var(--muted); font-size: 12px; }
.hotkey-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; margin: 24px 0; }
.hotkey-list div { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #c2c9b1; font-size: 11px; }
.dialog-note { padding-top: 14px; border-top: 1px solid var(--line); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
@media (max-width: 1200px) {
  .command-bar .brand-wordmark { display: none; }
}
@media (max-width: 1100px) {
  .command-bar { grid-template-columns: auto minmax(0, 1fr) auto auto auto; grid-template-areas: "brand resources sound help settings" "empire groups groups clock clock"; gap: 6px 12px; min-height: 96px; padding: 8px 14px; }
  .resource { padding: 0 6px; }
  .control-groups { width: min(100%, 340px); justify-self: center; }
  .command-dock { grid-template-columns: 162px 215px minmax(0, 1fr); gap: 14px; padding: 12px 14px; }
  .minimap-panel { padding-right: 12px; }
  #minimap { width: 144px; height: 144px; }
  .selection-panel { padding-right: 12px; }
  .selection-portrait { width: 54px; height: 60px; }
  .selection-portrait .sprite-thumb { --sprite-size: 52px; }
  .selection-summary h2 { font-size: 17px; }
  .action-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .action-card { min-height: 68px; padding: 5px 7px; }
}
@media (max-width: 780px) {
  .command-bar { gap: 6px 10px; padding: 8px 12px; }
  .command-bar .brand-wordmark { display: none; }
  .command-bar .brand > .icon { width: 26px; height: 29px; }
  .resource { padding: 0 6px; gap: 4px; }
  .resource-value { font-size: 17px; }
  .resource .icon { width: 18px; height: 18px; }
  .empire-overview { gap: 8px; }
  .age-numeral { width: 25px; height: 26px; font-size: 17px; }
  .empire-overview > div { gap: 1px; }
  #age { font-size: 12px; line-height: 1.1; }
  #pop { margin: 0; line-height: 1.15; }
  .match-clock { grid-template-columns: 14px auto; gap: 2px 3px; justify-content: end; }
  #clock { font-size: 11px; line-height: 1.2; }
  #connection { margin: 0; line-height: 1.2; }
  #help-toggle { width: 28px; height: 28px; padding: 5px; }
  .command-bar .sound-settings > summary { width: 28px; height: 28px; padding: 5px; }
  .command-dock { grid-template-columns: 133px minmax(0, 1fr); min-height: 0; gap: 10px 14px; padding: 10px 12px; }
  #minimap { width: 116px; height: 116px; }
  .minimap-panel { grid-row: 1; }
  .selection-panel { grid-row: 1; border: 0; padding: 0; }
  .selection-summary { margin: 6px 0; }
  .selection-portrait { width: 48px; height: 48px; }
  .selection-portrait .sprite-thumb { --sprite-size: 46px; }
  #selection-details { min-height: 20px; }
  #select-keep { margin-top: 0; }
  .orders-panel { grid-column: 1 / -1; }
  .orders-panel .panel-caption { min-height: 16px; margin-bottom: 4px; }
  .action-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); max-height: 112px; }
  .action-card { min-height: 52px; }
  .action-card > .icon { width: 19px; height: 19px; }
  .action-card .sprite-thumb { --sprite-size: 30px; }
  .battlefield-caption { top: 12px; left: 14px; }
  .map-compass { top: 12px; right: 14px; }
  .battlefield-footer { padding: 0 12px; gap: 12px; }
  .footer-hint { display: none; }
  .result-panel { padding: 16px 24px; }
  .result-panel h1 { font-size: 30px; }
}
@media (max-width: 640px) {
  .command-bar { grid-template-columns: auto minmax(0, 1fr) 28px 28px 28px; grid-template-areas: "brand resources sound help settings" "empire empire clock clock clock" "groups groups groups groups groups"; min-height: 0; }
  .control-groups { width: 100%; justify-self: stretch; }
}
@media (max-width: 420px) {
  .command-bar { gap: 6px; padding: 7px 8px; }
  .resource { display: grid; grid-template-columns: 12px minmax(0, 1fr); grid-template-rows: 11px auto; gap: 1px 3px; padding: 0 3px; }
  .resource div { display: contents; }
  .resource .icon { grid-column: 1; grid-row: 1; width: 12px; height: 12px; }
  .resource-label { grid-column: 2; grid-row: 1; font-size: 8px; letter-spacing: .04em; }
  .resource-value { grid-column: 1 / -1; grid-row: 2; font-size: 15px; line-height: 1.25; }
  .hotkey-list { grid-template-columns: 1fr; }
  #connection { font-size: 8px; }
}
@media (max-height: 600px) and (min-width: 781px) {
  .command-bar { min-height: 58px; }
  .command-dock { min-height: 154px; padding-top: 7px; padding-bottom: 7px; grid-template-columns: 137px 230px minmax(0, 1fr); }
  #minimap { width: 112px; height: 112px; }
  .panel-caption { margin-bottom: 3px; min-height: 20px; }
  .selection-summary { margin: 3px 0; }
  .selection-portrait { width: 44px; height: 44px; }
  .selection-portrait .sprite-thumb { --sprite-size: 42px; }
  #selection-details { min-height: 22px; }
  #select-keep { margin-top: 0; }
  .action-grid { max-height: 115px; }
  .action-card { min-height: 52px; }
}
.formation-control { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.formation-control[hidden] { display: none; }
.formation-control select { width: auto; min-height: 26px; padding: 3px 20px 3px 6px; font-size: 11px; }
.selection-production { margin-top: 10px; font-size: 10px; color: var(--muted); }
.selection-production p { margin: 4px 0; }
.production-entry { display: grid; gap: 4px; margin: 6px 0; }
.production-entry progress { width: 100%; height: 5px; accent-color: #c4b271; }
.garrison-roster { display: flex; flex-wrap: wrap; gap: 4px; }
.garrison-roster > span { width: 28px; height: 28px; overflow: hidden; }
.garrison-roster .sprite-thumb { transform: scale(.44); transform-origin: top left; }
.game-page.editor-mode { display: block; height: auto; min-height: 100dvh; overflow: auto; }
.editor-mode > #hud, .editor-mode > #battlefield, .editor-mode > .command-dock, .editor-mode > .battlefield-footer { display: none; }
.map-editor-page { width: min(1280px, calc(100% - 32px)); margin: 24px auto; }
.map-editor-page > header { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
#match-chat { position: relative; }
#match-social { position: absolute; z-index: 8; bottom: 28px; left: 0; width: min(420px, calc(100vw - 24px)); max-height: min(560px, 75vh); overflow: auto; background: #18271f; border: 1px solid #82764b; }
#match-chat:not([open]) > #match-social { display: none; }
.zoom-control { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.zoom-control select { width: auto; min-height: 24px; padding: 2px 18px 2px 5px; font-size: 10px; }
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 20px; background: #182b23; border-top: 1px solid #b5c38a33; }
.game-page.replay-mode { grid-template-rows: auto minmax(100px, 1fr) auto auto auto; }
.replay-controls[hidden] { display: none; }
.replay-controls label { display: flex; align-items: center; gap: 8px; color: #c6cfb7; font-size: 12px; }
.replay-controls > input { flex: 1 1 200px; accent-color: #c5b57a; }
.replay-controls select, .replay-controls input[type="url"] { min-width: 0; max-width: 210px; padding: 6px; border: 1px solid #b5c38a44; border-radius: 4px; background: #12251e; color: #eee8d3; }
