:root {
  color-scheme: light;
  --ink: #2d281f;
  --muted: #766d5d;
  --paper: #e8d6a6;
  --paper-dark: #c8aa68;
  --panel: #f4e7c1;
  --panel-light: #fff2c9;
  --line: #8b7144;
  --line-dark: #5f4725;
  --line-light: #f8e8b8;
  --deep: #3c3326;
  --good: #3f7a54;
  --warn: #bd7d24;
  --danger: #a83f32;
  --blue: #3d6684;
  --shadow: 5px 5px 0 #5f4b2a;
  --inner-shadow: inset 3px 3px 0 rgba(255, 247, 209, 0.72), inset -3px -3px 0 rgba(123, 86, 36, 0.18);
  --pixel: "Microsoft YaHei", "Noto Sans SC", "Courier New", monospace;
  font-family: var(--pixel);
}

* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 244, 202, 0.72), transparent 42rem),
    linear-gradient(rgba(232, 214, 166, 0.92), rgba(221, 195, 134, 0.96)),
    repeating-linear-gradient(0deg, rgba(92, 72, 35, 0.11) 0 1px, transparent 1px 12px),
    repeating-linear-gradient(90deg, rgba(92, 72, 35, 0.08) 0 1px, transparent 1px 12px);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06) 50%, rgba(86, 58, 25, 0.04) 50%) 0 0 / 100% 4px,
    radial-gradient(circle at center, transparent 58%, rgba(72, 48, 22, 0.18));
  mix-blend-mode: multiply;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

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

.topbar,
.metrics-panel,
.city-map-panel,
.event-card,
.stage-panel,
.brief-console,
.operations-panel,
.news-panel,
.log-panel,
.start-copy,
.start-form,
.ending-screen,
.tutorial-card {
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow), var(--inner-shadow);
  position: relative;
}

.topbar::after,
.metrics-panel::after,
.city-map-panel::after,
.event-card::after,
.brief-console::after,
.operations-panel::after,
.news-panel::after,
.log-panel::after,
.start-copy::after,
.start-form::after,
.ending-screen::after,
.tutorial-card::after {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border: 1px solid rgba(255, 242, 190, 0.66);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background:
    linear-gradient(90deg, rgba(123, 76, 24, 0.10), transparent 38%),
    var(--panel);
}

.identity h1,
.panel-heading h2,
.map-toolbar h2,
.event-heading h2,
.start-copy h2,
.ending-screen h2,
.tutorial-card h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

.identity h1 {
  font-size: clamp(1.35rem, 3vw, 2.25rem);
  color: #2f2416;
  text-shadow: 2px 2px 0 #f7e8bd, 4px 4px 0 rgba(95, 75, 42, 0.25);
}

.eyebrow {
  margin: 0 0 5px;
  color: #7b4c18;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.day-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  color: var(--deep);
  font-size: 0.9rem;
}

.day-panel span,
.day-panel strong {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 8px;
  border: 2px solid var(--line);
  background: var(--panel-light);
  box-shadow: 2px 2px 0 #98773e;
  white-space: nowrap;
}

#fundsLabel {
  background: #f1cf78;
}

.top-actions,
.start-actions,
.tab-row {
  display: flex;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button,
.tab-button,
.small-action,
.choice-button {
  border: 3px solid var(--line);
  background: var(--panel-light);
  color: var(--ink);
  box-shadow: 3px 3px 0 #7c612f;
  font-weight: 900;
  transition: transform 80ms steps(1), box-shadow 80ms steps(1), filter 120ms steps(2);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
}

.primary-button {
  min-height: 46px;
  padding: 10px 14px;
  background: linear-gradient(#9d6826, #7b4c18);
  color: #fff4ca;
}

.secondary-button,
.tab-button,
.small-action {
  min-height: 36px;
  padding: 8px 12px;
}

.icon-button:hover,
.choice-button:hover,
.primary-button:hover,
.secondary-button:hover,
.tab-button:hover,
.small-action:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 #7c612f;
  filter: saturate(1.12);
}

.icon-button:active,
.choice-button:active,
.primary-button:active,
.secondary-button:active,
.tab-button:active,
.small-action:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 #7c612f;
}

.tab-button.active {
  background: linear-gradient(#edc568, #d4a74d);
  color: #2f2416;
}

.start-screen,
.ending-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 14px;
}

