/* M1 v3 · 星露谷方向手绘暖色样张 · 对齐现有 H5 米白/橙基调 */
:root {
  --bg: #f7ebdd;
  --paper: #fffbf4;
  --cream: #f2e2cc;
  --line: rgba(156, 107, 67, 0.24);
  --ink: #4a3a2e;
  --muted: #7a6653;
  --orange: #f28c28;
  --orange-dark: #d9741a;
  --orange-soft: #f7b56b;
  --wood: #c98a5b;
  --wood-dark: #9c6b43;
  --red: #d9534f;
  --green: #7faf6b;
  --blue: #6c9bc9;
  --yellow: #ffd166;
  --shadow: 0 10px 26px rgba(122, 88, 52, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app { position: fixed; inset: 0; }
#viewport { position: absolute; inset: 0; touch-action: none; overscroll-behavior: none; }
/* 微信 X5：canvas 自身也必须禁用默认手势，否则单指拖拽会被页面滚动吃掉 */
#scene {
  display: block; width: 100%; height: 100%;
  touch-action: none; -ms-touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* 暖色暗角：让画面更像手绘场景，不拦截操作 */
#app::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, rgba(255, 214, 160, 0) 48%, rgba(122, 78, 40, 0.16) 100%);
}

/* 顶栏 */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(247, 235, 221, 0.96), rgba(247, 235, 221, 0.62) 70%, transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; gap: 2px; margin-right: 6px; }
.brand b { font-size: 15px; letter-spacing: 0.5px; }
.brand span { font-size: 10px; color: var(--muted); }
/* 版本自显徽标：老板一眼确认是否新版 */
.ver-badge {
  appearance: none; font: inherit; cursor: pointer; line-height: 1;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  margin-right: 8px; padding: 5px 11px 4px; border-radius: 14px;
  border: 2px solid var(--orange-dark);
  background: linear-gradient(180deg, #ffbe74, var(--orange));
  color: #fff; box-shadow: 0 4px 12px rgba(242, 140, 40, 0.38);
}
.ver-badge b { font-size: 24px; font-weight: 900; letter-spacing: 0.5px; }
.ver-badge span { font-size: 9px; font-weight: 700; opacity: 0.95; }
.ver-badge i { font-style: normal; font-size: 8px; opacity: 0.85; white-space: nowrap; }
.ver-badge:active { transform: translateY(1px); }
.spacer { flex: 1 1 auto; }
.btn {
  appearance: none; border: 1.5px solid var(--line); background: var(--paper);
  color: var(--ink); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 12px;
  min-height: 34px; cursor: pointer; box-shadow: 0 2px 6px rgba(122, 88, 52, 0.08);
}
.btn:hover { border-color: rgba(242, 140, 40, 0.65); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); color: #fff; border-color: transparent; font-weight: 700; }
.btn.ghost { background: transparent; box-shadow: none; }
select.btn { padding-right: 26px; }
#quality { min-width: 94px; }

/* HUD */
#hud {
  position: absolute; right: 12px; top: calc(62px + env(safe-area-inset-top)); z-index: 15;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
  font-size: 11px; color: var(--muted); pointer-events: none;
}
#hud .row {
  background: rgba(255, 251, 244, 0.9); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 5px 10px; min-width: 156px; display: flex; justify-content: space-between; gap: 12px;
}
#hud b { color: var(--ink); font-weight: 700; }

#economy {
  position: absolute; left: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 15;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
#economy .chip {
  background: rgba(255, 251, 244, 0.92); border: 1.5px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; display: flex; gap: 8px; align-items: center;
}
#economy .chip b { color: var(--orange-dark); }

#prompt {
  position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 16; background: rgba(255, 251, 244, 0.94); border: 1.5px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 12px; color: var(--muted); max-width: min(92vw, 660px); text-align: center;
  pointer-events: none;
}

