/* ============================================================
   背包里的小花园 · 网页版
   温暖绘本风：奶油纸面、陶土花箱、帆布背包。
   ============================================================ */

:root {
  --paper: #F7F1E5;
  --card: #FFFCF4;
  --ink: #3D4637;
  --ink-2: #6F7667;
  --ink-3: #A99A78;
  --line: #E7DCC6;
  --primary: #587A49;
  --primary-dark: #46613A;
  --select: #E4EDD8;
  --bag: #C7A77D;
  --pot: #B56F50;
  --soil: #E6D5B8;
  --water: #529FC2;
  --flower: #E8B84C;
  --invalid: #B74C46;
  --shadow: 0 10px 26px rgba(120, 96, 60, 0.14);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 80% at 50% -10%, #FDF8EE 0%, rgba(253, 248, 238, 0) 60%),
    radial-gradient(90% 60% at 100% 100%, #F2E9D8 0%, rgba(242, 233, 216, 0) 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body.locked { overflow: hidden; }

.hidden { display: none !important; }

.app {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* ---------- 通用按钮 ---------- */
.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: 14px;
  min-height: 48px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.btn.primary {
  background: var(--primary);
  color: #FFFDF6;
  box-shadow: 0 6px 14px rgba(88, 122, 73, 0.26);
}
.btn.primary:active { background: var(--primary-dark); }

.btn.ghost {
  background: rgba(255, 253, 246, 0.6);
  border-color: #D9CDB4;
  color: var(--ink);
}
.btn.ghost:active { background: #F1E9D8; }

.btn.small { min-height: 44px; font-size: 14px; padding: 0 12px; }
.btn.wide { width: 100%; margin-bottom: 10px; }
.btn.danger { color: var(--invalid); border-color: #E0BDB8; }
.btn.danger-solid { background: var(--invalid); color: #fff; box-shadow: 0 6px 14px rgba(183, 76, 70, 0.24); }

/* ---------- 首页 ---------- */
.hero { text-align: center; padding-top: 15vh; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--ink-3);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--ink);
}

.lede {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

.stage {
  margin: 14px 0 0;
  background: linear-gradient(180deg, #F3E7D0, #EBDCBF);
  border-radius: 24px;
  padding: 8px;
  box-shadow: var(--shadow);
}

.stage canvas { display: block; width: 100%; height: auto; border-radius: 18px; }

#view-game .stage,
#view-ending .stage {
  max-width: 356px;
  margin-left: auto;
  margin-right: auto;
}

.stage-home {
  width: min(300px, 74vw);
  margin: 24px auto 0;
  padding: 6px;
  border-radius: 20px;
}

.stage-home canvas { border-radius: 15px; }

.actions { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }

.meta-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
}

.meta-row b { color: var(--ink); font-size: 14px; }
.meta-row .warn { color: var(--invalid); flex-basis: 100%; text-align: center; }

.dot { width: 3px; height: 3px; border-radius: 50%; background: #C9BC9F; display: inline-block; }

.links {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.link {
  appearance: none;
  border: 0;
  background: none;
  padding: 10px 4px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #D8CBAD;
  text-underline-offset: 4px;
}
.link:active { color: var(--primary); }

.footnote { margin: 20px 2px 0; font-size: 11.5px; line-height: 1.7; color: var(--ink-3); text-align: center; }
.footnote.center { text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1.5px solid #DED1B7;
  background: rgba(255, 253, 246, 0.7);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn.ghost { border-color: transparent; background: none; pointer-events: none; }
.icon-btn:active { background: #F1E9D8; }

.chev {
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--ink-2);
  border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg) translate(1px, -1px);
  display: block;
}

.daytag { font-size: 13px; color: var(--ink-2); letter-spacing: 1px; }
.daytag b { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- 状态条 ---------- */
.hud {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.hud-cell {
  flex: 0 0 auto;
  min-width: 74px;
  background: rgba(255, 253, 246, 0.78);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
}

.hud-cell.grow { flex: 1; min-width: 0; }

.hud-cell span { font-size: 10.5px; color: var(--ink-3); letter-spacing: 1px; }
.hud-cell b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.hud-cell.grow b { font-size: 14px; }
.hud-cell i { font-style: normal; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hud-cell i.done { color: var(--primary); }

/* ---------- 提示 ---------- */
.hint {
  margin: 10px 2px 8px;
  min-height: 30px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  padding: 7px 11px;
  border-radius: 12px;
  background: rgba(255, 253, 246, 0.6);
  border: 1px dashed #DED1B7;
}
.hint.good { color: var(--primary); border-color: #B7C9A4; background: rgba(228, 237, 216, 0.55); }
.hint.bad { color: var(--invalid); border-color: #E0BDB8; background: rgba(247, 232, 229, 0.6); }

/* ---------- 种子卡 ---------- */
.tray { margin-top: 4px; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.seed-card {
  appearance: none;
  font-family: inherit;
  background: var(--card);
  border: 1.5px solid #E3D7BF;
  border-radius: 16px;
  padding: 8px 4px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 112px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.seed-card.on {
  border-color: var(--primary);
  background: #F3F8EC;
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(88, 122, 73, 0.18);
}

.card-art { width: 46px; height: 46px; display: block; }

.seed-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }

.seed-dots {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-auto-rows: 5px;
  gap: 2px;
  margin: 1px 0;
}
.seed-dots i { background: #E2D8C2; border-radius: 1px; }
.seed-dots i.on { background: #8CA971; }

.seed-meta { font-size: 9.5px; color: var(--ink-3); letter-spacing: 0.2px; white-space: nowrap; }
.seed-badge { font-size: 10px; color: var(--ink-2); background: #F1E9D8; border-radius: 6px; padding: 1px 6px; }

.tray-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.tray-actions .btn { flex: 1; }

/* ---------- 水滴 ---------- */
.drops {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 253, 246, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  min-height: 48px;
  flex: 1;
}

.drop {
  width: 13px;
  height: 13px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 1.5px solid #A9C6D5;
  background: transparent;
  transition: background 0.15s ease;
}
.drop.on { background: var(--water); border-color: var(--water); }

.drop-text { font-size: 12px; color: var(--ink-2); margin-left: 2px; font-variant-numeric: tabular-nums; }

#waterTray { display: flex; gap: 10px; margin-top: 4px; }
#waterTray .btn { flex: 0 0 auto; min-width: 116px; }

/* ---------- 结算 ---------- */
.result-head { text-align: center; margin: 18px 0 16px; }

.score-big { display: flex; align-items: baseline; justify-content: center; gap: 4px; color: var(--primary); }
.score-big b { font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.score-big span { font-size: 14px; }

.stars { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }

.star {
  width: 20px;
  height: 20px;
  background: #DFD5C0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  display: block;
}
.star.on { background: var(--flower); }

.result-title { margin-top: 6px; font-size: 16px; font-weight: 600; letter-spacing: 1px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(120, 96, 60, 0.06);
}

.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 2px;
}

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13.5px;
  border-bottom: 1px dashed #EDE3CF;
  color: var(--ink-2);
}
.breakdown li:last-child { border-bottom: none; }
.breakdown li b { color: var(--ink); font-variant-numeric: tabular-nums; }
.breakdown li.total { color: var(--ink); font-weight: 600; }

.stat-line { margin: 0 0 6px; font-size: 13px; color: var(--ink); }
.stat-line.muted { color: var(--ink-2); font-size: 12.5px; }

.field { display: block; }
.field span { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 6px; letter-spacing: 1px; }

.field input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid #E3D7BF;
  background: #FDFAF1;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--primary); }

/* ---------- 图鉴 ---------- */
.album-count { margin: 0 2px 14px; font-size: 12.5px; color: var(--ink-2); }

.album { display: flex; flex-direction: column; gap: 10px; }

.album-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 4px 14px rgba(120, 96, 60, 0.06);
}

.album-card.locked { background: #FBF5E9; }

.album-art {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  flex: 0 0 132px;
  align-content: center;
  background: #F6EEDD;
  border-radius: 12px;
  padding: 4px;
}

.album-art canvas { width: 100%; height: auto; display: block; }
.album-art .silhouette { filter: grayscale(1) opacity(0.35); }

.album-body { flex: 1; min-width: 0; }
.album-body h3 { margin: 2px 0 4px; font-size: 15px; font-weight: 700; }
.album-ability { margin: 0 0 6px; font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.album-story { margin: 0 0 4px; font-size: 12px; line-height: 1.65; color: var(--ink); }
.album-meta { margin: 0; font-size: 10.5px; color: var(--ink-3); }

/* ---------- 设置 ---------- */
.row-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
  position: relative;
  font-size: 14px;
}
.row-switch + .row-switch { border-top: 1px dashed #EDE3CF; }
.row-switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: #DFD5C0;
  position: relative;
  transition: background 0.18s ease;
  flex: 0 0 auto;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(90, 74, 48, 0.25);
  transition: transform 0.18s ease;
}
.row-switch input:checked + .switch { background: var(--primary); }
.row-switch input:checked + .switch::after { transform: translateX(20px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 86vw;
  background: rgba(61, 70, 55, 0.94);
  color: #FFFCF4;
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 80;
  box-shadow: 0 8px 20px rgba(50, 40, 25, 0.25);
}

/* ---------- 弹层 ---------- */
.overlay-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay-mask {
  position: absolute;
  inset: 0;
  background: rgba(48, 39, 26, 0.44);
  animation: fade-in 0.16s ease;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: 0 -10px 34px rgba(60, 48, 30, 0.22);
  animation: sheet-up 0.22s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.sheet-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.sheet-sub { margin: 0 0 8px; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); }
.sheet-body { margin: 0 0 14px; font-size: 13.5px; line-height: 1.75; color: var(--ink-2); }

.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.detail-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.detail-art { width: 78px; height: 78px; flex: 0 0 78px; background: #F6EEDD; border-radius: 14px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.tag {
  font-size: 11px;
  color: var(--ink-2);
  background: #F2EAD8;
  border: 1px solid #E4D8BE;
  border-radius: 8px;
  padding: 2px 8px;
}

.rules, .guide { margin: 0 0 10px; padding-left: 20px; }
.rules li, .guide p { font-size: 13px; line-height: 1.8; color: var(--ink-2); margin-bottom: 6px; }
.guide { padding-left: 0; list-style: none; }
.guide p { margin: 0 0 10px; }
.guide b { color: var(--primary); margin-right: 4px; }

.report { list-style: none; margin: 8px 0 0; padding: 0; }
.report li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  font-size: 13.5px;
  border-bottom: 1px dashed #EDE3CF;
  color: var(--ink-2);
}
.report li b { color: var(--primary); font-variant-numeric: tabular-nums; }
.report li.bloom b { color: var(--pot); }
.report li.objective b { color: var(--flower); }
.report li.empty { color: var(--ink-3); justify-content: center; border-bottom: none; font-size: 12.5px; }

.report-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1.5px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}
.report-total b { font-size: 19px; color: var(--primary); font-variant-numeric: tabular-nums; }

.poster-wrap { background: #F2EAD8; border-radius: 14px; padding: 8px; margin-bottom: 4px; }
.poster-wrap img { width: 100%; display: block; border-radius: 10px; }

.offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 750px;
  height: 1120px;
  pointer-events: none;
  opacity: 0;
}

/* ---------- 动效 ---------- */
@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.reduce-motion *,
body.reduce-motion *::after,
body.reduce-motion *::before {
  animation: none !important;
  transition: none !important;
}

@media (min-width: 640px) {
  .overlay-root { align-items: center; }
  .sheet {
    border-radius: 20px;
    max-height: 84vh;
    margin: 0 16px;
    animation: fade-in 0.16s ease;
  }
  .hero { padding-top: 8vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