.start-copy {
  min-height: 540px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.58fr);
  column-gap: clamp(14px, 3vw, 34px);
  align-content: center;
  align-items: center;
  gap: 18px;
  overflow: hidden;
  padding: clamp(24px, 5vw, 62px);
  background:
    linear-gradient(90deg, rgba(246, 228, 181, 0.96) 0%, rgba(246, 228, 181, 0.82) 48%, rgba(246, 228, 181, 0.55) 100%),
    url("./assets/city-map.png") center / cover;
}

.start-copy > .eyebrow,
.start-copy > h2,
.start-copy > p,
.start-copy > .start-actions {
  position: relative;
  z-index: 2;
  grid-column: 1;
}

.start-copy::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 18px;
  width: 76px;
  height: 76px;
  border: 3px solid var(--line);
  background:
    linear-gradient(45deg, transparent 43%, #7b4c18 43% 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, #7b4c18 43% 57%, transparent 57%),
    #e9c26f;
  box-shadow: 4px 4px 0 #7c612f;
}

.start-copy h2 {
  max-width: 820px;
  font-size: clamp(2rem, 6vw, 4.4rem);
  padding-left: clamp(0px, 9vw, 92px);
}

.start-copy p:not(.eyebrow) {
  max-width: 720px;
  margin: 0;
  color: var(--deep);
  font-size: 1.02rem;
  line-height: 1.75;
}

.cover-mascots {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 4;
  align-self: stretch;
  z-index: 3;
  width: 100%;
  min-height: 430px;
  pointer-events: none;
}

.cover-mascot {
  position: absolute;
  bottom: 0;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform-origin: 50% 88%;
  pointer-events: auto;
}

.cover-mascot:hover,
.cover-mascot:focus-visible {
  filter: brightness(1.06) saturate(1.12);
}

.mascot-sprite {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: var(--frame-ratio);
  image-rendering: pixelated;
  filter:
    drop-shadow(6px 8px 0 rgba(65, 45, 20, 0.30))
    drop-shadow(0 0 0 #6d522a);
  transform-origin: 50% 88%;
}

.mascot-sprite::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 600%;
  height: 100%;
  background-image: var(--sprite-url);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transform: translateX(var(--frame-shift, 0%));
  will-change: transform;
}

.mascot-name {
  position: absolute;
  left: 50%;
  bottom: -2px;
  min-width: 70px;
  padding: 4px 8px;
  border: 2px solid var(--line-dark);
  background: #f4cf78;
  color: #3a2a15;
  box-shadow: 2px 2px 0 #76562b;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  transform: translateX(-50%);
}

.mascot-dingdong {
  left: 0;
  width: 46%;
  --frame-ratio: 377 / 413;
  --sprite-url: url("./assets/mascot-dingdong-sprite.png");
}

.mascot-dabai {
  right: 0;
  width: 54%;
  --frame-ratio: 369 / 506;
  --sprite-url: url("./assets/mascot-dabai-sprite.png");
}

.mascot-bubble {
  position: absolute;
  top: 0;
  width: min(82%, 340px);
  margin: 0;
  padding: 10px 12px;
  border: 3px solid var(--line-dark);
  background: #fff0bd;
  color: #3a2a15;
  box-shadow: 4px 4px 0 #7c612f, inset 2px 2px 0 rgba(255, 251, 222, 0.88);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.55;
  z-index: 5;
  pointer-events: none;
  animation: mascotBubblePulse 2600ms steps(2) infinite;
}

.mascot-bubble.from-dingdong {
  left: 0;
  right: auto;
}

.mascot-bubble.from-dabai {
  left: auto;
  right: 0;
}

.mascot-bubble::after {
  content: "";
  position: absolute;
  bottom: -13px;
  width: 18px;
  height: 18px;
  border-right: 3px solid var(--line-dark);
  border-bottom: 3px solid var(--line-dark);
  background: #fff0bd;
  transform: rotate(45deg);
}

.mascot-bubble.from-dingdong::after {
  left: 58px;
}

.mascot-bubble.from-dabai::after {
  right: 58px;
}

.cover-mascot[data-action="play"] .mascot-sprite {
  filter:
    drop-shadow(7px 9px 0 rgba(65, 45, 20, 0.32))
    brightness(1.04)
    saturate(1.04);
  animation: mascotReactWave 720ms steps(4) 1;
}

.cover-mascot[data-action="play"] {
  z-index: 4;
}

.cover-mascot[data-action-kind="point"] .mascot-sprite {
  animation-name: mascotReactPoint;
}