/* 视角按钮 */
#viewCtl {
  position: absolute; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 16;
  display: flex; gap: 6px; align-items: center;
}
.rbtn {
  appearance: none; border: 1.5px solid var(--line); background: rgba(255, 251, 244, 0.94);
  color: var(--ink); width: 40px; height: 40px; border-radius: 50%; font-size: 17px; line-height: 1;
  cursor: pointer; box-shadow: 0 2px 6px rgba(122, 88, 52, 0.1);
}
.rbtn:active { transform: translateY(1px); background: var(--orange-soft); }

/* 大单黑板 */
#blackboard {
  position: absolute; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 14; width: min(92vw, 470px); background: #3f5145; border: 4px solid #9c6b43;
  border-radius: 12px; padding: 9px 14px; box-shadow: var(--shadow); pointer-events: none;
  font-size: 12px; color: #eef4ea;
}
#blackboard .bb-title { font-size: 11px; color: #b7cfb2; letter-spacing: 1px; margin-bottom: 3px; }
#blackboard .bb-main { font-size: 13px; }
#blackboard .bb-main b { color: var(--yellow); }
#blackboard .bb-sub { font-size: 11px; color: #b7cfb2; margin-top: 2px; }

/* 加载层 */
#loading {
  position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; background: var(--bg);
  text-align: center; padding: 24px;
}
#loading[hidden] { display: none; }
#loading .logo { font-size: 24px; font-weight: 800; letter-spacing: 1px; }
#loading .logo span { color: var(--orange); }
#loading .bar { width: min(280px, 70vw); height: 9px; background: var(--cream); border-radius: 99px; overflow: hidden; }
#loading .bar i { display: block; height: 100%; width: 40%; background: var(--orange); border-radius: 99px; animation: loadPulse 1.1s ease-in-out infinite alternate; }
@keyframes loadPulse { from { margin-left: 0; } to { margin-left: 60%; } }
#loading .msg { font-size: 12px; color: var(--muted); max-width: 360px; line-height: 1.6; }

/* 特写界面 */
#stationUI { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#stationUI[hidden] { display: none; }
#stationBar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(247, 235, 221, 0.96), rgba(247, 235, 221, 0.45) 75%, transparent);
  pointer-events: none;
}
#stationBar > * { pointer-events: auto; }
.st-title-wrap { display: flex; flex-direction: column; gap: 1px; }
.st-title-wrap b { font-size: 15px; }
.st-title-wrap span { font-size: 10px; color: var(--muted); }
.st-cash {
  background: var(--orange); color: #fff; font-weight: 800; font-size: 13px;
  border-radius: 999px; padding: 7px 14px; box-shadow: 0 3px 10px rgba(242, 140, 40, 0.3);
}

#stationPanel {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(680px, 94vw); max-height: 44vh; overflow: auto;
  background: rgba(255, 251, 244, 0.96); border: 2px solid rgba(156, 107, 67, 0.2);
  border-radius: 18px; box-shadow: var(--shadow); padding: 12px 14px 14px;
  pointer-events: auto;
}

