:root {
  color-scheme: dark;
  --ink: #111713;
  --ink-soft: #1c2721;
  --panel: rgba(20, 27, 23, 0.96);
  --panel-2: rgba(34, 38, 30, 0.96);
  --paper: #e8ddc3;
  --paper-soft: #c9b990;
  --gold: #d6b064;
  --gold-bright: #f5d98b;
  --red: #a8452f;
  --red-bright: #d66d43;
  --ember: #c46a3c;
  --north: #4d8790;
  --river: #7666a6;
  --neutral: #8a816b;
  --good: #78b68a;
  --bad: #d76b59;
  --line: rgba(221, 190, 125, 0.34);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  font-family: "Noto Serif SC", "Songti SC", "Microsoft YaHei", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #090c0a;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  color: var(--paper);
  background:
    radial-gradient(circle at 50% -10%, rgba(102, 77, 41, 0.4), transparent 45%),
    linear-gradient(180deg, #111713, #060806);
  overscroll-behavior: none;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55);
  opacity: 0.48;
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  width: min(100%, 620px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(rgba(15, 20, 16, 0.94), rgba(8, 10, 8, 0.98)),
    repeating-linear-gradient(45deg, transparent 0 9px, rgba(255,255,255,0.016) 10px 11px);
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.75);
}

.screen {
  position: relative;
  min-height: 100svh;
}

.loading-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--paper);
  background: #0c120f;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading-screen.is-leaving {
  opacity: 0;
  visibility: hidden;
}

.loading-screen strong {
  letter-spacing: 0.18em;
}

.loading-screen small {
  color: var(--paper-soft);
}

.seal-mark {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border: 2px solid var(--red-bright);
  color: #efb479;
  font-size: 34px;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 5px #0c120f, inset 0 0 0 6px rgba(214,109,67,0.6);
  animation: seal-breathe 2.2s ease-in-out infinite;
}

.home-screen {
  padding: calc(28px + env(safe-area-inset-top)) 18px calc(30px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(8, 13, 10, 0.12), rgba(8, 12, 9, 0.72) 32%, #0c100d 72%),
    url("./assets/art/hanmo-map-v1.webp") center top / 100% auto no-repeat;
}

.home-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(218, 179, 97, 0.08) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(circle at 50% 16%, rgba(224, 165, 76, 0.18), transparent 24%);
  mask-image: linear-gradient(black, transparent 58%);
}

.brand-block,
.campaign-card,
.select-section,
.home-actions,
.home-note {
  position: relative;
  z-index: 1;
}

.brand-block {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: center;
  text-shadow: 0 3px 12px #000;
}

.eyebrow,
.campaign-kicker,
.section-heading span {
  margin: 0;
  color: var(--gold-bright);
  font-size: 12px;
  letter-spacing: 0.22em;
}

.brand-block h1 {
  margin: 9px 0 3px;
  color: #f0d99e;
  font-size: clamp(45px, 13vw, 72px);
  line-height: 1;
  letter-spacing: 0.13em;
  text-indent: 0.13em;
  text-shadow:
    0 2px 0 #6d4320,
    0 5px 14px rgba(0,0,0,0.95),
    0 0 26px rgba(229,176,73,0.28);
}

.brand-subtitle {
  margin: 8px 0 14px;
  color: #ddd0b4;
  letter-spacing: 0.18em;
}

.campaign-card,
.select-section,
.ruler-detail {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(33, 40, 32, 0.96), rgba(17, 23, 19, 0.96));
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,0.05);
}

.campaign-card {
  padding: 17px;
  border-radius: 5px;
  border-top: 2px solid var(--gold);
}

.campaign-card h2 {
  margin: 6px 0;
  color: #f1dfb8;
  font-size: 22px;
}

.campaign-card p {
  margin: 0;
  color: #bfb59f;
  font-size: 13px;
  line-height: 1.75;
}

.loop-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(215, 181, 109, 0.23);
  background: rgba(7, 9, 7, 0.56);
  color: var(--gold-bright);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.loop-strip i {
  color: #79684d;
  font-style: normal;
}

.select-section {
  margin-top: 14px;
  padding: 15px;
  border-radius: 5px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 4px 0 0;
  color: #ead9b2;
  font-size: 19px;
}

.section-heading small {
  max-width: 42%;
  color: #928a78;
  font-size: 10px;
  text-align: right;
}