.cover-mascot[data-action-kind="cheer"] .mascot-sprite {
  animation-name: mascotReactCheer;
}

.cover-mascot[data-action="play"] .mascot-name {
  background: #ffd86f;
}

.start-form {
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 16px;
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  font-weight: 900;
}

label {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 2px solid var(--line);
  background: var(--panel-light);
}

.tilesheet-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border: 3px solid var(--line);
  background: #ead19a;
  box-shadow: inset 0 0 0 3px rgba(255, 244, 202, 0.65);
}

.game-grid {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 370px;
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.metrics-panel,
.stage-panel,
.brief-console,
.operations-panel,
.news-panel,
.log-panel {
  padding: 12px;
}

.stage-panel {
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(255, 244, 202, 0.72), rgba(216, 173, 83, 0.20)),
    var(--panel);
}

.stage-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: center;
  margin-bottom: 10px;
}

.stage-progress span,
.stage-progress strong,
.stage-focus {
  border: 2px solid var(--line);
  background: var(--panel-light);
  box-shadow: inset 2px 2px 0 rgba(255, 247, 209, 0.78);
}

.stage-progress span,
.stage-progress strong {
  min-height: 28px;
  padding: 5px 7px;
  font-size: 0.78rem;
}

.stage-meter {
  grid-column: 1 / -1;
  height: 13px;
  border: 2px solid var(--line);
  background: #cfb070;
  overflow: hidden;
}

#stageProgressFill {
  height: 100%;
  width: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 244, 202, 0.25) 0 5px, transparent 5px 10px),
    #bd7d24;
  transition: width 180ms steps(8);
  animation: meterScan 1.6s steps(8) infinite;
}

.stage-situation {
  margin: 0 0 9px;
  color: var(--deep);
  font-size: 0.84rem;
  line-height: 1.55;
}

.stage-focus {
  display: grid;
  gap: 3px;
  padding: 8px;
  margin-bottom: 9px;
}

.stage-focus span {
  color: var(--muted);
  font-size: 0.72rem;
}

.stage-focus strong {
  line-height: 1.42;
}

.stage-challenges {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-challenges li {
  position: relative;
  padding: 6px 8px 6px 22px;
  border: 2px solid #b89752;
  background: #f8e9bd;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.stage-challenges li::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 11px;
  width: 6px;
  height: 6px;
  background: #a83f32;
  box-shadow: 1px 1px 0 rgba(45, 40, 31, 0.45);
}

.panel-heading,
.map-toolbar {
  padding-bottom: 7px;
  border-bottom: 2px solid #b89752;
}

.panel-heading,
.map-toolbar {
  margin-bottom: 10px;
}

.panel-heading h2,
.map-toolbar h2,
.event-heading h2 {
  font-size: 1.05rem;
}

.metrics-list {
  display: grid;
  gap: 9px;
}

.metric {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 2px solid #b89752;
  background:
    linear-gradient(90deg, rgba(255, 244, 202, 0.82), rgba(248, 233, 189, 0.92)),
    #f8e9bd;
  box-shadow: inset 2px 2px 0 rgba(255, 247, 209, 0.85);
}

.metric.danger {
  border-color: #9b332b;
  background:
    linear-gradient(90deg, rgba(168, 63, 50, 0.12), rgba(248, 233, 189, 0.92)),
    #f8e9bd;
}

.metric.warn {
  border-color: #bd7d24;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.metric-name {
  font-weight: 900;
}

.metric-value {
  font-variant-numeric: tabular-nums;
  color: var(--deep);
}

.meter {
  height: 12px;
  overflow: hidden;
  background: #cfb070;
  border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px rgba(86, 58, 25, 0.18);
}

.meter-fill {
  height: 100%;
  width: 0;
  transition: width 160ms steps(8);
  position: relative;
  overflow: hidden;
}

.meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255, 244, 202, 0.18) 0 5px, transparent 5px 10px);
  animation: meterScan 1.4s steps(8) infinite;
}

.metric.good .meter-fill {
  background: var(--good);
}

.metric.warn .meter-fill {
  background: var(--warn);
}

.metric.danger .meter-fill {
  background: var(--danger);
}

.metric p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.resource-readouts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-top: 10px;
}

