/* 基础：重置、页面、设备框、屏幕容器、底部导航、弹层（sheet/modal/toast）、验收面板停靠位 */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* 根字号跟随系统（100%）；设置「字号」标准 / 大 / 特大 = 100% / 112.5% / 125%（S3 §9.5）。app.js 按 SETTINGS_V05.font_scale.scale 写行内根字号，
   这里的 data-font 档位是配置还没拿到时的兜底；SVG 场景里的标签跟着 --scene-label-scale 一起放大。 */
html { font-size: 100%; --scene-label-scale: 1; }
html[data-font='large'] { font-size: 112.5%; --scene-label-scale: 1.125; }
html[data-font='xlarge'] { font-size: 125%; --scene-label-scale: 1.25; }
:focus-visible { outline: 3px solid var(--cyan-400); outline-offset: 2px; border-radius: 10px; }
body {
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: #1A1712;
  color: #23201A;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }
svg { display: block; }
a { color: inherit; }
[hidden] { display: none !important; }
.num { font-family: var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mono { font-family: var(--font-mono); letter-spacing: 0; }
.label-mono {
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 0.875rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}
.label-mono.label-cjk { /* 中文眉标：不用等宽大字距（由 core/labels.js 自动标记） */
  font-family: var(--font-ui); font-weight: 650; font-size: 0.75rem; line-height: 0.875rem; letter-spacing: .04em; text-transform: none;
}
/* 中文段落避免末行只剩一个字；标题均衡断行 */
p, .card-sub, .small, .tiny, .notice, .lr-sub, .screen-sub, .dd-note, .cfm-body, .pay-result-sub { text-wrap: pretty; }
h1, h2, h3, .screen-title, .sheet-title, .card-title, .cfm-title { text-wrap: balance; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- 舞台：桌面居中设备框 + 右侧验收面板；手机全屏 */
#stage {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; gap: 28px;
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(92, 193, 100, .16), transparent 60%),
    radial-gradient(900px 600px at 85% 90%, rgba(46, 230, 214, .10), transparent 60%),
    radial-gradient(800px 500px at 70% 20%, rgba(245, 190, 30, .10), transparent 60%),
    #15130F;
}
#stage::before { /* 细网格：前作工业语汇 */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.device {
  position: relative; width: 390px; height: min(844px, calc(100vh - 40px)); border-radius: 46px; overflow: hidden;
  background: var(--bg-0); color: var(--ink); isolation: isolate;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 0 0 9px #0B0A08, 0 0 0 10px rgba(255,255,255,.10), 0 40px 120px rgba(0,0,0,.6);
  transition: background var(--t-slow) var(--ease-in-out), color var(--t-slow) var(--ease-in-out);
}
.device-notch { position: absolute; top: 10px; left: 50%; width: 112px; height: 30px; margin-left: -56px; border-radius: 20px; background: #050504; z-index: 90; pointer-events: none; }
.statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: 50px; z-index: 80; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between; padding: 6px 30px 0 34px;
  font: 600 0.9375rem/1 var(--font-ui); color: var(--ink);
}
.statusbar .sb-right { display: flex; gap: 6px; align-items: center; }
.device[data-scene-dark="1"] .statusbar { color: #fff; }
/* 状态栏底板：内容滚到状态栏下面时淡入毛玻璃（app.js 根据滚动设置 data-scrolled）。
   层级在弹层遮罩（60）之下、页面内容之上，打开弹层时会一起被遮罩压暗。 */
.statusbar-bg {
  position: absolute; top: 0; left: 0; right: 0; height: 50px; z-index: 58; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, var(--glass-strong) 0%, var(--glass-strong) 70%, var(--glass) 100%);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 1px 0 var(--line);
  transition: opacity var(--t-med) var(--ease-out);
}
.device[data-scrolled="1"] .statusbar-bg { opacity: 1; }

@media (max-width: 520px) {
  #stage { display: block; background: var(--bg-0, #EFE8D8); }
  #stage::before { display: none; }
  .device { width: 100vw; height: 100dvh; border-radius: 0; box-shadow: none; }
  .device-notch, .statusbar, .statusbar-bg { display: none; }
  .dev-dock { display: none; }
}

