@font-face {
  font-family: "ArkPixel";
  src: url("assets/font/ark-pixel.woff") format("woff");
  font-display: swap;
  /* 方舟像素字体 12px · SIL Open Font License 1.1 · 见 assets/font/OFL.txt */
}

:root {
  --bg: #f7ecd2;
  --panel: #fffdf5;
  --panel-2: #f7eeda;
  --ink: #3d3025;
  --ink-soft: #6f5c47;
  --dim: #8d7a62;
  --line: #6b5138;
  --line-2: #c9ae86;
  --green: #5f9e4e;
  --green-d: #3f7a3a;
  --green-l: #cfe4bb;
  --gold: #e8b74a;
  --gold-d: #b98a2e;
  --red: #cf5a45;
  --water: #5f9fd0;
  --soil: #8a6647;
  --shadow: 3px 3px 0 var(--line);
  --shadow-sm: 2px 2px 0 var(--line);
  --dock-h: 66px;
}

* { box-sizing: border-box; border-radius: 0; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  font-family: "ArkPixel", -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  background: #e7d8bb;
  display: grid;
  place-items: center;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  color: inherit;
  font-size: 12px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border-radius: 0;
}

img.px {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: inline-block;
  vertical-align: middle;
  -webkit-user-drag: none;
  user-select: none;
}

/* ---------------- 外壳 ---------------- */

.app {
  position: relative;
  width: min(100%, 460px);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 520px) {
  body {
    background-color: #e7d8bb;
    background-image:
      linear-gradient(45deg, #e2d2b2 25%, transparent 25%, transparent 75%, #e2d2b2 75%),
      linear-gradient(45deg, #e2d2b2 25%, transparent 25%, transparent 75%, #e2d2b2 75%);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
  }
  .app {
    height: min(100dvh - 40px, 900px);
    border: 3px solid var(--line);
    box-shadow: 8px 8px 0 rgba(107, 81, 56, .38);
  }
}

/* ---------------- HUD ---------------- */

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 6px;
  flex: 0 0 auto;
  background: var(--bg);
  border-bottom: 3px solid var(--line);
}

.logo {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}
.logo img { width: 20px; height: 20px; }

.chips { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.chip {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
  padding: 0 7px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip img { width: 18px; height: 18px; }
.chip b { font-size: 16px; }
.chip.store b { color: var(--ink-soft); }
.chip.weather { cursor: pointer; background: var(--panel-2); }
.chip.weather:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--line); }

@media (max-width: 370px) {
  .logo span { display: none; }
  .chip { padding: 0 4px; }
}

/* ---------------- 快捷操作 ---------------- */

.tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 7px 10px 0;
  flex: 0 0 auto;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px 5px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  cursor: pointer;
}
.tool img { width: 24px; height: 24px; }
.tool span { font-size: 16px; }
.tool:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.tool:disabled { opacity: .45; }
.tool.harvest { background: var(--green); border-color: var(--green-d); color: #fff; box-shadow: 2px 2px 0 var(--green-d); }
.tool.harvest:active { box-shadow: 0 0 0 var(--green-d); }

.hint {
  margin: 5px 12px 0;
  height: 21px;
  font-size: 16px;
  line-height: 21px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
}

/* ---------------- 农田场景 ---------------- */

.field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 3px solid var(--line);
  background-color: #dcebc4;
  background-image:
    linear-gradient(45deg, #d3e4b8 25%, transparent 25%, transparent 75%, #d3e4b8 75%),
    linear-gradient(45deg, #d3e4b8 25%, transparent 25%, transparent 75%, #d3e4b8 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.house {
  position: absolute;
  left: 10px;
  top: 6px;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  pointer-events: none;
}
.tree {
  position: absolute;
  right: 10px;
  top: 2px;
  width: 48px;
  height: 56px;
  image-rendering: pixelated;
  pointer-events: none;
}

.plots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  width: calc(100% - 20px);
  max-width: 372px;
}

.plot {
  position: relative;
  aspect-ratio: 1 / 1;
  background-image: url("assets/sprites/soil_tile.png");
  background-size: 32px 32px;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(58, 40, 24, .35);
  cursor: pointer;
  overflow: hidden;
}
.plot:active { filter: brightness(1.12); }

.plot.locked {
  background-image: none;
  box-shadow: inset 0 0 0 1px rgba(58, 40, 24, .13);
}
.plot.locked.poor { opacity: .72; }

.plot .plus {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: rgba(255, 248, 232, .55);
  pointer-events: none;
}

.plot .crop {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -54%);
  image-rendering: pixelated;
  pointer-events: none;
}
.plot.ready .crop { animation: bob 1.1s steps(2, end) infinite; }
@keyframes bob { 50% { transform: translate(-50%, -60%); } }

