/* 菌菇图鉴 — 苔绿 / 米白 / 菌盖红 */

:root {
  --primary: #5B8C3A;
  --primary-dark: #47702C;
  --bg: #FBF7EE;
  --surface: #FFFFFF;
  --cta: #D9553F;
  --accent: #F2B134;
  --ink: #23291E;
  --ink-2: #55604C;
  --muted: #8A9280;
  --line: #E2DFD2;

  --c-common: #7EC8A0;
  --c-rare: #4DA6FF;
  --c-epic: #B57BFF;
  --c-legend: #E0B400;

  --deadly: #B0203A;
  --warn: #D9553F;

  --nav-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- pages ---- */
.page {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  padding-top: var(--safe-t);
  overflow: hidden;
}
.page.active { display: flex; }
.page-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px 16px; }
.page.has-nav .page-body { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 14px); }

.page-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}
.page-header h1 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.page-header .back { font-size: 15px; color: var(--primary); padding: 4px 6px; }

/* ---- safety banner: never dismissible ---- */
.safety-bar {
  flex: none;
  background: #F5EDE6;
  border-bottom: 1px solid #E6D6C6;
  color: #6E5A48;
  font-size: 11px; line-height: 1.5;
  padding: 6px 14px;
}

/* ---- bottom nav ---- */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.bottom-nav button {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 10px;
}
.bottom-nav button .ico { font-size: 21px; line-height: 1; }
.bottom-nav button.on { color: var(--primary); }