/* ---------------------------------------------------------------- 屏幕容器 */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  /* 顶部留白 = 安全区 + 8px：桌面设备框 58px（模拟状态栏 50px），手机全屏只留系统安全区（tokens.css --safe-top） */
  padding: calc(var(--safe-top) + 8px) var(--sp-4) calc(96px + env(safe-area-inset-bottom)); scrollbar-width: none;
}
/* 商店 / 我的等页的顶部渐隐条（screens-shop.css .mf-topfade 写死 58px）跟随同一个安全区，手机全屏时不再压住页面标题 */
.device .mf-topfade { height: calc(var(--safe-top) + 8px); }
.screen-scroll::-webkit-scrollbar { display: none; }
.screen-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 16px; }
.screen-title { font: 700 var(--fs-title)/var(--lh-title) var(--font-ui); letter-spacing: -.02em; margin: 2px 0 0; }
.screen-sub { color: var(--muted); font-size: var(--fs-call); line-height: var(--lh-call); margin-top: 2px; }
.section { margin: 20px 0 10px; display: flex; align-items: baseline; justify-content: space-between; }
.section-title { font: 650 var(--fs-head)/var(--lh-head) var(--font-ui); letter-spacing: -.01em; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-call); line-height: var(--lh-call); }
.tiny { font-size: var(--fs-cap); line-height: var(--lh-cap); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 大 / 特大字号（112.5% / 125%）下文字一律换行、不截断（S3 §9.5「125% 字号下没有文字被截断」、AC-P2-6；W4-FE-FINAL 无障碍自检）：
   各屏幕单行省略号的写法在这两档改为折行（只列玩家界面里用到的；验收面板不在内）。标准字号照旧单行。 */
html[data-font='large'] :is(.ellipsis, .farm-xpnum, .farm-sub em, .farm-need-name, .pz-trait, .pz-v-row b, .fm-lbl-camp,
  .p2p-plate-tl, .p2p-plate-tr, .p2p-plate-bl, .p2p-plate-br, .ws-recipe-name, .mk-shophead .label-mono, .mk-card-cp, .p2p-fee-k, .shop-pass-cell small,
  .ward-group-cur, .ward-card-st, .me-stat-val, .funds-fn small, .funds-batch-tx, .shop-head > .grow > .label-mono, .inbox-sender-name, .pc-thumb-name,
  .ye-tile-name, .ye-opt-txt b, .mu-slot-sub, .vis-tile-sub > span, .vis-phrase-t, .gc-input, .nb-name-row .nb-title, .vis-gift .btn .btn-sub, .gc-top-sub-t),
html[data-font='xlarge'] :is(.ellipsis, .farm-xpnum, .farm-sub em, .farm-need-name, .pz-trait, .pz-v-row b, .fm-lbl-camp,
  .p2p-plate-tl, .p2p-plate-tr, .p2p-plate-bl, .p2p-plate-br, .ws-recipe-name, .mk-shophead .label-mono, .mk-card-cp, .p2p-fee-k, .shop-pass-cell small,
  .ward-group-cur, .ward-card-st, .me-stat-val, .funds-fn small, .funds-batch-tx, .shop-head > .grow > .label-mono, .inbox-sender-name, .pc-thumb-name,
  .ye-tile-name, .ye-opt-txt b, .mu-slot-sub, .vis-tile-sub > span, .vis-phrase-t, .gc-input, .nb-name-row .nb-title, .vis-gift .btn .btn-sub, .gc-top-sub-t) {
  white-space: normal; text-overflow: clip; overflow: visible; overflow-wrap: anywhere;
}
html[data-font='large'] .gc-input, html[data-font='xlarge'] .gc-input { height: auto; min-height: 44px; padding-top: 8px; padding-bottom: 8px; }

/* ---------------------------------------------------------------- 底部导航 */
.tabbar {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); height: 66px; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding: 0 6px;
  border-radius: 24px; background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: var(--shadow-2), var(--highlight);
}
.tab {
  position: relative; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font: 600 0.75rem/1 var(--font-ui); border-radius: 18px; transition: color var(--t-fast);
}
.tab .tab-icon { width: 26px; height: 26px; transition: transform var(--t-med) var(--ease-spring); }
.tab.active { color: var(--ink); }
.tab.active .tab-icon { transform: translateY(-1px) scale(1.06); }
.tab.active::before {
  content: ""; position: absolute; inset: 3px 6px; border-radius: 16px; z-index: -1;
  background: linear-gradient(180deg, rgba(92,193,100,.18), rgba(92,193,100,.08));
  box-shadow: inset 0 0 0 1px rgba(62,164,78,.22);
  animation: tabpill var(--t-med) var(--ease-spring);
}
.device[data-theme="night"] .tab.active::before { background: linear-gradient(180deg, rgba(46,230,214,.16), rgba(46,230,214,.06)); box-shadow: inset 0 0 0 1px rgba(46,230,214,.25); }
.tab .tab-dot { position: absolute; top: 7px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--rose-500); box-shadow: 0 0 0 2px var(--surface-solid); }
@keyframes tabpill { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------------------------------------------------------- 弹层 */
.overlay-root { position: absolute; inset: 0; z-index: 60; pointer-events: none; }
/* 弹层打开时焦点先落在弹层容器上（kit.js），容器本身不画焦点框；关弹层后找不到触发按钮时焦点回到页面容器 */
.sheet:focus, .modal:focus, .screen-host:focus { outline: none; }
.scrim { position: absolute; inset: 0; background: var(--scrim); pointer-events: auto; animation: fadein var(--t-med) var(--ease-out); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88%; display: flex; flex-direction: column; pointer-events: auto;
  background: var(--bg-1); border-radius: 30px 30px 0 0; box-shadow: var(--shadow-3);
  animation: sheetin var(--t-slow) var(--ease-out); padding-bottom: env(safe-area-inset-bottom);
}
.sheet.closing { animation: sheetout var(--t-med) var(--ease-in-out) forwards; pointer-events: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 10px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px 6px; flex: none; }
.sheet-title { font: 700 1.1875rem/1.5rem var(--font-ui); letter-spacing: -.01em; }
/* 关闭按钮：视觉 36px，热区 44px */
.sheet-head .sheet-close { width: 36px; height: 36px; border-radius: 12px; flex: none; }
.sheet-head .sheet-close::after { content: ""; position: absolute; inset: -4px; }
.sheet-body { overflow-y: auto; padding: 8px 20px 24px; scrollbar-width: none; }
.sheet-body::-webkit-scrollbar { display: none; }
.sheet-foot { padding: 12px 20px 20px; border-top: 1px solid var(--line); flex: none; background: var(--bg-1); }
.modal {
  position: absolute; left: 22px; right: 22px; top: 50%; transform: translateY(-50%); pointer-events: auto;
  background: var(--bg-1); border-radius: 28px; box-shadow: var(--shadow-3); overflow: hidden;
  animation: modalin var(--t-slow) var(--ease-spring);
}
.modal.closing { animation: fadeout var(--t-fast) ease forwards; pointer-events: none; }
.scrim.closing { animation: fadeout var(--t-med) ease forwards; pointer-events: none; }
@keyframes sheetin { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheetout { to { transform: translateY(100%); } }
@keyframes modalin { from { transform: translateY(-46%) scale(.92); opacity: 0; } to { transform: translateY(-50%) scale(1); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; } }

.toast-root { position: absolute; top: calc(var(--safe-top) + 6px); left: 16px; right: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; transition: top var(--t-med) var(--ease-out); }
/* 锚点避开关键数值：农场 HUD（50–162px）、拜访页农场主卡片（54–148px） */
.device[data-route="farm"] .toast-root { top: 172px; right: 60px; } /* 右侧还有一列图标按钮 */
.device[data-route="visit"] .toast-root { top: 158px; }
/* 有底部弹层（sheet）开着时：背后的 HUD 已被遮罩盖住，提示回到最上方的遮罩区（弹层最高 88%，上方总留着一条），只留最新一条，不压弹层内容 */
.device:has(.sheet:not(.closing)) .toast-root { top: calc(var(--safe-top) + 6px); right: 16px; }
.device:has(.sheet:not(.closing)) .toast:not(:last-child) { display: none; }
/* 有弹窗（modal）开着时，提示移到底部，不压住弹窗标题（同时开着 sheet 和 modal 时以这条为准） */
.device:has(.modal:not(.closing)) .toast-root { top: auto; bottom: calc(28px + env(safe-area-inset-bottom)); flex-direction: column-reverse; }
.device:has(.modal:not(.closing)) .toast:not(:last-child) { display: flex; }
.toast {
  max-width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; border-radius: 18px;
  background: var(--surface-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2), 0 10px 30px rgba(0,0,0,.14), var(--highlight);
  font: 600 0.875rem/1.1875rem var(--font-ui); color: var(--ink); animation: toastin var(--t-slow) var(--ease-spring);
}
.toast.tone-error { border-color: rgba(229, 86, 107, .35); }
/* 提示条上的入口按钮（toast 的 action）：提示层本身不接点击，只有这颗按钮可点；触控 ≥44px */
.toast-act { pointer-events: auto; flex: none; min-height: 44px; min-width: 44px; padding: 0 14px; margin: -6px -8px -6px 4px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--surface-2, var(--surface-solid)); color: var(--ink); font: 700 0.8125rem/1 var(--font-ui); cursor: pointer; }
.toast.tone-good { border-color: rgba(62, 164, 78, .35); }
.toast.tone-warn { border-color: rgba(245, 190, 30, .5); }
.toast .toast-icon { width: 26px; height: 26px; flex: none; }
.toast.leaving { animation: toastout var(--t-med) var(--ease-in-out) forwards; }
@keyframes toastin { from { transform: translateY(-16px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastout { to { transform: translateY(-10px); opacity: 0; } }

/* 特效层（飞币、粒子），在 vdom 之外由 fx.js 操作 */
.fx-layer { position: absolute; inset: 0; z-index: 75; pointer-events: none; overflow: hidden; }

/* ---------------------------------------------------------------- 验收面板（桌面停靠在设备右侧） */
.dev-dock {
  width: 340px; height: min(844px, calc(100vh - 40px)); overflow-y: auto; border-radius: 26px; padding: 18px;
  background: rgba(24, 22, 18, .82); color: #EDE7D8; border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 30px 80px rgba(0,0,0,.5);
  scrollbar-width: thin;
}
@media (max-width: 860px) { .dev-dock { display: none; } }

/* 减少动态：设置 motion = reduce（应用内，<html data-motion>）或 system 且系统要求减少；motion = full 时不跟随系统（S3 §9.5「不只依赖系统设置」）。
   只去掉动画，音效与结果照常（fx.js）。 */
html[data-motion='reduce'] *, html[data-motion='reduce'] *::before, html[data-motion='reduce'] *::after {
  animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion='full']) *, html:not([data-motion='full']) *::before, html:not([data-motion='full']) *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important;
  }
}

/* v0.5b（W2-FE-CORE-ECON）底栏暖色光点：「有新东西」但不是红点（S2 §14：村子的红点只给待回应的手艺）。
   形状（柔光环）+ 颜色（琥珀）都和红点不同；尊重减少动态（不呼吸）。 */
.tab .tab-glow { position: absolute; top: 6px; right: calc(50% - 19px); width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle, var(--banana-400) 0 38%, rgba(245, 190, 30, .35) 40% 100%); box-shadow: 0 0 0 2px var(--surface-solid);
  animation: tab-glow 2.4s var(--ease-in-out) infinite; }
@keyframes tab-glow { 0%, 100% { opacity: .75; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.08); } }
html[data-motion='reduce'] .tab .tab-glow { animation: none; }
@media (prefers-reduced-motion: reduce) { html:not([data-motion='full']) .tab .tab-glow { animation: none; } }
