:root {
  color-scheme: light dark;
  --paper: #efe5c6;
  --paper-strong: #f7efd8;
  --paper-muted: #d8c79d;
  --ink: #1d2926;
  --ink-muted: #58615b;
  --line: #a79468;
  --teal: #2d6d63;
  --teal-dark: #194a44;
  --red: #9f3e32;
  --red-dark: #6f2824;
  --gold: #ad7b24;
  --shadow: 0 18px 50px rgb(53 39 14 / 18%);
  --radius: 3px;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: #d4c398; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgb(255 255 255 / 35%), transparent 34rem),
    repeating-linear-gradient(4deg, rgb(68 48 17 / 2%) 0 1px, transparent 1px 6px),
    var(--paper);
}

button, input { font: inherit; }

button { color: inherit; }

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid #177d92;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: white;
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.game-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0;
}

.masthead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: rgb(247 239 216 / 70%);
}

.brand-block h1, .paper-dialog h2, .panel-title-row h2, .battle-heading h2 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-weight: 650;
  letter-spacing: .04em;
}

.brand-block h1 { font-size: 1.75rem; line-height: .95; white-space: nowrap; }

.eyebrow, .panel-kicker {
  margin: 0 0 4px;
  color: var(--red);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.match-tools { display: flex; align-items: center; gap: 6px; }

.clock-block { min-width: 92px; text-align: right; }
.clock-block span { display: block; color: var(--ink-muted); font-size: .72rem; }
.clock-block strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.25rem; }

.text-button {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 22%);
  cursor: pointer;
}

kbd {
  display: inline-grid;
  min-width: 20px;
  min-height: 20px;
  place-items: center;
  padding: 2px 5px;
  border: 1px solid currentColor;
  border-radius: 2px;
  font: 700 .65rem ui-monospace, monospace;
  opacity: .65;
}

.status-ribbon {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 0 10px;
  border-inline: 1px solid var(--line);
}

.faction-status { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 7px; min-width: 0; }
.faction-status.danger { background: rgb(159 62 50 / 9%); box-shadow: inset 3px 0 var(--red); }
.enemy-status { grid-template-columns: 1fr auto auto; text-align: right; }
.enemy-status .faction-mark { order: 3; }
.enemy-status .health-track { order: -1; }
.faction-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-family: Georgia, serif;
}
.enemy-status .faction-mark { background: var(--red); }
.faction-status small, .economy-status small { display: block; color: var(--ink-muted); font-size: .7rem; }
.health-track { min-width: 54px; height: 7px; overflow: hidden; border: 1px solid rgb(47 42 27 / 28%); background: rgb(58 40 22 / 10%); }
.health-track i { display: block; width: 100%; height: 100%; background: var(--teal); transition: width .18s linear; }
.health-track i.critical { background: var(--red); }
.enemy-status .health-track i { margin-left: auto; background: var(--red); }
.economy-status { display: flex; gap: 15px; padding: 0 12px; border-inline: 1px solid var(--line); text-align: center; }
.economy-status strong { font-variant-numeric: tabular-nums; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 10px; align-items: stretch; margin-top: 8px; }
.battle-panel, .command-center { border: 1px solid var(--line); background: rgb(247 239 216 / 62%); box-shadow: var(--shadow); }
.battle-panel { display: flex; min-height: 0; flex-direction: column; padding: 8px; }
.battle-heading, .panel-title-row, .group-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.battle-heading { margin-bottom: 6px; }
.battle-heading h2, .panel-title-row h2 { font-size: 1.2rem; }
.order-readout { padding: 5px 8px; border-left: 3px solid var(--teal); color: var(--teal-dark); background: rgb(45 109 99 / 8%); font-size: .78rem; font-weight: 750; }
.order-readout.danger { color: var(--red-dark); border-left-color: var(--red); background: rgb(159 62 50 / 10%); }

.canvas-frame {
  display: flex;
  min-height: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#battlefield {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 960 / 520;
  border: 1px solid #645d43;
  background: #708a72;
  touch-action: manipulation;
}