/* ---- garden ---- */
#garden-wrap { position: relative; flex: 1; min-height: 0; }
#garden-canvas { width: 100%; height: 100%; display: block; }
.garden-top {
  position: absolute; top: 8px; left: 10px; right: 10px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
.chip {
  background: rgba(255,255,255,0.86);
  border-radius: 999px; padding: 4px 11px;
  font-size: 12px; font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  pointer-events: auto;
}
/* Spores waiting: the one chip worth looking at on a return visit. */
.chip.ready {
  background: var(--accent); color: #3A2E00; font-weight: 700;
  animation: chip-pulse 2.4s ease-in-out infinite;
}
@keyframes chip-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .chip.ready { animation: none; }
}
.garden-tools {
  position: absolute; right: 10px; bottom: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.tool {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  font-size: 19px; display: grid; place-items: center;
}
.garden-actions {
  flex: none; display: flex; gap: 10px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
/* the nav is absolutely positioned over the page, so pages that end in an
   action bar have to leave room for it themselves */
.page.has-nav .garden-actions { margin-bottom: var(--nav-h); }

/* ---- buttons ---- */
.btn {
  border-radius: 10px; padding: 11px 16px;
  font-size: 15px; font-weight: 600;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn.cta { background: var(--cta); }
.btn.ghost { background: #EDEFE4; color: var(--ink-2); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.row + .row { margin-top: 8px; }

/* Three entry buttons on one line: side-by-side labels wrapped mid-word
   ("合成菌 / 卡"), so the icon goes above the label instead. */
.tile-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 10px;
}
.btn.tile {
  flex-direction: column; gap: 3px;
  padding: 9px 4px; font-size: 13px; line-height: 1.25;
  white-space: nowrap;
}
.btn.tile .ico { font-size: 20px; line-height: 1; }

/* ---- form controls ---- */
/* The browser defaults ship an iOS-blue slider, which fights the palette. */
.pick {
  padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 14px; font-family: inherit;
}
input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1; max-width: 160px; height: 5px; border-radius: 3px;
  background: #E6E9DC; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.28); cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff; cursor: pointer;
}
input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: #E6E9DC; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- resource strip ---- */
.res-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.res {
  display: flex; align-items: center; gap: 5px;
  background: #EFF2E6; border-radius: 8px;
  padding: 5px 9px; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.res i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---- biome picker ---- */
.biome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.biome {
  border: 2px solid var(--line); border-radius: 12px;
  padding: 12px; text-align: left; background: var(--surface);
}
.biome.on { border-color: var(--primary); background: #F1F6E9; }
.biome b { display: block; font-size: 15px; margin-bottom: 3px; }
.biome span { font-size: 12px; color: var(--muted); }

/* ---- quiz ---- */
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.quiz-progress { flex: 1; height: 5px; background: #E6E9DC; border-radius: 3px; overflow: hidden; }
.quiz-progress i { display: block; height: 100%; background: var(--primary); transition: width .25s; }
.timer-bar { height: 4px; background: #E6E9DC; border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.timer-bar i { display: block; height: 100%; background: var(--accent); }
.timer-bar.low i { background: var(--cta); }

.q-art {
  height: 190px; border-radius: 12px;
  background: linear-gradient(180deg, #EAF0DC 0%, #D6E0C0 100%);
  display: grid; place-items: center; margin-bottom: 12px;
  overflow: hidden;
}
.q-art canvas { display: block; }
.q-text { font-size: 16px; font-weight: 600; margin-bottom: 12px; line-height: 1.5; }
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  text-align: left; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 11px 14px; background: var(--surface); font-size: 15px;
}
.opt .en { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.opt.right { border-color: var(--primary); background: #EDF5E2; }
.opt.wrong { border-color: var(--cta); background: #FBECE8; }
.opt[disabled] { pointer-events: none; }

.explain {
  margin-top: 12px; padding: 11px 13px;
  background: #F3F1E4; border-radius: 10px;
  font-size: 13.5px; line-height: 1.65;
}
.explain .tag { font-weight: 600; }
.disclaimer-note {
  margin-top: 8px; font-size: 11.5px; color: #6E5A48;
  border-top: 1px dashed #D8CBB8; padding-top: 7px;
}

/* ---- draw result ---- */
/* The card sits in the middle of the screen rather than hugging the top with
   a third of the page empty under it. "safe" keeps the top reachable if the
   text ever grows past the viewport. */
#page-reveal .page-body {
  display: flex; flex-direction: column;
  justify-content: center;
  justify-content: safe center;
}
.reveal { text-align: center; padding: 8px 0 4px; }
/* Both were inline, so the pill and the drawing shared a line and the pill
   ended up jammed against the mushroom's left side. */
.rarity-banner {
  display: block; width: fit-content; border-radius: 999px;
  padding: 5px 18px; font-weight: 700; font-size: 14px;
  color: #fff; margin: 0 auto 10px;
}
.reveal canvas { display: block; margin: 0 auto; }
.reveal h2 { margin: 8px 0 2px; font-size: 22px; }
.reveal .latin { font-style: italic; color: var(--muted); font-size: 13px; }
.reveal .quote {
  margin: 12px auto; max-width: 30em;
  font-size: 14.5px; color: var(--ink-2);
}
.edib {
  display: inline-block; border-radius: 8px;
  padding: 4px 12px; font-size: 13px; font-weight: 600;
  color: #fff; margin: 6px 0;
}
.edib-note { font-size: 12px; color: var(--muted); max-width: 30em; margin: 0 auto; }

/* ---- collection ---- */
.coll-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; background: var(--surface);
}
.pill.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 9px;
}
.cell {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 4px 7px; text-align: center;
  position: relative;
}
.cell canvas { display: block; margin: 0 auto; }
.cell .nm { font-size: 11.5px; line-height: 1.25; margin-top: 3px; }
.cell .dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
}
.cell.locked canvas { filter: brightness(0) opacity(0.14); }
.cell.locked .nm { color: var(--muted); }
.cell .skull { position: absolute; top: 5px; left: 6px; font-size: 11px; }

/* ---- detail ---- */
.detail-art { height: 200px; display: grid; place-items: center; }
.kv { display: grid; grid-template-columns: 5em 1fr; gap: 5px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.lookalike-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.lookalike {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 5px 10px; background: var(--surface); font-size: 13px;
}

/* ---- overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20,26,18,0.55);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.overlay.on { display: flex; }
.sheet {
  background: var(--surface); border-radius: 16px;
  padding: 18px 18px 16px; width: 100%; max-width: 360px;
  max-height: 84vh; overflow-y: auto;
}
.sheet h2 { margin: 0 0 10px; font-size: 17px; }
.sheet .btn { margin-top: 12px; }

.foray-anim {
  position: fixed; inset: 0; z-index: 70;
  background: linear-gradient(180deg, #8FA684 0%, #4E6136 100%);
  display: none; flex-direction: column;
  align-items: center; justify-content: center; color: #fff;
}
.foray-anim.on { display: flex; }
.foray-anim .big { font-size: 52px; margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 26px + var(--safe-b));
  transform: translateX(-50%);
  background: rgba(20,26,18,0.9); color: #fff;
  padding: 9px 16px; border-radius: 999px;
  font-size: 13.5px; z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 82vw; text-align: center;
}
.toast.on { opacity: 1; }
/* Pages that end in a 62px action bar push the toast above it; on the others
   it stays low, out of the way of the content. */
#page-garden.active ~ .toast,
#page-reveal.active ~ .toast { bottom: calc(var(--nav-h) + 84px + var(--safe-b)); }

/* ---- tasks ---- */
.task { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.task + .task { border-top: 1px solid var(--line); }
.task .bar { flex: 1; height: 5px; background: #E6E9DC; border-radius: 3px; overflow: hidden; }
.task .bar i { display: block; height: 100%; background: var(--primary); }
.task .lbl { font-size: 13.5px; min-width: 7.5em; }
.task .btn { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }

/* ---- safety card ---- */
.safety-card { background: #FBECE8; border: 1px solid #F0CDC4; }
.safety-card h2 { color: var(--deadly); }
.safety-card ol { margin: 6px 0 0; padding-left: 1.3em; font-size: 13.5px; line-height: 1.75; }

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