/* ============ FocusForest Web PWA ============ */
:root {
  --color-primary: #3FAB94;
  --color-bg: #E6FEED;
  --color-forest: #37573E;
  --color-grow: #07A414;
  --color-accent: #A4D973;
  --color-text: #222222;
  --color-muted: #6B7A6F;
  --color-withered: #8A7A6A;
  --color-danger: #C0563F;
  --color-dark-bg: #1A2620;
  --color-dark-card: #243029;
  --color-card: #FFFFFF;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; min-width: 44px; min-height: 44px; }
select, input[type=number] { font-size: 16px; }

/* ============ Screen stack ============ */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 80px);
  position: relative;
}
.screen.active { display: flex; }

.screen-header { padding: 8px 4px 16px; }
.screen-header h1 { font-size: 26px; color: var(--color-forest); }

/* ============ Top bar ============ */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0 12px;
}
.topbar-right { display: flex; align-items: center; gap: 6px; }
.top-coin {
  background: #fff; border-radius: 16px; padding: 8px 12px;
  font-size: 13px; color: var(--color-forest); font-weight: 600;
  box-shadow: 0 2px 8px rgba(55,87,62,0.08);
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px;
  font-size: 20px; background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
}

/* ============ Ring ============ */
.ring-wrap {
  position: relative;
  width: min(78vw, 340px);
  margin: 12px auto;
  aspect-ratio: 1/1;
}
#ring-svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--color-primary); stroke-opacity: 0.15; stroke-width: 14; }
.ring-fg { fill: none; stroke: var(--color-primary); stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset 0.2s linear; }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
}
.tree-stage { width: 40%; height: 40%; object-fit: contain; }
.time-display { font-size: 40px; font-weight: 600; color: var(--color-forest); font-variant-numeric: tabular-nums; }
.progress-pct { font-size: 13px; color: var(--color-muted); }

/* ============ Meta row ============ */
.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 12px 8px;
}
.capsule {
  background: #fff; border-radius: 16px; padding: 6px 14px;
  font-size: 14px; color: var(--color-forest);
  box-shadow: 0 2px 8px rgba(55,87,62,0.08);
}
.coin-badge { font-size: 16px; font-weight: 600; color: var(--color-forest); }
.small-text { font-size: 12px; padding: 4px 8px; min-height: 32px; }
.tag-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px;
}
.tag-item {
  background: #fff; border-radius: 12px; padding: 12px 8px;
  text-align: center; font-size: 14px; color: var(--color-forest);
}
.tag-item.selected { outline: 2px solid var(--color-primary); }