.battle-footer { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(390px, 1.2fr); gap: 6px; margin-top: 6px; }
.battle-message {
  min-height: 44px;
  padding: 7px 10px;
  border-left: 3px solid var(--gold);
  background: rgb(173 123 36 / 9%);
  color: var(--ink-muted);
}
.realm-ledger { display: grid; min-width: 0; gap: 3px; padding: 4px 6px; border-left: 3px solid var(--teal); background: rgb(45 109 99 / 8%); }
.ledger-row { display: flex; min-width: 0; align-items: center; gap: 6px; }
.ledger-row > strong { flex: 0 0 30px; color: var(--teal-dark); font: 750 .62rem Georgia, "Noto Serif SC", serif; }
.ledger-items { display: flex; min-width: 0; gap: 3px; overflow: hidden; }
.ledger-chip { flex: 0 0 auto; padding: 2px 5px; border: 1px solid rgb(45 109 99 / 34%); background: rgb(255 255 255 / 24%); color: var(--teal-dark); font-size: .6rem; font-weight: 750; white-space: nowrap; }
.ledger-chip.active { color: #684817; border-color: rgb(173 123 36 / 50%); background: rgb(173 123 36 / 12%); }
.ledger-empty { color: var(--ink-muted); font-size: .62rem; font-style: italic; }

.command-center { display: flex; min-height: 0; flex-direction: column; overflow: hidden; padding: 9px; }
.badge-stack { display: grid; gap: 4px; justify-items: end; }
.difficulty-badge { padding: 5px 9px; color: var(--red-dark); border: 1px solid var(--red); font-size: .75rem; font-weight: 800; }
.era-badge { color: var(--teal-dark); font-size: .68rem; font-weight: 850; letter-spacing: .06em; }
.command-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 8px; }
.command-tabs button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}
.command-tabs button[aria-selected="true"] { color: white; border-color: var(--teal-dark); background: var(--teal); }
.tab-count {
  display: inline-grid;
  min-width: 22px;
  min-height: 18px;
  place-items: center;
  margin-left: 2px;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .62rem;
  line-height: 1;
}
.tab-count:empty { display: none; }
.command-page { min-height: 0; }
.control-group { padding: 5px 0; border-top: 1px solid var(--line); }
.command-page .control-group:first-child { margin-top: 6px; }
.group-heading { margin-bottom: 4px; }
.group-heading h3 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; }
.group-heading span { color: var(--ink-muted); font-size: .68rem; text-align: right; }
.control-grid { display: grid; gap: 5px; }
.control-grid.two-column { grid-template-columns: 1fr 1fr; }
.control-grid.multi-column { grid-template-columns: 1fr 1fr; }

.action-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  background: rgb(255 255 255 / 24%);
  cursor: pointer;
}

