/* 砍树小能手 · 经营版 UI */
:root {
  --green: #3fae5a; --green-d: #1f7a4d; --wood: #a86b34; --wood-d: #6b4425;
  --cream: #fff8e6; --ink: #2b2118; --gold: #ffc531; --red: #e85b46;
  --panel: #fffaf0; --line: #e9dcc0;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --dock-h: 26%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden;
  overscroll-behavior: none; touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink); -webkit-user-select: none; user-select: none;
  background: #143a2c;
}
body {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 15%, #2b6b4a 0, transparent 45%), radial-gradient(circle at 82% 85%, #245b41 0, transparent 45%), #143a2c;
}
#app { position: relative; width: min(100vw, 460px); height: min(100dvh, 880px); overflow: hidden; background: #7ed957; isolation: isolate; }
@media (min-width: 620px) and (min-height: 700px) { #app { border-radius: 26px; box-shadow: 0 24px 70px rgba(0,0,0,.5), 0 0 0 8px rgba(255,255,255,.06); } }
@media (max-width: 619px), (max-height: 699px) { #app { width: 100vw; height: 100dvh; } }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- 顶部 HUD ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; z-index: 5; padding: calc(var(--safe-t) + 10px) 12px 0; pointer-events: none; }
.hud-top { display: flex; align-items: center; gap: 7px; }
.brand { font-size: 14px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.3); letter-spacing: 1px; white-space: nowrap; }
.hud-coins { display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); padding: 5px 9px; border-radius: 999px; color: #ffe066; font-size: 14px; font-variant-numeric: tabular-nums; }
.hud-coins strong { font-size: 15px; }
.ico-coin { width: 13px; height: 13px; border-radius: 50%; background: var(--gold); border: 2px solid #b8790b; box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); display: inline-block; }
.hud-level { background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); padding: 5px 9px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 800; }
.hud-level strong { font-size: 14px; }
.hud-account { margin-left: auto; pointer-events: auto; border: 1px solid rgba(255,255,255,.4); background: rgba(0,0,0,.45); color: #fff; font-size: 11px; font-weight: 800; padding: 6px 10px; border-radius: 999px; cursor: pointer; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-account.on { background: rgba(255,197,49,.92); color: #5d3b00; border-color: #fff; }
.exp-bar { position: relative; height: 13px; margin-top: 7px; border-radius: 999px; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.28); overflow: hidden; }
.exp-bar > div { height: 100%; width: 0; background: linear-gradient(180deg, #b6f36a, #4dbb52); transition: width .25s; }
.exp-bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.res-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 7px; }
.res-card { background: rgba(255,255,255,.88); border: 1.5px solid rgba(255,255,255,.9); border-radius: 11px; padding: 6px 7px; display: flex; align-items: center; gap: 6px; position: relative; box-shadow: 0 2px 6px rgba(0,0,0,.12); overflow: hidden; }
.res-ico { width: 18px; height: 18px; border-radius: 4px; flex: 0 0 18px; display: block; }
.ico-log { background: linear-gradient(90deg, #6f421e, #c98a4b); border-radius: 9px; }
.ico-plank { background: linear-gradient(180deg, #e6bb75, #c98a4b); }
.ico-goods { background: linear-gradient(135deg, #f0c98a, #a86b34); border-radius: 3px; }
.res-info { display: flex; flex-direction: column; line-height: 1.1; }
.res-info span { font-size: 9px; color: #8a735c; font-weight: 700; }
.res-info b { font-size: 14px; font-variant-numeric: tabular-nums; }
.res-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0,0,0,.08); }
.res-bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width .25s; }
.res-card.full .res-bar i { background: var(--red); }

/* ---------- 黄金树事件 ---------- */
.gold-btn { position: absolute; z-index: 6; top: calc(var(--safe-t) + 148px); left: 50%; transform: translateX(-50%); border: 2px solid #fff; background: linear-gradient(180deg, #ffe27a, #f0a521); color: #5d3b00; font-size: 13px; font-weight: 900; padding: 9px 16px; border-radius: 999px; box-shadow: 0 4px 0 #b76a12, 0 8px 18px rgba(0,0,0,.3); cursor: pointer; animation: bob 1s ease-in-out infinite; }
.gold-btn span { opacity: .75; margin-left: 4px; }
@keyframes bob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }

/* ---------- 底部操作台 ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; height: var(--dock-h); min-height: 172px; display: flex; flex-direction: column; background: linear-gradient(180deg, rgba(28,52,36,.82), rgba(18,36,26,.96)); backdrop-filter: blur(8px); border-top: 2px solid rgba(255,255,255,.18); padding-bottom: var(--safe-b); }
.dock-tabs { display: flex; flex: 0 0 38px; border-bottom: 1px solid rgba(255,255,255,.14); }
.dock-tabs button { flex: 1; border: 0; background: transparent; color: rgba(255,255,255,.65); font-size: 12px; font-weight: 800; cursor: pointer; position: relative; }
.dock-tabs button.on { color: #fff; }
.dock-tabs button.on::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--gold); }
.tab { display: none; flex: 1; min-height: 0; padding: 10px 12px; }
.tab.active { display: flex; flex-direction: column; }
.scroll-box { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.tall-box { max-height: 46vh; }

.produce-row { display: flex; gap: 10px; flex: 1; min-height: 0; }
.chop-btn { flex: 1.15; border: 0; border-radius: 18px; background: linear-gradient(180deg, #ffd85c, #f39b21); color: #5a3200; box-shadow: 0 5px 0 #b76a12, 0 10px 20px rgba(0,0,0,.3); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative; overflow: hidden; }
.chop-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b76a12; }
.chop-main { font-size: 27px; font-weight: 900; letter-spacing: 4px; text-shadow: 0 2px 0 rgba(255,255,255,.45); }
.chop-sub { font-size: 11px; font-weight: 800; opacity: .8; }
.chop-axe { width: 26px; height: 26px; position: relative; margin-bottom: 2px; }
.chop-axe::before { content: ""; position: absolute; left: 2px; top: 1px; width: 16px; height: 14px; background: linear-gradient(135deg,#f2f7fa,#9fb4c4); border: 2px solid #43586a; border-radius: 3px 12px 12px 3px; transform: rotate(-12deg); }
.chop-axe::after { content: ""; position: absolute; left: 14px; top: 10px; width: 5px; height: 18px; border-radius: 2px; background: #8a5426; transform: rotate(38deg); }
.produce-side { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.side-btn { flex: 1; border: 1.5px solid rgba(255,255,255,.28); background: rgba(255,255,255,.1); color: #fff; border-radius: 14px; padding: 8px; text-align: left; cursor: pointer; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.side-btn b { font-size: 13px; }
.side-btn span { font-size: 10px; opacity: .7; }
.side-btn.boss-on { background: rgba(63,174,90,.55); border-color: #8ce88a; }
.chain-line { flex: 0 0 22px; text-align: center; font-size: 10px; color: rgba(255,255,255,.72); font-weight: 700; padding-top: 5px; }

/* 升级列表 */
.group-title { font-size: 11px; font-weight: 900; color: rgba(255,255,255,.55); letter-spacing: 2px; margin: 8px 2px 5px; }
.up-row { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 8px 9px; margin-bottom: 6px; }
.up-ico { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; background: rgba(255,197,49,.22); border: 1px solid rgba(255,197,49,.45); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #ffe066; }
.up-info { flex: 1; min-width: 0; }
.up-info b { display: block; font-size: 12px; color: #fff; }
.up-info span { display: block; font-size: 10px; color: rgba(255,255,255,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-lv { font-size: 10px; color: #ffe066; font-weight: 800; white-space: nowrap; }
.buy-btn { border: 0; border-radius: 10px; padding: 8px 9px; min-width: 62px; font-size: 11px; font-weight: 900; cursor: pointer; background: var(--gold); color: #5d3b00; white-space: nowrap; }
.buy-btn.poor { background: rgba(255,255,255,.16); color: rgba(255,255,255,.55); }
.buy-btn.max { background: rgba(63,174,90,.4); color: #d9ffe0; }

/* 订单 */
.order-card { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 12px; padding: 9px 10px; margin-bottom: 7px; }
.order-top { display: flex; align-items: center; gap: 6px; }
.order-top b { font-size: 13px; color: #fff; }
.order-reward { margin-left: auto; color: #ffe066; font-size: 12px; font-weight: 900; }
.order-bottom { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.order-time { flex: 1; height: 5px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.order-time i { display: block; height: 100%; background: var(--green); }
.order-count { font-size: 10px; color: rgba(255,255,255,.7); }
.deliver-btn { border: 0; border-radius: 9px; padding: 6px 12px; font-size: 11px; font-weight: 900; background: var(--green); color: #fff; cursor: pointer; }
.deliver-btn.off { background: rgba(255,255,255,.16); color: rgba(255,255,255,.5); }

/* 更多 */
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.more-grid button { border: 1.5px solid rgba(255,255,255,.22); background: rgba(255,255,255,.1); color: #fff; border-radius: 12px; padding: 14px 4px; font-size: 11px; font-weight: 800; cursor: pointer; }
.more-grid button:active { transform: scale(.95); }

/* ---------- 弹窗 ---------- */
.screen { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 14px) 14px calc(var(--safe-b) + 14px); background: rgba(12,32,22,.68); backdrop-filter: blur(4px); }
.screen.active { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel { width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border: 3px solid #fff; border-radius: 22px; padding: 18px 16px; box-shadow: 0 8px 0 rgba(0,0,0,.2), 0 20px 50px rgba(0,0,0,.4); animation: pop .22s cubic-bezier(.2,1.3,.5,1); }
.panel.wide { max-width: 420px; }
.panel.small { max-width: 310px; text-align: center; }
.panel.tall { max-height: 92%; }
@keyframes pop { from { transform: scale(.9) translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-title { margin: 0; font-size: 19px; font-weight: 900; color: var(--wood-d); }
.x-btn { border: 0; background: #eee0c4; color: #7a6650; width: 28px; height: 28px; border-radius: 9px; font-size: 18px; font-weight: 900; cursor: pointer; line-height: 1; }
.btn { border: 0; cursor: pointer; font-family: inherit; font-weight: 900; font-size: 14px; padding: 11px 16px; border-radius: 13px; color: #fff; background: rgba(0,0,0,.1); }
.btn:active { transform: translateY(2px); }
.btn-primary { background: linear-gradient(180deg, #ffd85c, #f39b21); color: #5a3200; box-shadow: 0 4px 0 #b76a12; }
.btn-ghost { background: #efe3c9; color: var(--wood-d); border: 1.5px solid #ddcba9; }
.panel-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.panel-actions .btn { flex: 1; min-width: 88px; }
.close-btn { width: 100%; margin-top: 12px; }
.panel-desc { font-size: 12px; color: #7a6650; line-height: 1.6; margin: 8px 0; }
.panel-desc.tiny { font-size: 10px; margin: 10px 0 2px; }
.tabs { display: flex; gap: 7px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 0; border-radius: 11px; padding: 9px; font-weight: 800; font-size: 12px; background: #efe3c9; color: #8a735c; cursor: pointer; }
.tabs button.on { background: var(--green-d); color: #fff; }

/* 表单 */
.form label { display: block; font-size: 12px; font-weight: 800; color: #7a6650; margin-bottom: 10px; }
.form input { display: block; width: 100%; margin-top: 5px; border: 2px solid var(--line); background: #fff; border-radius: 11px; padding: 11px 12px; font-size: 14px; font-family: inherit; color: var(--ink); outline: none; -webkit-user-select: text; user-select: text; }
.form input:focus { border-color: var(--green); }
.form-tip { font-size: 11px; color: #8a735c; line-height: 1.55; margin: 4px 0 10px; }
.form-error { font-size: 12px; color: #c0392b; font-weight: 700; min-height: 16px; margin-bottom: 6px; }
.form .btn { width: 100%; margin-top: 6px; }

/* 账号 / 管理后台 */
.account-card { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; font-size: 12px; line-height: 1.9; color: #6b5842; }
.account-card b { color: var(--wood-d); font-size: 14px; }
.badge { display: inline-block; font-size: 10px; font-weight: 900; padding: 2px 8px; border-radius: 999px; background: #e8f3e2; color: #2f7a4d; margin-left: 6px; }
.badge.admin { background: #ffe9a8; color: #8a5a00; }
.badge.banned { background: #fde0dc; color: #b93a2c; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.admin-stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 2px; text-align: center; }
.admin-stats span { display: block; font-size: 9px; color: #9a8470; }
.admin-stats b { font-size: 15px; color: var(--green-d); }
.admin-user { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.au-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.au-top b { font-size: 13px; }
.au-meta { font-size: 10px; color: #9a8470; margin: 5px 0 8px; line-height: 1.6; }
.au-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.au-actions button { border: 1px solid var(--line); background: #f7f0df; color: #6b5842; border-radius: 8px; padding: 6px 8px; font-size: 10px; font-weight: 800; cursor: pointer; }
.au-actions button.danger { background: #fde0dc; color: #b93a2c; border-color: #f3c2bb; }
.au-actions button.good { background: #e8f3e2; color: #2f7a4d; border-color: #c9e4c4; }

/* 记录 / 排行 / 成就 */
.rec-row { display: flex; gap: 9px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 6px; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: 0 0 8px; margin-top: 5px; }
.rec-body { flex: 1; min-width: 0; }
.rec-body b { display: block; font-size: 12px; color: var(--wood-d); }
.rec-body span { font-size: 10px; color: #9a8470; }
.rec-val { font-size: 12px; font-weight: 900; color: #c58b10; }
.rank-row { display: flex; align-items: center; gap: 9px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 6px; font-size: 12px; }
.rank-no { width: 22px; height: 22px; border-radius: 7px; background: #eee0c4; color: #8a735c; font-weight: 900; display: flex; align-items: center; justify-content: center; flex: 0 0 22px; }
.rank-row:nth-child(1) .rank-no { background: var(--gold); color: #5d3b00; }
.rank-row:nth-child(2) .rank-no { background: #cfd8dc; }
.rank-row:nth-child(3) .rank-no { background: #e0b48b; }
.rank-score { margin-left: auto; font-weight: 900; color: var(--green-d); }
.ach-row { display: flex; gap: 9px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 6px; }
.ach-row.done { border-color: #b9e0b4; background: #f2fbef; }
.ach-mark { width: 24px; height: 24px; border-radius: 8px; background: #eee0c4; color: #8a735c; display: flex; align-items: center; justify-content: center; font-weight: 900; flex: 0 0 24px; font-size: 13px; }
.ach-row.done .ach-mark { background: var(--green); color: #fff; }
.ach-row b { font-size: 12px; display: block; }
.ach-row span { font-size: 10px; color: #9a8470; }
.ach-reward { margin-left: auto; font-size: 11px; font-weight: 900; color: #c58b10; white-space: nowrap; }
.help-list { display: flex; flex-direction: column; gap: 11px; }
.help-item { display: flex; gap: 10px; align-items: flex-start; }
.help-item > b { flex: 0 0 24px; height: 24px; border-radius: 8px; background: var(--green-d); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.help-item strong { font-size: 13px; color: var(--wood-d); }
.help-item p { margin: 3px 0 0; font-size: 11px; line-height: 1.55; color: #7a6650; }
.setting-list { display: flex; flex-direction: column; margin-bottom: 8px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; cursor: pointer; }
.setting-row input { display: none; }
.switch { width: 44px; height: 25px; border-radius: 999px; background: #d6cbb6; position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.setting-row input:checked + .switch { background: var(--green); }
.setting-row input:checked + .switch::after { transform: translateX(19px); }
.setting-note { font-size: 11px; color: #8a735c; line-height: 1.6; margin-bottom: 10px; }

/* 离线奖励 */
.offline-ico { width: 62px; height: 62px; margin: 0 auto 10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe27a, #f0a521); box-shadow: 0 5px 0 #b76a12; position: relative; }
.offline-ico::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.75); }
.offline-coin { font-size: 40px; font-weight: 900; color: #c58b10; margin: 8px 0 16px; }
#offlineScreen .btn { width: 100%; }

/* Toast */
.toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 172px); transform: translate(-50%, -10px); z-index: 40; background: rgba(30,25,18,.92); color: #fff; font-size: 12px; font-weight: 800; padding: 9px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .25s; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 680px) {
  .chop-main { font-size: 22px; }
  .brand { font-size: 12px; }
  .res-card { padding: 5px; }
  .dock-tabs { flex-basis: 32px; }
  .tab { padding: 7px 10px; }
  .gold-btn { top: calc(var(--safe-t) + 128px); }
}

/* ============================================================
   2.0 伐木小镇：地图视图 / 双视图切换 / 场所面板
   ============================================================ */
#viewSwitch {
  position: absolute; z-index: 15; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(-50%);
  display: flex; gap: 3px; padding: 3px; border-radius: 999px;
  background: rgba(20, 45, 32, .84); border: 1.5px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0, 0, 0, .3); white-space: nowrap;
}
#viewSwitch button { border: 0; background: transparent; color: rgba(255, 255, 255, .72); font-size: 11px; font-weight: 800; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
#viewSwitch button.on { background: linear-gradient(180deg, #ffd85c, #f39b21); color: #5a3200; box-shadow: 0 2px 0 #b76a12; }

#classicView, #townView { position: absolute; inset: 0; }
/* 用 visibility 而非 display:none：1.0 的 Canvas 仍保有尺寸，渲染器不会拿到 0 宽高 */
body[data-view="town"] #classicView { visibility: hidden; pointer-events: none; }
body[data-view="classic"] #townView { visibility: hidden; pointer-events: none; }
/* 地图在桌面/平板铺满屏幕；切回经营总览仍是原来的手机框 */
body[data-view="town"] #app { width: 100vw; max-width: none; height: 100dvh; border-radius: 0; box-shadow: none; }
#townCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#townTop {
  position: absolute; z-index: 8; top: calc(var(--safe-t) + 44px); left: 8px; right: 8px;
  display: flex; gap: 5px; align-items: center; flex-wrap: wrap; pointer-events: none;
}
.tt-item { display: flex; align-items: center; gap: 4px; background: rgba(20, 45, 32, .74); border: 1px solid rgba(255, 255, 255, .25); color: #fff; font-size: 11px; font-weight: 800; padding: 5px 9px; border-radius: 999px; }
.tt-item b { color: #ffe066; font-variant-numeric: tabular-nums; }
.tt-btn { pointer-events: auto; margin-left: auto; border: 1px solid rgba(255, 255, 255, .4); background: rgba(20, 45, 32, .74); color: #fff; font-size: 10px; font-weight: 800; padding: 6px 10px; border-radius: 999px; cursor: pointer; }

#townHud {
  position: absolute; z-index: 8; top: calc(var(--safe-t) + 80px); left: 8px; width: min(238px, 54vw);
  background: rgba(20, 45, 32, .93); border: 1px solid rgba(255, 255, 255, .28); border-radius: 12px;
  padding: 8px 10px; color: #fff; pointer-events: none;
}
.th-row { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; margin-bottom: 4px; }
.th-row > span { width: 26px; flex: 0 0 26px; }
.th-bar { flex: 1; height: 7px; border-radius: 99px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.th-bar i { display: block; height: 100%; width: 100%; transition: width .2s; }
.th-bar i.gas { background: linear-gradient(90deg, #ffce54, #f39b21); }
.th-bar i.stam { background: linear-gradient(90deg, #9be36a, #3fae5a); }
.th-row b { font-size: 10px; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.th-line { display: flex; gap: 8px; font-size: 10px; opacity: .92; margin-top: 3px; flex-wrap: wrap; }
.th-line span:last-child { color: #ffe066; font-weight: 800; }
#tEvent { margin-top: 5px; font-size: 10px; font-weight: 800; color: #ffe066; cursor: pointer; pointer-events: auto; }
#tEvent.has { animation: tpulse 1.2s ease-in-out infinite; }
@keyframes tpulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

#miniWrap { position: absolute; z-index: 8; right: 8px; top: calc(var(--safe-t) + 80px); width: min(150px, 36vw); background: rgba(20, 45, 32, .93); border: 1px solid rgba(255, 255, 255, .25); border-radius: 12px; padding: 6px; pointer-events: auto; }
#miniMap { width: 100%; height: 76px; display: block; border-radius: 6px; cursor: crosshair; background: #7ed957; }
#miniWrap span { display: block; text-align: center; font-size: 9px; color: rgba(255, 255, 255, .78); margin-top: 3px; }

#townControls { position: absolute; z-index: 9; left: 0; right: 0; bottom: 0; padding: 0 14px calc(var(--safe-b) + 14px); display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; pointer-events: none; }
#joystick { pointer-events: auto; width: 104px; height: 104px; flex: 0 0 104px; border-radius: 50%; background: rgba(20, 45, 32, .45); border: 2px solid rgba(255, 255, 255, .42); position: relative; touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #cfd8d0); border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); }
#actionBtns { pointer-events: auto; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; max-width: 62%; }
.act { border: 2px solid rgba(255, 255, 255, .7); background: rgba(20, 45, 32, .82); color: #fff; font-size: 12px; font-weight: 900; padding: 12px 13px; border-radius: 16px; cursor: pointer; touch-action: none; }
.act.primary { background: linear-gradient(180deg, #ffd85c, #f39b21); color: #5a3200; border-color: #fff; box-shadow: 0 4px 0 #b76a12; }
.act.sprint { background: rgba(60, 120, 180, .88); }
.act.sprint.on { background: #f39b21; color: #3a2000; }

/* ---------- 场所面板 ---------- */
#townPanel {
  /* 用 left/right 定位而非 transform 居中：pop 动画的 transform 会覆盖 translateX(-50%)，
     导致面板被推到右侧、内容被裁切。 */
  position: absolute; z-index: 12; left: 10px; right: 10px; width: auto;
  bottom: calc(var(--safe-b) + 126px); max-height: min(58vh, 540px);
  background: var(--panel); border: 3px solid #fff; border-radius: 18px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .18), 0 20px 50px rgba(0, 0, 0, .4);
  display: none; flex-direction: column; overflow: hidden;
}
#townPanel.open { display: flex; animation: tpop .2s cubic-bezier(.2, 1.3, .5, 1); }
@keyframes tpop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.tp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; border-bottom: 2px solid var(--line); flex: 0 0 auto; }
.tp-head-txt { min-width: 0; }
.tp-head h2 { margin: 0; font-size: 17px; font-weight: 900; color: var(--wood-d); }
.tp-head p { margin: 3px 0 0; font-size: 11px; color: #7a6650; line-height: 1.5; }
.sound-chip { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #e2f2e0; color: #1f7a4d; font-size: 10px; font-weight: 800; }
.sound-chip.indoor { background: #e6e9f5; color: #4a5a8c; }
.tp-body { padding: 10px 14px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.tp-sec { margin-bottom: 12px; }
.tp-sec-t { font-size: 12px; font-weight: 900; color: var(--green-d); border-left: 4px solid var(--green); padding-left: 7px; margin-bottom: 7px; }
.tp-kv { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.tp-kv b { font-variant-numeric: tabular-nums; color: var(--wood-d); }
.tp-tip { font-size: 11px; color: #8a735c; line-height: 1.6; margin: 6px 0 8px; }
.tp-btn { border: 1.5px solid var(--green-d); background: #fff; color: var(--green-d); font-size: 11px; font-weight: 800; padding: 7px 10px; border-radius: 10px; cursor: pointer; margin: 3px 4px 3px 0; }
.tp-btn:hover { background: #eaf6e6; }
.tp-btn.primary { background: linear-gradient(180deg, #ffd85c, #f39b21); color: #5a3200; border-color: #b76a12; box-shadow: 0 3px 0 #b76a12; }
.tp-btn.danger { border-color: #c0503c; color: #c0503c; }
.tp-inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.tp-inline select, .tp-inline input, .tp-line-ops select {
  border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 11px;
  background: #fff; color: var(--ink); max-width: 190px;
}
.tp-line { border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 9px; margin-bottom: 8px; background: #fff; }
.tp-line.down { border-color: #e85b46; background: #fff4f0; }
.tp-line-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.tp-line-top .lv { font-size: 10px; color: #8a735c; font-weight: 700; }
.tp-line-top .st { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; }
.tp-line-top .st.ok { background: #e2f2e0; color: #1f7a4d; }
.tp-line-top .st.off { background: #eee; color: #888; }
.tp-line-top .st.bad { background: #ffe3dd; color: #c0503c; }
.tp-prog { height: 5px; border-radius: 99px; background: #eee6d4; overflow: hidden; margin: 6px 0 4px; }
.tp-prog i { display: block; height: 100%; background: linear-gradient(90deg, #b6f36a, #4dbb52); transition: width .2s; }
.tp-line-meta { font-size: 10px; color: #8a735c; line-height: 1.5; }
.tp-line-ops { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; margin-top: 5px; }
.tp-line-ops .tp-btn { padding: 5px 7px; font-size: 10px; margin: 2px 2px 0 0; }
.tp-goal { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.tp-goal.done { color: var(--green-d); font-weight: 800; }
.tp-event { border: 1.5px solid #e8c46a; background: #fff9e4; border-radius: 10px; padding: 8px; margin-bottom: 7px; }
.tp-event b { display: block; font-size: 12px; color: #a9713b; }
.tp-event span { display: block; font-size: 10px; color: #8a735c; margin: 3px 0 5px; }
.tp-skill { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; background: #fff; }
.tp-skill > b { font-size: 12px; }
.tp-skill > span { display: block; font-size: 10px; color: #8a735c; margin: 2px 0 5px; }
.tp-skill-lv { font-size: 10px; color: #8a735c; padding: 2px 0; }
.tp-skill-lv.done { color: var(--green-d); font-weight: 800; }
.tp-done { font-size: 11px; color: var(--green-d); font-weight: 800; }
.bargain { margin-top: 4px; }
#bargainBar { position: relative; height: 16px; border-radius: 99px; background: linear-gradient(90deg, #f3d9a4, #7ed957 45%, #7ed957 55%, #f3d9a4); border: 1.5px solid var(--line); margin-bottom: 6px; }
#bargainNeedle { position: absolute; top: -3px; width: 4px; height: 22px; border-radius: 2px; background: #e85b46; box-shadow: 0 0 0 1px #fff; }
#bargainBar .bz { position: absolute; left: 50%; top: 0; transform: translateX(-50%); font-size: 9px; font-weight: 900; color: #1f7a4d; line-height: 16px; }

@media (min-width: 760px) {
  #townPanel { left: auto; right: 16px; transform: none; bottom: 16px; width: 400px; max-height: calc(100dvh - 150px); }
  #townHud { width: 260px; }
  #miniWrap { width: 170px; }
  #miniMap { height: 92px; }
}
@media (max-width: 619px) {
  #townHud { width: min(210px, 53vw); }
  #miniWrap { width: min(122px, 32vw); }
  #miniMap { height: 62px; }
  .act { padding: 10px 11px; font-size: 11px; }
}
@media (max-height: 620px) {
  #townHud, #miniWrap { top: calc(var(--safe-t) + 72px); }
  #joystick { width: 84px; height: 84px; flex-basis: 84px; }
  #joyKnob { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
  #townPanel { bottom: calc(var(--safe-b) + 100px); max-height: 52vh; }
  .act { padding: 9px 10px; }
}