/* 桌面/横屏：操作面板停靠右侧，柜体完整露出 */
@media (min-width: 900px) {
  #stationPanel {
    left: auto; right: 14px; bottom: 14px; transform: none;
    width: 360px; max-height: calc(100vh - 92px);
  }
  .st-grid.cols8 { gap: 5px; }
  .slot { aspect-ratio: 1 / 0.9; }
}
.st-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.st-stats b { color: var(--ink); font-size: 14px; }
.st-hint { font-size: 13px; line-height: 1.55; margin: 2px 0 10px; color: var(--ink); }
.st-note { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 9px; }
.st-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.st-btn {
  appearance: none; border: 1.5px solid var(--line); background: var(--cream);
  color: var(--ink); border-radius: 12px; padding: 9px 14px; font: inherit; font-size: 13px;
  min-height: 42px; cursor: pointer; flex: 1 1 150px;
}
.st-btn:active { transform: translateY(1px); }
.st-btn.primary { background: var(--orange); border-color: transparent; color: #fff; font-weight: 700; }

.st-grid { display: grid; gap: 6px; }
.st-grid.cols8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.st-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.slot {
  appearance: none; aspect-ratio: 1 / 0.72; border-radius: 8px; border: 1.5px dashed rgba(156, 107, 67, 0.3);
  background: rgba(242, 226, 204, 0.55); cursor: pointer; min-height: 26px;
}
.slot.on { background: linear-gradient(180deg, var(--orange-soft), var(--orange)); border: 1.5px solid var(--orange-dark); }
.slot:active { transform: scale(0.96); }
.nt {
  appearance: none; border: 1.5px solid var(--line); background: var(--cream); border-radius: 12px;
  padding: 9px 8px; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; text-align: left; min-height: 54px;
}
.nt b { color: var(--ink); font-size: 12px; }
.nt.on { background: #fff3e2; border-color: var(--orange); }
.nt.on span { color: var(--orange-dark); }
.nt:active { transform: translateY(1px); }

/* 特写态隐藏宏观 HUD */
#app.station #topbar,
#app.station #hud,
#app.station #economy,
#app.station #blackboard,
#app.station #prompt,
#app.station #viewCtl { display: none; }
#app.station #toast {
  bottom: auto; top: calc(68px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-6px);
}
#app.station #toast.show { transform: translateX(-50%) translateY(0); }

/* 切换遮罩 */
#fade {
  position: absolute; inset: 0; z-index: 40; background: var(--bg);
  opacity: 0; pointer-events: none; transition: opacity 0.17s ease;
}
#fade.on { opacity: 1; pointer-events: auto; }

/* 报告弹窗 */
#reportModal {
  position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(74, 58, 46, 0.5); padding: 16px;
}
#reportModal[hidden] { display: none; }
#reportModal .sheet {
  width: min(720px, 94vw); max-height: 86vh; background: var(--paper); border: 2px solid rgba(156, 107, 67, 0.2);
  border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
#reportModal .head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1.5px solid var(--line); }
#reportModal .head b { font-size: 13px; }
#reportModal .body { padding: 10px 12px; overflow: auto; }
#reportText { margin: 0; font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; color: var(--ink); }
#reportModal .foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 12px; border-top: 1.5px solid var(--line); }

/* 提示 */
#toast {
  position: absolute; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px);
  z-index: 35; background: var(--orange); color: #fff; font-weight: 700;
  padding: 9px 16px; border-radius: 999px; font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s; max-width: 86vw; text-align: center;
  box-shadow: 0 6px 18px rgba(242, 140, 40, 0.3);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 2.5D 兜底 */
