:root {
  --ink: #22302c;
  --paper: #ece5d6;
  --paper-2: #f7f2e6;
  --jade: #2f4f4a;
  --vermilion: #b4442e;
  --gold: #c8a75c;
  --muted: #6d6455;
  --line: #cfc6b3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #d8d0be;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  -webkit-text-size-adjust: 100%;
}

body { display: flex; justify-content: center; }

.app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 18px 40px rgba(40,36,28,.14);
  position: relative;
  overflow-x: hidden;
}

/* ---------- 顶部 ---------- */
.topbar {
  background: var(--jade);
  color: #eee6d3;
  padding: 14px 16px 12px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand h1 { font-size: 19px; margin: 0; letter-spacing: .06em; }
.brand .stall { font-size: 12px; opacity: .78; }
.stats {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; margin-top: 10px;
  font-size: 11px; text-align: center;
  color: #ded5c2;
}
.stats b { display: block; font-size: 15px; color: #fff4dc; font-weight: 600; margin-top: 2px; }

/* ---------- 开摊 ---------- */
.intro { padding: 0; }
.intro.hide, .game.hide, .sheet.hide { display: none; }
/* hide 是通用开关，必须压过后面所有 display（雨棚条是 flex、货架是 grid，
   同级选择器后写的 display 会把 display:none 顶掉，hide 就失灵）。 */
/* 通用隐藏：底栏两态、货架里的开摊/收摊按钮都靠它切换，别只写给 sheet 用 */
.hide { display: none !important; }
.hero { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: #1c2622; }
.hero img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 62%; }
.hero-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(18,28,24,.04) 0%, rgba(18,28,24,.16) 42%, rgba(18,28,24,.84) 100%);
}
.hero-copy { position: absolute; left: 20px; right: 20px; bottom: 18px; color: #fff8ea; }
.hero .eyebrow { color: #f2d9a9; border-left-color: #f2d9a9; text-shadow: 0 1px 6px rgba(0,0,0,.35); }
.hero h2 {
  color: #fff8ea; font-size: 31px; line-height: 1.25;
  margin: 10px 0 0; letter-spacing: .06em;
  text-shadow: 0 2px 14px rgba(0,0,0,.42);
}
.intro-body { padding: 20px 20px 40px; }
.eyebrow {
  font-size: 11px; letter-spacing: .22em; color: var(--vermilion);
  border-left: 3px solid var(--vermilion); padding-left: 8px;
}
.intro h2 { font-size: 30px; margin: 12px 0 6px; letter-spacing: .04em; }
.intro .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.intro p.lead { font-size: 15px; line-height: 1.95; text-indent: 2em; color: #33302a; }
.guide { margin: 18px 0 0; padding: 14px 16px; background: var(--paper-2); border: 1px solid var(--line); }
.guide li { font-size: 13px; line-height: 1.9; margin-left: -6px; color: #4b4539; }
.start-capital { margin-top: 12px; padding: 10px 12px; border: 1px dashed rgba(120, 106, 84, 0.6); border-radius: 10px; background: rgba(251, 247, 236, 0.9); font-size: 13px; font-weight: 600; color: var(--vermilion); }
.namebox { margin-top: 20px; display: flex; gap: 8px; }
.namebox input {
  flex: 1; border: 1px solid var(--line); background: #fffdf7;
  padding: 12px; font-size: 15px; font-family: inherit; color: var(--ink);
}
.btn {
  border: 0; background: var(--vermilion); color: #fff8ea;
  padding: 12px 18px; font-size: 15px; font-family: inherit;
  cursor: pointer; letter-spacing: .06em;
}
.btn:disabled { background: #b8b0a0; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--jade); color: var(--jade); }
.btn.primary { background: var(--jade); }

/* ---------- 标签页 ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--paper-2); position: sticky; top: 86px; z-index: 12; }
.tab {
  flex: 1; background: none; border: 0; padding: 12px 4px; font-family: inherit;
  font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--jade); border-bottom-color: var(--jade); font-weight: 600; }
.pane { display: none; padding: 14px 14px 26px; }
.pane.show { display: block; }

/* ---------- 摊位 ---------- */
.ctx-note { font-size: 12px; color: var(--muted); margin: 0 0 10px; line-height: 1.7; }

.cust-box { background: var(--paper-2); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.cust-box.empty { color: var(--muted); }
.cust-box:not(.empty) { border-left: 4px solid var(--gold); }
.cust-who { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cust-ava { width: 34px; height: 34px; object-fit: cover; background: #d9d0bd; }
.cust-desc { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.cust-want { font-size: 14px; margin-bottom: 4px; }
.cust-offer { font-size: 13px; color: #4b4539; }
.cust-ops { display: flex; gap: 8px; margin-top: 12px; }
.cust-ops .btn { flex: 1; padding: 10px 4px; font-size: 14px; }

.row2 { display: flex; gap: 8px; margin-bottom: 12px; }
.row2 .btn { flex: 1; }

.shelf-note { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.goods-shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.good-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.good-card .gc-name { font-size: 13px; font-weight: 600; }
.good-card .gc-cost { font-size: 12px; color: var(--muted); margin-top: 3px; }
.good-card .gc-price { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 13px; }
.good-card .gc-price b { min-width: 46px; text-align: center; }
.step { width: 28px; height: 28px; border: 1px solid var(--jade); background: var(--paper); color: var(--jade); border-radius: 8px; font-size: 16px; line-height: 1; cursor: pointer; font-family: inherit; }
.good-card .gc-buy { display: flex; gap: 6px; margin-top: 9px; }
.good-card .gc-buy .mini { flex: 1; }
.mini { border: 1px solid var(--jade); background: transparent; color: var(--jade); font-family: inherit; font-size: 12px; padding: 5px 7px; cursor: pointer; }
.mini.primary { background: var(--jade); color: #f3ead6; }
.mini:disabled { border-color: #bbb2a1; color: #9c9484; cursor: not-allowed; }

/* ---------- v1.2 货分档：锁着的货灰掉并写清解锁条件 ---------- */
.good-card.locked { opacity: .62; background: #f4efe2; }
.good-card.locked .gc-price b { color: #9c9484; }
.lock-tag { display: inline-block; font-size: 10px; font-weight: 400; color: #9c9484; border: 1px solid #cfc6b2; border-radius: 4px; padding: 0 3px; margin-left: 2px; }
.lock-hint { flex: 1; font-size: 11.5px; color: #8c8471; align-self: center; line-height: 1.4; }
.lock-hint.sold { color: var(--vermilion); }
.good-card .gc-cost .tea-left { color: var(--vermilion); }

/* ---------- v1.2 挑夫在途订单 ---------- */
.order-list { margin: 0 0 10px; background: #f7f1df; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; padding: 8px 10px; }
.order-head { font-size: 12px; color: #8a6f36; font-weight: 600; margin-bottom: 4px; }
/* 银行面板：欠款 / 手头铜钱 / 还钱按钮。 */
.bank-row { font-size: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.bank-row b { color: #a33b2e; font-size: 16px; }
.bank-row.muted { font-size: 12px; color: #8a7f68; border-bottom: none; }
.bank-actions { display: flex; gap: 8px; margin-top: 10px; }
.bank-actions .mini { flex: 1; }
.order-row { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: #4b4539; padding: 3px 0; border-top: 1px dashed var(--line); }
.order-row:first-of-type { border-top: 0; }
.order-row .o-fee { color: #9a8f7a; }
.order-row .o-left { color: var(--jade); white-space: nowrap; }

.settle-bar { margin: 16px 0 4px; display: flex; gap: 8px; align-items: center; }
.settle-bar .btn { flex: 1; }

.log { margin-top: 16px; background: #fbf7ec; border: 1px solid var(--line); max-height: 200px; overflow: auto; }
.log-line { font-size: 12px; padding: 7px 10px; border-bottom: 1px dashed var(--line); line-height: 1.6; }
.log-line .t { color: #9a8f7a; margin-right: 8px; font-size: 11px; }
.log-line.good { color: #2f5d43; }
.log-line.bad { color: var(--vermilion); }

/* ---------- 点位 ---------- */
.point { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.point.done { background: linear-gradient(90deg, rgba(200,167,92,.14), transparent); }
.p-no { width: 30px; height: 30px; border-radius: 50%; background: var(--jade); color: #f1e8d6; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.point.done .p-no { background: var(--gold); color: #2b2418; }
.p-name { font-size: 15px; font-weight: 700; }
.p-loc { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.p-task { font-size: 12px; color: #4b4539; margin: 4px 0; line-height: 1.6; }
.p-prog { font-size: 11.5px; color: var(--muted); }
.p-prog .ok { color: #2f5d43; }
.p-prog .off { color: var(--vermilion); }
.p-note { font-size: 11.5px; color: #9a7f4e; margin-top: 4px; }
.p-op { align-self: center; }

/* ---------- 券 ---------- */
.coupon-card { background: var(--paper-2); border: 1px solid var(--line); padding: 12px; margin-bottom: 12px; }
.coupon-card.owned { border-color: var(--gold); background: #fdf8ea; }
.c-head { display: flex; justify-content: space-between; align-items: baseline; }
.c-type { font-size: 11px; color: var(--muted); }
.c-title { font-size: 13px; color: #4b4539; margin: 6px 0 10px; line-height: 1.7; }
.c-face { font-size: 14px; color: var(--vermilion); margin-bottom: 10px; }
.c-code { font-size: 26px; letter-spacing: .18em; font-variant-numeric: tabular-nums; color: var(--jade); font-weight: 700; }
.c-qr { margin: 10px 0; }
.c-qr svg { width: 132px; height: 132px; display: block; }
.c-hint { font-size: 11px; color: var(--muted); }

/* ---------- 商家 ---------- */
.merch { padding: 12px 0; border-bottom: 1px solid var(--line); }
.m-head { display: flex; justify-content: space-between; font-size: 14px; }
.m-head span { font-size: 11px; color: var(--muted); }
.m-role { font-size: 12px; color: var(--jade); margin-top: 4px; }
.m-task { font-size: 12px; color: #4b4539; margin-top: 4px; line-height: 1.6; }
.m-coupon { font-size: 12px; color: var(--vermilion); margin-top: 4px; }

/* ---------- 弹层 ---------- */
#receiptMask {
  position: fixed; inset: 0; background: rgba(24,20,14,.62);
  display: none; align-items: center; justify-content: center; padding: 18px; z-index: 60;
}
#receiptMask.show { display: flex; }
.receipt-wrap { width: 100%; max-width: 400px; background: #fff; }
#receiptImg img, #receiptImg canvas { display: block; width: 100%; }
.receipt-ops { display: flex; gap: 8px; padding: 10px; }
.receipt-ops .btn { flex: 1; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 26px; z-index: 70; pointer-events: none;
  opacity: 0; transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast-in {
  background: rgba(34,48,44,.95); color: #f6edd8; padding: 12px 16px;
  font-size: 13px; line-height: 1.7; max-width: 320px; border-left: 3px solid var(--gold);
}
small { color: #c9bd9f; }

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  /* 窄屏优先留经营活动相关的数：铜钱/日子/天气/满意度/今日盈亏；摊位与徽章收起。 */
  .stats > div:nth-child(4), .stats > div:nth-child(5) { display: none; }
  .p-prog { font-size: 11px; }
}

/* ================= v1.1 街景舞台 ================= */
.stage {
  position: relative;
  width: 100%;
  height: calc(100vh - 132px);
  min-height: 420px;
  max-height: 720px;
  background: #cfdad4;
  overflow: hidden;
}
.stage canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }

.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 10px 12px; pointer-events: none;
}
.bag {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  background: rgba(47, 79, 74, 0.86); color: #f6efdd;
  font-size: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
.bag-ico {
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(214, 168, 74, 0.9);
  color: #4a3a18; font-size: 11px; line-height: 20px; text-align: center;
}
.bag b { font-size: 15px; font-weight: 600; }
.hud-btns { pointer-events: auto; display: flex; gap: 6px; }
.hud-btn {
  border: 0; font-family: inherit; cursor: pointer;
  padding: 6px 10px; border-radius: 999px; font-size: 12px;
  background: rgba(251, 247, 236, 0.9); color: var(--jade);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
}
.hud-btn:active { transform: translateY(1px); }

/* 底栏：开摊后只有吆喝/补货+10/降价/涨价/收摊 5 个动作；没开摊时只剩一个「开摊」。
   摊位、点位、领券、商家四个面板入口都在顶部 HUD，不进底栏。 */
.actionbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
  pointer-events: none; z-index: 5;
}
/* 库存条：底栏上方一排小 chips，每件已解锁的货显示名字与剩几份。
   货多了横向能滑（8 种货在手机上排不下）。卖光了标红，当前这件货描边。
   跑马灯：货多了就自动横向滚动循环，不用滚动条，不用手动滑。 */
.stock-wrap {
  position: relative; max-width: 520px; margin: 0 auto 6px; pointer-events: auto;
}
.stock-strip {
  display: flex; gap: 4px; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.stock-chip {
  flex: 0 0 auto; border: 0; cursor: pointer; font-family: inherit;
  padding: 4px 8px; border-radius: 999px; font-size: 11px; white-space: nowrap;
  background: rgba(251, 247, 236, 0.92); color: var(--jade);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.stock-chip.soldout { background: rgba(194, 91, 78, 0.95); color: #fff6e6; }
.stock-chip.active { box-shadow: 0 0 0 2px rgba(47, 79, 74, 0.95), 0 1px 4px rgba(0, 0, 0, 0.12); }
.stock-chip:active { transform: translateY(1px); }
.bar-inner { max-width: 520px; margin: 0 auto; pointer-events: auto; }
.bar-hint { text-align: center; font-size: 12px; color: #f6efdd; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); margin-bottom: 6px; }
.bar-focus { text-align: center; margin-bottom: 6px; }
.bar-focus span {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: rgba(47, 79, 74, 0.85); color: #f6efdd; font-size: 12px;
}
.bar-btns { display: flex; gap: 6px; }
.bar-btn {
  flex: 1; border: 0; cursor: pointer; font-family: inherit;
  padding: 10px 0; border-radius: 999px;
  background: rgba(251, 247, 236, 0.94); color: var(--jade);
  font-size: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
}
/* 降价/涨价中间的当前货价格（跟着库存条当前这件货走），不是按钮，只显示。 */
.bar-price {
  flex: 0 0 auto; align-self: center; padding: 0 2px;
  font-size: 14px; font-weight: 700; color: #fff4dc; white-space: nowrap;
}
.bar-btn small { font-size: 11px; opacity: 0.8; margin-left: 2px; }
.bar-btn.red { background: rgba(194, 91, 78, 0.95); color: #fff6e6; }
.bar-btn:disabled { background: rgba(150, 143, 130, 0.8); color: #f6efdd; cursor: not-allowed; box-shadow: none; }
.bar-btn:active { transform: translateY(1px); }
.bar-open-btn {
  width: 100%; border: 0; cursor: pointer; font-family: inherit;
  padding: 12px 0; border-radius: 999px;
  background: rgba(194, 91, 78, 0.95); color: #fff6e6;
  font-size: 15px; box-shadow: 0 3px 10px rgba(120, 40, 30, 0.28);
}
.bar-open-btn:active { transform: translateY(1px); }
/* 休息一市：没开摊时的第二选择，样式比开摊弱一档（不开摊、只歇一市）。 */
.bar-rest-btn {
  width: 100%; border: 1px solid var(--line); cursor: pointer; font-family: inherit;
  padding: 10px 0; border-radius: 999px; margin-top: 8px;
  background: rgba(251, 247, 236, 0.9); color: #5a4a3a;
  font-size: 13px;
}
.bar-rest-btn:active { transform: translateY(1px); }

.scene-tip {
  position: absolute; left: 50%; top: 54px; transform: translate(-50%, -6px);
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
  background: rgba(47, 79, 74, 0.88); color: #f4ecd8;
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
}
.scene-tip.show { opacity: 1; transform: translate(-50%, 0); }
.scene-tip.bad { background: rgba(150, 66, 54, 0.9); }

/* 下雨天提示条：下雨 + 雨棚没支起来时露出来，写清来客少了 3 成，带一个动作按钮。 */
.rain-bar {
  position: absolute; left: 50%; top: 92px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: 92%;
  padding: 7px 10px; border-radius: 12px; font-size: 12px; line-height: 1.35;
  background: rgba(47, 79, 74, 0.92); color: #f4ecd8;
  box-shadow: 0 4px 14px rgba(20, 30, 28, 0.35); z-index: 6;
}
.rain-bar .rain-text { flex: 1; }
.rain-bar .rain-btn {
  flex: 0 0 auto; border: 0; border-radius: 999px; padding: 5px 10px;
  background: #e8b64c; color: #3a2a12; font-size: 12px; font-weight: 700;
}
.rain-bar .rain-btn:active { transform: translateY(1px); }

/* 进货分栏：货物 / 开店用品。 */
.stall-tabs { display: flex; gap: 6px; margin: 2px 0 8px; }
.stall-tab {
  flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 7px 0;
  background: var(--paper-2); color: var(--ink); font-size: 13px;
}
.stall-tab.active { background: var(--jade); color: #f4ecd8; border-color: var(--jade); }
/* 开店用品卡：复用 good-card 的样子，买一次一直能用。 */
.supply-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.supply-card.current-loc { border-color: var(--gold); background: #fdf8ea; }
.supply-card .gc-name { font-size: 13px; font-weight: 600; }
.supply-card .gc-cost { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.supply-card .gc-buy { display: flex; gap: 6px; margin-top: 9px; }
.supply-card .gc-buy .mini { flex: 1; }
.supply-card .owned { font-size: 12px; color: var(--muted); }

/* 抽屉面板：贴底的货架，打开时街景留在上面，不要让玩家往下翻页找货 */
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 520px;
  margin: 0; padding: 12px 14px 26px;
  background: var(--paper);
  border-top: 2px solid rgba(47, 79, 74, 0.18);
  max-height: 62vh; overflow: auto;
  z-index: 40;
}
.sheet.hide { display: none; }
/* 进货弹窗：居中弹出、带遮罩，不是贴底的网页抽屉。其余面板仍是贴底抽屉。 */
.backdrop {
  position: fixed; inset: 0; background: rgba(20, 30, 28, 0.45);
  z-index: 35;
}
.backdrop.hide { display: none; }
.sheet.popup {
  top: 50%; bottom: auto; transform: translate(-50%, -50%);
  width: min(92vw, 440px); max-height: 82vh;
  border: 1px solid rgba(47, 79, 74, 0.22);
  border-top: 1px solid rgba(47, 79, 74, 0.22);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 25, 22, 0.35);
  padding: 14px 14px 18px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.sheet-head b { font-size: 14px; color: var(--jade); letter-spacing: .04em; }
.sheet-close {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-family: inherit; font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
/* 顶栏在手机上不折行（v1.1） */
.topbar .stats { gap: 8px; }
.topbar .stats div { white-space: nowrap; font-size: 11px; }
.topbar .stats b { font-size: 12px; white-space: nowrap; }
.topbar .brand .stall { white-space: nowrap; }