:root {
  color-scheme: light;
  --ink: #2b2a24;
  --cream: #fff8e6;
  --wood: #8a5a32;
  --wood-d: #5e3b1e;
  --gold: #f0c64f;
  --green: #4f7a3a;
  --red: #c2412d;
  --brush: 'Ma Shan Zheng', 'STKaiti', 'KaiTi', serif;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #86b45a; color: var(--ink); -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
h2, p { margin: 0; }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; display: block; touch-action: none; }

/* ---------- 顶部 HUD ---------- */
.hud { position: fixed; z-index: 10; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.pill { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px 0 8px; background: linear-gradient(#fff8e6, #f3e6c4); border: 3px solid var(--wood-d); border-radius: 999px; box-shadow: 0 4px 0 var(--wood-d), 0 8px 16px rgba(43,42,36,.2); font-weight: 800; }
.pill strong { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.coin-icon { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--ink); background: radial-gradient(circle at 35% 30%, #fff2b0, var(--gold) 55%, #b88a26); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.pill.coin { min-width: 130px; }
.pill.coin strong { color: #7a4f10; }
.pill.goal { flex-direction: column; align-items: stretch; justify-content: center; gap: 2px; min-width: 150px; height: 46px; padding: 0 14px; border-radius: 14px; }
.pill.goal span:first-child { font: 400 18px/1 var(--brush); }
.goal-bar { display: block; height: 7px; background: #e5d6ad; border-radius: 4px; overflow: hidden; }
.goal-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6aa142, #9fd06a); transition: width .4s; }
.pill.goal small { font-size: 11px; color: #7a6a4a; }
.pill.bag span { font-size: 12px; color: #7a6a4a; }
.pill.bag strong { font-size: 18px; }
.tools { display: flex; gap: 6px; margin-left: auto; }
.tool { min-width: 46px; height: 46px; padding: 0 12px; font-weight: 800; background: linear-gradient(#fff8e6, #f3e6c4); border: 3px solid var(--wood-d); border-radius: 14px; box-shadow: 0 4px 0 var(--wood-d); }
.tool:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-d); }

/* 底部提示：当前该做什么 */
.hint { position: fixed; z-index: 10; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 8px 18px; font-weight: 800; font-size: 15px; color: var(--ink); background: #ffe58a; border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink); pointer-events: none; white-space: nowrap; animation: hint-bob 1.4s ease-in-out infinite; }
@keyframes hint-bob { 50% { transform: translate(-50%, -4px); } }
.pause-banner { position: fixed; z-index: 15; inset: 0; display: grid; place-items: center; font: 400 48px/1 var(--brush); color: var(--cream); background: rgba(43,42,36,.45); letter-spacing: 6px; pointer-events: none; }

/* ---------- 面板 ---------- */
.help { position: fixed; z-index: 30; top: 76px; right: 12px; width: min(360px, calc(100vw - 24px)); padding: 18px 18px 14px; background: var(--cream); border: 3px solid var(--wood-d); border-radius: 18px; box-shadow: 0 6px 0 var(--wood-d), 0 16px 30px rgba(43,42,36,.3); }
.help h2 { margin-bottom: 8px; font: 400 28px/1.1 var(--brush); }
.help ol { margin: 0 0 10px; padding-left: 20px; font-size: 14px; line-height: 1.6; color: #4a4536; }
.help b { color: var(--ink); }
.x { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; font-size: 24px; line-height: 1; background: none; border: 0; }
.link-btn { padding: 4px 0; font-size: 12px; color: #8a8270; background: none; border: 0; text-decoration: underline; }

.scrim { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(43,42,36,.45); }
.modal { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; background: var(--cream); border: 3px solid var(--wood-d); border-radius: 20px; box-shadow: 0 6px 0 var(--wood-d), 0 20px 40px rgba(43,42,36,.35); animation: pop-in .25s cubic-bezier(.3,1.5,.5,1); }
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal h2 { font: 400 32px/1.1 var(--brush); }
.pill.small { height: 38px; } .pill.small strong { font-size: 18px; } .pill.small .coin-icon { width: 24px; height: 24px; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 12px; background: #fff; border: 2px solid rgba(43,42,36,.15); border-radius: 14px; }
.row-copy { flex: 1; min-width: 0; }
.row-copy strong { display: flex; align-items: baseline; gap: 6px; font-size: 16px; }
.row-copy strong i { font-style: normal; font-size: 12px; color: #8a8270; font-weight: 700; }
.row-copy small { display: block; font-size: 12px; color: #6a6450; }
.buy { min-width: 96px; min-height: 44px; padding: 0 12px; font-weight: 800; font-size: 15px; color: #fff; background: linear-gradient(#6f9a4f, var(--green)); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); font-variant-numeric: tabular-nums; }
.buy:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.buy.is-short { color: #6a6450; background: #e5ddc8; }
.buy:disabled { color: #8a8270; background: transparent; border-color: rgba(43,42,36,.2); box-shadow: none; cursor: default; }
.big-btn { display: block; width: 100%; min-height: 52px; margin-top: 14px; font-size: 17px; font-weight: 800; color: #fff; background: linear-gradient(#d8563f, var(--red)); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.toasts { position: fixed; z-index: 50; top: 76px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { max-width: min(420px, calc(100vw - 32px)); padding: 8px 16px; font-weight: 700; font-size: 14px; color: var(--cream); background: rgba(43,42,36,.88); border-radius: 999px; animation: toast-in .2s ease-out, toast-out .3s ease-in 2.7s forwards; }
.toast.warn { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

@media (max-width: 640px) {
  .hud { flex-wrap: wrap; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 8px 8px; }
  .pill { height: 40px; padding: 0 10px 0 6px; }
  .pill strong { font-size: 18px; }
  .coin-icon { width: 24px; height: 24px; }
  .pill.coin { min-width: 0; }
  .pill.goal { min-width: 110px; height: 40px; padding: 0 10px; }
  .pill.bag span { display: none; }
  .tool { min-width: 40px; height: 40px; padding: 0 8px; }
  .tools { margin-left: auto; }
  .hint { font-size: 13px; }
  .toasts { top: 62px; }
  .help { top: 62px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* ---------- 第二循环：木料、村祠、营地 ---------- */
.wood-icon { width: 28px; height: 22px; flex: none; border-radius: 6px; border: 2px solid var(--ink); background: repeating-linear-gradient(90deg, #a0683a 0 6px, #8a5a32 6px 8px); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.pill.wood strong { color: #6b4422; }
.pill.hall { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; padding: 0 12px; border-radius: 14px; }
.pill.hall span { font: 400 16px/1.1 var(--brush); color: var(--red); }
.pill.hall small { font-size: 11px; color: #7a6a4a; }
.pill.hall b { color: var(--ink); }
.lead { margin: 6px 0; font-size: 13px; line-height: 1.6; color: #4a4536; }
.tip { margin: 4px 0; font-size: 12px; color: var(--red); font-weight: 700; }
.stat-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 12px; background: #fff; border: 2px solid rgba(43,42,36,.15); border-radius: 12px; font-size: 13px; color: #6a6450; }
.stat-row b { font-size: 18px; color: var(--ink); margin-right: 6px; font-variant-numeric: tabular-nums; }
.cost-row { display: flex; gap: 8px; margin: 8px 0; }
.cost-row span { flex: 1; padding: 8px 10px; font-weight: 800; font-size: 13px; text-align: center; border-radius: 10px; background: #f6dcd6; color: var(--red); border: 2px solid rgba(194,65,45,.3); }
.cost-row span.ok { background: #e3f1d3; color: var(--green); border-color: rgba(79,122,58,.3); }
.big-btn:disabled { color: #8a8270; background: #e5ddc8; box-shadow: none; cursor: default; }
.ghost-btn { display: block; width: 100%; margin-top: 10px; padding: 10px; font-weight: 700; color: #6a6450; background: none; border: 2px dashed rgba(43,42,36,.25); border-radius: 12px; }
.modal h3 { margin: 14px 0 0; font-size: 16px; }
.modal h3 small { font-weight: 500; font-size: 12px; color: #8a8270; }
.stage-card { margin-top: 10px; padding: 12px; background: linear-gradient(#3d4a5a, #2b3440); color: var(--cream); border: 3px solid var(--ink); border-radius: 14px; }
.stage-card .lead { color: #d8d2c0; }
.stage-card .lead b { color: #ffe58a; }
.stage-head { display: flex; align-items: center; justify-content: space-between; }
.stage-head strong { font: 400 22px/1.1 var(--brush); }
.odds { padding: 2px 10px; font-size: 12px; font-weight: 800; border-radius: 999px; }
.odds-ok { background: #6aa142; } .odds-mid { background: #e0a02c; color: var(--ink); } .odds-bad { background: var(--red); }
.vs { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; font-size: 12px; font-weight: 800; }
.vs-bar { flex: 1; height: 10px; background: var(--red); border-radius: 6px; overflow: hidden; }
.vs-bar i { display: block; height: 100%; background: #6aa142; }
.battle { margin: 8px 0; }
.b-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.b-bar { flex: 1; height: 12px; background: rgba(255,255,255,.15); border-radius: 6px; overflow: hidden; }
.b-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #8fd16a, #6aa142); transition: none; }
.b-bar.enemy i { background: linear-gradient(90deg, #e0566b, var(--red)); }
#b-result { font-weight: 800; color: #ffe58a; }
.row.locked { opacity: .55; border-style: dashed; }
.row.idle { background: #fff6df; }
@media (max-width: 640px) {
  .pill.hall { display: none; }
  .pill.wood { padding-right: 10px; }
  .wood-icon { width: 22px; height: 18px; }
}
@media (max-width: 1000px) { .pill.bag { display: none; } .pill.goal { min-width: 120px; } .pill.coin { min-width: 0; } .tool { padding: 0 8px; } }