.action-card:hover:not(:disabled) { border-color: var(--teal); background: rgb(45 109 99 / 8%); }
.action-card:disabled { cursor: not-allowed; opacity: .68; }
.action-card[data-state="locked"], .research-button[data-state="locked"] { border-style: dashed; }
.action-card[data-state="built"] { opacity: 1; color: var(--teal-dark); border-color: var(--teal); background: rgb(45 109 99 / 10%); box-shadow: inset 3px 0 var(--teal); }
.action-card[data-state="training"] {
  border-color: var(--teal);
  background: linear-gradient(90deg, rgb(45 109 99 / 18%) var(--progress), rgb(255 255 255 / 24%) 0);
}
.action-card[data-state="building"], .research-button[data-state="building"], .age-button[data-state="building"] {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgb(173 123 36 / 16%) var(--progress), rgb(255 255 255 / 22%) 0);
}
.action-card span > strong, .action-card span > small { display: block; }
.action-card small { margin-top: 3px; color: var(--ink-muted); font-size: .68rem; line-height: 1.25; }
.action-card.compact { grid-template-columns: 30px 1fr; min-width: 0; }
.action-card.compact kbd, .action-card.slim kbd { display: none; }
.action-card.slim { grid-template-columns: 30px 1fr; min-width: 0; min-height: 42px; gap: 7px; padding: 4px 6px; }
.action-card.slim .card-icon { width: 28px; height: 28px; }
.action-card.slim small { margin-top: 1px; }
.unit-grid .action-card { min-height: 55px; padding: 6px; }
.wide-card { grid-column: 1 / -1; }
.card-icon { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--ink); border-radius: 50%; font-family: Georgia, serif; }
.action-card[data-structure] .card-icon {
  border: 0;
  border-radius: 0;
  background: center / contain no-repeat var(--building-icon);
  filter: drop-shadow(0 1px 1px rgb(29 41 38 / 28%));
  font-size: 0;
}
.action-card[data-structure="barracks"] { --building-icon: url("./assets/buildings/generated/barracks.png"); }
.action-card[data-structure="windmill"] { --building-icon: url("./assets/buildings/generated/windmill.png"); }
.action-card[data-structure="blacksmith"] { --building-icon: url("./assets/buildings/generated/blacksmith.png"); }
.action-card[data-structure="chancel"] { --building-icon: url("./assets/buildings/generated/chancel.png"); }
.action-card[data-structure="workshop"] { --building-icon: url("./assets/buildings/generated/workshop.png"); }
.action-card[data-structure="watchtower"] { --building-icon: url("./assets/buildings/generated/watchtower.png"); }
.action-card[data-structure="naturalPower"] { --building-icon: url("./assets/buildings/generated/natural-power.png"); }

.unit-glyph { position: relative; display: block; width: 23px; height: 34px; margin: auto; }
.unit-glyph::before { content: ""; position: absolute; top: 2px; left: 7px; width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; }
.unit-glyph::after { content: ""; position: absolute; top: 14px; left: 9px; width: 2px; height: 18px; background: currentColor; box-shadow: -5px 8px 0 -1px currentColor, 5px 8px 0 -1px currentColor; }
.unit-glyph.rifle { color: var(--red-dark); }
.unit-glyph.rifle::after { transform: rotate(-18deg); box-shadow: 6px 0 0 -1px currentColor; }
.unit-glyph.cannon::before { top: 20px; left: 1px; width: 8px; height: 8px; border-width: 2px; box-shadow: 13px 0 0 -1px var(--paper-strong), 13px 0 0 1px currentColor; }
.unit-glyph.cannon::after { top: 9px; left: 3px; width: 25px; height: 5px; transform: rotate(-9deg); box-shadow: none; }
.unit-glyph.hero { color: var(--gold); }
.unit-glyph.hero::before { border-radius: 2px 2px 50% 50%; }
.unit-glyph.cavalry::after { width: 17px; height: 10px; transform: translateX(-5px); box-shadow: -5px 8px 0 -3px currentColor, 8px 8px 0 -3px currentColor; }
.unit-glyph.mage { color: #6f4c8d; }
.unit-glyph.mage::after { left: 6px; width: 3px; height: 20px; box-shadow: 10px -8px 0 -1px currentColor; }
.unit-glyph.colossus { transform: scale(1.15); color: var(--red-dark); }

.age-button, .repair-button, .research-button {
  width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 22%);
  text-align: left;
  cursor: pointer;
}
.age-button { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-left: 3px solid var(--gold); }
.repair-button { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; border-left: 3px solid var(--teal); }
.repair-button.selected { color: white; border-color: var(--teal-dark); background: var(--teal); }
.age-button strong, .age-button small, .repair-button strong, .repair-button small, .research-button strong, .research-button small { display: block; }
.age-button small, .repair-button small, .research-button small { color: var(--ink-muted); font-size: .65rem; }
.repair-button.selected small { color: rgb(255 255 255 / 78%); }
.research-button:disabled, .age-button:disabled, .repair-button:disabled { cursor: not-allowed; opacity: .68; }
.research-button[data-state="complete"] { color: var(--teal-dark); border-color: var(--teal); background: rgb(45 109 99 / 10%); box-shadow: inset 3px 0 var(--teal); opacity: 1; }
.command-group { margin-top: auto; padding-bottom: 0; background: rgb(247 239 216 / 78%); }