/* ============ Buttons ============ */
.action-row { margin-top: auto; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.primary-btn {
  min-width: 200px; padding: 16px 32px;
  background: var(--color-primary); color: #fff;
  border-radius: 28px; font-size: 18px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(63,171,148,0.35);
}
.primary-btn.block { width: 100%; }
.primary-btn:disabled { opacity: 0.5; }
.text-btn { color: var(--color-muted); font-size: 15px; padding: 12px; }
.text-btn.danger { color: var(--color-danger); }
.wide-btn {
  width: 100%; padding: 14px; margin: 6px 0;
  background: #fff; border-radius: 12px; font-size: 16px; color: var(--color-forest);
  text-align: left; padding-left: 16px;
}
.wide-btn.danger { color: var(--color-danger); }

/* ============ Tab bar ============ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(12px);
  padding: 8px 0 calc(var(--safe-b) + 8px);
  border-top: 1px solid rgba(55,87,62,0.1);
}
.tab { font-size: 13px; color: var(--color-muted); padding: 6px 12px; }
.tab.active { color: var(--color-primary); font-weight: 600; }

/* ============ Forest field（旷野 + 空地种植） ============ */
.forest-progress { font-size: 13px; color: var(--color-muted); margin-top: 4px; }
.forest-progress b { color: var(--color-primary); font-weight: 700; }

.forest-field {
  flex: 1; min-height: 0; position: relative;
  border-radius: 18px; overflow: hidden;
  background: #DFF6E6 url('assets/components/forest-meadow.png') center bottom / cover no-repeat;
  box-shadow: inset 0 2px 20px rgba(55,87,62,0.10), 0 2px 8px rgba(55,87,62,0.06);
}
.forest-slots {
  height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-content: end; gap: 2px;
  padding: 16px 6px 24px;
}
.slot {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.slot img {
  width: 88%; height: 88%; object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(30,60,40,0.25));
}
.slot.withered img { filter: grayscale(1) opacity(0.55); }
.slot.empty::after {
  content: ''; width: 9px; height: 9px; border-radius: 50%;
  background: rgba(55,87,62,0.10);
  border: 1px dashed rgba(55,87,62,0.28);
}
.forest-summary {
  text-align: center; font-size: 13px; color: var(--color-muted);
  padding: 10px 4px 2px;
}
.empty-hint { color: var(--color-muted); text-align: center; padding: 40px 20px; }

/* ============ Stats ============ */
.stats-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: 16px; padding: 16px; text-align: center;
  box-shadow: 0 2px 8px rgba(55,87,62,0.06);
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.section-title { margin: 16px 4px 8px; color: var(--color-forest); font-size: 16px; }
.bar-chart {
  display: flex; align-items: flex-end; gap: 8px; height: 140px;
  background: #fff; border-radius: 16px; padding: 16px;
}
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-fill { width: 100%; background: var(--color-accent); border-radius: 6px 6px 0 0; min-height: 4px; transition: height 0.3s; }
.bar-label { font-size: 10px; color: var(--color-muted); }

/* ============ Settings ============ */
.settings-list { display: flex; flex-direction: column; gap: 12px; }
.setting-group {
  background: #fff; border-radius: 16px; padding: 4px 16px;
  box-shadow: 0 2px 8px rgba(55,87,62,0.06);
}
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid rgba(55,87,62,0.06);
  font-size: 15px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row select, .setting-row input { border: none; font-size: 15px; color: var(--color-forest); background: transparent; }
.setting-row input[type=number] { width: 50px; text-align: right; }

/* ============ Sheets ============ */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
.sheet.hidden { display: none; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.sheet-body {
  position: relative; width: 100%;
  background: var(--color-bg); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(var(--safe-b) + 20px);
  max-height: 80vh; overflow-y: auto;
}
.sheet-body h2 { font-size: 20px; color: var(--color-forest); margin-bottom: 16px; text-align: center; }

.species-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px;
}
.species-card {
  background: #fff; border-radius: 14px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.species-card img { width: 60px; height: 60px; object-fit: contain; }
.species-card.selected { outline: 2px solid var(--color-primary); }
.species-card.locked { opacity: 0.6; }
.species-name { font-size: 12px; color: var(--color-forest); }
.species-price { font-size: 12px; color: var(--color-muted); }

.mode-list { display: flex; flex-direction: column; gap: 8px; }
.mode-item {
  background: #fff; border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
}
.mode-item.selected { outline: 2px solid var(--color-primary); }
.mode-item b { color: var(--color-forest); font-size: 15px; }
.mode-item small { color: var(--color-muted); font-size: 12px; }

/* ============ Modal ============ */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.4); }
.modal.hidden { display: none; }
.modal-body {
  width: 85%; background: #fff; border-radius: 18px; padding: 20px;
}
.modal-body h3 { font-size: 17px; color: var(--color-forest); margin-bottom: 8px; }
.modal-body p { font-size: 14px; color: var(--color-text); margin-bottom: 16px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .primary-btn { min-width: 80px; padding: 10px 20px; font-size: 15px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff;
  padding: 10px 20px; border-radius: 20px; font-size: 14px;
  z-index: 100; max-width: 80vw; text-align: center;
}
.toast.hidden { display: none; }

/* ============ Onboarding ============ */
.onboarding {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(180deg, #E6FEED 0%, #C8F0D6 100%);
  display: flex; flex-direction: column; padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px);
}
.onboarding.hidden { display: none; }
.onboarding-track {
  flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.onboard-page {
  min-width: 100%; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.onboard-page img { width: 70%; aspect-ratio: 1; object-fit: contain; }
.onboard-page h2 { color: var(--color-forest); font-size: 22px; }
.onboard-page p { color: var(--color-muted); font-size: 15px; }

.hidden { display: none !important; }