.plot .bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 5px;
  height: 4px;
  background: rgba(30, 20, 10, .38);
  pointer-events: none;
}
.plot .bar i {
  display: block;
  height: 100%;
  width: 0;
  background-color: #cfe4bb;
  background-image: repeating-linear-gradient(90deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 4px);
}

.plot .spark {
  position: absolute;
  right: 4px;
  top: 3px;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  animation: bob 1s steps(2, end) infinite;
  pointer-events: none;
}

.plot .weeds {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  opacity: .9;
  pointer-events: none;
}
.plot .price {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  padding: 0 3px;
  background: rgba(42, 30, 18, .62);
  color: #fff8e8;
  font-size: 10px;
  line-height: 14px;
  white-space: nowrap;
  pointer-events: none;
}

/* 农夫 */
.farmer {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 48px;
  z-index: 6;
  pointer-events: none;
  will-change: transform;
}
.farmer-body {
  width: 32px;
  height: 48px;
  transition: transform .12s steps(2, end);
}
.farmer.picking .farmer-body { transform: translateY(4px); }
.farmer.chase-ready { pointer-events: auto; cursor: pointer; }
.farmer.chase-ready::after {
  content: "!";
  position: absolute;
  top: -16px;
  left: 50%;
  margin-left: -9px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  font-size: 14px;
  color: #fff8e8;
  background: #b3402c;
  border: 2px solid #fff8e8;
  box-shadow: 0 0 0 2px #b3402c;
  animation: bob 0.7s steps(2, end) infinite;
}
.farmer img {
  width: 32px;
  height: 48px;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
}

.deco {
  position: absolute;
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  pointer-events: none;
  opacity: .95;
  z-index: 1;
}
.deco[data-deco="rock"] { width: 24px; height: 18px; }

.fence {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  background-image: url("assets/sprites/fence.png");
  background-size: 26px 26px;
  background-repeat: repeat-x;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 2;
  opacity: .95;
}

.thief {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 48px;
  z-index: 8;
  display: none;
  cursor: pointer;
  will-change: transform;
}
.thief.on { display: block; }
.thief-body {
  width: 32px;
  height: 48px;
  transition: transform .12s steps(2, end);
}
.thief.grabbing .thief-body { transform: translateY(4px); }
.thief img {
  width: 32px;
  height: 48px;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
}

.pop.bad { color: #ff9a86; }

.fx {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}
.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #fff;
  text-shadow: 1px 1px 0 #3d3025, -1px 0 0 #3d3025, 0 -1px 0 #3d3025, 1px 0 0 #3d3025;
  white-space: nowrap;
  animation: popup .9s steps(8, end) forwards;
}
.pop.gold { color: #ffd76a; }
@keyframes popup {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.8); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* ---------------- Dock ---------------- */

.dock {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 3px solid var(--line);
}

.dock-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 2px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  cursor: pointer;
}
.dock-btn img { width: 24px; height: 24px; opacity: .7; }
.dock-btn span { font-size: 16px; }
.dock-btn.active { color: var(--green-d); background: var(--green-l); border-color: var(--green-d); }
.dock-btn.active img { opacity: 1; }
.dock-badge {
  display: none;
  position: absolute;
  top: 0;
  right: 14%;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  background: var(--red);
  border: 2px solid var(--panel);
  color: #fff;
  font-size: 9px;
  font-style: normal;
  line-height: 10px;
  text-align: center;
}
.dock-badge.on { display: block; }