.ruler-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.ruler-card {
  min-width: 0;
  padding: 5px 4px 8px;
  border: 1px solid rgba(208, 182, 123, 0.22);
  border-radius: 3px;
  background: linear-gradient(#30392f, #171d19);
  box-shadow: inset 0 1px rgba(255,255,255,0.05), 0 5px 10px rgba(0,0,0,0.25);
  cursor: pointer;
}

.ruler-card.selected {
  border-color: var(--gold-bright);
  background: linear-gradient(#57452b, #211b14);
  box-shadow: 0 0 0 2px rgba(219,177,88,0.16), 0 7px 18px rgba(0,0,0,0.45);
  transform: translateY(-2px);
}

.ruler-portrait,
.general-face,
.mini-face {
  display: block;
  background-repeat: no-repeat;
  background-size: 200% 200%;
}

.ruler-portrait {
  width: 100%;
  aspect-ratio: 0.86;
  margin-bottom: 6px;
  border: 1px solid rgba(235,205,137,0.24);
  background-color: #232921;
  background-blend-mode: normal;
  box-shadow: inset 0 -16px 18px rgba(0,0,0,0.36);
}

.ruler-card strong,
.ruler-card small {
  display: block;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ruler-card strong {
  color: #eee0bf;
  font-size: 13px;
}

.ruler-card small {
  margin-top: 2px;
  color: #938a76;
  font-size: 9px;
}

.ruler-detail {
  margin-top: 10px;
  padding: 12px;
  border-left: 3px solid var(--red-bright);
  background: rgba(12, 17, 13, 0.76);
}

.detail-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-heading h3 {
  margin: 0;
  color: #f0dfb7;
  font-size: 20px;
}

.detail-heading h3 small {
  margin-left: 8px;
  color: var(--gold);
  font-size: 11px;
}

.role-seal {
  padding: 3px 8px;
  border: 1px solid #8e5f3b;
  color: #d9b77a;
  font-size: 10px;
}

.trait-copy,
.quote-copy {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.55;
}

.trait-copy {
  color: #d7c8a8;
}

.quote-copy {
  color: #908b7c;
}

.ruler-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 10px;
}

.ruler-stats span {
  padding: 5px 2px;
  border-top: 1px solid rgba(215,181,109,0.17);
  color: #8d8779;
  font-size: 9px;
  text-align: center;
}

.ruler-stats b {
  display: block;
  margin-top: 2px;
  color: #e5cd97;
  font-size: 14px;
}

.home-actions {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border: 1px solid;
  border-radius: 3px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.primary-button {
  border-color: #efca73 #7d481f #5c3317 #d7ad56;
  color: #24160d;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 18%),
    linear-gradient(#e4b75d, #a45d28 72%, #713716);
  box-shadow:
    inset 0 1px #ffe6a8,
    inset 0 -4px rgba(72,30,10,0.42),
    0 6px 0 #48240f,
    0 10px 22px rgba(0,0,0,0.45);
  font-weight: 800;
  text-shadow: 0 1px rgba(255,255,255,0.25);
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: inset 0 1px #ffe6a8, inset 0 -2px rgba(72,30,10,0.35), 0 2px 0 #48240f, 0 5px 10px rgba(0,0,0,0.4);
}

.secondary-button {
  border-color: #776a50;
  color: #e5d7b6;
  background: linear-gradient(#30382f, #171b17);
  box-shadow: inset 0 1px rgba(255,255,255,0.06), 0 4px 0 #090b09;
}

.compact {
  min-height: 40px;
  padding: 8px 15px;
  letter-spacing: 0.06em;
}

.home-note {
  margin: 18px 0 0;
  color: #777366;
  font-size: 10px;
  text-align: center;
}

.game-screen {
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
  background: #0c110e;
}

.top-hud {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr auto 42px;
  align-items: center;
  min-height: calc(64px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #222c25, #111711);
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}

.ruler-medallion {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  color: #e6d3aa;
  background: none;
  cursor: pointer;
}

.ruler-medallion .mini-face {
  width: 40px;
  height: 40px;
  border: 2px solid #ba9450;
  border-radius: 50%;
  background-color: #283129;
  box-shadow: 0 3px 8px #000;
}

.ruler-medallion b {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-block {
  text-align: right;
}

.calendar-block strong,
.calendar-block small {
  display: block;
}

.calendar-block strong {
  color: var(--gold-bright);
  font-size: 13px;
}

.calendar-block small {
  margin-top: 2px;
  color: #8f8b7d;
  font-size: 10px;
}

.icon-button {
  width: 34px;
  height: 34px;
  margin-left: 6px;
  border: 1px solid #776746;
  border-radius: 50%;
  color: #ead49f;
  background: radial-gradient(circle at 35% 28%, #5a523c, #1a1d18 64%);
  box-shadow: inset 0 1px rgba(255,255,255,0.12), 0 3px 7px #000;
  cursor: pointer;
}

.resource-strip {
  position: relative;
  z-index: 7;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid rgba(218,183,110,0.2);
  background: rgba(17, 23, 19, 0.97);
}

.resource-strip > div {
  position: relative;
  padding: 7px 3px 8px 25px;
  border-right: 1px solid rgba(218,183,110,0.1);
}

.resource-strip span,
.resource-strip strong {
  display: block;
}

.resource-strip span {
  color: #817b6b;
  font-size: 8px;
}

.resource-strip strong {
  color: #e5d1a5;
  font-size: 12px;
}

.resource-icon {
  position: absolute;
  top: 50%;
  left: 8px;
  width: 11px;
  height: 11px;
  transform: translateY(-50%) rotate(45deg);
  border: 1px solid rgba(255,255,255,0.35);
  background: #b88d42;
  box-shadow: 0 0 7px rgba(218,178,90,0.35);
}

.resource-icon.grain {
  border-radius: 9px 0 9px 0;
  background: #a7a153;
}

.resource-icon.iron {
  background: #778d8d;
}

.resource-icon.renown {
  border-radius: 50%;
  background: #b5623f;
}

.map-stage {
  position: relative;
  height: clamp(470px, 62svh, 650px);
  min-height: 470px;
  overflow: hidden;
  border-bottom: 2px solid #5f4a2c;
  isolation: isolate;
  background: #28382c;
}

.map-art {
  position: absolute;
  z-index: -4;
  inset: 0;
  background: url("./assets/art/hanmo-map-v1.webp") center 45% / cover no-repeat;
  filter: saturate(0.82) contrast(1.08) brightness(0.82);
  transform: scale(1.025);
}

.map-vignette {
  position: absolute;
  z-index: -2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6,9,7,0.47), transparent 16%, transparent 74%, rgba(7,10,8,0.72)),
    radial-gradient(ellipse at center, transparent 48%, rgba(4,7,5,0.58) 100%);
}

.cloud-layer {
  position: absolute;
  z-index: -1;
  width: 62%;
  height: 22%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.11;
  filter: blur(22px);
  background: radial-gradient(ellipse, rgba(218,222,200,0.52), transparent 69%);
  transform: translateZ(0);
  animation: none;
}

.cloud-a {
  top: 14%;
  left: 6%;
}

.cloud-b {
  right: 5%;
  bottom: 8%;
  left: auto;
}

.route-layer,
.city-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.route-layer {
  z-index: 1;
  pointer-events: none;
}

.route-line {
  stroke: rgba(234, 219, 173, 0.34);
  stroke-width: 0.7;
  stroke-dasharray: 1.2 1.2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.85));
  transition: stroke 0.25s ease, stroke-width 0.25s ease;
}

.route-line.controlled {
  stroke-dasharray: none;
  stroke-width: 1.4;
}

.route-line.route-ember { stroke: rgba(226,124,70,0.78); }
.route-line.route-north { stroke: rgba(91,164,174,0.72); }
.route-line.route-river { stroke: rgba(147,124,200,0.7); }

.route-line.focused {
  stroke: #ffe1a0;
  stroke-width: 2;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 3px rgba(255, 225, 160, .72));
}

.city-layer {
  z-index: 3;
}

.city-node {
  --owner: var(--neutral);
  position: absolute;
  display: grid;
  grid-template-columns: 31px auto;
  min-width: 62px;
  min-height: 38px;
  padding: 3px 6px 3px 3px;
  align-items: center;
  column-gap: 4px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(222, 200, 151, 0.58);
  border-color: color-mix(in srgb, var(--owner), white 32%);
  border-radius: 3px;
  color: #f1e5c8;
  background: linear-gradient(145deg, rgba(36,42,35,0.96), rgba(12,16,13,0.94));
  box-shadow:
    inset 0 1px rgba(255,255,255,0.1),
    0 3px 0 rgba(0,0,0,0.7),
    0 7px 12px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.city-node.owner-ember { --owner: var(--ember); }
.city-node.owner-north { --owner: var(--north); }
.city-node.owner-river { --owner: var(--river); }
.city-node.owner-neutral { --owner: var(--neutral); }

.city-node.selected {
  z-index: 6;
  transform: translate(-50%, -55%) scale(1.12);
  box-shadow:
    inset 0 1px rgba(255,255,255,0.16),
    0 3px 0 rgba(0,0,0,0.76),
    0 0 0 3px rgba(255,225,155,0.22),
    0 0 22px var(--owner);
}

.city-node.capital::after {
  content: "都";
  position: absolute;
  top: -10px;
  right: -8px;
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid #f1d284;
  border-radius: 50%;
  color: #2a190d;
  background: #d7ac57;
  font-size: 8px;
  font-weight: 900;
}

.city-node.frontier::before {
  display: none;
  content: none;
}

.city-node.frontier:not(.selected) {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--owner), white 42%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--owner) 18%, transparent), 0 7px 12px rgba(0,0,0,.5);
}

.city-banner {
  display: grid;
  grid-row: 1 / 3;
  width: 29px;
  height: 31px;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff3d3;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.22), transparent 30%),
    var(--owner);
  font-size: 15px;
  font-weight: 800;
  text-shadow: 0 2px 3px #000;
  clip-path: polygon(0 0,100% 0,100% 82%,50% 100%,0 82%);
}