.resource-readouts div,
.brief-item,
.alert,
.history-list li,
.ending-metrics div,
.map-inspector,
.action-card,
.news-card {
  border: 2px solid var(--line);
  background: #f8e9bd;
  box-shadow: inset 2px 2px 0 rgba(255, 247, 209, 0.78);
}

.resource-readouts div {
  position: relative;
  min-width: 0;
  padding: 8px;
  cursor: help;
}

.resource-readouts div::before,
.resource-readouts div::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 80ms steps(2), transform 80ms steps(2);
  z-index: 12;
}

.resource-readouts div::before {
  content: "";
  top: calc(100% + 4px);
  border: 7px solid transparent;
  border-bottom-color: var(--line-dark);
}

.resource-readouts div::after {
  content: attr(data-tooltip);
  top: calc(100% + 16px);
  width: min(260px, 78vw);
  padding: 9px 10px;
  border: 3px solid var(--line-dark);
  background: #fff1c8;
  color: var(--ink);
  box-shadow: 4px 4px 0 rgba(95, 75, 42, 0.72), inset 2px 2px 0 rgba(255, 255, 255, 0.58);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.5;
}

.resource-readouts div:hover::before,
.resource-readouts div:hover::after,
.resource-readouts div:focus-visible::before,
.resource-readouts div:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.resource-readouts span,
.brief-item span,
.history-meta {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.resource-readouts strong {
  display: block;
  margin-top: 3px;
  font-size: 1.05rem;
}

.status-effects {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.status-effect {
  padding: 8px;
  border: 2px solid #b89752;
  background: #f8e9bd;
  box-shadow: inset 2px 2px 0 rgba(255, 247, 209, 0.78);
}

.status-effect.good {
  border-color: #3f7a54;
  background: linear-gradient(90deg, rgba(63, 122, 84, 0.16), #f8e9bd);
}

.status-effect.danger {
  border-color: #a83f32;
  background: linear-gradient(90deg, rgba(168, 63, 50, 0.15), #f8e9bd);
}

.status-effect.mixed {
  border-color: #3d6684;
  background: linear-gradient(90deg, rgba(61, 102, 132, 0.14), #f8e9bd);
}

.status-effect strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.78rem;
}

.status-effect p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.map-column {
  display: grid;
  gap: 12px;
}

.city-map-panel {
  padding: 12px;
}

.map-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#mapHint {
  padding: 5px 8px;
  border: 2px solid var(--line);
  background: var(--panel-light);
  font-size: 0.78rem;
  font-weight: 900;
}

.city-map-wrap {
  position: relative;
  overflow: hidden;
  border: 4px solid var(--line);
  background: #d9bd76;
  box-shadow: inset 0 0 0 4px rgba(255, 244, 202, 0.52);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.city-map-wrap.is-dragging {
  cursor: grabbing;
}

.city-map-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(255, 244, 202, 0.12), transparent 34%, rgba(61, 45, 26, 0.12)),
    radial-gradient(circle at center, transparent 62%, rgba(61, 45, 26, 0.22));
}

.city-map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(105deg, transparent 0 38%, rgba(255, 244, 202, 0.16) 45%, transparent 52% 100%);
  mix-blend-mode: screen;
  animation: mapSweep 11s steps(24) infinite;
}

.map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  transform-origin: 0 0;
  will-change: transform;
}

.city-map {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.08) saturate(0.96) contrast(1.03);
  pointer-events: none;
}

.map-hotspots {
  position: absolute;
  inset: 0;
  z-index: 7;
}

.map-highlight-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.map-highlight {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  filter: drop-shadow(2px 2px 0 rgba(95, 71, 37, 0.25));
  transition: opacity 100ms steps(2);
}

.map-highlight.hover {
  opacity: 1;
}

.map-hotspot {
  position: absolute;
  width: var(--hit-w, 9%);
  height: var(--hit-h, 9%);
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  overflow: visible;
  transition: filter 120ms steps(2);
}

.map-hotspot::after {
  content: "";
  position: absolute;
  left: var(--marker-x, 50%);
  top: var(--marker-y, 50%);
  z-index: 2;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff1c8;
  background:
    linear-gradient(90deg, transparent 0 5px, rgba(255, 241, 200, 0.9) 5px 9px, transparent 9px),
    rgba(189, 125, 36, 0.82);
  box-shadow: 2px 2px 0 rgba(45, 40, 31, 0.58);
  animation: hotspotIdle 2.6s steps(4) infinite;
}

.map-hotspot::before {
  content: none;
}