/* ---------------- 抽屉 ---------------- */

.scrim {
  position: absolute;
  inset: 0 0 calc(var(--dock-h) + env(safe-area-inset-bottom)) 0;
  background: rgba(61, 48, 37, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s steps(2, end);
  z-index: 30;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom));
  height: auto;
  max-height: 66%;
  min-height: 34%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 3px solid var(--line);
  box-shadow: 0 -4px 0 rgba(107, 81, 56, .25);
  transform: translateY(calc(100% + var(--dock-h) + 10px));
  transition: transform .18s steps(4, end);
  z-index: 35;
  will-change: transform;
}
.sheet.open { transform: translateY(0); }

.sheet-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 44px 6px;
  flex: 0 0 auto;
  border-bottom: 2px solid var(--line-2);
}
.sheet-head b { font-size: 16px; }
.grab {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 4px;
  background: var(--line-2);
}
.sheet-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:active { transform: translate(1px, 1px); }

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}
.sheet-body::-webkit-scrollbar { width: 0; }

/* ---------------- 通用 ---------------- */

.btn {
  border: 2px solid var(--green-d);
  padding: 8px 12px;
  background: var(--green);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--green-d);
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--green-d); }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn.ghost {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.btn.ghost:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--line); }
.btn.wide { width: 100%; padding: 10px; margin-top: 10px; }
.btn.red { background: var(--panel); color: var(--red); border-color: var(--red); box-shadow: 2px 2px 0 var(--red); }

.cap { margin: 4px 0 10px; }
.cap-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; }
.cap-row b { color: var(--ink); font-variant-numeric: tabular-nums; }

.rows { display: flex; flex-direction: column; gap: 6px; }

.row, .order {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: var(--panel-2);
  border: 2px solid var(--line-2);
}
.row > img, .order > img { width: 22px; height: 22px; }
.row-main, .order-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; display: flex; align-items: center; gap: 5px; }
.row-sub { font-size: 12px; color: var(--dim); margin-top: 1px; }

.tag {
  font-size: 12px;
  padding: 0 4px;
  border: 1px solid var(--line-2);
  color: var(--dim);
  background: var(--panel);
}
.tag.up { color: var(--green-d); border-color: var(--green); background: #e8f2dd; }
.tag.down { color: var(--red); border-color: var(--red); background: #fbe4de; }

.mini {
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 5px 9px;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--line);
}
.mini:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--line); }
.mini:disabled { opacity: .4; box-shadow: none; }
.mini.green { background: var(--green); color: #fff; border-color: var(--green-d); box-shadow: 2px 2px 0 var(--green-d); }

.empty-state { text-align: center; color: var(--dim); padding: 26px 10px; font-size: 16px; line-height: 1.9; }
.empty-state small { color: #b6a184; font-size: 12px; }

.order-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.reward { font-size: 12px; color: var(--gold-d); font-variant-numeric: tabular-nums; }

.panel-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.panel-foot .hint { flex: 1; margin: 0; height: auto; white-space: normal; }

.upg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--panel-2);
  border: 2px solid var(--line-2);
}
.upg + .upg { margin-top: 6px; }
.upg > img { width: 22px; height: 22px; }
.upg-main { flex: 1; min-width: 0; }
.upg-name { font-size: 16px; }
.lv {
  font-size: 12px;
  color: var(--green-d);
  background: #e8f2dd;
  border: 1px solid var(--green);
  padding: 0 3px;
  margin-left: 4px;
}
.upg-desc { font-size: 12px; color: var(--dim); margin-top: 1px; }