.city-node strong {
  align-self: end;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.node-troops {
  align-self: start;
  margin-top: 2px;
  color: #bcb096;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 8px;
  white-space: nowrap;
}

.objective-card {
  position: absolute;
  z-index: 7;
  top: 10px;
  left: 10px;
  width: min(56%, 280px);
  padding: 10px 12px;
  border: 1px solid rgba(229,195,121,0.45);
  border-left: 3px solid var(--gold);
  background: linear-gradient(105deg, rgba(13,18,14,0.94), rgba(24,30,23,0.84));
  box-shadow: 0 6px 18px rgba(0,0,0,0.52);
  pointer-events: none;
}

.objective-heading {
  display: flex;
  justify-content: space-between;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.objective-heading button {
  width: 22px;
  height: 22px;
  margin-top: -5px;
  margin-right: -6px;
  border: 1px solid #8d7547;
  border-radius: 50%;
  color: #e7cd90;
  background: #25271f;
  pointer-events: auto;
}

.objective-card > strong {
  display: block;
  margin-top: 3px;
  color: #f2e0b5;
  font-size: 15px;
}

.objective-card > p {
  margin: 4px 0 7px;
  color: #aba38e;
  font-size: 9px;
  line-height: 1.45;
}

.objective-meter {
  position: relative;
  height: 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
}

.objective-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9d5d32, #e3bc68);
  transition: width 0.35s ease;
}

.objective-meter em {
  position: absolute;
  right: 0;
  bottom: 8px;
  color: #d7c494;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 8px;
  font-style: normal;
}

.map-legend {
  position: absolute;
  z-index: 5;
  right: 7px;
  bottom: 7px;
  display: flex;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid rgba(219,189,125,0.19);
  background: rgba(9,13,10,0.74);
  color: #b9ad92;
  font-size: 8px;
  backdrop-filter: blur(4px);
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.map-legend i {
  width: 7px;
  height: 7px;
  border-radius: 1px;
}

.map-legend i.ember { background: var(--ember); }
.map-legend i.north { background: var(--north); }
.map-legend i.river { background: var(--river); }
.map-legend i.neutral { background: var(--neutral); }

.city-command {
  position: relative;
  z-index: 6;
  padding: 12px 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.04);
  background:
    linear-gradient(135deg, rgba(215,177,102,0.035) 25%, transparent 25%) 0 0 / 14px 14px,
    linear-gradient(180deg, #202820, #101510);
}

.city-command > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.city-command h2 {
  display: inline;
  margin: 0 0 0 7px;
  color: #f0dfb8;
  font-size: 21px;
}

.city-command header small {
  display: block;
  margin-top: 3px;
  color: #8c8678;
  font-size: 9px;
}

.faction-tag {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid currentColor;
  color: var(--neutral);
  font-size: 9px;
}

.faction-tag.owner-ember { color: #df8252; }
.faction-tag.owner-north { color: #75aeb3; }
.faction-tag.owner-river { color: #9e8bc8; }
.faction-tag.owner-neutral { color: #aaa18e; }

.troop-total {
  min-width: 74px;
  padding: 5px 8px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.troop-total span,
.troop-total strong {
  display: block;
}

.troop-total span {
  color: #8c8576;
  font-size: 9px;
}

.troop-total strong {
  margin-top: 2px;
  color: #f1cd7f;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 17px;
}

.city-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 10px;
}

.city-stat span {
  display: flex;
  justify-content: space-between;
  color: #9c9584;
  font-size: 8px;
}

.city-stat em {
  font-style: normal;
}

.city-stat strong {
  color: #d9c89e;
  font-family: "Microsoft YaHei", sans-serif;
}

.city-stat > i {
  display: block;
  height: 3px;
  margin-top: 3px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
}

.city-stat > i b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #86532e, #d8ae5d);
}

.fog-card {
  grid-column: 1 / -1;
  padding: 8px;
  border: 1px dashed rgba(215,185,121,0.26);
  color: #a59e8c;
  font-size: 10px;
  text-align: center;
}

.city-intel {
  min-height: 16px;
  margin: 8px 0;
  color: #8d8778;
  font-size: 9px;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.command-grid button {
  min-height: 48px;
  padding: 5px 2px;
  border: 1px solid #5d594a;
  border-radius: 2px;
  color: #cfc2a2;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 22%),
    linear-gradient(#31382f, #171b17 76%);
  box-shadow:
    inset 0 1px rgba(255,255,255,0.08),
    inset 0 -3px rgba(0,0,0,0.38),
    0 3px 0 #090b09;
  cursor: pointer;
}

.command-grid button:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px rgba(255,255,255,0.06), 0 1px 0 #090b09;
}

.command-grid button i,
.command-grid button span {
  display: block;
}

.command-grid button i {
  color: #d6ae64;
  font-size: 15px;
  font-style: normal;
  font-weight: 800;
}

.command-grid button span {
  margin-top: 2px;
  font-size: 10px;
}

.command-grid .accent-command {
  border-color: #ba7443;
  color: #f1d8a7;
  background:
    linear-gradient(180deg, rgba(255,230,178,0.17), transparent 22%),
    linear-gradient(#7e4129, #401e16 76%);
  box-shadow: inset 0 1px rgba(255,255,255,0.12), inset 0 -3px rgba(0,0,0,0.42), 0 3px 0 #1d0d09;
}

.turn-console {
  display: grid;
  grid-template-columns: 1fr minmax(155px, 42%);
  gap: 10px;
  align-items: center;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(217,178,101,0.2);
  background: #0c110d;
}

.turn-console > div > span {
  color: #8b8577;
  font-size: 9px;
}

.action-pips {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.action-pips i {
  width: 23px;
  height: 7px;
  transform: skewX(-18deg);
  border: 1px solid #514d40;
  background: #222620;
}

.action-pips i.full {
  border-color: #d1a453;
  background: linear-gradient(#f0cc78, #9d5d2c);
  box-shadow: 0 0 7px rgba(222,170,75,0.36);
}

.end-turn-button {
  min-height: 43px;
  padding: 5px 8px;
  border: 1px solid #a06d3d;
  color: #edd8aa;
  background: linear-gradient(#5f3925, #2f1a14);
  box-shadow: inset 0 1px rgba(255,255,255,0.12), inset 0 -3px rgba(0,0,0,0.35), 0 3px 0 #160b08;
  cursor: pointer;
}

.end-turn-button.ready {
  border-color: #e0b86a;
  box-shadow: inset 0 1px rgba(255,255,255,0.15), inset 0 -3px rgba(0,0,0,0.35), 0 3px 0 #160b08, 0 0 10px rgba(220,160,66,0.24);
  animation: none;
}

.end-turn-button span,
.end-turn-button small {
  display: block;
}

.end-turn-button span {
  font-weight: 800;
}

.end-turn-button small {
  margin-top: 1px;
  color: #ab9578;
  font-size: 8px;
}

.bottom-dock {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: min(100%, 620px);
  height: calc(66px + env(safe-area-inset-bottom));
  margin: auto;
  padding-bottom: env(safe-area-inset-bottom);
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid #77603a;
  background: linear-gradient(#202720, #0b0f0c 76%);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.5);
}

.dock-button {
  position: relative;
  border: 0;
  border-right: 1px solid rgba(213,180,110,0.09);
  color: #867e6c;
  background: transparent;
  cursor: pointer;
}

.dock-button i,
.dock-button span {
  display: block;
}

.dock-button i {
  width: 27px;
  height: 27px;
  margin: 4px auto 1px;
  padding-top: 4px;
  border: 1px solid #4d4b40;
  transform: rotate(45deg);
  font-size: 12px;
  font-style: normal;
}

.dock-button i::first-letter {
  transform: rotate(-45deg);
}

.dock-button span {
  font-size: 9px;
}

.dock-button.active {
  color: var(--gold-bright);
  background: radial-gradient(circle at 50% 10%, rgba(210,164,77,0.2), transparent 65%);
}

.dock-button.active i {
  border-color: #c69e53;
  background: #3a2b1b;
  box-shadow: 0 0 10px rgba(217,169,79,0.22);
}

.dock-button em {
  position: absolute;
  top: 4px;
  right: 18%;
  min-width: 16px;
  padding: 1px 4px;
  border-radius: 8px;
  color: white;
  background: var(--red);
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 8px;
  font-style: normal;
}

.map-stage[data-city-density="high"] .city-node {
  grid-template-columns: 27px auto;
  min-width: 54px;
  min-height: 34px;
  padding: 2px 4px 2px 2px;
  column-gap: 3px;
}

.map-stage[data-city-density="high"] .city-banner {
  width: 25px;
  height: 28px;
  font-size: 13px;
}

.map-stage[data-city-density="high"] .city-node strong { font-size: 9px; }
.map-stage[data-city-density="high"] .node-troops { font-size: 7px; }

.history-progress {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(175, 142, 78, .48);
  background: linear-gradient(145deg, rgba(64, 46, 25, .42), rgba(13, 18, 15, .84));
  box-shadow: inset 0 1px rgba(255, 235, 184, .08);
}

.history-progress-heading {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.history-progress-heading h3,
.history-progress-heading p,
.history-progress-heading strong,
.history-progress-heading small { margin: 0; }
.history-progress-heading h3 { color: #ead29b; font-size: 14px; }
.history-progress-heading p,
.history-progress-heading small { color: #9d9583; font-size: 9px; line-height: 1.45; }
.history-progress-heading strong { color: #e8bd62; font-size: 12px; text-align: right; }
.history-progress-heading small { grid-column: 3; text-align: right; }

.history-timeline { display: grid; gap: 7px; }
.history-timeline-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 3px 8px;
  padding: 8px 9px;
  border-left: 2px solid #6d6452;
  background: rgba(0, 0, 0, .2);
}
.history-timeline-item.is-current { border-left-color: #e2b85d; background: rgba(195, 133, 43, .11); }
.history-timeline-item.is-future { border-left-color: #718a79; }
.history-timeline-item time,
.history-timeline-item span { color: #9c927e; font-size: 9px; }
.history-timeline-item strong { color: #d9c79e; font-size: 11px; }
.history-timeline-item p,
.history-timeline-item small,
.history-timeline-item em { grid-column: 1 / -1; margin: 0; font-size: 9px; line-height: 1.45; }
.history-timeline-item p { color: #aaa18d; }
.history-timeline-item small { color: #777265; }
.history-timeline-item em { color: #d98d63; font-style: normal; }
.history-divergences { padding: 8px 10px; border: 1px dashed rgba(205, 137, 83, .46); }
.history-divergences h3,
.history-divergences p { margin: 0; }
.history-divergences h3 { margin-bottom: 4px; color: #d98d63; font-size: 11px; }
.history-divergences p { color: #a99b83; font-size: 9px; line-height: 1.55; }
.history-source-note { margin: 0; color: #766f61; font-size: 8px; line-height: 1.45; }

@media (max-width: 420px) {
  .history-progress-heading { grid-template-columns: 30px minmax(0, 1fr); }
  .history-progress-heading strong,
  .history-progress-heading small { grid-column: 2; text-align: left; }
}

.sheet,
.modal,
.tutorial,
.ending {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  width: min(100%, 620px);
  margin: auto;
}

.sheet {
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(3,5,4,0.72);
  backdrop-filter: blur(3px);
}

.sheet-card {
  position: relative;
  z-index: 1;
  max-height: min(76svh, 720px);
  overflow: hidden;
  border: 1px solid #80643c;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background:
    linear-gradient(135deg, rgba(221,185,113,0.04) 25%, transparent 25%) 0 0 / 18px 18px,
    #161d18;
  box-shadow: 0 -20px 45px rgba(0,0,0,0.68);
  animation: sheet-rise 0.24s ease-out;
}

.sheet-card > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 62px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(220,185,113,0.18);
  background: linear-gradient(90deg, #3b3021, #1b211b);
}

.sheet-card header span {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.17em;
}

.sheet-card h2 {
  margin: 3px 0 0;
  color: #f0dfb6;
  font-size: 21px;
}

.close-button {
  width: 34px;
  height: 34px;
  border: 1px solid #776545;
  border-radius: 50%;
  color: #d7c295;
  background: #1b211b;
  font-size: 22px;
}

.sheet-content {
  max-height: calc(76svh - 62px);
  padding: 12px 13px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.sheet-intro {
  margin: 0 0 12px;
  padding: 9px 10px;
  border-left: 2px solid var(--gold);
  color: #aca38f;
  background: rgba(255,255,255,0.025);
  font-size: 11px;
  line-height: 1.6;
}

.recruit-options {
  display: grid;
  gap: 9px;
}

.recruit-choice {
  display: flex;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid #5e5848;
  color: #e4d5b5;
  background: linear-gradient(#2d352c, #171c18);
  box-shadow: inset 0 1px rgba(255,255,255,0.07), 0 3px 0 #090b09;
}

.recruit-choice small {
  color: #b89e6d;
}

.general-list,
.city-list,
.report-list,
.diplomacy-list {
  display: grid;
  gap: 8px;
}

.group-title {
  margin: 12px 0 7px;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.general-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 9px;
  align-items: center;
  min-height: 70px;
  padding: 8px;
  border: 1px solid rgba(211,179,108,0.18);
  background: rgba(255,255,255,0.025);
}

.general-face {
  width: 56px;
  height: 56px;
  border: 1px solid #79623c;
  border-radius: 3px;
  background-color: #283128;
}

.general-card h3,
.general-card p,
.general-card small {
  margin: 0;
}

.general-card h3 {
  color: #eadab7;
  font-size: 14px;
}

.general-card p {
  margin-top: 3px;
  color: #b2a993;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 9px;
}

.general-card small {
  display: block;
  margin-top: 4px;
  color: #817d70;
  font-size: 9px;
  line-height: 1.35;
}
.appointment-card {
  grid-template-columns: 56px minmax(0, 1fr) minmax(190px, 0.72fr);
}

.appointment-card.unavailable {
  border-color: rgba(148, 83, 66, 0.42);
  background: rgba(78, 35, 27, 0.12);
}

.appointment-card.unavailable .general-face,
.appointment-card.unavailable > div:not(.appointment-controls) {
  filter: saturate(0.45);
  opacity: 0.68;
}

.appointment-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, auto);
  gap: 7px;
  align-items: stretch;
  min-width: 0;
}

.appointment-controls button {
  min-height: 40px;
  padding: 6px 10px;
}

.appointment-controls .appointment-status,
.general-admin-panel > .appointment-status {
  grid-column: 1 / -1;
  margin: 0;
  color: #b9aa87;
  font-size: 9px;
  line-height: 1.45;
}

.appointment-permission-card {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.appointment-permission-card p,
.appointment-permission-card small {
  margin: 0;
}


.general-card > button,
.inline-actions button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #88643d;
  color: #e7c98c;
  background: linear-gradient(#563621, #2d1b14);
  box-shadow: 0 2px 0 #110907;
}

.city-list-item {
  --owner: var(--neutral);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 57px;
  padding: 9px 12px;
  border: 1px solid rgba(156, 137, 98, 0.55);
  border-color: color-mix(in srgb, var(--owner), transparent 45%);
  border-left: 4px solid var(--owner);
  color: #e3d5b7;
  background: linear-gradient(90deg, color-mix(in srgb, var(--owner), transparent 88%), rgba(255,255,255,0.018));
  text-align: left;
}

.city-list-item.owner-ember { --owner: var(--ember); }
.city-list-item.owner-north { --owner: var(--north); }
.city-list-item.owner-river { --owner: var(--river); }
.city-list-item.owner-neutral { --owner: var(--neutral); }

.city-list-item div strong,
.city-list-item div small {
  display: block;
}

.city-list-item div strong {
  font-size: 15px;
}

.city-list-item div small,
.city-list-item > span {
  margin-top: 3px;
  color: #928b79;
  font-size: 9px;
}

.diplomacy-card {
  --owner: var(--neutral);
  padding: 12px;
  border: 1px solid rgba(156, 137, 98, 0.54);
  border-color: color-mix(in srgb, var(--owner), transparent 46%);
  background: linear-gradient(140deg, color-mix(in srgb, var(--owner), transparent 88%), rgba(255,255,255,0.018));
}

.diplomacy-card.owner-north { --owner: var(--north); }
.diplomacy-card.owner-river { --owner: var(--river); }

.diplomacy-card header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.faction-sigil {
  display: grid;
  width: 42px;
  height: 42px;
  flex: none;
  place-items: center;
  border: 1px solid rgba(222, 200, 151, 0.55);
  border-color: color-mix(in srgb, var(--owner), white 30%);
  color: #fff1d0;
  background: var(--owner);
  font-size: 18px;
  font-weight: 800;
  clip-path: polygon(0 0,100% 0,100% 80%,50% 100%,0 80%);
}

.diplomacy-card h3,
.diplomacy-card p {
  margin: 0;
}

.diplomacy-card h3 {
  color: #e9d8b4;
}

.diplomacy-card header p {
  margin-top: 3px;
  color: #918b7a;
  font-size: 9px;
}

.relation-meter {
  height: 5px;
  margin-top: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
}

.relation-meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #a84233, #d1ad5d, #6baa82);
}

.relation-copy {
  margin-top: 6px !important;
  color: #b9ae95;
  font-size: 10px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-actions button {
  flex: 1;
}

.report-item {
  padding: 10px 12px;
  border-left: 3px solid #746c59;
  background: rgba(255,255,255,0.025);
}

.report-item.tone-good,
.report-item.tone-reward { border-color: var(--good); }
.report-item.tone-bad { border-color: var(--bad); }
.report-item.tone-world { border-color: var(--north); }
.report-item.tone-turn { border-color: var(--gold); }

.report-turn {
  color: #777568;
  font-size: 8px;
}

.report-item h3 {
  margin: 3px 0 2px;
  color: #dfcfac;
  font-size: 13px;
}

.report-item p {
  margin: 0;
  color: #9f9887;
  font-size: 10px;
  line-height: 1.5;
}

.realm-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.realm-card {
  --owner: var(--neutral);
  display: grid;
  grid-template-columns: 42px 1fr;
  padding: 10px;
  border: 1px solid rgba(156, 137, 98, 0.52);
  border-color: color-mix(in srgb, var(--owner), transparent 48%);
  background: color-mix(in srgb, var(--owner), transparent 90%);
}

.realm-card.owner-ember { --owner: var(--ember); }
.realm-card.owner-north { --owner: var(--north); }
.realm-card.owner-river { --owner: var(--river); }
.realm-card.owner-neutral { --owner: var(--neutral); }

.realm-card .faction-sigil {
  grid-row: 1 / 5;
  margin-right: 8px;
}

.realm-card h3,
.realm-card strong,
.realm-card p,
.realm-card small {
  margin: 0;
}

.realm-card h3 {
  font-size: 13px;
}

.realm-card strong {
  color: #e8c77e;
  font-size: 18px;
}

.realm-card p,
.realm-card small {
  color: #918a79;
  font-size: 9px;
}

.realm-target {
  margin: 14px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  color: #e3c987;
  background: rgba(198,145,62,0.07);
  text-align: center;
}

.modal,
.tutorial,
.ending {
  place-items: center;
  padding: 18px;
  background: rgba(3,5,4,0.78);
  backdrop-filter: blur(6px);
}

.modal-card,
.tutorial-card,
.ending-card {
  width: min(100%, 440px);
  border: 1px solid #80633a;
  border-top: 3px solid var(--gold);
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(219,182,107,0.045) 25%, transparent 25%) 0 0 / 18px 18px,
    #182019;
  box-shadow: 0 22px 60px rgba(0,0,0,0.7);
}

.modal-card {
  padding: 18px;
}

.modal-card header span {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.modal-card h2 {
  margin: 4px 0 14px;
  color: #f0dfb8;
}

.modal-card label {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: #ada590;
  font-size: 10px;
}

.modal-card select {
  width: 100%;
  min-height: 41px;
  padding: 6px 10px;
  border: 1px solid #5f5948;
  border-radius: 2px;
  color: #e6d7b7;
  background: #111712;
}

.range-label > span {
  display: flex;
  justify-content: space-between;
}

.range-label strong {
  color: var(--gold-bright);
  font-family: "Microsoft YaHei", sans-serif;
}

.range-label input {
  width: 100%;
  accent-color: var(--red-bright);
}

.battle-preview {
  min-height: 58px;
  margin-top: 13px;
  padding: 10px;
  border: 1px solid #5a5548;
  color: #afa690;
  background: rgba(0,0,0,0.22);
  font-size: 10px;
  line-height: 1.55;
}

.battle-preview.safe { border-color: rgba(107,176,130,0.5); }
.battle-preview.danger { border-color: rgba(211,93,73,0.57); color: #deb1a6; }
.battle-preview.unknown { border-color: rgba(210,171,92,0.46); }

.modal-actions,
.tutorial-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 9px;
  margin-top: 14px;
}

.notice {
  position: fixed;
  z-index: 80;
  right: max(12px, calc((100vw - 620px) / 2 + 12px));
  bottom: calc(78px + env(safe-area-inset-bottom));
  display: grid;
  width: min(calc(100vw - 24px), 450px);
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid #80643d;
  border-left: 4px solid var(--gold);
  border-radius: 4px;
  background: rgba(17,23,18,0.97);
  box-shadow: 0 14px 38px rgba(0,0,0,0.65);
  animation: notice-in 0.22s ease-out;
}

.notice.tone-good,
.notice.tone-reward { border-left-color: var(--good); }
.notice.tone-bad { border-left-color: var(--bad); }

.notice-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #8f7140;
  color: #efcc81;
  background: #2d2519;
  font-size: 20px;
  font-weight: 800;
  clip-path: polygon(0 0,100% 0,100% 78%,50% 100%,0 78%);
}

.notice.has-speaker { grid-template-columns: 62px minmax(0, 1fr) auto; }
.notice-speaker,
.report-toast-speaker {
  position: relative;
  align-self: stretch;
  min-height: 60px;
  overflow: visible;
}
.notice-speaker[hidden],
.report-toast-speaker[hidden] { display: none; }
.notice-speaker-face,
.report-toast-speaker-face {
  position: absolute;
  inset: 0 7px 13px 0;
  border: 1px solid rgba(210, 169, 84, .56);
  border-radius: 3px 12px 3px 3px;
  background-color: #20251e;
  background-repeat: no-repeat;
  box-shadow: inset 0 -12px 18px rgba(0, 0, 0, .5), 0 5px 12px rgba(0, 0, 0, .28);
}
.notice-speaker small,
.report-toast-speaker small {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  overflow: hidden;
  color: #e2c77f;
  font: 700 8px/12px var(--font-display);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.speaker-gesture {
  position: absolute;
  z-index: 3;
  top: 22px;
  right: -2px;
  width: 17px;
  height: 7px;
  border: 2px solid #d7ad69;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #6d3c2b;
  box-shadow: 0 1px 0 rgba(255,255,255,.2);
  transform: rotate(-24deg);
  transform-origin: left center;
  animation: speakerWave 1.15s ease-in-out infinite;
}
.speaker-gesture::after {
  position: absolute;
  top: -4px;
  right: -5px;
  width: 8px;
  height: 11px;
  border: 2px solid #d7ad69;
  border-radius: 60% 55% 48% 62%;
  background: #a96845;
  content: '';
}
@keyframes speakerWave {
  0%, 100% { transform: rotate(-24deg); }
  45% { transform: rotate(18deg); }
}

.notice strong,
.notice p,
.notice small {
  display: block;
  margin: 0;
}

.notice strong {
  color: #ead9b4;
  font-size: 13px;
}

.notice p {
  margin-top: 3px;
  color: #aaa18e;
  font-size: 10px;
  line-height: 1.45;
}

.notice small {
  margin-top: 4px;
  color: #c7a96f;
  font-size: 9px;
}

.notice button {
  align-self: stretch;
  padding: 5px 9px;
  border: 1px solid #655a44;
  color: #cdb98c;
  background: #272b23;
  font-size: 10px;
}

.tutorial-card,
.ending-card {
  padding: 21px;
  text-align: center;
}

.tutorial-step {
  color: var(--gold);
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.tutorial-card h2,
.ending-card h2 {
  margin: 8px 0;
  color: #f1dfb7;
  font-size: 24px;
}

.tutorial-card > p,
.ending-card > p {
  margin: 0;
  color: #aea691;
  font-size: 12px;
  line-height: 1.75;
}

.tutorial-visual {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 18px 0;
}

.tutorial-visual span {
  padding: 8px 10px;
  border: 1px solid #685c42;
  color: #d7bc83;
  background: rgba(255,255,255,0.025);
  font-size: 10px;
}

.text-button {
  min-height: 40px;
  border: 0;
  color: #8f8878;
  background: transparent;
}

.ending-seal {
  display: grid;
  width: 67px;
  height: 67px;
  margin: auto;
  place-items: center;
  border: 2px solid var(--gold);
  color: #efd28c;
  font-size: 34px;
  box-shadow: inset 0 0 0 5px #182019, inset 0 0 0 6px rgba(217,175,84,0.55);
  transform: rotate(-3deg);
}

.ending.defeat .ending-seal {
  border-color: var(--bad);
  color: #e89078;
}

.ending-card > #ending-kicker {
  margin-top: 13px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.ending-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 18px 0;
}

.ending-stats div {
  padding: 10px 4px;
  border: 1px solid rgba(211,179,108,0.18);
  background: rgba(255,255,255,0.025);
}

.ending-stats strong,
.ending-stats span {
  display: block;
}

.ending-stats strong {
  color: #efcf88;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

.ending-stats span {
  margin-top: 3px;
  color: #8d8778;
  font-size: 8px;
}

.ending-card > button {
  width: 100%;
  margin-top: 9px;
}

.map-stage.is-resolving .map-art {
  animation: none;
}

.map-stage.is-resolving::after {
  display: none;
  content: none;
}

@keyframes seal-breathe {
  50% { transform: rotate(2deg) scale(1.04); filter: brightness(1.18); }
}


@keyframes route-pulse {
  50% { stroke: #fff0bd; filter: drop-shadow(0 0 4px #d49b48); }
}

@keyframes frontier-alert {
  to { inset: -13px; opacity: 0; }
}

@keyframes button-glow {
  50% { border-color: #e0b86a; box-shadow: inset 0 1px rgba(255,255,255,0.15), 0 0 15px rgba(220,160,66,0.3); }
}

@keyframes sheet-rise {
  from { transform: translateY(28px); opacity: 0; }
}

@keyframes notice-in {
  from { transform: translateY(14px); opacity: 0; }
}

@keyframes battle-shake {
  20% { transform: scale(1.025) translateX(-4px); filter: saturate(0.9) contrast(1.16) brightness(1); }
  40% { transform: scale(1.025) translateX(4px); }
  60% { transform: scale(1.025) translateX(-2px); }
}

@keyframes battle-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (max-width: 620px), (orientation: portrait) {
  .appointment-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .appointment-card .general-face {
    width: 48px;
    height: 48px;
  }
  .appointment-controls {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(108px, auto);
  }
}

@media (min-width: 621px) {
  .notice {
    right: calc((100vw - 620px) / 2 + 12px);
  }
}

@media (max-width: 380px) {
  .home-screen {
    padding-right: 12px;
    padding-left: 12px;
  }

  .map-stage {
    min-height: 440px;
    height: 58svh;
  }

  .city-node {
    grid-template-columns: 27px auto;
    min-width: 54px;
    padding-right: 4px;
  }

  .city-banner {
    width: 25px;
    height: 29px;
    font-size: 13px;
  }

  .city-node strong {
    font-size: 9px;
  }

  .node-troops {
    font-size: 7px;
  }

  .objective-card {
    width: 61%;
  }

  .command-grid {
    gap: 5px;
  }

  .general-card {
    grid-template-columns: 48px 1fr auto;
  }

  .general-face {
    width: 48px;
    height: 48px;
  }

  .realm-grid {
    grid-template-columns: 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;
  }
}

/* Opening key art and adaptive orientation */
.opening-screen {
  position: relative;
  height: 100svh;
  min-height: 580px;
  overflow: hidden;
  isolation: isolate;
  background: #101713;
}

.opening-art {
  position: absolute;
  z-index: -3;
  inset: 0;
  background: url("./assets/art/opening-hero-v1.webp") center 42% / cover no-repeat;
  filter: saturate(0.92) contrast(1.06) brightness(0.82);
  animation: opening-breathe 12s ease-in-out infinite alternate;
}

.opening-shade {
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7,10,8,0.72), transparent 26%, transparent 58%, rgba(6,9,7,0.92) 91%),
    linear-gradient(90deg, rgba(9,13,10,0.48), transparent 55%);
}

.opening-brand {
  position: absolute;
  top: calc(7svh + env(safe-area-inset-top));
  left: 0;
  width: 100%;
  padding: 0 22px;
  text-align: center;
  text-shadow: 0 4px 15px #000;
}

.opening-brand p {
  margin: 0;
  color: #e0bb6c;
  font-size: 11px;
  letter-spacing: 0.25em;
}

.opening-brand h1 {
  margin: 8px 0 5px;
  color: #f6da88;
  font-size: clamp(50px, 15vw, 78px);
  line-height: 1;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  text-shadow:
    0 2px 0 #7b451e,
    0 5px 0 #3c210f,
    0 10px 24px rgba(0,0,0,0.85),
    0 0 22px rgba(232,178,69,0.28);
}

.opening-brand span {
  color: #ddd0b0;
  font-size: 11px;
  letter-spacing: 0.16em;
}

.opening-calligraphy {
  position: absolute;
  top: 29%;
  left: 7%;
  display: flex;
  gap: 7px;
  color: rgba(242,226,188,0.86);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 17px;
  letter-spacing: 0.18em;
  text-shadow: 0 2px 8px #000;
  writing-mode: vertical-rl;
}

.opening-calligraphy span {
  padding: 9px 5px;
  border-left: 1px solid rgba(224,190,112,0.4);
  background: linear-gradient(180deg, rgba(10,14,11,0.7), transparent);
}

.opening-copy {
  position: absolute;
  right: 18px;
  bottom: calc(150px + env(safe-area-inset-bottom));
  left: 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, rgba(8,12,9,0.88), rgba(8,12,9,0.24));
  text-shadow: 0 2px 7px #000;
}

.opening-copy span {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.opening-copy h2 {
  margin: 4px 0;
  color: #f0dfb8;
  font-size: 18px;
}

.opening-copy p {
  margin: 0;
  color: #b9ae95;
  font-size: 10px;
}

.opening-actions {
  position: absolute;
  right: 18px;
  bottom: calc(47px + env(safe-area-inset-bottom));
  left: 18px;
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.opening-actions #enter-button {
  grid-column: 1 / -1;
}

.opening-note {
  position: absolute;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 0;
  margin: 0;
  color: rgba(219,207,179,0.62);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-align: center;
}

.ruler-portrait {
  aspect-ratio: 1;
}

/* Mobile commander intelligence card */
.general-roster-strip {
  display: flex;
  gap: 8px;
  margin: -2px -2px 12px;
  padding: 2px 2px 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #7c633c transparent;
}

.general-thumb {
  width: 72px;
  flex: 0 0 72px;
  padding: 5px 4px 7px;
  border: 1px solid #4d4b40;
  color: #b9ae94;
  background: linear-gradient(#2c342c, #151a16);
}

.general-thumb.selected {
  border-color: var(--gold-bright);
  color: #f1dba8;
  box-shadow: 0 0 0 2px rgba(221,178,86,0.13);
}

.general-thumb > span {
  display: block;
  width: 60px;
  height: 60px;
  margin: auto;
  border: 1px solid rgba(218,184,111,0.3);
  background-repeat: no-repeat;
  background-size: 200% 200%;
}

.general-thumb strong,
.general-thumb small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.general-thumb small {
  margin-top: 1px;
  color: #817c6e;
  font-size: 8px;
}

.general-detail-card {
  overflow: hidden;
  border: 1px solid #75613f;
  border-top: 2px solid var(--gold);
  background:
    radial-gradient(circle at 18% 10%, rgba(133,101,53,0.16), transparent 30%),
    linear-gradient(145deg, #252b25, #111612);
  box-shadow: inset 0 1px rgba(255,255,255,0.05), 0 12px 28px rgba(0,0,0,0.35);
}

.general-detail-main {
  display: grid;
  grid-template-columns: minmax(116px, 38%) 1fr;
  min-height: 158px;
  border-bottom: 1px solid rgba(215,181,109,0.18);
}

.general-large-face {
  width: 100%;
  aspect-ratio: 1;
  align-self: end;
  border-right: 1px solid rgba(215,181,109,0.22);
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-color: #262d27;
  box-shadow: inset 0 -24px 30px rgba(0,0,0,0.38);
}

.general-identity {
  align-self: center;
  padding: 13px 12px;
}

.general-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.general-badges span {
  padding: 3px 6px;
  border: 1px solid #5c594d;
  color: #afa58f;
  font-size: 8px;
}

.general-badges span.ember {
  border-color: #a85d39;
  color: #e38b5c;
}

.general-badges span.wander {
  border-color: #82795f;
  color: #c5b999;
}

.general-badges span.captive {
  border-color: #9f5042;
  color: #ef9c86;
  background: rgba(112, 43, 34, 0.18);
}

.general-identity h3 {
  margin: 8px 0 2px;
  color: #f2dfb5;
  font-size: 27px;
  letter-spacing: 0.08em;
}

.general-identity > p {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
}

.general-identity > small {
  display: block;
  margin-top: 9px;
  color: #a39b89;
  font-size: 10px;
  line-height: 1.55;
}

.general-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  padding: 10px;
  background: rgba(0,0,0,0.17);
}

.general-stat-grid > div {
  padding: 6px 5px;
  border-right: 1px solid rgba(216,181,109,0.1);
}

.general-stat-grid span,
.general-stat-grid strong {
  display: block;
  text-align: center;
}

.general-stat-grid span {
  color: #928b7b;
  font-size: 8px;
}

.general-stat-grid strong {
  margin-top: 2px;
  color: #ecd08d;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

.general-stat-grid i {
  display: block;
  height: 3px;
  margin-top: 5px;
  overflow: hidden;
  background: rgba(255,255,255,0.07);
}

.general-stat-grid i b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7c4b2e, #e0b85f);
}

.general-trait-banner {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
  margin: 0 10px;
  padding: 9px 10px;
  border: 1px solid rgba(207,169,91,0.2);
  background: rgba(126,68,38,0.12);
}

.general-trait-banner span {
  padding: 4px 6px;
  color: #f0d18d;
  background: #7a3c29;
  font-size: 8px;
}

.general-trait-banner strong {
  color: #e5c881;
  font-size: 11px;
}

.general-trait-banner p {
  margin: 0;
  color: #9d9583;
  font-size: 9px;
}

.ability-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
}

.ability-tags span {
  padding: 5px 10px;
  border: 1px solid #444941;
  color: #686e66;
  background: #171c18;
  font-size: 9px;
}

.ability-tags span.active {
  border-color: #39749a;
  color: #b6d9ed;
  background: linear-gradient(#245d7e, #183d53);
  box-shadow: inset 0 1px rgba(255,255,255,0.14);
}

.general-detail-card > button {
  width: calc(100% - 20px);
  margin: 0 10px 12px;
}

/* Orientation hand-off */
.orientation-gate {
  position: fixed;
  z-index: 96;
  inset: 0;
  display: grid;
  width: min(100%, 620px);
  margin: auto;
  padding: 28px;
  place-content: center;
  justify-items: center;
  color: #e7d7b5;
  background:
    radial-gradient(circle at center, rgba(88,70,41,0.32), transparent 35%),
    rgba(8,12,9,0.97);
  text-align: center;
}

.device-rotate {
  position: relative;
  width: 96px;
  height: 84px;
  margin-bottom: 12px;
}

.device-rotate i {
  position: absolute;
  top: 9px;
  left: 28px;
  width: 42px;
  height: 70px;
  border: 3px solid #dfbc70;
  border-radius: 7px;
  box-shadow: inset 0 0 0 3px #101610, 0 0 18px rgba(218,177,86,0.22);
  animation: rotate-device 2.2s ease-in-out infinite;
}

.device-rotate span {
  position: absolute;
  right: 1px;
  bottom: 1px;
  color: #d76943;
  font-size: 34px;
}

.orientation-gate > p {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.orientation-gate h2 {
  margin: 7px 0;
  color: #f1dfb6;
  font-size: 25px;
}

.orientation-gate > small {
  max-width: 360px;
  color: #9e9785;
  font-size: 11px;
  line-height: 1.7;
}

.orientation-gate > button {
  width: min(100%, 320px);
  margin-top: 14px;
}

.orientation-gate .text-button {
  margin-top: 5px;
}

/* Landscape-first strategy layout */
@media (orientation: landscape) and (min-width: 650px) {
  body.in-game {
    overflow: hidden;
  }

  body.in-game .app-shell {
    width: 100%;
    max-width: 1280px;
    height: 100svh;
    min-height: 0;
  }

  .game-screen {
    display: grid;
    height: 100svh;
    min-height: 0;
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr) minmax(300px, 35%);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .top-hud,
  .resource-strip {
    grid-column: 1 / -1;
  }

  .top-hud {
    grid-row: 1;
    min-height: calc(52px + env(safe-area-inset-top));
    padding-top: calc(5px + env(safe-area-inset-top));
    padding-bottom: 5px;
  }

  .resource-strip {
    grid-row: 2;
  }

  .resource-strip > div {
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .map-stage {
    grid-row: 3 / 5;
    grid-column: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    border-right: 2px solid #665033;
    border-bottom: 0;
  }

  .map-art {
    background-position: center 48%;
  }

  .city-command {
    grid-row: 3;
    grid-column: 2;
    min-height: 0;
    overflow-y: auto;
    border-top: 0;
  }

  .turn-console {
    grid-row: 4;
    grid-column: 2;
  }

  .command-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .bottom-dock {
    width: 100%;
    max-width: 1280px;
    height: calc(58px + env(safe-area-inset-bottom));
  }

  .dock-button i {
    width: 24px;
    height: 24px;
    margin-top: 3px;
    padding-top: 3px;
  }

  .objective-card {
    width: min(42%, 260px);
  }

  .city-node {
    min-width: 58px;
  }

  .sheet {
    width: 100%;
    max-width: 1280px;
    align-items: stretch;
    justify-items: end;
  }

  .sheet-card {
    width: min(460px, 46vw);
    max-height: none;
    height: calc(100svh - 58px - env(safe-area-inset-bottom));
    margin-bottom: calc(58px + env(safe-area-inset-bottom));
    border: 1px solid #80643c;
    border-right: 0;
    border-radius: 12px 0 0 12px;
    animation-name: sheet-slide;
  }

  .sheet-content {
    max-height: calc(100svh - 120px - env(safe-area-inset-bottom));
  }

  .modal,
  .tutorial,
  .ending,
  .orientation-gate {
    width: 100%;
    max-width: 1280px;
  }

  .notice {
    right: max(12px, calc((100vw - 1280px) / 2 + 12px));
    bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .opening-brand {
    top: calc(6svh + env(safe-area-inset-top));
    width: 55%;
    text-align: left;
  }

  .opening-brand h1 {
    font-size: clamp(44px, 8vw, 72px);
    text-indent: 0;
  }

  .opening-art {
    background-image: url("./assets/art/opening-hero-landscape-v1.webp");
    background-position: center 46%;
  }

  .opening-calligraphy {
    top: 30%;
    left: 5%;
  }

  .opening-copy {
    right: 4%;
    bottom: calc(102px + env(safe-area-inset-bottom));
    left: auto;
    width: min(43%, 470px);
  }

  .opening-actions {
    right: 4%;
    bottom: calc(34px + env(safe-area-inset-bottom));
    left: auto;
    width: min(43%, 470px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .opening-actions #enter-button {
    grid-column: auto;
  }

  .opening-note {
    display: none;
  }
}

@keyframes opening-breathe {
  from { transform: scale(1.015); }
  to { transform: scale(1.055); }
}

@keyframes rotate-device {
  0%, 25% { transform: rotate(0deg); }
  65%, 100% { transform: rotate(90deg); }
}

@keyframes sheet-slide {
  from { transform: translateX(40px); opacity: 0; }
}

/* Historical biographies, personal missions and fate choices v38 */
.campaign-history-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.history-mode-group .campaign-option small { line-height: 1.35; }
.general-history-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(175, 133, 72, .48);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(47, 31, 19, .92), rgba(24, 19, 14, .96));
  box-shadow: inset 0 0 20px rgba(211, 163, 84, .06);
}
.general-history-heading { display: flex; align-items: center; gap: 10px; }
.general-history-heading > div { display: grid; gap: 2px; min-width: 0; }
.general-history-heading small, .history-source-line { color: #b9a98d; }
.history-seal {
  display: grid; place-items: center; flex: 0 0 34px; height: 34px;
  border: 1px solid #ad7a42; border-radius: 50%; color: #e8c784; background: #4d241c;
  font-family: serif; font-size: 20px;
}
.general-biography { margin: 0; color: #e1d4bc; line-height: 1.65; }
.personal-mission-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.personal-mission-card { display: grid; align-content: start; gap: 5px; min-width: 0; padding: 9px; border: 1px solid rgba(132, 105, 68, .48); border-radius: 8px; background: rgba(15, 13, 11, .48); }
.personal-mission-card p { margin: 0; color: #cbbda6; font-size: 12px; line-height: 1.45; }
.personal-mission-card small { color: #9d917e; }
.personal-mission-card.status-completed { border-color: rgba(192, 151, 73, .8); background: rgba(91, 59, 24, .25); }
.personal-mission-card.claimed { opacity: .68; }
.fate-choice-panel { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding-top: 10px; border-top: 1px solid rgba(172, 126, 65, .35); }
.fate-choice-panel p { margin: 0; color: #cdbfa8; font-size: 12px; }

@media (orientation: portrait), (max-width: 560px) {
  .campaign-history-options, .personal-mission-list { grid-template-columns: 1fr; }
  .fate-choice-panel { grid-template-columns: 1fr 1fr; }
  .fate-choice-panel strong, .fate-choice-panel p { grid-column: 1 / -1; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .general-history-panel { padding: 9px; gap: 7px; }
  .personal-mission-card { padding: 7px; }
}