.order-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.order-button {
  min-height: 50px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 22%);
  cursor: pointer;
}
.order-button span, .order-button small { display: block; }
.order-button span { font-weight: 850; }
.order-button small { margin: 2px 0 4px; color: var(--ink-muted); }
.order-button.selected.attack { color: white; border-color: var(--red-dark); background: var(--red); }
.order-button.selected.retreat { color: white; border-color: var(--teal-dark); background: var(--teal); }
.order-button.selected small { color: rgb(255 255 255 / 78%); }

.paper-dialog {
  width: min(580px, calc(100% - 28px));
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-strong);
  box-shadow: 0 28px 100px rgb(0 0 0 / 42%);
}
.paper-dialog::backdrop { background: rgb(18 25 22 / 70%); backdrop-filter: blur(3px); }
.paper-dialog form, .paper-dialog > div { padding: clamp(22px, 5vw, 40px); }
.paper-dialog h2 { font-size: clamp(1.8rem, 6vw, 3rem); line-height: 1.06; }
.paper-dialog p { line-height: 1.65; }
.paper-dialog fieldset { display: grid; gap: 9px; margin: 22px 0; padding: 0; border: 0; }
.paper-dialog legend { margin-bottom: 10px; font-weight: 800; }
.paper-dialog label {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  cursor: pointer;
}
.paper-dialog label:has(input:checked) { border-color: var(--red); background: rgb(159 62 50 / 8%); }
.paper-dialog label strong, .paper-dialog label small { display: block; }
.paper-dialog label small { margin-top: 3px; color: var(--ink-muted); }
.paper-dialog ol { padding-left: 1.4rem; line-height: 1.65; }
.paper-dialog li + li { margin-top: 9px; }
.keyboard-help { color: var(--ink-muted); font-size: .8rem; }
.seal-button {
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  color: #fff8e6;
  border: 1px solid var(--red-dark);
  border-radius: var(--radius);
  background: var(--red);
  font-weight: 850;
  letter-spacing: .08em;
  cursor: pointer;
}
.seal-button:hover { background: var(--red-dark); }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0; }
.result-stats div { padding: 12px 8px; border: 1px solid var(--line); text-align: center; }
.result-stats dt { color: var(--ink-muted); font-size: .72rem; }
.result-stats dd { margin: 5px 0 0; font-weight: 850; }

@media (min-width: 860px) and (min-height: 680px) {
  html, body { height: 100%; overflow: hidden; }
  .game-shell { display: flex; height: 100svh; flex-direction: column; padding: 8px 0; }
  .masthead { flex: 0 0 auto; }
  .game-layout { min-height: 0; flex: 1; }
}

@media (max-width: 859px), (max-height: 679px) {
  .game-layout { grid-template-columns: 1fr; }
  .command-center { display: block; overflow: visible; }
  .canvas-frame { min-height: auto; }
  #battlefield { width: 100%; height: auto; }
}

@media (max-width: 680px) {
  .game-shell { width: min(100% - 18px, 1380px); padding-top: 14px; }
  .masthead { grid-template-columns: 1fr auto; align-items: center; }
  .match-tools { flex-wrap: wrap; justify-content: flex-end; }
  .clock-block { width: 100%; }
  .status-ribbon { grid-column: 1 / -1; grid-row: 2; grid-template-columns: 1fr 1fr; gap: 10px; padding: 9px 0 0; border: 0; border-top: 1px solid var(--line); }
  .economy-status { grid-column: 1 / -1; grid-row: 2; justify-content: space-around; padding-top: 10px; border-top: 1px solid var(--line); border-inline: 0; }
  .faction-status { grid-template-columns: auto 1fr; }
  .faction-status .health-track { grid-column: 1 / -1; width: 100%; }
  .enemy-status { grid-template-columns: 1fr auto; }
  .enemy-status .faction-mark { order: 2; }
  .enemy-status .health-track { order: 3; }
  .battle-panel { padding: 8px; }
  .battle-footer { grid-template-columns: 1fr; }
  .ledger-items { flex-wrap: wrap; overflow: visible; }
  .battle-heading { align-items: flex-start; }
  .order-readout { max-width: 145px; font-size: .72rem; }
  .command-center { display: block; padding: 12px; }
  .control-grid.two-column { grid-template-columns: 1fr 1fr; }
  .result-stats { grid-template-columns: 1fr 1fr; }
}