#fallbackBanner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 45;
  background: var(--paper); border: 2px solid rgba(156, 107, 67, 0.2); border-radius: 18px; padding: 20px;
  width: min(92vw, 430px); text-align: center; box-shadow: var(--shadow);
}
#fallbackBanner[hidden] { display: none; }
#fallbackBanner h3 { margin: 0 0 8px; font-size: 15px; }
#fallbackBanner p { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
#fallbackBanner .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* 横屏 / 小屏 */
@media (max-width: 560px) {
  .brand span { display: none; }
  .ver-badge { padding: 3px 8px 2px; margin-right: 4px; border-radius: 11px; }
  .ver-badge b { font-size: 19px; }
  .ver-badge span { font-size: 8px; }
  .ver-badge i { display: none; }
  #blackboard { top: calc(100px + env(safe-area-inset-top)); }
  /* 竖屏 HUD 收成一条，放在黑板下方，避免互相压字 */
  #hud {
    top: calc(178px + env(safe-area-inset-top));
    left: 10px; right: 10px;
    flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 4px;
  }
  #hud .row { min-width: 0; padding: 3px 8px; font-size: 10px; gap: 6px; }
  #hud .row:nth-child(n+4) { display: none; }
  /* 底部信息条横向排，给操作按钮和提示让位 */
  #economy {
    left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom));
    flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 5px;
  }
  #economy .chip { padding: 4px 9px; font-size: 11px; gap: 4px; }
  #viewCtl { bottom: calc(52px + env(safe-area-inset-bottom)); right: 10px; }
  #prompt {
    bottom: calc(102px + env(safe-area-inset-bottom));
    font-size: 10px; padding: 5px 10px; max-width: 94vw; line-height: 1.45;
  }
  #toast { bottom: calc(146px + env(safe-area-inset-bottom)); }
  #stationPanel { max-height: 44vh; padding: 10px; }
  .st-grid.cols8 { gap: 4px; }
  .slot { min-height: 24px; }
}
@media (max-height: 540px) {
  #blackboard { display: none; }
  #hud .row:nth-child(n+4) { display: none; }
  #stationPanel { max-height: 48vh; }
  .st-grid.cols8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

/* v3.6d 装修模式工具条 */
#decoBar{position:fixed;left:0;right:0;bottom:0;transform:none;display:flex;flex-direction:column;background:rgba(28,24,20,.94);border-top:2px solid #6b5a44;z-index:60;box-shadow:0 -6px 24px rgba(0,0,0,.4);max-height:44vh;padding:0}
#decoTipRow{padding:8px 14px 0}
#decoCards{display:flex;gap:8px;overflow-x:auto;padding:8px 14px 4px;min-height:72px}
.deco-card{flex:0 0 auto;width:78px;border:1px solid #6b5a44;border-radius:10px;background:rgba(245,230,204,.08);padding:8px 6px;display:flex;flex-direction:column;align-items:center;gap:4px;cursor:grab;touch-action:none;user-select:none}
.deco-card.empty{opacity:.4;cursor:default}
.dc-dot{width:14px;height:14px;border-radius:4px}
.dc-name{color:#f5e6cc;font-size:12px;font-weight:600}
.dc-ct{color:#f5e6cc;font-size:12px}.dc-ct i{font-style:normal;color:#b8a888;font-size:10px}
#decoBtns{display:flex;gap:8px;justify-content:center;align-items:center;padding:4px 12px 12px}
#decoConfirm{position:fixed;display:flex;gap:14px;z-index:80;touch-action:none}
#decoConfirm button{width:52px;height:52px;border-radius:50%;font-size:26px;line-height:1;border:2px solid #fff;cursor:pointer;touch-action:none;box-shadow:0 4px 16px rgba(0,0,0,.5)}
#decoYes{background:#35c26b;color:#fff}
#decoNo{background:#e5484d;color:#fff}
#decoTip{color:#f5e6cc;font-size:13px;margin-right:4px}
#decoBar .btn.ghost{background:rgba(245,230,204,.12);color:#f5e6cc;border-color:#8a755c}
#decoBar[hidden]{display:none}
#decoConfirm[hidden]{display:none}

/* v3.6e 大单卡与进货面板 */
.st-note.bigcard{border:1px solid #d4a017;border-radius:10px;padding:10px 12px;background:rgba(212,160,23,.08);color:#f5e6cc}
.st-note.bigcard .st-btn{margin-top:8px}
.st-grid.cols2{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}
.st-grid.cols3{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;max-height:42vh;overflow:auto}
.st-grid .nt{display:flex;flex-direction:column;gap:2px;align-items:flex-start;text-align:left;background:rgba(245,230,204,.06);border:1px solid #6b5a44;border-radius:10px;padding:8px 10px;color:#f5e6cc;cursor:pointer}
.st-grid .nt b{font-size:13px}
.st-grid .nt span{font-size:11px;color:#cdbfa8}
.st-grid .nt.on{border-color:#d4a017;background:rgba(212,160,23,.15)}
