:root {
  --ink: #201914;
  --ink-soft: #51453a;
  --paper: #f3e6bf;
  --paper-light: #fff8df;
  --paper-dark: #d1bd8f;
  --cinnabar: #9a3327;
  --cinnabar-dark: #642019;
  --jade: #28766d;
  --jade-dark: #184b47;
  --gold: #c28a2b;
  --line: rgba(70, 52, 36, .34);
  --shadow: 0 14px 34px rgba(30, 22, 15, .24);
  --serif: "Noto Serif SC", "Songti SC", STSong, SimSun, serif;
  --brush: "FZKai-Z03", "KaiTi", "STKaiti", var(--serif);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #171310; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--serif); background: #171310; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #f1ba42; outline-offset: 3px; }
.skip-link { position: fixed; left: 12px; top: 12px; z-index: 100; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; color: var(--ink); background: var(--paper-light); }
.skip-link:focus { width: auto; height: auto; margin: 0; padding: 12px 16px; overflow: visible; clip-path: none; }
.page-shell {
  min-height: 100vh;
  background:
    linear-gradient(rgba(243,230,191,.88), rgba(225,205,159,.93)),
    radial-gradient(circle at 15% 5%, #fff5cc 0 8%, transparent 30%),
    repeating-linear-gradient(97deg, rgba(72,54,35,.04) 0 1px, transparent 1px 7px);
}
.page-shell::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22; background: radial-gradient(ellipse at 8% 80%, #302921 0 4%, transparent 5%), radial-gradient(ellipse at 90% 14%, #4d4034 0 6%, transparent 7%); mix-blend-mode: multiply; }
.site-bar { position: relative; z-index: 2; min-height: 72px; padding: 12px clamp(16px, 3vw, 44px); display: grid; grid-template-columns: 130px 1fr auto; gap: 20px; align-items: center; color: #f7edd1; background: rgba(29, 23, 18, .96); border-bottom: 3px solid var(--gold); }
.site-mark { color: inherit; font: 800 20px/1 system-ui, sans-serif; letter-spacing: .12em; text-decoration: none; }
.game-title { display: flex; align-items: center; justify-content: center; gap: 12px; }
.game-title h1 { margin: 0; font: 700 25px/1 var(--brush); letter-spacing: .14em; }
.game-title p { margin: 5px 0 0; color: #cdbf9f; font: 12px/1.2 system-ui, sans-serif; }
.seal { width: 42px; height: 42px; display: grid; place-items: center; border: 2px solid #d7604e; color: #d7604e; font: 800 14px/1 system-ui, sans-serif; transform: rotate(-3deg); }
.site-bar nav { display: flex; gap: 18px; }
.site-bar nav a { color: #f7edd1; font: 600 13px/1 system-ui, sans-serif; text-decoration: none; }
.site-bar nav a:hover { color: #f3bf5c; }
.game-layout { position: relative; z-index: 1; max-width: 1500px; margin: 0 auto; padding: 24px clamp(14px, 2vw, 30px) 40px; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(330px, .72fr); gap: 22px; }
.battle-column, .camp-column { min-width: 0; }
.resource-bar { min-height: 66px; display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.resource { min-width: 126px; display: flex; align-items: center; gap: 10px; padding: 8px 15px 8px 9px; color: #f9edc9; background: #3d2920; border: 2px solid #241a15; box-shadow: inset 0 0 0 2px rgba(255,255,255,.06); }
.resource-glyph { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; }
.bun-glyph { background: radial-gradient(circle at 52% 25%, #fff8e5 0 18%, #e9d2a1 19% 62%, #a66e3a 63% 68%, transparent 69%); }
.coin-glyph { background: var(--gold); border: 3px double #f8da61; color: #5c2a16; font: 800 16px/1 var(--brush); }
.resource b { display: block; font: 800 24px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.resource small { display: block; margin-top: 3px; color: #c9b797; font: 11px/1 system-ui, sans-serif; }
.campaign-mark { margin-left: auto; text-align: right; }
.campaign-mark span { display: block; color: var(--cinnabar); font: 700 28px/1 var(--brush); }
.campaign-mark b { display: block; margin-top: 5px; min-height: 22px; color: var(--cinnabar); font: 22px/1 system-ui, sans-serif; letter-spacing: 3px; }
.campaign-mark b i { display: inline-block; width: 15px; height: 15px; margin-left: 4px; border: 2px solid var(--cinnabar); border-radius: 50% 50% 45% 45%; transform: rotate(45deg); opacity: .24; }
.campaign-mark b i.is-full { background: var(--cinnabar); opacity: 1; }
.battle-frame, .camp-column, .field-notes { border: 2px solid #574738; background: rgba(247, 235, 199, .78); box-shadow: var(--shadow); }
.battle-frame { padding: 14px; position: relative; }
.battle-heading-row, .camp-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.chapter-story { display: block; max-width: 610px; margin-top: 5px; color: var(--ink-soft); font: 11px/1.4 system-ui, sans-serif; }
.kicker { margin: 0 0 5px; color: var(--cinnabar); font: 800 11px/1 system-ui, sans-serif; letter-spacing: .19em; text-transform: uppercase; }
h2 { margin: 0; font: 700 27px/1.1 var(--brush); letter-spacing: .08em; }
.battle-tools { display: flex; gap: 7px; }
.icon-button { min-width: 46px; height: 44px; border: 1px solid #75634e; background: var(--paper-light); cursor: pointer; box-shadow: 2px 3px 0 #7d684d; font: 800 13px/1 system-ui, sans-serif; }
.icon-button[aria-pressed="true"] { color: #fff4d3; background: var(--cinnabar); }
#battlefield { display: block; width: 100%; aspect-ratio: 3 / 2; border: 2px solid #3e3329; background: #dec99c; cursor: crosshair; touch-action: none; }
.wave-progress { height: 7px; margin-top: 8px; overflow: hidden; background: rgba(51,40,30,.18); }
.wave-progress span { display: block; width: 0; height: 100%; background: var(--cinnabar); transition: width .2s ease; }
.battle-status { min-height: 22px; padding-top: 8px; color: var(--ink-soft); font: 13px/1.45 system-ui, sans-serif; }
.action-dock { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.action-button { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 14px; border: 2px solid #34251d; cursor: pointer; box-shadow: 4px 5px 0 #4c372b; transition: transform .12s ease, box-shadow .12s ease; }
.action-button:hover { transform: translateY(-2px); box-shadow: 4px 7px 0 #4c372b; }
.action-button:active { transform: translateY(3px); box-shadow: 2px 2px 0 #4c372b; }
.action-button:disabled { cursor: not-allowed; filter: grayscale(.7); opacity: .58; transform: none; }
.recruit-action { background: #e1c178; }
.battle-action { color: #fff3d1; background: var(--cinnabar); }
.action-brush { font: 700 31px/1 var(--brush); letter-spacing: .12em; }
.action-button small { font: 600 12px/1.3 system-ui, sans-serif; }
.field-notes { min-height: 128px; padding: 14px 16px; display: grid; grid-template-columns: 120px 1fr; gap: 14px; }
.field-notes ol { max-height: 94px; margin: 0; padding: 0 0 0 22px; overflow: auto; color: var(--ink-soft); font: 13px/1.6 system-ui, sans-serif; }
.field-notes li:first-child { color: var(--ink); font-weight: 700; }
.camp-column { align-self: start; position: sticky; top: 12px; padding: 17px; background: rgba(228, 207, 160, .9); }
.camp-head > span { padding: 6px 9px; color: #f6eccd; background: #4a392d; font: 700 12px/1 system-ui, sans-serif; }
.combine-hint { margin: 0 0 12px; color: var(--ink-soft); font: 12px/1.5 system-ui, sans-serif; }
.recruitment-panel { margin-bottom: 12px; padding: 10px; border: 2px solid #5a4534; background: rgba(255,248,223,.74); }
.recruitment-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.recruitment-head b { color: var(--cinnabar); font: 700 17px/1 var(--brush); }
.recruitment-head small { color: var(--ink-soft); font: 10px/1.3 system-ui, sans-serif; text-align: right; }
.recruitment-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.candidate-card { position: relative; min-width: 0; min-height: 78px; padding: 5px 3px; display: grid; place-items: center; align-content: center; gap: 5px; border: 2px solid #8a7559; background: var(--paper-light); cursor: pointer; box-shadow: 0 2px 0 rgba(57,40,28,.2); }
.candidate-card:hover, .candidate-card:focus-visible { border-color: var(--cinnabar); transform: translateY(-2px); }
.candidate-card b { font: 700 clamp(24px, 2.6vw, 34px)/1 var(--brush); }
.candidate-card small { color: var(--ink-soft); font: 700 9px/1 system-ui, sans-serif; }
.candidate-card strong { padding: 3px 5px; color: #fff5d6; background: var(--cinnabar); font: 800 9px/1 system-ui, sans-serif; }
.candidate-card:disabled { cursor: not-allowed; opacity: .48; filter: grayscale(.6); transform: none; }
.candidate-card.hero-tone { color: #8c3e32; background: linear-gradient(145deg, #fff5c8, #e8c778); }
.candidate-empty { min-height: 78px; display: grid; place-items: center; border: 1px dashed rgba(77,58,42,.36); color: rgba(63,48,36,.52); font: 11px/1.3 system-ui, sans-serif; text-align: center; }
.recruitment-panel > p { margin: 8px 0 0; color: var(--ink-soft); font: 10px/1.45 system-ui, sans-serif; }
.inventory-grid { min-height: 295px; display: grid; grid-template-columns: repeat(5, minmax(52px, 1fr)); align-content: start; gap: 7px; padding: 9px; border: 2px solid #443529; background: rgba(64,44,31,.75); }
.unit-card { position: relative; min-width: 0; aspect-ratio: .8; padding: 4px; display: flex; flex-direction: column; justify-content: space-between; border: 2px solid #8a7559; background: var(--paper-light); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); touch-action: none; user-select: none; }
.unit-card:hover { border-color: var(--gold); }
.unit-card.is-selected { outline: 3px solid var(--jade); outline-offset: 1px; transform: translateY(-2px); }
.unit-card.is-dragging { opacity: .55; }
.unit-card .card-grade { align-self: flex-start; padding: 2px 4px; color: var(--ink-soft); background: rgba(94,76,54,.12); font: 700 8px/1 system-ui, sans-serif; }
.unit-card .card-char { align-self: center; font: 700 clamp(27px, 3.3vw, 42px)/1 var(--brush); }
.unit-card .card-level { align-self: flex-end; color: var(--cinnabar); font: 800 10px/1 system-ui, sans-serif; }
.xp-track { width: 100%; height: 4px; overflow: hidden; background: rgba(40,118,109,.2); }
.xp-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--jade), #5fac8e); transition: width .2s ease; }
.unit-card.hero-card { border-color: #b17c24; background: linear-gradient(145deg, #fff5c8, #e8c778); }
.unit-card.elite-card { border-color: #8c3e32; box-shadow: inset 0 0 0 2px #d5a54f; }
.unit-card.fragment-card { background: #fbf2d5; }
.unit-card.fragment-card .card-char { color: #b27627; }
.unit-card.farmer-card { border-color: #708044; background: linear-gradient(145deg, #f4efc9, #cdd69a); }
.unit-card.farmer-card .card-char { color: #5d6e2f; }
.unit-card .lane-ribbon { position: absolute; left: -4px; top: 50%; padding: 2px 3px; color: white; background: var(--jade); font: 700 8px/1 system-ui, sans-serif; }
.empty-card { aspect-ratio: .8; border: 1px dashed rgba(221,198,151,.3); }
.selected-strip { min-height: 42px; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; color: #f6eac9; background: #3c2d24; font: 12px/1 system-ui, sans-serif; }
.selected-strip b { font-size: 13px; }
.selected-strip button { min-width: 54px; min-height: 42px; border: 1px solid #9b856d; color: inherit; background: transparent; cursor: pointer; }
.economy-strip { min-height: 52px; display: grid; grid-template-columns: 38px 1fr; gap: 9px; align-items: center; padding: 8px 10px; border-top: 1px solid rgba(236,216,170,.22); color: #f6eac9; background: #4a3925; }
.economy-strip b, .economy-strip small { display: block; }
.economy-strip b { font: 700 14px/1.2 var(--serif); }
.economy-strip small { margin-top: 4px; color: #d5c59e; font: 10px/1.35 system-ui, sans-serif; }
.blessing-strip { padding: 7px 10px; color: #efe2bd; background: #2f514c; border-top: 1px solid rgba(255,255,255,.12); font: 700 10px/1.35 system-ui, sans-serif; }
.camp-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.camp-menu > button { min-height: 61px; display: grid; grid-template-columns: 37px 1fr; gap: 8px; align-items: center; padding: 7px; text-align: left; border: 1px solid #76624d; background: rgba(255,248,223,.72); cursor: pointer; }
.camp-menu > button:hover { border-color: var(--cinnabar); background: var(--paper-light); }
.menu-glyph { width: 35px; height: 35px; display: grid; place-items: center; color: #f8edcf; background: var(--jade); font: 700 17px/1 var(--brush); }
.camp-menu b, .camp-menu small { display: block; }
.camp-menu b { font: 700 14px/1.2 var(--serif); }
.camp-menu small { margin-top: 4px; color: var(--ink-soft); font: 10px/1.2 system-ui, sans-serif; }
.probability-note { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.probability-note div { display: flex; flex-wrap: wrap; gap: 5px; }
.probability-note span { padding: 4px 6px; color: var(--ink-soft); background: rgba(255,255,255,.34); font: 10px/1 system-ui, sans-serif; }
footer { position: relative; z-index: 1; padding: 22px; text-align: center; color: #cdbc98; background: #211a15; font: 12px/1.6 system-ui, sans-serif; }
footer p { margin: 2px; }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(16,12,9,.76); backdrop-filter: blur(3px); }
.sheet-dialog { width: min(620px, calc(100vw - 28px)); max-height: min(84vh, 760px); padding: 27px; overflow: auto; border: 3px solid #4e3c2f; background: var(--paper); box-shadow: 0 24px 70px rgba(0,0,0,.5); }
.wide-dialog { width: min(900px, calc(100vw - 28px)); }
.dialog-close { position: sticky; float: right; top: 0; z-index: 2; width: 44px; height: 44px; border: 0; color: white; background: var(--jade); cursor: pointer; font: 800 28px/1 system-ui, sans-serif; }
.sheet-dialog > h2 { margin-bottom: 22px; font-size: 34px; }
.sheet-dialog > p:not(.kicker) { color: var(--ink-soft); font: 15px/1.7 system-ui, sans-serif; }
.guide-steps { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 8px; }
.guide-steps li { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); }
.guide-steps b { color: var(--cinnabar); font: 700 18px/1.3 var(--brush); }
.guide-steps span { font: 14px/1.55 system-ui, sans-serif; }
.wide-button, .danger-button { width: 100%; min-height: 50px; border: 2px solid #3f3025; cursor: pointer; font-weight: 800; }
.wide-button { color: white; background: var(--jade); }
.danger-button { margin-top: 9px; color: #fff2d3; background: var(--cinnabar); }
.catalog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.catalog-card { padding: 14px; border: 1px solid var(--line); background: rgba(255,249,225,.72); }
.catalog-card .catalog-name { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.catalog-card b { font: 700 21px/1 var(--brush); }
.catalog-card em { color: var(--cinnabar); font: 700 10px/1.4 system-ui, sans-serif; font-style: normal; }
.catalog-card p, .catalog-card small { margin: 0; color: var(--ink-soft); font: 12px/1.55 system-ui, sans-serif; }
.catalog-card small { display: block; margin-top: 8px; color: var(--jade-dark); font-weight: 700; }
.catalog-list { display: grid; gap: 9px; }
.catalog-row { padding: 13px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); background: rgba(255,249,225,.72); }
.catalog-row b, .catalog-row small { display: block; }
.catalog-row small { margin-top: 5px; color: var(--ink-soft); font: 12px/1.5 system-ui, sans-serif; }
.catalog-row button { min-width: 92px; min-height: 42px; border: 1px solid #3c554f; color: white; background: var(--jade); cursor: pointer; }
.catalog-row.is-locked { opacity: .48; filter: grayscale(1); }
.merchant-list { display: grid; gap: 10px; }
.merchant-list button { min-height: 70px; display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 15px; text-align: left; border: 1px solid var(--line); background: var(--paper-light); cursor: pointer; }
.merchant-list button:hover { border-color: var(--cinnabar); }
.merchant-list b, .merchant-list small { display: block; }
.merchant-list small { margin-top: 4px; color: var(--ink-soft); font: 12px/1.4 system-ui, sans-serif; }
.merchant-list strong { color: var(--cinnabar); white-space: nowrap; }
.save-actions { margin-top: 22px; }
.reward-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.reward-card { min-height: 170px; padding: 14px; border: 2px solid #786143; background: var(--paper-light); cursor: pointer; }
.reward-card:hover { border-color: var(--cinnabar); transform: translateY(-2px); }
.reward-card b { display: block; margin: 18px 0 10px; font: 700 24px/1 var(--brush); }
.reward-card small { color: var(--ink-soft); font: 12px/1.5 system-ui, sans-serif; }
.reward-card em { display: block; margin: -4px 0 8px; color: var(--cinnabar); font: 800 10px/1.2 system-ui, sans-serif; font-style: normal; }
.merchant-list + h3 { margin: 24px 0 10px; font: 700 22px/1.2 var(--brush); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.result-stats div { padding: 12px 8px; text-align: center; background: rgba(255,255,255,.38); }
.result-stats b, .result-stats small { display: block; }
.result-stats b { font: 800 24px/1 system-ui, sans-serif; }
.result-stats small { margin-top: 4px; color: var(--ink-soft); font: 10px/1 system-ui, sans-serif; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 24px; min-width: 180px; max-width: calc(100vw - 30px); padding: 12px 18px; text-align: center; color: #fff3d4; background: #2b211a; border: 1px solid #b99459; box-shadow: var(--shadow); font: 600 13px/1.4 system-ui, sans-serif; opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .site-bar { grid-template-columns: auto 1fr; }
  .site-bar nav { display: none; }
  .game-title { justify-content: flex-end; }
  .game-layout { grid-template-columns: 1fr; max-width: 860px; }
  .camp-column { position: static; }
  .inventory-grid { min-height: 0; grid-template-columns: repeat(8, minmax(52px, 1fr)); }
  .unit-card { aspect-ratio: .78; }
}

@media (max-width: 620px) {
  .site-bar { min-height: 64px; padding: 10px 13px; gap: 8px; }
  .site-mark { font-size: 16px; }
  .game-title { gap: 8px; }
  .game-title h1 { font-size: 20px; }
  .game-title p, .seal { display: none; }
  .game-layout { padding: 12px 9px 28px; gap: 13px; }
  .resource-bar { min-height: 54px; gap: 7px; margin-bottom: 7px; }
  .resource { min-width: 0; flex: 1 1 0; padding: 6px 8px; gap: 5px; }
  .resource-glyph { width: 32px; height: 32px; }
  .resource b { font-size: 18px; }
  .campaign-mark span { font-size: 20px; }
  .campaign-mark b { font-size: 17px; }
  .battle-frame { padding: 8px; }
  h2 { font-size: 22px; }
  .battle-heading-row { margin-bottom: 7px; }
  .battle-tools { gap: 4px; }
  .icon-button { min-width: 42px; height: 42px; box-shadow: 1px 2px 0 #7d684d; font-size: 11px; }
  #battlefield { aspect-ratio: 4 / 3; }
  .action-dock { gap: 7px; margin: 10px 0; }
  .action-button { min-height: 66px; gap: 7px; box-shadow: 2px 3px 0 #4c372b; }
  .action-brush { font-size: 26px; }
  .action-button small { font-size: 10px; }
  .field-notes { min-height: 105px; padding: 11px; grid-template-columns: 86px 1fr; }
  .field-notes ol { max-height: 80px; font-size: 11px; }
  .camp-column { padding: 12px; }
  .candidate-card { min-height: 68px; }
  .candidate-card b { font-size: 25px; }
  .inventory-grid { grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 6px; }
  .unit-card .card-char { font-size: 30px; }
  .camp-menu { gap: 6px; }
  .camp-menu > button { min-height: 58px; }
  .catalog-grid, .reward-grid { grid-template-columns: 1fr; }
  .sheet-dialog { padding: 20px 16px; }
  .sheet-dialog > h2 { font-size: 28px; }
}

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