/* 布衣宰辅 V0.1 - 县治经营原型 */

:root {
  --paper: #f6f0e3;
  --paper-deep: #ede2cf;
  --card: #fffdf7;
  --card-tint: #faf5ea;
  --ink: #2b2722;
  --muted: #7a6f60;
  --line: rgba(80, 60, 40, 0.16);
  --red: #9e2b25;
  --red-dark: #7d201c;
  --gold: #a67b24;
  --jade: #4e7a56;
  --blue: #3e6e78;
  --warn: #b14b3a;
  --shadow: 0 12px 34px rgba(80, 60, 40, 0.14);
  --radius: 8px;
  --font-serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-sans: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  min-width: 320px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
}

.icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.12em;
}

.screen[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, opacity 0.18s;
}

.btn:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--card-tint);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--red);
  border-color: var(--red-dark);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
}

.btn-ghost {
  background: transparent;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-month {
  min-width: 190px;
}

.tag {
  display: inline-block;
  font-size: 12px;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 2px 8px;
  line-height: 1.4;
}

/* 开始界面 */

.start-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #fbf7ed 0%, var(--paper-deep) 100%);
}

.start-card {
  width: min(540px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 38px 32px;
  text-align: center;
}

.start-seal {
  width: 88px;
  height: 88px;
  margin: 0 auto 12px;
  border: 2px solid var(--red);
  border-radius: 8px;
  color: var(--red);
  display: grid;
  place-items: center;
  background: #fff;
}

.start-seal .icon {
  width: 52px;
  height: 52px;
}

.start-kicker {
  font-size: 13px;
  color: var(--muted);
}

.start-card h1 {
  font-family: var(--font-serif);
  font-size: 42px;
  color: var(--red);
  margin: 8px 0 4px;
}

.start-sub {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 22px;
}

.start-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  text-align: left;
}

.start-name-row label {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.start-name-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.start-name-row input:focus {
  border-color: var(--red);
}

.start-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.start-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

/* 科举序章 */

.exam-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #fbf7ed 0%, var(--paper-deep) 100%);
}

.exam-layout {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
  align-items: start;
}

.exam-stages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-stage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
}

.exam-stage-item.done {
  color: var(--jade);
}

.exam-stage-item.current {
  border-color: var(--red);
  color: var(--red);
  font-weight: 700;
}

.stage-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.exam-main {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.exam-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.exam-stage-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
}

.exam-score {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
}

.exam-question {
  font-size: 17px;
  line-height: 1.8;
  margin-bottom: 16px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--red);
}

.option-btn.correct {
  border-color: var(--jade);
  background: rgba(78, 122, 86, 0.08);
}

.option-btn.wrong {
  border-color: var(--warn);
  background: rgba(177, 75, 58, 0.08);
}

.opt-mark {
  color: var(--jade);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.option-btn.wrong .opt-mark {
  color: var(--warn);
}

.exam-explain {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--card-tint);
  border-left: 3px solid var(--gold);
  font-size: 13px;
  color: var(--muted);
}

.exam-next {
  margin-top: 16px;
  width: 100%;
}

/* 游戏主界面 */

