:root {
  --paper: #fffdf4;
  --line: #e6e1d5;
  --dark: #20372d;
  --muted: #586b5b;
  --forest: #416d4b;
  --safe-top: max(12px, env(safe-area-inset-top, 0px));
  --safe-right: max(12px, env(safe-area-inset-right, 0px));
  --safe-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  --safe-left: max(12px, env(safe-area-inset-left, 0px));
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #172b23;
  color: var(--dark);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft Yahei", sans-serif;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .64; cursor: default; }
button:focus-visible { outline: 3px solid #8dbc88; outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.layout, .play-column, .viewport { position: absolute; inset: 0; }
.viewport { overflow: hidden; isolation: isolate; }
.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: crosshair;
  touch-action: none;
}

.viewport-top {
  position: absolute;
  inset: var(--safe-top) var(--safe-right) auto var(--safe-left);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.scene-chip {
  display: grid;
  gap: 2px;
  max-width: 50%;
  border-radius: 10px;
  padding: 7px 12px;
  background: #fffdf4ed;
  box-shadow: 0 3px 14px #17281f33;
}
.scene-chip span { color: var(--muted); font-size: 11px; }
.scene-chip strong { font-size: 17px; }
.viewport-badges { display: flex; gap: 5px; pointer-events: auto; }
.viewport-badges button, .interaction-hint, .icon-circle {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #e6e1d5;
  border-radius: 9px;
  background: #fffdf4f5;
  color: var(--dark);
}
.viewport-badges button { padding: 0 8px; font-size: 18px; }
.viewport-badges #btnTools { font-size: 13px; font-weight: 700; }

.tool-panel {
  position: absolute;
  z-index: 3;
  inset: calc(var(--safe-top) + 52px) var(--safe-right) auto auto;
  width: min(300px, calc(100% - var(--safe-left) - var(--safe-right)));
  max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 52px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 5px 24px #14281855;
}
.status-row { display: grid; gap: 3px; font-size: 13px; margin-bottom: 10px; }
.status-row span, .menu-version { color: var(--muted); font-size: 11px; }
.menu-version { margin-top: 10px; }
.toolbelt { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.toolbelt button:last-child { grid-column: 1 / -1; }
.btn {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefa;
  color: var(--dark);
  font-size: 13px;
  font-weight: 650;
}
.btn:hover, .btn.active { background: #eaf1e4; }
.btn.primary { background: var(--forest); color: white; border-color: var(--forest); }
.btn.primary:hover { background: #34583b; }
.btn.wide { width: 100%; }
.btn small { color: var(--muted); font-size: 10px; }

.interaction-hint, .toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 2 * max(var(--safe-left), var(--safe-right)));
  text-align: center;
  font-size: 13px;
}
.interaction-hint {
  bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  font-weight: 750;
  box-shadow: 0 3px 14px #17281f33;
}
.keycap {
  flex: 0 0 23px;
  border: 1px solid #adc0aa;
  background: #edf4e9;
  border-radius: 5px;
  line-height: 23px;
  font-family: monospace;
}
.toast {
  bottom: calc(var(--safe-bottom) + 53px);
  width: max-content;
  z-index: 2;
  padding: 9px 14px;
  border-radius: 9px;
  background: #1d332def;
  color: white;
  pointer-events: none;
}

.dialog-backdrop, .welcome-backdrop, .global-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: #101d19ad;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.welcome-backdrop { z-index: 7; background: linear-gradient(135deg, #172e21bd, #2c3924c9); }
.global-overlay { position: fixed; z-index: 20; }
.welcome-card, .dialog, .help-sheet {
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(14px, 3vw, 28px);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 14px 55px #0a1c1655;
}
.welcome-card { width: min(520px, 100%); text-align: center; }
.welcome-mark { color: #835f2d; font-size: 11px; letter-spacing: .18em; font-weight: 800; }
.welcome-card h1 { margin: 8px 0; color: #36533a; font-size: clamp(30px, 4.6vw, 48px); line-height: 1.16; }
.welcome-card p, .dialog p, .help-sheet p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.hero-select { display: flex; gap: 10px; justify-content: center; margin: 10px 0 14px; }
.hero-opt {
  width: 86px;
  padding: 6px;
  display: grid;
  justify-items: center;
  gap: 2px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #f9f8ef;
  color: var(--dark);
  font-size: 12px;
  font-weight: 700;
}
.hero-opt.selected { background: #eaf3df; border-color: #6fa36f; }
.hero-opt img { height: clamp(55px, 12vh, 87px); width: auto; image-rendering: pixelated; }
.launch { width: min(100%, 275px); font-size: 15px; }
.welcome-foot { margin-top: 10px; font-size: 11px; color: var(--muted); line-height: 1.55; }
.dialog { width: min(380px, 100%); text-align: center; }
.dialog-icon { font-size: 28px; }
.dialog-kicker { font-size: 11px; color: var(--muted); }
.dialog h2 { font-size: 24px; margin: 8px 0; }
.dialog .dialog-warning { color: #836a4e; font-size: 12px; }
.help-sheet { width: min(600px, 100%); }
.help-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.help-heading h2 { margin: 0; font-size: 21px; }
.icon-circle { font-size: 23px; }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.help-grid > div { display: flex; flex-wrap: wrap; gap: 4px 9px; padding: 8px; background: #f1f4eb; border-radius: 7px; font-size: 12px; }
.help-grid span { color: var(--muted); }

@media (pointer: coarse) {
  .keycap { display: none; }
}
@media (max-width: 520px) {
  .scene-chip strong { font-size: 15px; }
  .help-grid { grid-template-columns: 1fr; }
}

/* CORE-02 农田操作小面板；仅数据测试交互，不替换正式游戏 HUD */
.farm-panel{position:absolute;z-index:5;right:var(--safe-right);top:calc(var(--safe-top) + 56px);width:min(350px,calc(100vw - 24px));max-height:calc(100dvh - 98px);overflow-y:auto;background:#fff9edfa;color:#56412d;border:2px solid #d4b488;border-radius:13px;box-shadow:0 10px 40px #25160f9c;padding:16px;pointer-events:auto}
.farm-panel-heading{display:flex;justify-content:space-between;align-items:center;font-size:16px}.farm-panel-heading button{background:#ecdbca;border:1px solid #c6a98a;border-radius:8px;padding:3px 12px;font-size:22px}

.farm-actions{display:grid;grid-template-columns:repeat(4,1fr);gap:5px;margin:12px 0}.farm-actions button{min-height:40px;padding:5px 2px;background:#f4e3ca;border:1px solid #cba57d;border-radius:7px;font-size:12px;color:#725138}.farm-actions button:hover:not(:disabled){background:#e8c899}.farm-trade{grid-template-columns:repeat(2,1fr)}.farm-footnote{font-size:11px;color:#9e8b78;margin-bottom:0}

.farm-starter{display:block;width:100%;min-height:34px;border:1px solid #c7b789;border-radius:7px;background:#eef0ce;color:#68743c;font-size:12px;padding:6px;margin-top:5px}

/* CORE-03 仅用于基础玩法验证的动物操作面板。沿用农田面板色彩与原 HUD。 */
.animal-panel{right:var(--safe-right);max-width:350px}
.animal-switch{display:flex;gap:8px;margin:14px 0}.animal-switch button{flex:1;min-height:36px;background:#f9eedb;border:1px solid #d6b99b;color:#73533e;border-radius:9px;font-size:13px}.animal-switch button.active{background:#dfc08f;border-color:#b58d5b;font-weight:700}
.animal-hero{display:flex;gap:13px;align-items:center;background:#fbf0dd;border:1px solid #ead4b7;border-radius:10px;padding:9px}.animal-hero img{width:84px;height:88px;object-fit:contain;image-rendering:pixelated}.animal-hero strong{font-size:16px}.animal-hero p{font-size:12px;color:#916c45;line-height:1.6;margin:7px 0 0}
.animal-progress{height:9px;background:#eadbc4;border-radius:9px;overflow:hidden;margin:11px 0}.animal-progress span{display:block;height:100%;width:0;background:linear-gradient(90deg,#91b96f,#e6bf65);transition:width .3s}
.animal-controls{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin:14px 0}.animal-controls button,.animal-panel .farm-trade button{background:#f5e5cc;color:#73533e;border:1px solid #cba57d;padding:10px 4px;border-radius:8px;font-size:12px}.animal-panel button:disabled{opacity:.45}

/* CORE-04 临时可视化交互面板；不改正式HUD及CORE-02/03美术。 */
.processing-panel{width:min(430px,calc(100vw - 24px));max-width:calc(100vw - 22px)}
.processing-hint{font-size:12px;color:#9b684d;border:1px solid #ecd0b2;background:#fcedde;border-radius:9px;padding:8px;margin:12px 0}
.processing-hint.processing-unlocked{color:#476f46;background:#edf2dd;border-color:#c6dba7}
.processing-products{display:grid;grid-template-columns:repeat(4,1fr);gap:5px;margin:12px 0}
.processing-products button{border:1px solid #e4c9a2;background:#f7e9cf;border-radius:9px;color:#77533e;padding:5px;font-size:12px;display:grid;place-items:center;gap:3px}
.processing-products button.active{background:#efd4a6;border-color:#b58448;box-shadow:inset 0 0 0 1px #ce9d5e}
.processing-products img{display:block;width:65px;height:61px;object-fit:contain;image-rendering:pixelated}
.processing-select,.processing-slot-heading{display:flex;justify-content:space-between;align-items:center;margin:10px 0;color:#805b3c}
.processing-select span,.processing-slot-heading small{font-size:11px;color:#a47b54}
.processing-primary{display:block;width:100%;background:#dfb66f;color:#56371f;border:1px solid #b6894e;padding:11px;border-radius:9px;font-weight:800}
.processing-primary:disabled{opacity:.4}
.processing-slot-heading{margin-top:17px}.processing-slots{display:grid;gap:6px}
.processing-slot{padding:9px;background:#fbedd7;border:1px solid #ddc4a2;border-radius:9px;min-height:47px}
.processing-slot.ready{background:#eff0d6;border-color:#c8d39d}
.processing-slot-top{display:flex;align-items:center;justify-content:space-between;font-size:12px;color:#735039}
.processing-slot-top span{color:#9a7954}.processing-slot button{font-size:11px;margin-top:5px;border:1px solid #9aba7d;border-radius:6px;padding:5px 13px;background:#d3e7bb;color:#426039}
.processing-track{height:7px;background:#e0d1b3;border-radius:7px;overflow:hidden;margin-top:7px}.processing-track i{display:block;height:100%;background:#80ac69}
.processing-trade{display:flex;align-items:center;gap:8px;margin-top:13px}.processing-trade button{padding:8px;border-radius:8px;background:#f1e2ca;border:1px solid #c9a574;color:#795235;font-size:12px}.processing-trade span{font-size:11px;color:#7b684e}

/* CORE-02 V2.0 · 72 small-plots grouped by eight 3×3 fields */





/* V1.2: formal painting of processing tools is displayed inside the real CORE-04 panel. */
.v12-processing-art{height:110px;width:100%;background:#f8dec2 url('v12_art/工作台/00_田园工坊像素界面-1.png') center 32%/cover no-repeat;border:3px solid #a3764b;border-radius:11px;margin:8px 0}
