:root {
  color-scheme: dark;
  --bg: #111314;
  --panel: #1b2020;
  --panel-2: #232929;
  --line: #3b4442;
  --text: #e7e1d2;
  --muted: #aaa493;
  --accent: #d0b35f;
  --danger: #d6674f;
  --good: #7aa874;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "Noto Sans SC",
    system-ui,
    sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 1px solid #4b5452;
  background: #2a302f;
  color: var(--text);
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

button:hover {
  background: #343c3a;
  border-color: #707a76;
}

button:active {
  transform: translateY(1px);
}

.shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.status-strip,
.map-panel,
.side-panel {
  border: 1px solid var(--line);
  background: rgba(27, 32, 32, 0.94);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 16px;
}

.identity h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.identity p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.setup,
.time-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.setup label {
  color: var(--muted);
  font-size: 13px;
}

select {
  min-width: 150px;
  border: 1px solid #4b5452;
  background: #141716;
  color: var(--text);
  padding: 8px 10px;
}

.topbar button,
.command-grid button {
  min-height: 36px;
  border-radius: 6px;
  padding: 7px 12px;
}

.speed-button.active,
#startGame {
  border-color: #b89d50;
  background: #5e4d23;
}

#dateLabel {
  min-width: 82px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
}

.faction-card {
  border-left: 5px solid var(--faction-color);
  background: #151918;
  padding: 10px;
  min-height: 82px;
}

.faction-card.active {
  outline: 2px solid rgba(208, 179, 95, 0.75);
}

.faction-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.faction-card dl,
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.faction-card dt,
.metrics dt {
  color: #7f8985;
}

.faction-card dd,
.metrics dd {
  margin: 0;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.front-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.front-list:empty {
  display: none;
}

.front-choice {
  min-height: 32px;
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
  text-align: center;
}

.front-choice.is-selected {
  border-color: #d0b35f;
  background: #5e4d23;
}

.risk-good {
  color: var(--good);
}

.risk-watch {
  color: var(--accent);
}

.risk-bad {
  color: var(--danger);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 350px;
  gap: 14px;
  margin-top: 14px;
}

.map-panel {
  position: relative;
  overflow: auto;
  min-height: 650px;
  padding: 10px;
}

#mapSvg {
  display: block;
  width: 100%;
  min-width: 820px;
  height: auto;
  background:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    #171b1a;
  background-size: 40px 40px;
}

.province rect {
  stroke: rgba(236, 230, 210, 0.44);
  stroke-width: 1.4;
  transition:
    filter 150ms ease,
    stroke-width 150ms ease,
    opacity 150ms ease;
}

.province:hover rect {
  filter: brightness(1.15);
  stroke-width: 2.4;
}

.province.selected rect {
  stroke: #fff0ac;
  stroke-width: 3;
}

.province text {
  pointer-events: none;
  fill: #f5eedc;
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.62);
  stroke-width: 3px;
}

.province .stat {
  font-size: 10px;
  font-weight: 500;
  fill: #d9d2c1;
}

.front-line {
  stroke: #e6d06f;
  stroke-linecap: round;
  stroke-width: 4;
  opacity: 0.76;
  pointer-events: none;
}

.front-line.hot {
  stroke: var(--danger);
  stroke-width: 6;
  opacity: 0.95;
}

.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 650px;
  max-height: calc(100vh - 172px);
  overflow: hidden;
}

.panel-block {
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.panel-block h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.details {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.details.empty {
  min-height: 52px;
}

.detail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.detail-title strong {
  color: var(--text);
  font-size: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #515b58;
  border-left: 5px solid var(--badge-color);
  padding: 2px 8px;
  color: var(--text);
  background: #151918;
  font-size: 12px;
}

.command-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.command-grid button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.log-block {
  min-height: 0;
  flex: 1;
  border-bottom: 0;
  display: flex;
  flex-direction: column;
}

.war-log {
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0 0 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.war-log li {
  margin-bottom: 8px;
}

@media (max-width: 1100px) {
  .topbar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .setup,
  .time-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .map-panel {
    min-height: 480px;
  }

  .side-panel {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 10px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .command-grid {
    grid-template-columns: 1fr;
  }
}
