@import url("https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Serif+SC:wght@400;500;600;700;900&display=swap");

:root {
  color-scheme: dark;
  --ink: #14110d;
  --ink-soft: #211b15;
  --panel: rgba(30, 25, 19, 0.94);
  --panel-light: rgba(46, 37, 27, 0.84);
  --paper: #d5c6a2;
  --paper-dim: #96886b;
  --gold: #c6a15b;
  --gold-bright: #e5c77f;
  --red: #a33a2d;
  --red-bright: #d15a43;
  --jade: #628b76;
  --border: rgba(204, 174, 112, 0.18);
  --border-strong: rgba(204, 174, 112, 0.38);
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 52% -10%, rgba(137, 95, 45, 0.2), transparent 37%),
    linear-gradient(110deg, #12100d 0%, #1d1812 48%, #100e0b 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
.territory:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.paper-noise {
  position: fixed;
  inset: 0;
  z-index: 1000;
  opacity: 0.12;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.topbar {
  height: 74px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 30px;
  background: rgba(14, 12, 10, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--paper);
  text-decoration: none;
  width: fit-content;
}

.brand-seal {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #e4d4ad;
  font-family: "Ma Shan Zheng", cursive;
  font-size: 27px;
  background: #873126;
  border: 2px solid #bb7667;
  box-shadow: inset 0 0 0 3px #6e261e, 0 5px 15px rgba(0, 0, 0, 0.25);
  transform: rotate(-2deg);
}

.brand strong {
  display: block;
  font-size: 19px;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--paper-dim);
  font-size: 9px;
  letter-spacing: 0.48em;
}

.era-block {
  min-width: 250px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--gold-bright);
}

.turn-pips {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 7px;
}

.turn-pips i {
  width: 28px;
  height: 3px;
  background: var(--gold);
  transition: 0.25s ease;
  box-shadow: 0 0 8px rgba(220, 180, 96, 0.3);
}

.turn-pips i.used {
  background: #3d352a;
  box-shadow: none;
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 6px;
}

.text-button,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
  padding: 9px 11px;
  font-size: 12px;
  letter-spacing: 0.12em;
  transition: color 0.2s, background 0.2s;
}

.text-button:hover,
.icon-button:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.04);
}

.danger-text:hover {
  color: #d88170;
}

.icon-button {
  font-size: 20px;
  line-height: 1;
}

.resource-bar {
  min-height: 64px;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  padding: 0 30px;
  background: rgba(31, 26, 20, 0.72);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}

.resource {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  max-width: 250px;
  padding: 10px 20px;
  border-right: 1px solid var(--border);
}

.resource:first-child {
  border-left: 1px solid var(--border);
}

.resource-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  color: var(--gold-bright);
  font-size: 13px;
  border-radius: 50%;
}

.resource small,
.resource strong {
  display: block;
}

.resource small {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--paper-dim);
}

.resource strong {
  margin-top: 1px;
  color: #eee3ca;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.resource em {
  color: #7ca38c;
  font-style: normal;
  font-size: 9px;
  white-space: nowrap;
}

.resource em.negative {
  color: #bf7466;
}

.game-shell {
  display: grid;
  grid-template-columns: 216px minmax(570px, 1fr) 275px;
  min-height: calc(100vh - 138px);
  max-width: 1720px;
  margin: 0 auto;
}

.left-rail,
.right-rail {
  padding: 20px 14px;
  background: rgba(17, 14, 11, 0.55);
}

.left-rail {
  border-right: 1px solid var(--border);
}

.right-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-left: 1px solid var(--border);
}

.panel-ink {
  position: relative;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 42%),
    var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.13);
}

.panel-ink::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  right: 5px;
  bottom: 5px;
  border-right: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
  opacity: 0.35;
}

.ruler-card {
  padding: 15px 13px 13px;
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 11px;
}

.ruler-portrait {
  position: relative;
  width: 50px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(160deg, #625336, #2f281d);
  border: 1px solid var(--border-strong);
}

.ruler-portrait::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(225, 199, 127, 0.23);
}

.ruler-portrait span {
  font-family: "Ma Shan Zheng", cursive;
  font-size: 28px;
  color: #e6d3a8;
  z-index: 1;
}

.ruler-portrait i {
  position: absolute;
  width: 60px;
  height: 20px;
  border-radius: 50%;
  bottom: -12px;
  background: #7d3127;
}

.ruler-card small {
  color: var(--paper-dim);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.ruler-card h2 {
  margin: 3px 0 1px;
  color: #eee1c4;
  font-size: 17px;
  letter-spacing: 0.08em;
}

.ruler-card p {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
}

.mandate-meter {
  grid-column: 1 / -1;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.mandate-meter > span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 9px;
}

.mandate-meter b {
  color: var(--paper-dim);
  letter-spacing: 0.2em;
}

.mandate-meter em {
  color: #9bb09e;
  font-style: normal;
}

.mandate-meter > div,
.goal-track {
  height: 3px;
  background: #332d24;
  overflow: hidden;
}

.mandate-meter i,
.goal-track i {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, #7a2d25, var(--gold));
  transition: width 0.45s ease;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 18px 0;
}

.nav-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  text-align: left;
  padding: 11px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
  transition: 0.2s ease;
}

.nav-item > span {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 28px;
  height: 32px;
  font-family: "Ma Shan Zheng", cursive;
  color: #8d7d5e;
  font-size: 20px;
}

.nav-item b {
  font-size: 13px;
  letter-spacing: 0.12em;
  color: #bdaf92;
}

.nav-item small {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: #6f6657;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--border);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(132, 48, 38, 0.28), rgba(99, 77, 38, 0.07));
  border-color: rgba(174, 111, 75, 0.22);
  box-shadow: inset 3px 0 #9d3e31;
}

.nav-item.active b,
.nav-item.active > span {
  color: var(--gold-bright);
}

.campaign-goal {
  padding: 14px 13px;
}

.section-kicker {
  color: var(--gold);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.goal-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 9px 0 7px;
}

.goal-row strong {
  color: #eadfc6;
  font-size: 20px;
}

.goal-row > span {
  color: var(--paper-dim);
  font-size: 10px;
}

.campaign-goal p {
  margin: 11px 0 0;
  color: #807665;
  font-size: 9px;
  line-height: 1.7;
}

.stage {
  min-width: 0;
  padding: 24px 24px 30px;
  background:
    linear-gradient(rgba(17, 14, 11, 0.72), rgba(17, 14, 11, 0.83)),
    radial-gradient(circle at center, rgba(158, 119, 61, 0.14), transparent 60%);
}

.view {
  display: none;
  animation: reveal 0.32s ease;
}