/* A fixed parchment palette keeps unit and faction colors consistent. */
:root { color-scheme: light; --paper: #e8dfc6; --paper-strong: #f7f0dd; --line: #b6aa88; --ink-muted: #626557; --shadow: 0 6px 20px #16251f18; }
html { background: #20362e; }
body { background: #20362e; }
.game-shell { width: calc(100% - 24px); max-width: 1800px; }
.masthead { background: #162d26; color: #f2ecd9; border-color: #486052; border-bottom: 2px solid #b19859; padding: 10px 14px; gap: 20px; }
.brand-block h1 { font-size: 25px; letter-spacing: .12em; }
.brand-block .eyebrow { color: #b5a574; font-size: 9px; letter-spacing: .17em; margin-bottom: 7px; }
.status-ribbon { border-color: #43594b; gap: 16px; }
.masthead small, .clock-block span { color: #b8c4b6; }
.masthead strong { font-variant-numeric: tabular-nums; }
.faction-status { grid-template-columns: 28px 1fr; column-gap: 8px; row-gap: 4px; }
.faction-status .health-track { grid-column: 2; width: 100%; height: 5px; border: 0; background: #ffffff20; }
.faction-status .faction-mark { grid-row: 1 / 3; width: 28px; height: 34px; border-radius: 2px 2px 12px 12px; }
.enemy-status { text-align: left; }
.enemy-status .faction-mark, .enemy-status .health-track { order: initial; }
.economy-status { gap: 22px; border-color: #43594b; padding-inline: 18px; }
.economy-status strong { font-size: 20px; white-space: nowrap; }
#goldText { color: #efd18b; font-size: 25px; }
.clock-block { min-width: 60px; }
.text-button { border-color: #526556; background: #ffffff06; font-size: 12px; }
.text-button:hover { background: #ffffff16; }
.game-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; margin-top: 12px; }
.battle-panel { padding: 10px; border-color: #6a7761; background: #e8dfc6; }
.battle-heading { align-items: center; margin-bottom: 9px; }
.battle-heading h2 { font-size: 20px; }
.battle-heading .panel-kicker { color: #707460; font-size: 9px; letter-spacing: .24em; }
.canvas-frame { background: #536e5d; border: 1px solid #465e4f; position: relative; }
#battlefield { border: 0; object-fit: contain; width: 100%; height: 100%; }
.match-paused .canvas-frame::after { content: "战局已暂停 · 按 P 继续"; position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 8px 16px; background: #152d27e8; color: #f5ecd4; border: 1px solid #bbac79; font-size: 12px; pointer-events: none; white-space: nowrap; }
.battle-footer { grid-template-columns: 1fr; gap: 5px; }
.battle-message { min-height: 32px; padding: 7px 10px; font-size: 12px; line-height: 1.4; }
.realm-ledger { background: transparent; border: 0; padding: 2px; }
.ledger-items { overflow-x: auto; scrollbar-width: thin; }
.ledger-chip, .ledger-empty { font-size: 10px; }
.command-center { padding: 0; background: #f0e8d1; border-color: #8c8e71; }
.panel-title-row { padding: 5px 12px; background: #2c4639; color: #faf0d8; align-items: center; }
.panel-title-row .panel-kicker { color: #b9c3a6; font-size: 9px; letter-spacing: .12em; }
.panel-title-row h2 { font-size: 21px; }
.era-badge { color: #efd18b; font-size: 12px; }
.difficulty-badge { color: #c6cebb; font-size: 10px; padding: 0; border: 0; font-weight: 500; }
.command-tabs { margin: 0; gap: 0; border-bottom: 1px solid #b6aa88; }
.command-tabs button { min-height: 38px; border: 0; border-bottom: 3px solid transparent; font-size: 14px; background: #e6dcc0; }
.command-tabs button[aria-selected="true"] { background: #f7f0dd; border-color: #2d6d63; color: #194a44; }
.tab-count { border: 0; background: #20362e0d; border-radius: 2px; font-size: 10px; }
.production-strip { display: flex; flex: 0 0 auto; gap: 5px; min-height: 30px; padding: 4px 12px; overflow-x: auto; background: #dfd4b4; scrollbar-width: thin; }
.production-empty { margin: auto 0; color: #666550; font-size: 11px; white-space: nowrap; }
.production-item { flex: 0 0 auto; padding: 3px 7px 5px; font-size: 11px; color: #554011; border-bottom: 2px solid #ab7d30; background: linear-gradient(90deg, #c9a45255 var(--progress), #f6ebd0 0); }
.command-page { padding: 2px 12px 8px; overflow-y: auto; scrollbar-width: thin; flex: 1; }
.control-group { border-color: #c9bd9f; padding: 3px 0; }
.group-heading { margin: 3px 0 6px; align-items: center; }
.group-heading h3 { font-size: 13px; }
.group-heading span { font-size: 10px; }
.control-grid { gap: 6px; }
.action-card.slim, .action-card.compact { grid-template-columns: 36px minmax(0,1fr); gap: 7px; padding: 4px 7px; min-height: 54px; border-radius: 2px; line-height: 1.2; }
.action-card.slim .card-icon { width: 36px; height: 40px; }
.action-card strong, .research-button strong { font-size: 13px; }
.action-card span > small, .research-button small { font-size: 10px; line-height: 1.2; }
.action-card .card-benefit, .card-benefit { display: block; margin-top: 2px; font-size: 10px; line-height: 1.2; color: #68705d; }
.action-card, .research-button { background: #fbf6e7; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.action-card:disabled, .research-button:disabled, .age-button:disabled, .repair-button:disabled { opacity: 1; }
.action-card[data-state="locked"], .research-button[data-state="locked"] { background: #e8e1cc; border-style: solid; border-color: #cfc5a9; color: #77796a; }
.action-card[data-state="locked"] .card-icon, .action-card[data-state="locked"] .unit-glyph { filter: grayscale(1); opacity: .6; }
.action-card[data-state="available"], .research-button[data-state="available"] { border-color: #839d7e; box-shadow: inset 2px 0 #47765b; }
.action-card:hover:not(:disabled), .research-button:hover:not(:disabled) { border-color: #286656; background: #fffdf4; box-shadow: inset 2px 0 #286656, 0 2px 5px #16352818; }
.action-card[data-state="building"], .action-card[data-state="training"], .research-button[data-state="building"] { box-shadow: inset 0 -3px #b28638; }
.action-card[data-state="built"] .card-benefit, .research-button[data-state="complete"] .card-benefit { color: #326b53; }
.research-button { min-height: 65px; padding: 7px 9px; }
.age-button, .repair-button { min-height: 43px; gap: 12px; }
.age-button strong, .repair-button strong { flex-shrink: 0; font-size: 12px; }
.age-button small, .repair-button small { text-align: right; font-size: 10px; }
.command-group { flex: 0 0 auto; margin-top: auto; padding: 6px 12px 8px; background: #e5dac0; border-top: 1px solid #b6aa88; }
.command-group .group-heading { margin: 0 0 6px; }
.order-button { display: grid; grid-template-columns: 1fr auto; text-align: left; padding: 6px 12px; min-height: 46px; }
.order-button span { font-size: 14px; }
.order-button small { grid-row: 2; font-size: 10px; margin: 2px 0 0; }
.order-button kbd { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.paper-dialog { border: 1px solid #b5a16e; border-top: 5px solid #2c4639; }
.paper-dialog h2 { font-size: 29px; line-height: 1.3; }
.paper-dialog fieldset { grid-template-columns: 1fr 1fr; gap: 8px; }
.paper-dialog label { padding: 10px; }
.paper-dialog label strong { font-size: 12px; }
.paper-dialog label small { font-size: 11px; }
.paper-dialog label:has(input:checked) { background: #e1ebdb; border-color: #397252; }
.seal-button { background: #2c604b; border-color: #224936; }
.seal-button:hover { background: #214b3a; }
@media (min-width: 860px) {
  html, body { height: 100%; overflow: hidden; }
  .game-shell { display: flex; height: 100dvh; flex-direction: column; padding: 10px 0; }
  .game-layout { min-height: 0; flex: 1; }
  .command-center { display: flex; overflow: hidden; }
}
@media (min-width: 860px) and (max-width: 1160px) {
  .game-layout { grid-template-columns: minmax(0,1fr) 328px; }
  .masthead { gap: 10px; }
  .brand-block h1 { font-size: 20px; }
  .economy-status { gap: 9px; padding-inline: 10px; }
  .economy-status strong { font-size: 15px; }
  .faction-status strong { font-size: 12px; }
  .status-ribbon { gap: 8px; }
}
@media (max-width: 859px) {
  html, body { height: 100%; overflow: hidden; }
  .game-shell { height: 100dvh; min-height: 560px; display: flex; flex-direction: column; width: calc(100% - 12px); padding: 6px 0; }
  .masthead { grid-template-columns: 1fr auto; gap: 8px; padding: 8px 10px; }
  .brand-block h1 { font-size: 20px; }
  .brand-block .eyebrow, .clock-block span, .match-tools kbd { display: none; }
  .match-tools { flex-wrap: nowrap; }
  .clock-block { width: auto; min-width: 45px; }
  .clock-block strong { font-size: 14px; }
  .text-button { min-height: 32px; padding: 5px 8px; }
  .status-ribbon { grid-column: 1/-1; grid-row: 2; display: flex; gap: 10px; padding: 5px 0 0; border: 0; }
  .faction-status { flex: 1; grid-template-columns: 1fr; }
  .faction-status .faction-mark { display: none; }
  .faction-status .health-track { grid-column: 1; order: initial; }
  .faction-status strong { font-size: 10px; }
  .faction-status small { font-size: 9px; }
  .economy-status { gap: 10px; padding: 0 8px; border: 0; }
  .economy-status strong, #goldText { font-size: 16px; }
  .economy-status small { font-size: 9px; }
  .game-layout { min-height: 0; flex: 1; grid-template-columns: 1fr; grid-template-rows: minmax(160px,.8fr) minmax(270px,1fr); gap: 6px; margin-top: 6px; }
  .battle-panel { padding: 5px; }
  .battle-heading { margin-bottom: 4px; }
  .battle-heading h2 { font-size: 14px; }
  .battle-heading .panel-kicker, .battle-footer { display: none; }
  .order-readout { max-width: none; font-size: 10px; padding: 3px 6px; }
  .canvas-frame { min-height: 0; }
  .command-center { display: flex; padding: 0; overflow: hidden; }
  .panel-title-row { padding: 5px 10px; }
  .panel-title-row h2 { font-size: 14px; }
  .panel-title-row .panel-kicker, .difficulty-badge { display: none; }
  .command-tabs button { min-height: 34px; }
  .production-strip { min-height: 27px; padding: 4px 10px; }
  .command-page { padding-inline: 8px; }
  .command-group { padding: 5px 8px; }
  .command-group .group-heading { display: none; }
  .order-button { min-height: 42px; padding: 5px 10px; }
  .action-card.slim, .action-card.compact, .research-button { min-height: 59px; }
  .paper-dialog form { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