.map-hotspot.road::after {
  background: #3d6684;
}

.map-hotspot.people::after {
  background: #3f7a54;
}

.map-hotspot.active,
.map-hotspot:hover {
  z-index: 8;
}

.map-hotspot.active::after,
.map-hotspot:hover::after {
  width: 16px;
  height: 16px;
  background:
    linear-gradient(90deg, transparent 0 5px, rgba(255, 241, 200, 0.85) 5px 8px, transparent 8px),
    #a83f32;
  animation: hotspotActive 1.1s steps(4) infinite;
}

.map-hotspot .map-hotspot-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  z-index: 3;
  transform: translateX(-50%);
  display: none;
  min-width: max-content;
  padding: 3px 6px;
  border: 2px solid var(--line);
  background: #fff1c8;
  color: var(--ink);
  font-size: 0.72rem;
  box-shadow: 2px 2px 0 rgba(45, 40, 31, 0.55);
}

.map-hotspot:hover .map-hotspot-label,
.map-hotspot.active .map-hotspot-label {
  display: block;
}

.map-inspector {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 10px;
  background:
    linear-gradient(90deg, rgba(255, 244, 202, 0.8), rgba(248, 233, 189, 0.95)),
    #f8e9bd;
}

.map-inspector h3 {
  margin: 0 0 5px;
}

.map-inspector p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.map-stats {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
}

.map-stats span {
  padding: 5px 7px;
  border: 2px solid #b89752;
  background: var(--panel-light);
  white-space: nowrap;
}

.event-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 310px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 244, 202, 0.6), rgba(244, 218, 155, 0.25)),
    var(--panel);
}

.event-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -35%;
  width: 32%;
  pointer-events: none;
  z-index: 1;
  background:
    linear-gradient(90deg, transparent, rgba(255, 241, 200, 0.16), transparent),
    repeating-linear-gradient(0deg, transparent 0 9px, rgba(123, 76, 24, 0.12) 9px 11px);
  animation: eventScan 5.5s steps(18) infinite;
}

.event-visual {
  position: relative;
  z-index: 2;
  min-height: 310px;
  overflow: hidden;
  border-right: 3px solid var(--line);
  background:
    repeating-linear-gradient(0deg, rgba(95, 71, 37, 0.1) 0 2px, transparent 2px 8px),
    #c8aa68;
  isolation: isolate;
}

.event-visual::before,
.event-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.event-visual::before {
  background:
    linear-gradient(90deg, transparent 0 44%, rgba(255, 241, 200, 0.1) 50%, transparent 56% 100%),
    repeating-linear-gradient(0deg, rgba(45, 40, 31, 0.08) 0 1px, transparent 1px 7px);
  mix-blend-mode: soft-light;
  animation: eventVisualSweep 7s steps(16) infinite;
}

.event-visual::after {
  background: radial-gradient(circle at 50% 45%, transparent 48%, rgba(45, 40, 31, 0.18));
  mix-blend-mode: multiply;
}

.event-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.12) saturate(0.92) contrast(1.05);
  animation: eventImageBreath 8s steps(8) infinite;
}

.event-anim {
  position: absolute;
  z-index: 5;
  display: block;
  pointer-events: none;
  opacity: 0;
}

.event-visual[data-motion] {
  --event-light: #8b7144;
}

.event-visual[data-motion="medical"] {
  --event-light: #9b4a3b;
}

.event-visual[data-motion="supply"] {
  --event-light: #a9823d;
}

.event-visual[data-motion="code"] {
  --event-light: #55734e;
}

.event-visual[data-motion="factory"] {
  --event-light: #526c70;
}

.event-visual[data-motion="shelter"] {
  --event-light: #8f6f44;
}

.event-visual[data-motion] .event-anim-a,
.event-visual[data-motion] .event-anim-b,
.event-visual[data-motion] .event-anim-c {
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  width: auto;
  height: auto;
  border: 0;
  background: none;
  box-shadow: none;
  transform: none;
  opacity: 0.62;
}

.event-visual[data-motion] .event-anim-a {
  left: 10px;
  top: 10px;
  width: 7px;
  height: 7px;
  background: var(--event-light);
  box-shadow: 11px 0 0 rgba(255, 241, 200, 0.58), 22px 0 0 rgba(95, 71, 37, 0.46);
  animation: eventPanelBlink 2.6s steps(3) infinite;
}