.game-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.game-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(251, 247, 237, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.game-title {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.game-logo {
  width: 40px;
  height: 40px;
  border: 1px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  background: #fff;
  display: grid;
  place-items: center;
}

.game-logo .icon {
  width: 24px;
  height: 24px;
}

.game-title-text {
  display: flex;
  flex-direction: column;
}

.game-title-text strong {
  font-family: var(--font-serif);
  font-size: 15px;
}

.game-title-text span {
  font-size: 12px;
  color: var(--muted);
}

.stat-strip {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.stat-icon {
  color: var(--red);
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
}

.stat-value {
  font-weight: 700;
}

.game-body {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 0;
}

.side-nav {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.nav-btn .icon {
  width: 18px;
  height: 18px;
  color: var(--red);
}

.nav-btn.active {
  background: var(--card-tint);
  border-color: var(--line);
  font-weight: 600;
}

.nav-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
}

.panel {
  padding: 20px;
  overflow: auto;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 1220px;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 10px rgba(80, 60, 40, 0.06);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card-head .icon {
  width: 20px;
  height: 20px;
  color: var(--red);
}

.card-head h3 {
  font-family: var(--font-serif);
  font-size: 16px;
}

.card-sub {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.progress {
  height: 10px;
  background: #e9dfcc;
  border-radius: 5px;
  overflow: hidden;
  margin: 8px 0 14px;
}

.progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.ov-stat {
  border-left: 2px solid var(--gold);
  padding-left: 10px;
}

.ov-stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.ov-stat strong {
  font-size: 14px;
}

.grade-excellent {
  color: var(--jade);
}

.grade-good {
  color: var(--blue);
}

.grade-fair {
  color: var(--gold);
}

.grade-poor,
.grade-jail {
  color: var(--warn);
}

.policy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.policy-row:last-child {
  border-bottom: 0;
}

.policy-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.seg {
  display: flex;
  gap: 6px;
}

.seg-btn {
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-building,
.mini-official {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-tint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.mini-icon {
  color: var(--red);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.mini-icon .icon {
  width: 18px;
  height: 18px;
}

.mini-building strong,
.mini-official strong {
  font-size: 13px;
}

.mini-building small,
.mini-official small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.ledger {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  font-size: 14px;
}

.ledger span {
  color: var(--muted);
}

.ledger strong {
  text-align: right;
}

.ledger-net {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

.ledger-net.warn {
  color: var(--warn);
}

.log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-item {
  font-size: 13px;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 8px;
}

.log-item.warn {
  color: var(--warn);
  border-color: var(--warn);
}

.log-item.event {
  color: var(--blue);
  border-color: var(--blue);
}

.log-item.success {
  color: var(--jade);
  border-color: var(--jade);
}

.resource-big {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.resource-big div {
  background: var(--card-tint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.resource-big span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.resource-big strong {
  font-size: 20px;
  font-family: var(--font-serif);
}

.table {
  display: flex;
  flex-direction: column;
}

.tr {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}

.tr span {
  color: var(--muted);
}

.tr.total {
  font-weight: 700;
  border-bottom: 0;
}

.tr.total.warn {
  color: var(--warn);
}

.post-list,
.official-list,
.building-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--card-tint);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.post-icon {
  color: var(--red);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.post-info strong {
  font-size: 14px;
}

.post-info small,
.post-info em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.official-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.official-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.official-avatar {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--red);
  display: grid;
  place-items: center;
  background: var(--card-tint);
  flex-shrink: 0;
}

.official-head strong {
  font-size: 14px;
}

.official-head small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.post-chip {
  margin-left: auto;
  font-size: 12px;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}

.official-stats {
  display: flex;
  gap: 12px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--muted);
}

.warn-text {
  color: var(--warn);
  font-weight: 700;
}

.official-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.in-post {
  font-size: 12px;
  color: var(--jade);
  line-height: 2;
}

.building-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.building-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--red);
  display: grid;
  place-items: center;
  background: var(--card-tint);
}

.building-icon .icon {
  width: 24px;
  height: 24px;
}

.building-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-chip {
  font-size: 12px;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 1px 6px;
}

.building-info p {
  font-size: 13px;
  margin: 4px 0;
}

.building-info small {
  color: var(--muted);
}

.event-card h4 {
  font-family: var(--font-serif);
  font-size: 20px;
  margin: 6px 0;
}

.event-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.empty-card p {
  color: var(--muted);
}

.action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  bottom: 0;
}

.mobile-nav {
  display: none;
}

/* 弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 34, 26, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-paper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(680px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 20px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}

.event-paper h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  margin-bottom: 8px;
}

.event-desc {
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 16px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
}

.event-choice:hover:not(.disabled) {
  border-color: var(--red);
  background: var(--card-tint);
}

.event-choice.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.choice-label {
  font-weight: 700;
}

.choice-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.effect {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}

.effect.up {
  color: var(--jade);
  background: rgba(78, 122, 86, 0.1);
}

.effect.down {
  color: var(--warn);
  background: rgba(177, 75, 58, 0.1);
}

.choice-note {
  font-size: 12px;
  color: var(--muted);
}

/* 任满结算 */

.ending-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #fbf7ed 0%, var(--paper-deep) 100%);
}

.ending-doc {
  width: min(760px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
}

.doc-seal {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  border: 2px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  display: grid;
  place-items: center;
  background: #fff;
}

.doc-seal .icon {
  width: 36px;
  height: 36px;
}

.doc-kicker {
  font-size: 13px;
  color: var(--muted);
}

.ending-doc h2 {
  font-family: var(--font-serif);
  font-size: 30px;
  margin: 10px 0 16px;
}

.ending-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.ending-score span {
  color: var(--muted);
}

.ending-score strong {
  font-size: 42px;
  color: var(--red);
}

.ending-score em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.ending-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.ending-stat {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--card-tint);
}

.ending-stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.ending-stat strong {
  font-size: 16px;
}

.ending-breakdown p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.8;
  max-width: 560px;
  margin: 0 auto;
}

.ending-actions {
  margin-top: 20px;
}

/* 通知 */

.toast-root {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 1;
  transition: opacity 0.4s, transform 0.4s;
  max-width: min(340px, calc(100vw - 28px));
}

.toast.warn {
  background: var(--warn);
}

.toast.event {
  background: var(--blue);
}

.toast-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}

.toast.out {
  opacity: 0;
  transform: translateY(-6px);
}

/* 响应式 */

@media (max-width: 1100px) {
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2,
  .span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 1024px) {
  .game-body {
    grid-template-columns: 64px 1fr;
  }

  .side-nav .nav-btn {
    justify-content: center;
    padding: 11px 6px;
  }

  .side-nav .nav-btn > span {
    display: none;
  }

  .side-nav .nav-badge {
    right: 2px;
    top: 4px;
    transform: none;
  }
}

@media (max-width: 767px) {
  .game-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .stat-strip {
    order: 3;
    width: 100%;
  }

  .game-body {
    grid-template-columns: 1fr;
  }

  .side-nav {
    display: none;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: 62px;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 40;
  }

  .mobile-nav .nav-btn {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    justify-content: center;
    font-size: 11px;
    text-align: center;
  }

  .mobile-nav .nav-btn .icon {
    width: 20px;
    height: 20px;
  }

  .mobile-nav .nav-badge {
    position: static;
    transform: none;
  }

  .action-bar {
    position: fixed;
    bottom: calc(62px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    z-index: 30;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .panel {
    padding: 12px 10px calc(150px + env(safe-area-inset-bottom));
  }

  .exam-layout {
    grid-template-columns: 1fr;
  }

  .exam-stages {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .exam-stage-item {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }

  .overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resource-big {
    grid-template-columns: 1fr;
  }

  .building-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .building-action {
    display: flex;
    justify-content: center;
  }

  .ending-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .official-head {
    flex-wrap: wrap;
  }

  .post-chip {
    margin-left: 0;
  }

  .start-card {
    padding: 28px 20px;
  }

  .btn-month {
    min-width: 0;
    flex: 1;
  }

  .action-bar .btn-ghost {
    flex: 0 0 auto;
  }
}

@media (max-width: 480px) {
  .start-card h1 {
    font-size: 34px;
  }

  .game-title-text strong {
    font-size: 14px;
  }

  .stat-chip {
    font-size: 11px;
    padding: 4px 8px;
  }

  .btn {
    font-size: 14px;
  }

  .policy-row {
    flex-direction: column;
    align-items: stretch;
  }

  .seg {
    justify-content: stretch;
  }

  .seg-btn {
    flex: 1;
  }
}

/* 存档与设置 */
.header-icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  color: var(--red);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.header-icon-btn .icon {
  width: 20px;
  height: 20px;
}

.save-modal .modal-head h2,
.settings-modal .modal-head h2 {
  font-family: var(--font-serif);
  font-size: 20px;
}

.save-slot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.save-slot-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.slot-main {
  min-width: 0;
}

.slot-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.slot-head strong {
  font-size: 15px;
}

.slot-sub {
  font-size: 12px;
  color: var(--muted);
}

.slot-meta {
  font-size: 13px;
  margin-top: 4px;
}

.slot-time {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.slot-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.save-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}

.setting-label {
  font-size: 14px;
}

.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn-danger {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #8f3c2d;
  border-color: #8f3c2d;
}

/* 玄墨主题 */
body.theme-dark {
  --paper: #1c1a18;
  --paper-deep: #141210;
  --card: #262220;
  --card-tint: #2f2a26;
  --ink: #ece4d8;
  --muted: #a99d8c;
  --line: rgba(236, 228, 216, 0.16);
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
}

body.theme-dark .start-screen,
body.theme-dark .exam-screen,
body.theme-dark .ending-screen {
  background: linear-gradient(180deg, #211e1b 0%, #141210 100%);
}

body.theme-dark .start-card,
body.theme-dark .card,
body.theme-dark .modal-paper,
body.theme-dark .official-card,
body.theme-dark .building-card,
body.theme-dark .event-choice,
body.theme-dark .option-btn,
body.theme-dark .stat-chip,
body.theme-dark .save-slot-card,
body.theme-dark .header-icon-btn {
  background: var(--card);
  color: var(--ink);
}

body.theme-dark .mini-building,
body.theme-dark .mini-official,
body.theme-dark .post-card,
body.theme-dark .resource-big div,
body.theme-dark .ending-stat,
body.theme-dark .building-icon,
body.theme-dark .official-avatar,
body.theme-dark .exam-explain {
  background: var(--card-tint);
}

body.theme-dark .btn {
  background: var(--card-tint);
  color: var(--ink);
}

body.theme-dark .btn-primary {
  background: var(--red);
  border-color: var(--red-dark);
  color: #fff;
}

body.theme-dark .seg-btn {
  background: var(--card);
  color: var(--ink);
}

body.theme-dark .seg-btn.active {
  background: var(--red);
  color: #fff;
}

body.theme-dark .log-item,
body.theme-dark .event-desc,
body.theme-dark .exam-question,
body.theme-dark .event-paper h2,
body.theme-dark .ending-doc h2 {
  color: var(--ink);
}

body.theme-dark .toast {
  background: #3a332d;
}

/* 大字号 */
body.text-large .btn,
body.text-large .stat-chip,
body.text-large .log-item,
body.text-large .event-choice,
body.text-large .option-btn {
  font-size: 15px;
}
.origin-desc {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  border-left: 2px solid var(--gold);
  padding-left: 8px;
}

/* V0.3 地图系统 */
.map-panel-grid {
  max-width: 1240px;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 12px;
}

.map-tool-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.map-group-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.map-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.map-btn small {
  color: var(--muted);
  font-size: 11px;
}

.map-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.map-btn.active small {
  color: rgba(255, 255, 255, 0.82);
}

.map-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 3px;
  flex-shrink: 0;
}

.map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #e9e4d8;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

#countyMapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.map-info {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  background: rgba(255, 253, 247, 0.9);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink);
  pointer-events: none;
}

.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

body.theme-dark .map-btn {
  background: var(--card);
  color: var(--ink);
}

body.theme-dark .map-btn.active {
  background: var(--red);
  color: #fff;
}

body.theme-dark .map-info {
  background: rgba(38, 34, 32, 0.9);
  color: var(--ink);
}

@media (max-width: 767px) {
  .map-wrap {
    aspect-ratio: 1 / 1;
  }

  .map-toolbar {
    gap: 8px;
  }

  .map-tool-group {
    width: 100%;
  }

  .map-btn {
    flex: 1;
    justify-content: center;
  }
}


/* 免责声明 */
.disclaimer-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #fbf7ed 0%, var(--paper-deep) 100%);
}

.disclaimer-card {
  width: min(720px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
}

.disclaimer-seal {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  border: 2px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  display: grid;
  place-items: center;
  background: #fff;
}

.disclaimer-seal .icon {
  width: 36px;
  height: 36px;
}

.disclaimer-card h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  text-align: center;
  color: var(--red);
}

.disclaimer-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 16px;
}

.disclaimer-scroll {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 18px;
  background: var(--card-tint);
  line-height: 1.9;
  font-size: 14px;
}

.disclaimer-scroll h3 {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--red);
  margin: 14px 0 6px;
}

.disclaimer-scroll h3:first-child {
  margin-top: 0;
}

.disclaimer-scroll p {
  color: var(--ink);
}

.disclaimer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.disclaimer-hint {
  font-size: 13px;
  color: var(--muted);
}

body.theme-dark .disclaimer-screen {
  background: linear-gradient(180deg, #211e1b 0%, #141210 100%);
}

body.theme-dark .disclaimer-card {
  background: var(--card);
}

@media (max-width: 767px) {
  .disclaimer-card {
    padding: 20px 16px;
  }

  .disclaimer-scroll {
    max-height: 46vh;
  }

  .disclaimer-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .disclaimer-hint {
    text-align: center;
  }
}

[hidden] {
  display: none !important;
}

.option-btn.selected {
  border-color: var(--gold);
  background: rgba(218, 165, 32, 0.12);
}