.view.active {
  display: block;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.stage-heading {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 17px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.stage-heading h1 {
  margin: 2px 0 0;
  color: #e4d8be;
  font-size: 23px;
  letter-spacing: 0.15em;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 9px;
  color: var(--paper-dim);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  transform: rotate(45deg);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-player { background: #8e392e; }
.legend-enemy { background: #4d554a; }
.legend-selected { background: transparent; box-shadow: 0 0 0 2px var(--gold); }
.legend-siege { background: #b88635; box-shadow: 0 0 7px #d6a850; }

.map-and-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 17px;
  align-items: start;
}

.map-frame {
  position: relative;
  min-height: 620px;
  padding: 12px;
  background:
    radial-gradient(circle at 48% 45%, rgba(188, 160, 101, 0.18), transparent 55%),
    linear-gradient(160deg, #1a3031, #132527 48%, #192d2e);
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.32), var(--shadow);
}

.map-frame svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 620px;
  max-height: 720px;
  filter: drop-shadow(0 10px 17px rgba(0, 0, 0, 0.2));
}

.map-corner {
  position: absolute;
  z-index: 3;
  width: 21px;
  height: 21px;
  pointer-events: none;
}

.top-left { top: 5px; left: 5px; border-top: 1px solid var(--gold); border-left: 1px solid var(--gold); }
.top-right { top: 5px; right: 5px; border-top: 1px solid var(--gold); border-right: 1px solid var(--gold); }
.bottom-left { bottom: 5px; left: 5px; border-bottom: 1px solid var(--gold); border-left: 1px solid var(--gold); }
.bottom-right { bottom: 5px; right: 5px; border-bottom: 1px solid var(--gold); border-right: 1px solid var(--gold); }

.river {
  fill: none;
  stroke: rgba(90, 137, 143, 0.48);
  stroke-width: 9px;
  stroke-linecap: round;
  filter: url(#roughEdge);
  pointer-events: none;
}

.world-coast {
  fill: #655e45;
  stroke: #ba9f6c;
  stroke-width: 5px;
  stroke-linejoin: round;
  opacity: 0.46;
  pointer-events: none;
  filter: url(#roughEdge);
}

.neighboring-lands {
  pointer-events: none;
  opacity: 0.45;
}

.neighboring-lands path {
  fill: #766c4e;
  stroke: #a18f63;
  stroke-width: 2px;
  stroke-dasharray: 10 7;
}

.neighboring-lands text {
  fill: #c0ae84;
  text-anchor: middle;
  font-size: 13px;
  letter-spacing: 0.5em;
}

.river.minor {
  stroke-width: 5px;
  opacity: 0.63;
}

.territory {
  cursor: pointer;
}

.territory > path {
  fill: #484a3c;
  stroke: #928469;
  stroke-width: 2.5px;
  stroke-linejoin: round;
  transition: fill 0.28s, stroke 0.2s, filter 0.2s;
}

.territory:hover > path {
  filter: brightness(1.2);
  stroke: #c3a96c;
}

.territory.player > path {
  fill: #85372d;
  stroke: #cc8a6a;
}

.territory.selected > path {
  stroke: #efcf80;
  stroke-width: 5px;
  filter: drop-shadow(0 0 9px rgba(226, 191, 109, 0.45));
}

.territory.attackable > path {
  stroke-dasharray: 8 5;
  animation: borderMarch 1s linear infinite;
}

.territory.besieged > path {
  stroke: #db9d43;
  stroke-width: 5px;
  stroke-dasharray: 5 4;
  filter: drop-shadow(0 0 10px rgba(219, 119, 54, 0.7));
  animation: siegePulse 1.3s ease-in-out infinite alternate;
}

@keyframes siegePulse {
  to { filter: drop-shadow(0 0 15px rgba(218, 76, 49, 0.9)); }
}

@keyframes borderMarch {
  to { stroke-dashoffset: -13; }
}

.territory > text {
  fill: #eadfc5;
  text-anchor: middle;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.18em;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
}

.territory .map-owner {
  fill: #c1b38f;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.water-label,
.terrain-labels text {
  fill: #a9997a;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.capital-site,
.domain-assets {
  pointer-events: none;
}

.capital-site path {
  fill: rgba(25, 20, 15, 0.75);
  stroke: #efddb1;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.capital-site text {
  fill: #f0deb4;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-anchor: start;
  paint-order: stroke;
  stroke: #211a13;
  stroke-width: 3px;
}

.domain-assets {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity .25s, filter .25s;
}

.territory.player .domain-assets {
  opacity: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .65));
}

.farm-icon { transform: scale(var(--farm-scale, 1)); }
.barracks-icon { scale: var(--camp-scale, 1); }

.farm-icon rect {
  fill: rgba(164, 134, 52, 0.82);
  stroke: #f1d782;
  stroke-width: 2px;
}

.farm-icon rect + * { pointer-events: none; }

.farm-icon rect {
  background: url(#farmlandPattern);
}

.farm-icon::after { content: ""; }

.farm-icon rect {
  fill: url(#farmlandPattern);
}

#farmlandPattern path {
  fill: none;
  stroke: #d7bd69;
  stroke-width: 2px;
}

.barracks-icon path {
  fill: rgba(54, 27, 23, 0.82);
  stroke: #e4ad82;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.water-label {
  fill: rgba(118, 168, 174, 0.72);
  font-size: 11px;
  font-style: italic;
}

.terrain-labels text {
  fill: rgba(209, 190, 145, 0.48);
  font-size: 10px;
}

.mountains {
  fill: none;
  stroke: #c9b684;
  stroke-width: 3px;
  opacity: 0.33;
  pointer-events: none;
}

/* 真实地理战略层：山河在底，十三州是行政色，52个节点是战争单位。 */
.territory > .capital-site,
.territory > .domain-assets { display: none; }
.territory > text { opacity: .72; font-size: 17px; }
.territory .map-owner { opacity: .42; font-size: 8px; }
.territory.selected > path { stroke-width: 2.5px; filter: none; }
.territory.selected-region-province > path { stroke: rgba(236,203,126,.82); stroke-width: 3.5px; }

.mountain-ranges { pointer-events: none; }
.mountain-ranges .range {
  fill: none;
  stroke: rgba(190,169,118,.38);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 3 5;
  filter: drop-shadow(0 3px 2px rgba(20,17,12,.68));
}
.mountain-ranges .range::after { content: ""; }
.minor-label { font-size: 8px; }

.route-layer, .region-layer { isolation: isolate; }
.strategic-route {
  fill: none;
  stroke: rgba(197,179,137,.2);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
  transition: opacity .2s, stroke .2s;
}
.strategic-route.mountain, .strategic-route.pass { stroke-dasharray: 3 5; }
.strategic-route.river { stroke: rgba(101,160,168,.42); stroke-width: 3; }
.strategic-route.water { stroke: rgba(101,160,168,.48); stroke-width: 3; stroke-dasharray: 8 5; }
body.map-mode-supply .strategic-route,
body.map-mode-terrain .strategic-route,
body.map-mode-military .strategic-route { opacity: 1; stroke: rgba(219,197,146,.46); }
body.map-mode-terrain .strategic-route.river,
body.map-mode-terrain .strategic-route.water { stroke: rgba(95,177,188,.75); }

.strategic-region { cursor: pointer; filter: drop-shadow(0 2px 3px rgba(0,0,0,.9)); }
.strategic-region .region-shape {
  fill: #181a17;
  stroke: var(--region-color, #8b765b);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}
.strategic-region .region-influence { fill: transparent; pointer-events: all; }
body.map-mode-faction .strategic-region .region-influence,
body.map-mode-diplomacy .strategic-region .region-influence { fill: color-mix(in srgb, var(--region-color) 28%, transparent); }
.strategic-region.capital .region-shape { fill: var(--region-color); stroke: #f2d692; stroke-width: 4; }
.strategic-region.gate .region-shape { fill: none; stroke: #d3b56e; stroke-width: 4; }
.strategic-region.port .region-shape { fill: #233c43; stroke: #72aab1; }
.strategic-region.farm .region-shape { fill: #5f5730; stroke: #d0bb62; }
.region-glyph { fill: #f6dfad; text-anchor: middle; font-size: 6px; font-weight: 800; pointer-events: none; }
.gate .region-glyph { fill: #f0d187; font-size: 7px; }
.region-label {
  fill: #ead9b3;
  font-size: 8px;
  font-weight: 650;
  paint-order: stroke;
  stroke: rgba(17,16,13,.95);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}
.strategic-region:hover .region-shape { stroke: #fff0ad; filter: brightness(1.35); }
.strategic-region.selected .region-shape { stroke: #fff1a9; stroke-width: 5; filter: drop-shadow(0 0 7px #e0b95e); }
.strategic-region.reachable .region-shape { animation: nodeReachable .75s ease-in-out infinite alternate; }
.strategic-region.contested .region-shape { stroke: #ef664c; stroke-width: 5; }
@keyframes nodeReachable { to { filter: drop-shadow(0 0 8px #e5bd62); } }

body.map-mode-terrain .territory > path { fill: #4b4b3c; opacity: .67; }
body.map-mode-terrain .strategic-region .region-shape { stroke: #d1bd91; }
body.map-mode-supply .territory > path { fill: #303731; opacity: .72; }
body.map-mode-supply .strategic-region .region-shape { fill: color-mix(in srgb, #669064 var(--supply, 65%), #3a2724); }
body.map-mode-supply .strategic-region .region-influence { fill: color-mix(in srgb, rgba(87,144,83,.36) var(--supply, 55%), rgba(99,43,38,.18)); }
body.map-mode-population .territory > path { fill: #303331; opacity: .72; }
body.map-mode-population .strategic-region .region-shape { fill: color-mix(in srgb, #c3a45c var(--region-population, 50%), #282d2b); }
body.map-mode-grain .strategic-region .region-shape { fill: color-mix(in srgb, #b8a748 var(--region-grain, 50%), #29302a); }
body.map-mode-military .region-label { font-size: 7px; }

.key-gate { width: 11px; height: 11px; border: 2px solid #d3b56e; border-bottom-width: 4px; }
.key-port { width: 11px; height: 11px; border-radius: 50%; background: #315863; border: 2px solid #72aab1; }

.map-stamp {
  position: absolute;
  right: 29px;
  bottom: 23px;
  display: grid;
  place-items: center;
  width: 45px;
  height: 50px;
  color: rgba(183, 79, 62, 0.77);
  font-family: "Ma Shan Zheng", cursive;
  font-size: 15px;
  text-align: center;
  border: 2px solid rgba(183, 79, 62, 0.66);
  transform: rotate(-4deg);
}

.map-key {
  position: absolute;
  left: 25px;
  bottom: 20px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 10px;
  color: #cbbd9f;
  background: rgba(19, 17, 13, 0.78);
  border: 1px solid rgba(211, 183, 120, 0.32);
  font-size: 8px;
  backdrop-filter: blur(5px);
}

.map-key span { display: flex; align-items: center; gap: 5px; }
.map-key small { color: #7f7461; }
.map-key b { display: inline-block; width: 13px; height: 11px; }
.key-city { border: 2px solid #e5d0a0; background: #2c2118; }
.key-farm { background: repeating-linear-gradient(90deg, #bc9a3d 0 2px, #685a2d 2px 4px); border: 1px solid #e2c96f; }
.key-camp { clip-path: polygon(50% 0, 100% 45%, 84% 100%, 16% 100%, 0 45%); background: #a7654c; border: 1px solid #e4ad82; }

.province-card {
  padding: 16px;
  min-height: 0;
  position: static;
  display: grid;
  grid-template-columns: 1.1fr 1.3fr 1fr;
  gap: 0 16px;
}

.province-banner {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: center;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border);
}

.province-card > .province-banner { grid-column: 1; grid-row: 1 / 3; }
.province-card > p { grid-column: 2; grid-row: 1; margin-top: 0; }
.province-card > .province-stats { grid-column: 2; grid-row: 2; }
.province-card > .province-assets { grid-column: 1 / 3; grid-row: 3; }
.province-card > .controller-row { grid-column: 3; grid-row: 1; align-self: start; }
.province-card > .campaign-strip { grid-column: 3; grid-row: 2; }
.province-card > .primary-action { grid-column: 3; grid-row: 3 / 5; align-self: end; }
.province-card > .adjacency-note { grid-column: 1 / 3; grid-row: 4; }

.province-banner > span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 49px;
  background: #713027;
  border: 1px solid #ac6557;
  color: #eadbb9;
  font-family: "Ma Shan Zheng", cursive;
  font-size: 27px;
}

.province-banner small {
  color: var(--paper-dim);
  font-size: 8px;
  letter-spacing: 0.14em;
}

.province-banner h2 {
  margin: 2px 0 0;
  color: #e9ddc2;
  font-size: 19px;
}

.province-banner i {
  grid-column: 1 / -1;
  width: fit-content;
  padding: 3px 7px;
  color: #92b29e;
  background: rgba(74, 119, 91, 0.13);
  border: 1px solid rgba(92, 145, 111, 0.25);
  font-style: normal;
  font-size: 8px;
  letter-spacing: 0.12em;
}

.province-card > p {
  color: #938875;
  font-size: 10px;
  line-height: 1.8;
}

.province-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 13px 0;
  border: 1px solid var(--border);
}

.province-stats.four { grid-template-columns: repeat(4, 1fr); }

.province-stats div {
  padding: 8px 3px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.province-stats div:last-child { border: 0; }
.province-stats span, .province-stats strong { display: block; }
.province-stats span { color: #746b5b; font-size: 8px; }
.province-stats strong { margin-top: 3px; color: #d7c9aa; font-size: 12px; }

.province-assets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 4px;
}

.province-assets > span {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  column-gap: 7px;
  align-items: center;
  padding: 6px 8px;
  background: rgba(117, 92, 51, 0.08);
  border: 1px solid var(--border);
}

.province-assets b {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: #ead8ad;
  border: 1px solid #9f8050;
  font-size: 11px;
}

.province-assets i { color: #776d5c; font-size: 7px; font-style: normal; }
.province-assets strong { color: #cdbd9b; font-size: 9px; font-weight: 600; }
.province-assets .asset-city { background: #38271d; }
.province-assets .asset-farm { background: #5f592d; }
.province-assets .asset-camp { background: #612f27; }
.province-assets.enemy span { opacity: .42; }

.controller-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  font-size: 9px;
  border-top: 1px dotted var(--border-strong);
  border-bottom: 1px dotted var(--border-strong);
}

.controller-row span { color: #756c5d; }
.controller-row strong { color: var(--gold); text-align: right; }

.campaign-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  color: #c5934e;
  font-size: 8px;
}

.campaign-strip > div { height: 5px; background: #3b3023; overflow: hidden; }
.campaign-strip i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a03b2e, #e0a64c); transition: width .35s; }
.campaign-strip strong { color: #e2bd7b; }

.primary-action {
  width: 100%;
  padding: 11px 18px;
  margin-top: 13px;
  border: 1px solid #b55d4d;
  color: #f0ddbb;
  background: linear-gradient(180deg, #9d3f31, #762b24);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.04), 0 8px 18px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.16em;
  transition: filter 0.2s, transform 0.2s;
}

.primary-action:hover { filter: brightness(1.14); transform: translateY(-1px); }
.primary-action:disabled { cursor: not-allowed; filter: grayscale(0.8); opacity: 0.5; transform: none; }
.hidden { display: none !important; }

.adjacency-note {
  font-size: 8px !important;
  color: #665e51 !important;
}

.heading-note {
  margin: 0;
  color: var(--paper-dim);
  font-size: 9px;
  letter-spacing: 0.15em;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
}

.court-action {
  position: relative;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 106px;
  padding: 14px;
  text-align: left;
  background: linear-gradient(135deg, rgba(68, 56, 40, 0.7), rgba(30, 25, 20, 0.86));
  border: 1px solid var(--border);
  cursor: pointer;
  transition: 0.2s ease;
}

.court-action::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
  opacity: 0.35;
}

.court-action:hover { border-color: var(--border-strong); transform: translateY(-2px); background-color: rgba(70, 57, 39, 0.5); }
.court-action:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.court-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 58px;
  color: #dac69a;
  font-family: "Ma Shan Zheng", cursive;
  font-size: 24px;
  background: rgba(16, 13, 10, 0.5);
  border: 1px solid var(--border);
}

.court-action small,
.court-action b,
.court-action em { display: block; }
.court-action b { color: #e6d9bd; font-size: 15px; letter-spacing: 0.08em; }
.court-action small { margin-top: 4px; color: #807665; font-size: 9px; line-height: 1.5; }
.court-action em { margin-top: 7px; color: #9d8e70; font-size: 8px; font-style: normal; }
.court-action > strong { color: #bfa365; font-size: 16px; font-weight: 500; }

.policy-summary {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
}

.policy-summary h2 { margin: 3px 0 0; color: #e6dbc1; font-size: 16px; }
.policy-stat { padding: 8px 10px; border-left: 1px solid var(--border); }
.policy-stat span, .policy-stat strong { display: block; }
.policy-stat span { color: #786f60; font-size: 8px; }
.policy-stat strong { margin-top: 5px; color: var(--gold-bright); font-size: 16px; }

.army-power { text-align: right; }
.army-power small, .army-power strong { display: block; }
.army-power small { color: var(--paper-dim); font-size: 8px; letter-spacing: 0.16em; }
.army-power strong { color: var(--gold-bright); font-size: 22px; }

.army-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.unit-card {
  position: relative;
  padding: 18px;
  overflow: hidden;
  text-align: center;
  background: linear-gradient(160deg, rgba(78, 62, 41, 0.48), rgba(27, 22, 17, 0.92));
  border: 1px solid var(--border);
}

.unit-card::after {
  position: absolute;
  content: "";
  width: 100px;
  height: 100px;
  right: -45px;
  top: -55px;
  border-radius: 50%;
  background: var(--unit-color, #95644c);
  opacity: 0.11;
}

.unit-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--gold-bright);
  font-family: "Ma Shan Zheng", cursive;
  font-size: 23px;
  background: rgba(10, 8, 6, 0.34);
}

.unit-card > small { color: #766b59; font-size: 8px; letter-spacing: 0.24em; }
.unit-card h2 { margin: 2px 0 0; color: #e9ddc2; font-size: 16px; }
.unit-card > strong { display: block; margin: 5px 0; color: var(--gold-bright); font-size: 26px; }
.unit-card p { margin: 0 0 12px; color: #7f7564; font-size: 8px; }
.unit-card button {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-strong);
  background: rgba(126, 49, 38, 0.28);
  color: #d7c4a0;
  cursor: pointer;
  font-size: 10px;
}
.unit-card button:hover { background: rgba(156, 63, 48, 0.45); }
.unit-card button:disabled { opacity: 0.4; cursor: not-allowed; }
.unit-card em { display: block; margin-top: 7px; color: #6d6456; font-size: 7px; font-style: normal; }
.archers { --unit-color: #568a70; }
.cavalry { --unit-color: #a68443; }

.military-orders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin: 13px 0;
}

.order-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(48, 41, 31, 0.56);
  cursor: pointer;
}
.order-card span { color: #dfd2b6; font-size: 12px; }
.order-card small { grid-row: 2; color: #766d5e; font-size: 8px; }
.order-card strong { grid-row: 1 / 3; align-self: center; color: #9fb29a; font-size: 10px; }
.order-card:hover { border-color: var(--border-strong); }
.order-card:disabled { opacity: 0.4; cursor: not-allowed; }

.frontier {
  padding: 16px;
}
.frontier > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.frontier h2 { margin: 0; color: #e3d7bc; font-size: 15px; }
.frontier-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.frontier-target {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  padding: 9px;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(23, 19, 15, 0.55);
  cursor: pointer;
}
.frontier-target b { color: #d8cbaa; font-size: 11px; }
.frontier-target span { color: #776d5d; font-size: 8px; }
.frontier-target strong { grid-row: 1 / 3; align-self: center; color: #ba6c5c; font-size: 9px; }
.frontier-target:hover { border-color: var(--gold); }
.frontier-empty { color: #756c5d; font-size: 9px; }

.season-card {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 12px;
  background: linear-gradient(110deg, rgba(75, 85, 55, 0.25), rgba(39, 31, 23, 0.72));
  border: 1px solid var(--border);
}

.season-sun {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(211, 177, 102, 0.42);
  border-radius: 50%;
  color: var(--gold-bright);
  font-family: "Ma Shan Zheng", cursive;
  font-size: 22px;
  box-shadow: inset 0 0 18px rgba(192, 153, 72, 0.08);
}

.season-card small,
.season-card strong { display: block; }
.season-card small { color: var(--paper-dim); font-size: 8px; letter-spacing: 0.2em; }
.season-card strong { margin-top: 2px; color: #ddd0b3; font-size: 12px; }
.season-card p { margin: 3px 0 0; color: #82997f; font-size: 8px; }

.advisor-card { padding: 14px; }
.advisor-header { display: flex; gap: 10px; align-items: center; }
.advisor-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 42px;
  background: #3d392e;
  border: 1px solid var(--border);
  color: #cfb87e;
  font-family: "Ma Shan Zheng", cursive;
  font-size: 19px;
}
.advisor-header small, .advisor-header strong { display: block; }
.advisor-header small { color: #7e7463; font-size: 8px; }
.advisor-header strong { color: #d8cbae; font-size: 11px; margin-top: 2px; }
.advisor-card blockquote {
  position: relative;
  margin: 12px 0 0;
  padding: 11px 10px 8px;
  color: #9d927e;
  background: rgba(0, 0, 0, 0.13);
  border-top: 1px solid var(--border);
  font-size: 9px;
  line-height: 1.8;
}

.chronicle {
  min-height: 235px;
  max-height: calc(100vh - 435px);
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

.chronicle-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.chronicle-title h2 { margin: 2px 0 0; color: #ded2b8; font-size: 14px; }
.chronicle-title button { border: 0; background: transparent; color: #696154; font-size: 8px; cursor: pointer; }
.log-list { overflow-y: auto; padding-right: 5px; scrollbar-width: thin; scrollbar-color: #5f4c35 transparent; }
.log-entry {
  display: grid;
  grid-template-columns: 8px 1fr;
  column-gap: 8px;
  padding: 9px 0;
  border-bottom: 1px dotted rgba(204, 174, 112, 0.12);
}
.log-entry::before { content: ""; width: 5px; height: 5px; margin-top: 5px; border-radius: 50%; background: #7a725f; }
.log-entry.good::before { background: #6d9d78; }
.log-entry.bad::before { background: #b75143; }
.log-entry.war::before { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.log-entry time { color: #635b4f; font-size: 7px; }
.log-entry p { margin: 2px 0 0; color: #948977; font-size: 8px; line-height: 1.55; }

.end-turn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border: 1px solid #9d493b;
  background: linear-gradient(110deg, #783027, #4f231e);
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
  transition: 0.2s;
}
.end-turn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.end-turn small, .end-turn strong { display: block; text-align: left; }
.end-turn small { color: #b6927c; font-size: 7px; letter-spacing: 0.2em; }
.end-turn strong { color: #eedcba; font-size: 12px; margin-top: 2px; letter-spacing: 0.1em; }
.end-turn i { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid rgba(239, 212, 171, 0.25); border-radius: 50%; font-style: normal; }

.autosave-note { margin: -6px 0 0; color: #61594c; text-align: center; font-size: 7px; }
.autosave-note span { display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: #5b8d6b; }

.toast-stack {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 25px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  min-width: 220px;
  padding: 10px 15px;
  color: #eadfc7;
  background: rgba(33, 27, 20, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 10px;
  animation: toastIn 0.28s ease, toastOut 0.3s ease 2.7s forwards;
}
.toast.good { border-color: rgba(87, 145, 104, 0.55); }
.toast.bad { border-color: rgba(177, 72, 56, 0.62); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

dialog {
  padding: 0;
  color: var(--paper);
  background: #201a14;
  border: 1px solid var(--border-strong);
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.72);
}

dialog::backdrop {
  background: rgba(5, 4, 3, 0.82);
  backdrop-filter: blur(6px) sepia(0.2);
}

dialog[open] { animation: dialogIn 0.28s ease; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }

.setup-modal { width: min(530px, calc(100% - 30px)); }
.setup-modal form { position: relative; padding: 34px 42px 28px; background: radial-gradient(circle at top, rgba(147, 105, 52, 0.16), transparent 50%); }
.modal-ornament { position: absolute; top: 14px; right: 17px; color: #744c34; font-size: 24px; }
.setup-modal h1, .battle-modal h1, .event-modal h1, .help-modal h1 { margin: 5px 0 8px; color: #eddfc1; font-size: 25px; letter-spacing: 0.08em; }
.setup-modal form > p { color: #928572; font-size: 10px; line-height: 1.8; }
.setup-modal form > label { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; margin-top: 12px; color: #a7977b; font-size: 11px; }
.setup-modal input[type="text"], .setup-modal input:not([type]) { min-width: 0; }
.setup-modal input#kingdomInput, .setup-modal input#rulerInput {
  width: 100%;
  padding: 9px 11px;
  color: #e5d8bd;
  background: rgba(7, 6, 5, 0.35);
  border: 1px solid var(--border);
  border-radius: 0;
}
.setup-modal fieldset { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--border); }
.setup-modal legend { padding: 0 9px 0 0; color: var(--gold); font-size: 9px; letter-spacing: 0.2em; }
.choice { cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; padding: 10px; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.14); }
.choice b, .choice small { display: block; }
.choice b { color: #d8c9a9; font-size: 12px; }
.choice small { margin-top: 3px; color: #756b5a; font-size: 7px; }
.choice input:checked + span { border-color: var(--gold); background: rgba(139, 91, 39, 0.14); box-shadow: inset 0 -2px var(--gold); }
.begin-button { margin-top: 20px; }
.save-disclaimer { display: block; margin-top: 8px; color: #655d50; text-align: center; font-size: 7px; }

.modal-close {
  position: absolute;
  top: 11px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #8f816c;
  cursor: pointer;
  font-size: 20px;
}

.battle-modal { width: min(570px, calc(100% - 30px)); }
.battle-modal form, .event-modal form, .help-modal form { position: relative; padding: 30px 34px; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; margin: 20px 0; padding: 15px; background: rgba(0, 0, 0, 0.18); border: 1px solid var(--border); text-align: center; }
.versus small, .versus strong { display: block; }
.versus small { color: #796f5f; font-size: 8px; }
.versus strong { margin-top: 4px; color: #e1d2b3; font-size: 20px; }
.versus > span { color: var(--red-bright); font-size: 11px; }
.range-label, .odds-row { display: flex; justify-content: space-between; align-items: center; font-size: 10px; }
.range-label span, .odds-row span { color: #8d826e; }
.range-label strong { color: var(--gold-bright); }
.battle-modal input[type="range"] { width: 100%; margin: 10px 0; accent-color: var(--red-bright); }
.dispatch-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.dispatch-breakdown span { padding: 7px 5px; color: #8c826f; background: rgba(0, 0, 0, 0.16); border: 1px solid var(--border); text-align: center; font-size: 8px; }
.odds-row { margin-top: 14px; padding: 11px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.odds-row strong { color: #9fbb9e; }
.battle-warning { color: #7a6f5e; font-size: 8px; line-height: 1.6; }
.campaign-phase { margin: 10px 0 -8px; padding: 7px 10px; color: #d7b472; background: rgba(145, 91, 40, .1); border-left: 2px solid var(--gold); font-size: 9px; letter-spacing: .12em; }
.tactic-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 14px 0 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--border); }
.tactic-picker legend { padding-right: 8px; color: #8f826e; font-size: 8px; }
.tactic-picker label { cursor: pointer; }
.tactic-picker input { position: absolute; opacity: 0; }
.tactic-picker span { display: block; min-height: 58px; padding: 9px; border: 1px solid var(--border); background: rgba(0,0,0,.12); }
.tactic-picker b, .tactic-picker small { display: block; }
.tactic-picker b { color: #d4c5a7; font-size: 9px; }
.tactic-picker small { margin-top: 4px; color: #746b5c; font-size: 7px; line-height: 1.4; }
.tactic-picker input:checked + span { border-color: var(--gold); background: rgba(144, 91, 38, .16); box-shadow: inset 0 -2px var(--gold); }
.tactic-picker input:disabled + span { opacity: .35; cursor: not-allowed; }

.event-modal { width: min(460px, calc(100% - 30px)); text-align: center; }
.event-emblem { display: grid; place-items: center; width: 50px; height: 55px; margin: 0 auto 13px; color: #ead8b0; background: #743027; border: 2px solid #ad6356; font-family: "Ma Shan Zheng", cursive; font-size: 25px; transform: rotate(-2deg); }
.event-modal form > p { color: #968a75; font-size: 10px; line-height: 1.8; }
.event-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.event-choice { display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 11px 13px; text-align: left; border: 1px solid var(--border); background: rgba(56, 44, 31, 0.48); cursor: pointer; }
.event-choice b { color: #e0d1b2; font-size: 10px; }
.event-choice small { grid-row: 2; color: #766d5e; font-size: 8px; }
.event-choice em { grid-row: 1 / 3; align-self: center; color: var(--gold); font-size: 8px; font-style: normal; }
.event-choice:hover { border-color: var(--gold); }
.event-choice:disabled { opacity: 0.4; cursor: not-allowed; }

.result-modal { width: min(580px, calc(100% - 30px)); text-align: center; overflow: hidden; }
.result-content { position: relative; padding: 39px; background: radial-gradient(circle at center top, rgba(180, 128, 52, 0.18), transparent 60%); }
.result-rays { position: absolute; inset: -200px; opacity: 0.05; background: repeating-conic-gradient(from 0deg, var(--gold) 0 8deg, transparent 8deg 17deg); animation: spin 50s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-seal { position: relative; display: grid; place-items: center; width: 72px; height: 78px; margin: 0 auto 15px; color: #edd9ab; background: #8d3327; border: 3px double #d1816e; font-family: "Ma Shan Zheng", cursive; font-size: 38px; }
.result-content h1 { margin: 5px 0 10px; color: #f2e3c1; font-size: 32px; letter-spacing: 0.18em; }
.result-content > p { color: #9f927b; font-size: 11px; line-height: 1.8; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 20px 0; border: 1px solid var(--border); }
.result-stats div { padding: 10px; border-right: 1px solid var(--border); }
.result-stats div:last-child { border: 0; }
.result-stats small, .result-stats strong { display: block; }
.result-stats small { color: #756b5c; font-size: 8px; }
.result-stats strong { color: var(--gold-bright); font-size: 18px; margin-top: 4px; }

.help-modal { width: min(500px, calc(100% - 30px)); }
.help-modal ol { list-style: none; counter-reset: help; padding: 0; margin: 20px 0; }
.help-modal li { counter-increment: help; display: grid; grid-template-columns: 30px 50px 1fr; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.help-modal li::before { content: counter(help); display: grid; place-items: center; width: 23px; height: 23px; color: var(--gold); border: 1px solid var(--border-strong); font-size: 9px; }
.help-modal li b { color: #dcccaa; font-size: 11px; }
.help-modal li span { color: #887d69; font-size: 9px; line-height: 1.6; }
.help-tip { padding: 9px; color: #9c927e; background: rgba(145, 101, 42, 0.09); border-left: 2px solid var(--gold); font-size: 8px; }

@media (max-width: 1180px) {
  .game-shell { grid-template-columns: 190px minmax(550px, 1fr) 240px; }
  .resource { padding: 10px 11px; }
  .stage { padding: 20px 16px; }
  .map-and-detail { grid-template-columns: 1fr; }
  .province-card { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; min-height: 0; }
  .province-card > .province-banner { grid-column: 1; grid-row: 1 / 3; }
  .province-card > p { grid-column: 1; grid-row: 3; }
  .province-card > .province-stats { grid-column: 2; grid-row: 1; }
  .province-card > .controller-row { grid-column: 2; grid-row: 2; align-self: end; }
  .province-card > .province-assets { grid-column: 1 / 3; grid-row: 4; }
  .province-card > .campaign-strip { grid-column: 2; grid-row: 3; }
  .province-card > .primary-action { grid-column: 2; grid-row: 5; }
  .province-card > .adjacency-note { grid-column: 1 / 3; grid-row: 6; }
}

@media (max-width: 940px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 16px; }
  .era-block { display: none; }
  .resource-bar { padding: 0 12px; overflow-x: auto; grid-template-columns: repeat(5, minmax(150px, 1fr)); }
  .game-shell { display: block; }
  .left-rail { position: sticky; top: 74px; z-index: 35; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 8px 12px; border: 0; background: rgba(17, 14, 11, 0.96); }
  .ruler-card, .campaign-goal { display: none; }
  .main-nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
  .nav-item { grid-template-columns: 28px 1fr; padding: 8px; }
  .nav-item small { display: none; }
  .right-rail { display: grid; grid-template-columns: 1fr 1fr; border: 0; border-top: 1px solid var(--border); }
  .chronicle { grid-row: span 2; max-height: 260px; }
  .autosave-note { display: none; }
}

@media (max-width: 650px) {
  .topbar { height: 60px; }
  .brand strong { font-size: 16px; }
  .brand small { display: none; }
  .brand-seal { width: 35px; height: 35px; }
  .text-button { padding: 7px; font-size: 10px; }
  .resource-bar { min-height: 56px; grid-template-columns: repeat(5, minmax(125px, 1fr)); }
  .resource { padding: 7px 10px; }
  .resource-icon { width: 26px; height: 26px; }
  .resource strong { font-size: 14px; }
  .left-rail { top: 60px; }
  .stage { padding: 15px 10px 20px; }
  .stage-heading { margin-bottom: 10px; }
  .stage-heading h1 { font-size: 19px; }
  .legend { display: none; }
  .map-frame { min-height: auto; padding: 5px; }
  .map-frame { min-height: 440px; }
  .map-frame svg { min-height: 430px; }
  .province-card { display: block; }
  .province-stats, .province-assets, .controller-row, .campaign-strip, .province-card .primary-action, .adjacency-note { grid-column: auto; grid-row: auto; }
  .map-key small { display: none; }
  .action-grid { grid-template-columns: 1fr; }
  .court-action { min-height: 93px; }
  .policy-summary { grid-template-columns: repeat(2, 1fr); }
  .policy-summary > div:first-child { grid-column: 1 / -1; }
  .policy-stat { border-left: 0; border-top: 1px solid var(--border); }
  .army-overview { grid-template-columns: 1fr; }
  .unit-card { display: grid; grid-template-columns: 65px 1fr 1fr; text-align: left; align-items: center; gap: 4px 12px; }
  .unit-icon { grid-row: 1 / 6; margin: 0; }
  .unit-card > small, .unit-card h2, .unit-card > strong, .unit-card p { grid-column: 2; }
  .unit-card h2 { grid-row: 2; }
  .unit-card > strong { grid-column: 3; grid-row: 1 / 3; text-align: right; }
  .unit-card button { grid-column: 2 / 4; }
  .unit-card em { grid-column: 2 / 4; }
  .military-orders { grid-template-columns: 1fr; }
  .frontier-list { grid-template-columns: 1fr 1fr; }
  .right-rail { grid-template-columns: 1fr; padding: 14px 10px; }
  .chronicle { grid-row: auto; }
  .setup-modal form { padding: 28px 22px 22px; }
  .setup-modal fieldset { grid-template-columns: 1fr; }
  .tactic-picker { grid-template-columns: 1fr; }
  .setup-modal form > label { grid-template-columns: 52px 1fr; }
}

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

/* 大战略界面：地图是唯一主舞台，管理系统以抽屉覆盖。 */
body {
  height: 100vh;
  overflow: hidden;
  background: #0b0e0d;
}

.grand-topbar {
  height: 62px;
  grid-template-columns: 220px 1fr 170px;
  padding: 0 18px;
  background: linear-gradient(180deg, #171713, #0c0e0c);
  border-bottom-color: rgba(203, 157, 82, .32);
}

.grand-topbar .brand-seal { width: 36px; height: 38px; font-size: 23px; }
.grand-topbar .brand strong { font-size: 16px; }
.grand-topbar .brand small { font-size: 7px; }

.strategic-clock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.speed-controls {
  display: flex;
  border: 1px solid rgba(197, 158, 87, .26);
  background: #090b0a;
}

.speed-controls button {
  min-width: 34px;
  height: 28px;
  padding: 0 7px;
  color: #7f7767;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(197, 158, 87, .15);
  cursor: pointer;
  font-size: 9px;
}

.speed-controls button:last-child { border: 0; }
.speed-controls button:hover { color: #e2c582; background: rgba(164, 63, 43, .18); }
.speed-controls button.active { color: #f0d592; background: #7d3026; box-shadow: inset 0 -2px #d7a857; }

.resource-bar {
  position: fixed;
  z-index: 49;
  top: 62px;
  left: 142px;
  right: 230px;
  min-height: 52px;
  grid-template-columns: repeat(6, minmax(102px, 1fr));
  padding: 0;
  background: rgba(13, 15, 13, .94);
  border: 1px solid rgba(198, 157, 82, .18);
  box-shadow: 0 9px 25px rgba(0,0,0,.34);
  backdrop-filter: blur(10px);
}

.resource { min-height: 52px; padding: 6px 10px; }
.resource-icon { width: 26px; height: 26px; font-size: 11px; }
.resource strong { font-size: 13px; }
.resource em { font-size: 6px; }

.game-shell {
  height: calc(100vh - 62px);
  grid-template-columns: 142px minmax(0, 1fr) 230px;
  padding-bottom: 43px;
}

.left-rail {
  padding: 14px 9px;
  background: linear-gradient(180deg, #121411, #0b0d0c);
  border-right-color: rgba(198, 157, 82, .24);
}

.left-rail .ruler-card { margin-top: 0; padding: 10px; }
.ruler-portrait { width: 39px; height: 44px; }
.ruler-card h2 { font-size: 13px; }
.ruler-card p { font-size: 7px; }
.mandate-meter { grid-column: 1 / -1; }

.strategic-nav { margin: 12px -9px; }
.strategic-nav .nav-item {
  min-height: 48px;
  grid-template-columns: 30px 1fr;
  padding: 8px 12px;
}
.strategic-nav .nav-item > span { font-size: 14px; }
.strategic-nav .nav-item b { font-size: 10px; }
.strategic-nav .nav-item small { font-size: 7px; }
.campaign-goal { margin-top: auto; }

.stage {
  position: relative;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: #101616;
}

#mapView, #mapView.active { display: block; height: 100%; }
#mapView .stage-heading {
  position: absolute;
  z-index: 9;
  top: 68px;
  left: 18px;
  right: 18px;
  min-height: 42px;
  margin: 0;
  padding: 0 0 6px;
  pointer-events: none;
  border-bottom-color: rgba(212, 173, 94, .22);
}
#mapView .stage-heading .legend { pointer-events: auto; }
#mapView .stage-heading h1 { font-size: 17px; text-shadow: 0 2px 8px #000; }

.map-and-detail { height: 100%; display: block; }
.map-frame {
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  box-shadow: inset 0 0 90px rgba(0,0,0,.55);
  overflow: hidden;
}

.map-frame svg {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding-top: 42px;
  object-fit: contain;
}

.map-corner { display: none; }
.map-key { left: 15px; bottom: 14px; }
.map-stamp { right: 18px; bottom: 16px; opacity: .45; }

.province-card {
  position: absolute;
  z-index: 8;
  left: 18px;
  bottom: 54px;
  width: min(410px, calc(100% - 36px));
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 0 12px;
  padding: 12px;
  background: rgba(20, 21, 17, .92);
  border-color: rgba(210, 171, 94, .34);
  backdrop-filter: blur(9px);
}
.province-card > .province-banner { grid-column: 1; grid-row: 1 / 3; }
.province-card > p { display: none; }
.province-card > .province-stats { grid-column: 2; grid-row: 1; margin: 0 0 7px; }
.province-card > .province-assets { grid-column: 1 / 3; grid-row: 3; }
.province-card > .controller-row { grid-column: 2; grid-row: 2; }
.province-card > .campaign-strip { grid-column: 1 / 3; grid-row: 4; margin-top: 7px; }
.province-card > .primary-action { grid-column: 2; grid-row: 5; margin-top: 8px; }
.province-card > .adjacency-note { grid-column: 1; grid-row: 5; align-self: center; margin: 7px 0 0; }
.province-banner { padding-bottom: 7px; }
.province-banner > span { width: 37px; height: 41px; font-size: 22px; }
.province-banner h2 { font-size: 15px; }
.province-stats div { padding: 5px 2px; }
.province-assets > span { padding: 4px 6px; }
.province-assets b { width: 22px; height: 22px; }

.stage > .view:not(#mapView) {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(430px, 95%);
  display: block;
  padding: 78px 18px 22px;
  overflow-y: auto;
  background: linear-gradient(100deg, rgba(16,17,14,.99), rgba(23,22,17,.97));
  border-right: 1px solid rgba(207, 169, 91, .32);
  box-shadow: 20px 0 45px rgba(0,0,0,.48);
  transform: translateX(-104%);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .2s;
}

.stage > .view:not(#mapView).active { transform: none; opacity: 1; pointer-events: auto; }
.stage > .view:not(#mapView) .stage-heading { align-items: center; }
.drawer-close {
  margin-left: auto;
  width: 29px;
  height: 29px;
  color: #91826b;
  background: #191714;
  border: 1px solid var(--border);
  cursor: pointer;
}

.right-rail {
  gap: 9px;
  padding: 12px 10px 55px;
  overflow-y: auto;
  background: linear-gradient(180deg, #111310, #0b0d0c);
  border-left-color: rgba(198,157,82,.24);
}

.right-rail .season-card, .right-rail .advisor-card { display: none; }
.chronicle { min-height: 140px; max-height: 230px; padding: 11px; }
.army-command, .war-overview { padding: 11px; }
.chronicle-title h2 { font-size: 12px; }
.chronicle-title > span { color: #897a61; font-size: 8px; }
.army-list, .war-list { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }

.army-card {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 8px;
  color: #d7c9aa;
  background: rgba(52,49,39,.62);
  border: 1px solid rgba(203,168,96,.18);
  cursor: pointer;
  text-align: left;
}
.army-card:hover, .army-card.selected { border-color: #cfad66; background: rgba(106,58,39,.55); }
.army-card .army-flag { display: grid; place-items: center; width: 30px; height: 34px; color: #f0d9a6; background: #81372b; clip-path: polygon(0 0, 100% 0, 100% 76%, 50% 100%, 0 76%); font-size: 13px; }
.army-card b, .army-card small, .army-card em { display: block; }
.army-card b { font-size: 9px; }
.army-card small { margin-top: 2px; color: #817562; font-size: 7px; }
.army-card strong { color: #ddb96d; font-size: 10px; }
.army-card em { grid-column: 2 / 4; color: #8d8069; font-size: 7px; font-style: normal; }
.army-card .mini-bar { grid-column: 2 / 4; height: 3px; background: #302b22; }
.army-card .mini-bar i { display: block; height: 100%; background: #879b6d; }

.war-entry { padding: 8px; background: rgba(57,33,27,.55); border-left: 2px solid #a84936; }
.war-entry b, .war-entry span { display: block; }
.war-entry b { color: #d9c29d; font-size: 9px; }
.war-entry span { margin-top: 3px; color: #8c7763; font-size: 7px; line-height: 1.4; }
.war-empty { color: #6d6558; font-size: 8px; padding: 5px 0; }
.alert-dot { width: 7px; height: 7px; border-radius: 50%; background: #6f6657; }
.alert-dot.active { background: #d04d37; box-shadow: 0 0 8px #e46148; }
.end-turn { padding: 9px 12px; }
.autosave-note { margin: 0; }

.map-mode-bar {
  position: fixed;
  z-index: 60;
  left: 142px;
  right: 230px;
  bottom: 0;
  height: 43px;
  display: flex;
  align-items: stretch;
  background: #0a0c0b;
  border-top: 1px solid rgba(204,168,94,.3);
  box-shadow: 0 -8px 24px rgba(0,0,0,.36);
}
.map-mode-bar > span, .map-mode-bar button, .map-mode-bar em { display: flex; align-items: center; }
.map-mode-bar > span { padding: 0 14px; color: #756b59; font-size: 8px; border-right: 1px solid var(--border); }
.map-mode-bar button { padding: 0 15px; color: #817664; background: transparent; border: 0; border-right: 1px solid rgba(204,168,94,.11); cursor: pointer; font-size: 9px; }
.map-mode-bar button:hover { color: #e2c887; }
.map-mode-bar button.active { color: #f0d48f; background: #762f25; box-shadow: inset 0 3px #cf9f50; }
.map-mode-bar em { margin-left: auto; padding: 0 13px; color: #6e6557; font-size: 7px; font-style: normal; }

.order-hint {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 55px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  color: #dac8a2;
  background: rgba(31,25,19,.94);
  border: 1px solid #bd9851;
  transform: translateX(-50%);
  box-shadow: 0 9px 30px rgba(0,0,0,.4);
  font-size: 8px;
}
.order-hint span { color: #90836e; }
.order-hint button { color: #b99f72; background: transparent; border: 1px solid #665a46; cursor: pointer; font-size: 7px; }

.map-tooltip {
  position: fixed;
  z-index: 100;
  width: 210px;
  padding: 10px;
  color: #cbbb9c;
  background: rgba(13,15,13,.96);
  border: 1px solid #917b50;
  box-shadow: 0 12px 30px rgba(0,0,0,.48);
  pointer-events: none;
  font-size: 8px;
  line-height: 1.65;
}
.map-tooltip b { display: block; color: #ead7ad; font-size: 11px; }

.army-marker { cursor: pointer; filter: drop-shadow(0 3px 4px rgba(0,0,0,.75)); }
.army-marker .flag-body { fill: #8f3c2f; stroke: #f0c977; stroke-width: 2; }
.army-marker.enemy .flag-body { fill: #3f556a; }
.army-marker text { fill: #fff1c5; text-anchor: middle; font-size: 13px; font-weight: 800; pointer-events: none; }
.army-marker .army-size { font-size: 9px; fill: #ead4a6; paint-order: stroke; stroke: #18130f; stroke-width: 3px; }
.army-marker.selected .flag-body { stroke-width: 4; filter: drop-shadow(0 0 8px #f2c96d); }

.movement-line { fill: none; stroke: #e7c46f; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 13 9; animation: routeMarch .8s linear infinite; filter: drop-shadow(0 0 4px rgba(227,178,78,.75)); }
.movement-line.enemy { stroke: #c55443; }
.movement-arrow { fill: #e7c46f; }
.movement-progress { fill: #fff0b5; stroke: #352718; stroke-width: 2; }
@keyframes routeMarch { to { stroke-dashoffset: -22; } }

.front-line { stroke: #d05a43; stroke-width: 8; stroke-dasharray: 4 7; fill: none; filter: drop-shadow(0 0 6px rgba(210,65,45,.8)); animation: siegePulse 1s alternate infinite; }
.battle-badge { fill: #21150f; stroke: #e0a75b; stroke-width: 3; }
.battle-text { fill: #f0d293; text-anchor: middle; font-size: 11px; font-weight: 800; }

body.map-mode-faction .territory > path,
body.map-mode-diplomacy .territory > path { fill: var(--faction-color, #4f5046); }
body.map-mode-military .territory > path { fill: #333b3b; }
body.map-mode-military .territory.player > path { fill: #5f352d; }
body.map-mode-military .territory.besieged > path { fill: #7b3328; }
body.map-mode-economy .territory > path { fill: color-mix(in srgb, #75643a var(--mode-strength, 45%), #272c29); }
body.map-mode-morale .territory > path { fill: color-mix(in srgb, #5d865b var(--mode-strength, 45%), #382827); }
body.map-mode-grain .territory > path { fill: color-mix(in srgb, #9b843d var(--mode-strength, 45%), #2a2b25); }
body.map-mode-diplomacy .territory > path { filter: saturate(.45); }
body.map-mode-diplomacy .territory.player > path { filter: saturate(1.3) brightness(1.1); }

.diplomacy-list, .decision-list { display: flex; flex-direction: column; gap: 9px; }
.diplomacy-row, .decision-card { padding: 12px; background: rgba(45,42,34,.55); border: 1px solid var(--border); }
.diplomacy-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 9px; }
.diplomacy-row i { width: 10px; height: 32px; background: var(--faction-color); }
.diplomacy-row b, .diplomacy-row small { display: block; }
.diplomacy-row b { color: #d9caab; font-size: 10px; }
.diplomacy-row small { color: #786e5e; font-size: 7px; }
.diplomacy-row strong { color: #bf9d5d; font-size: 8px; }
.policy-tree { display: flex; flex-direction: column; align-items: center; gap: 25px; padding: 18px 0; }
.policy-tree::before { content: ""; position: absolute; height: 60px; border-left: 1px solid #806d45; }
.policy-branches { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.policy-node { min-width: 145px; padding: 13px; color: #aa9a7b; background: #201e19; border: 1px solid #675a43; cursor: pointer; }
.policy-node b, .policy-node small { display: block; }
.policy-node b { color: #d4c29c; font-size: 10px; }
.policy-node small { margin-top: 4px; color: #746956; font-size: 7px; }
.policy-node.unlocked { background: #49352a; border-color: #bf9651; }
.decision-card b { display: block; color: #dbc9a4; font-size: 10px; }
.decision-card p { color: #807463; font-size: 8px; line-height: 1.6; }
.decision-card button { width: 100%; padding: 8px; color: #dbc49a; background: #672d25; border: 1px solid #9e5743; cursor: pointer; }

@media (max-width: 1050px) {
  .grand-topbar { grid-template-columns: 170px 1fr 130px; }
  .resource-bar { left: 150px; right: 240px; }
  .game-shell { grid-template-columns: 150px minmax(0,1fr) 240px; }
  .map-mode-bar { left: 150px; right: 240px; }
  .strategic-nav .nav-item { padding-left: 9px; }
  .resource { padding: 5px 6px; }
  .resource-icon { display: none; }
}

@media (max-width: 780px) {
  body { overflow: auto; }
  .grand-topbar { position: sticky; grid-template-columns: 1fr auto; height: 58px; }
  .strategic-clock { grid-row: 2; position: fixed; top: 58px; left: 0; right: 0; height: 40px; z-index: 60; background: #0d0f0d; }
  .resource-bar { position: fixed; top: 98px; left: 0; right: 0; grid-template-columns: repeat(6, minmax(105px,1fr)); overflow-x: auto; }
  .game-shell { height: calc(100vh - 98px); padding-top: 52px; padding-bottom: 43px; grid-template-columns: 66px minmax(580px,1fr); }
  .left-rail { width: 66px; padding: 5px; }
  .ruler-card, .campaign-goal { display: none; }
  .strategic-nav { margin: 0 -5px; }
  .strategic-nav .nav-item { display: grid; grid-template-columns: 1fr; text-align: center; padding: 8px 2px; }
  .strategic-nav .nav-item b { font-size: 8px; }
  .strategic-nav .nav-item small { display: none; }
  .right-rail { position: fixed; z-index: 55; top: 150px; right: 0; bottom: 43px; width: 240px; transform: translateX(calc(100% - 24px)); transition: transform .2s; }
  .right-rail:hover, .right-rail:focus-within { transform: none; }
  .map-mode-bar { left: 66px; right: 0; overflow-x: auto; }
  .map-mode-bar em, .map-mode-bar > span { display: none; }
  .map-mode-bar button { white-space: nowrap; }
}