.event-visual[data-motion] .event-anim-b {
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--event-light) 0 8px,
    transparent 8px 16px
  );
  opacity: 0.36;
  animation: eventTicker 5s steps(18) infinite;
}

.event-visual[data-motion] .event-anim-c {
  inset: 11px;
  border: 1px solid rgba(255, 241, 200, 0.28);
  box-shadow: inset 0 0 0 1px rgba(45, 40, 31, 0.18);
  opacity: 0.52;
  animation: eventSoftPulse 4.6s steps(5) infinite;
}

.event-content {
  position: relative;
  z-index: 2;
  padding: 14px;
}

.event-heading {
  position: relative;
}

.event-heading::after {
  content: "";
  position: absolute;
  right: 0;
  top: 4px;
  width: 10px;
  height: 10px;
  background: #a83f32;
  box-shadow: 14px 0 0 #bd7d24, 28px 0 0 #3f7a54;
  animation: eventBlink 1.8s steps(3) infinite;
}

#eventBody {
  margin: 0;
  color: var(--deep);
  font-size: 0.94rem;
  line-height: 1.7;
}

.choice-list,
.action-list,
.news-list,
.brief-strip {
  display: grid;
  gap: 9px;
}

.choice-list {
  margin-top: 14px;
}

.choice-button {
  width: 100%;
  padding: 10px;
  text-align: left;
  position: relative;
  background:
    linear-gradient(90deg, #fff2c9, #f3dda2);
}

.choice-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  background: #bd7d24;
}

.choice-button:hover::before {
  background: #a83f32;
}

.choice-button:disabled {
  opacity: 0.58;
  filter: grayscale(0.22);
}

.choice-button:disabled::before {
  background: #766d5d;
}

.choice-button strong,
.action-card strong,
.news-card strong {
  display: block;
  margin-bottom: 5px;
}

.choice-button p,
.action-card p,
.news-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 6px;
  border: 2px solid #b89752;
  background: #ead19a;
  color: var(--deep);
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 1px 1px 0 rgba(95, 75, 42, 0.35);
}

.chip.good-change {
  background: #bdd49a;
}

.chip.bad-change {
  background: #e2a487;
}

.chip.delay {
  background: #d7c5e3;
}

.command-panel {
  display: grid;
  gap: 12px;
}

.brief-item {
  padding: 9px;
  line-height: 1.4;
}

.brief-item strong {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
}

.action-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  background:
    linear-gradient(90deg, rgba(255, 244, 202, 0.68), rgba(248, 233, 189, 0.95)),
    #f8e9bd;
}

.action-card.locked {
  opacity: 0.66;
  filter: grayscale(0.25);
}

.small-action {
  min-width: 64px;
  max-width: 94px;
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  border: 2px dashed var(--line);
}

.news-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 9px;
  padding: 7px;
  transition: transform 100ms steps(2), box-shadow 100ms steps(2);
}

.news-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #7c612f;
}

.news-card img {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border: 2px solid var(--line);
  filter: sepia(0.1) saturate(0.95);
}

.alerts {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.alert {
  padding: 9px 10px;
  color: var(--danger);
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  scrollbar-color: #8b7144 #f8e9bd;
}

.history-list::-webkit-scrollbar,
.tutorial-card::-webkit-scrollbar {
  width: 12px;
}

.history-list::-webkit-scrollbar-track,
.tutorial-card::-webkit-scrollbar-track {
  background: #f8e9bd;
  border-left: 2px solid var(--line);
}

.history-list::-webkit-scrollbar-thumb,
.tutorial-card::-webkit-scrollbar-thumb {
  background: #8b7144;
  border: 2px solid #f8e9bd;
}

.history-list li {
  padding: 9px;
}

.history-list strong {
  display: block;
  margin: 4px 0 7px;
}

.history-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.change-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.change {
  font-size: 0.72rem;
  font-weight: 900;
}

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

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

.ending-screen {
  grid-template-columns: 1fr;
  max-width: 860px;
  margin: 16px auto 0;
  padding: clamp(22px, 4vw, 42px);
}

.ending-screen p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

#endingScore {
  display: inline-block;
  margin: 4px 0 16px;
  color: #7b4c18;
  font-size: 1.25rem;
}

.ending-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-bottom: 16px;
}

.ending-metrics div {
  padding: 10px;
}

.ending-metrics span {
  display: block;
  color: var(--muted);
}

.ending-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 244, 202, 0.05) 0 2px, transparent 2px 6px),
    rgba(45, 40, 31, 0.7);
  z-index: 20;
}