.season-hero { text-align: center; padding: 4px 6px 12px; }
.season-hero .sun-big img { width: 34px; height: 34px; }
.season-hero h3 { margin: 4px 0 3px; font-size: 20px; }
.season-hero p { margin: 0; font-size: 12px; color: var(--ink-soft); line-height: 1.7; }
.sun-mult {
  display: inline-block;
  margin-top: 7px;
  padding: 3px 8px;
  background: #fbeecb;
  border: 2px solid var(--gold-d);
  color: var(--gold-d);
  font-size: 12px;
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.stat-cell { background: var(--panel-2); border: 2px solid var(--line-2); padding: 6px 8px; }
.stat-cell span { display: block; font-size: 12px; color: var(--dim); }
.stat-cell b { font-size: 16px; font-variant-numeric: tabular-nums; }

.danger-zone { margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--line-2); }
.danger-zone .btn { font-size: 12px; padding: 6px 9px; }

/* ---------------- 提示条 ---------------- */

.toasts {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  z-index: 60;
  pointer-events: none;
  width: min(94%, 420px);
  transition: bottom .18s steps(3, end);
}
.app.sheet-open .toasts {
  bottom: calc(66% + var(--dock-h) + env(safe-area-inset-bottom) + 10px);
}
.toast {
  padding: 6px 12px;
  background: var(--ink);
  border: 2px solid #24190f;
  color: #fff8e8;
  font-size: 16px;
  box-shadow: 3px 3px 0 rgba(36, 25, 15, .45);
  max-width: 100%;
  text-align: center;
  animation: toast-in .1s steps(2, end), toast-out .1s steps(2, end) 2s forwards;
}
.toast.good { background: var(--green-d); border-color: #2b5628; }
.toast.warn { background: #b07a26; border-color: #7d5415; }
.toast.bad { background: var(--red); border-color: #8f3527; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-4px); } }

/* ---------------- 弹窗 ---------------- */

.backdrop {
  position: absolute;
  inset: 0;
  z-index: 70;
  background: rgba(61, 48, 37, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in .1s steps(2, end);
}
@keyframes fade-in { from { opacity: 0; } }

.modal {
  width: 100%;
  max-height: 84%;
  overflow-y: auto;
  background: var(--panel);
  border-top: 3px solid var(--line);
  box-shadow: 0 -4px 0 rgba(107, 81, 56, .25);
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  animation: slide-up .16s steps(4, end);
}
@keyframes slide-up { from { transform: translateY(24px); } }

.modal h3 { margin: 0 0 5px; font-size: 20px; }
.modal .modal-sub { margin: 0 0 12px; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }

.seed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seed {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px;
  cursor: pointer;
  text-align: left;
  border: 2px solid var(--line-2);
  background: var(--panel-2);
}
.seed:active:not(.locked) { transform: translate(1px, 1px); }
.seed img { width: 26px; height: 26px; }
.seed .s-name { font-size: 16px; }
.seed .s-meta { font-size: 12px; color: var(--dim); }
.seed .s-price { font-size: 12px; color: var(--gold-d); }
.seed.locked { opacity: .55; }
.seed.locked .s-price { color: var(--dim); }

.report-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 0;
  border-bottom: 2px dashed var(--line-2);
  font-size: 16px;
}
.report-row img { width: 18px; height: 18px; }
.report-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.report-row em { font-style: normal; font-size: 12px; color: var(--red); }
.report-sum {
  margin-top: 10px;
  padding: 7px 9px;
  background: #fbeecb;
  border: 2px solid var(--gold-d);
  font-size: 12px;
  line-height: 1.7;
  color: #8a5f14;
}
.report-note { margin-top: 8px; font-size: 12px; color: var(--ink-soft); line-height: 1.65; }

.help-list { margin: 0; padding-left: 16px; font-size: 15px; line-height: 1.95; color: var(--ink-soft); }
.help-list b { color: var(--ink); }
.modal-actions { display: flex; gap: 6px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

@media (max-height: 560px) {
  .logo span { display: none; }
  .hint { display: none; }
  .sheet { height: 78%; }
}