.tutorial-card {
  position: relative;
  width: min(900px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: clamp(18px, 4vw, 34px);
}

.tutorial-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.tutorial-grid section {
  padding: 12px;
  border: 2px solid var(--line);
  background: var(--panel-light);
}

.tutorial-grid h3 {
  margin: 0 0 6px;
}

.tutorial-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@keyframes mapSweep {
  0% {
    transform: translateX(-70%);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  52% {
    opacity: 0.75;
  }
  100% {
    transform: translateX(72%);
    opacity: 0;
  }
}

@keyframes hotspotIdle {
  0%, 100% {
    box-shadow: 3px 3px 0 rgba(45, 40, 31, 0.65);
  }
  50% {
    box-shadow: 3px 3px 0 rgba(45, 40, 31, 0.65), 0 0 0 6px rgba(255, 241, 200, 0.24);
  }
}

@keyframes hotspotActive {
  0%, 100% {
    box-shadow: 3px 3px 0 rgba(45, 40, 31, 0.65), 0 0 0 4px rgba(168, 63, 50, 0.18);
  }
  50% {
    box-shadow: 3px 3px 0 rgba(45, 40, 31, 0.65), 0 0 0 10px rgba(168, 63, 50, 0.28);
  }
}

@keyframes eventScan {
  0% {
    transform: translateX(0);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translateX(430%);
    opacity: 0;
  }
}

@keyframes eventVisualSweep {
  0% {
    transform: translateX(-90%);
  }
  100% {
    transform: translateX(90%);
  }
}

@keyframes eventBlink {
  0%, 100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes eventPanelBlink {
  0%, 100% {
    opacity: 0.38;
  }
  50% {
    opacity: 0.72;
  }
}

@keyframes eventTicker {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 64px 0;
  }
}

@keyframes eventSoftPulse {
  0%, 100% {
    opacity: 0.36;
  }
  50% {
    opacity: 0.58;
  }
}

@keyframes meterScan {
  0% {
    transform: translateX(-18px);
  }
  100% {
    transform: translateX(18px);
  }
}

@keyframes eventImageBreath {
  0%, 100% {
    filter: sepia(0.12) saturate(0.92) contrast(1.05) brightness(1);
  }
  50% {
    filter: sepia(0.16) saturate(1) contrast(1.08) brightness(1.04);
  }
}

@keyframes mascotBubblePulse {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.04);
  }
}

@keyframes mascotReactWave {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  35% {
    transform: translateY(-3px) rotate(-2deg);
  }
  70% {
    transform: translateY(-2px) rotate(2deg);
  }
}

@keyframes mascotReactPoint {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  42% {
    transform: translateY(-2px) rotate(-1deg);
  }
  72% {
    transform: translateY(1px) rotate(1deg);
  }
}

@keyframes mascotReactCheer {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(-8px) scale(1.03, 0.98);
  }
  72% {
    transform: translateY(1px) scale(0.99, 1.02);
  }
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 1320px) {
  .game-grid {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .command-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 8px;
  }

  .topbar,
  .start-screen,
  .game-grid,
  .command-panel,
  .event-card,
  .map-inspector {
    grid-template-columns: 1fr;
  }

  .day-panel {
    justify-content: start;
  }

  .start-copy::before {
    width: 54px;
    height: 54px;
  }

  .start-copy {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: clamp(20px, 6vw, 36px);
  }

  .start-copy h2 {
    padding-left: 0;
    padding-top: 62px;
  }

  .cover-mascots {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    height: 300px;
    min-height: 300px;
    margin-top: 4px;
  }

  .mascot-bubble {
    top: 0;
    left: 0;
    right: auto;
    width: min(100%, 360px);
  }

  .mascot-bubble.from-dingdong::after {
    left: 72px;
    right: auto;
  }

  .mascot-bubble.from-dabai::after {
    left: auto;
    right: 72px;
  }

  .mascot-dingdong {
    left: 6%;
    width: min(36%, 180px);
  }

  .mascot-dabai {
    right: 8%;
    width: min(45%, 220px);
  }

  .event-visual {
    min-height: 180px;
    border-right: 0;
    border-bottom: 3px solid var(--line);
  }

  .city-map {
    aspect-ratio: 4 / 3;
  }

  .tutorial-grid,
  .ending-metrics {
    grid-template-columns: 1fr;
  }
}
