:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --bg1: #2c6a4d;
  --bg2: #143325;
  --panel: rgba(18, 52, 37, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --ink: #f5fbf4;
  --ink-soft: #b8d6c2;
  --gold: #ffd166;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg1), var(--bg2));
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
canvas#cv { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }

.layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--sat)) 16px calc(16px + var(--sab));
  pointer-events: none;
}
.layer > * { pointer-events: auto; }

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { cursor: default; }
.btn.primary, .btn.secondary, .btn.build.wide {
  width: 100%;
  padding: 15px 0;
  border-radius: 18px;
  font-size: 19px;
  font-weight: 800;
}
.btn.primary {
  background: linear-gradient(180deg, #6ad97a, #2fa24a);
  box-shadow: 0 6px 0 #1f7a36, 0 10px 24px rgba(47, 162, 74, 0.35);
}
.btn.secondary {
  padding: 11px 0;
  font-size: 17px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.btn.secondary small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.btn.big { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 0 12px; font-size: 22px; }
.btn.big small { font-size: 13px; font-weight: 700; opacity: 0.85; }
.btn.ghost { width: 100%; padding: 12px 0; background: transparent; color: var(--ink-soft); font-weight: 700; font-size: 16px; }
.btn.build {
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 15px;
  color: #4a2d00;
  background: linear-gradient(180deg, #ffe08a, #ffb22e);
  box-shadow: 0 4px 0 #c07a10;
  white-space: nowrap;
}
.btn.build:disabled { color: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.12); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.btn.build.ready { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.icon-btn {
  appearance: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(20, 50, 36, 0.55);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

/* bars */
.bar { display: flex; align-items: center; gap: 10px; }
.bar h2 { margin: 0; flex: 1; font-size: 22px; font-weight: 900; }
.pill { padding: 7px 12px; border-radius: 999px; background: rgba(20, 50, 36, 0.6); border: 1px solid var(--line); font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.pill.seeds { color: #e8ffe0; }

/* home */
#home .brand {
  flex: 1;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(20, 60, 40, 0.5), 0 0 18px rgba(20, 60, 40, 0.35);
}
.spacer { flex: 1; pointer-events: none; }
.home-bottom {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.welcome { margin: 0; font-size: 14px; color: var(--ink-soft); text-align: center; }
.task { display: flex; flex-direction: column; gap: 8px; }
.task-top { display: flex; align-items: center; gap: 10px; }
.task-text { flex: 1; min-width: 0; }
.task-name { font-size: 17px; font-weight: 900; }
.track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.track > div { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #8be07a, #ffd166); transition: width 0.4s ease; }
.row2 { display: flex; gap: 8px; }
.row2 .btn.secondary { flex: 1; min-width: 0; font-size: 15px; }
.row2 .btn.secondary small { font-size: 11px; white-space: nowrap; }
#dailyBtn.ready { border-color: #ffd23f; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 0 14px rgba(255, 210, 63, 0.35); }
#dailyBtn:disabled { opacity: 0.6; }

/* map */
#map { background: radial-gradient(120% 80% at 50% 0%, var(--bg1), var(--bg2)); pointer-events: auto; }
.map-scroll { flex: 1; overflow-y: auto; touch-action: pan-y; margin: 12px -16px 0; padding: 12px 16px 40px; }
.path { list-style: none; margin: 0 auto; padding: 0; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.node button {
  appearance: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #6ad97a, #2fa24a);
  box-shadow: 0 5px 0 #1f7a36;
}
.node.done button { background: linear-gradient(180deg, #ffe08a, #f0a020); box-shadow: 0 5px 0 #b06f0a; color: #4a2d00; }
.node.hard button { background: linear-gradient(180deg, #ff8a7a, #e0474c); box-shadow: 0 5px 0 #a02a30; color: #fff; }
.node.current button { outline: 4px solid rgba(255, 255, 255, 0.85); outline-offset: 4px; animation: bob 1.6s ease-in-out infinite; }
.node.locked button { background: #2b5140; box-shadow: 0 5px 0 #1a3529; color: rgba(255, 255, 255, 0.35); cursor: default; }
.node .stars { font-size: 13px; color: var(--gold); letter-spacing: 2px; min-height: 16px; }
.node .stars .off { color: rgba(255, 255, 255, 0.18); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* hud */
.hud-title { flex: 1; text-align: center; font-weight: 800; color: var(--ink-soft); font-size: 14px; }
.hud-score { font-size: 28px; font-weight: 900; color: var(--ink); line-height: 1.05; font-variant-numeric: tabular-nums; }
.goals { display: flex; gap: 6px; min-width: 42px; justify-content: flex-end; }
.goal {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  font-weight: 900;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.goal.done { background: rgba(106, 217, 122, 0.28); border-color: rgba(106, 217, 122, 0.7); }
.goal img { width: 22px; height: 22px; }
.goal .lbl { font-size: 12px; color: var(--ink-soft); font-weight: 800; }

/* modals */
.modal { justify-content: center; align-items: center; background: rgba(8, 24, 16, 0.55); pointer-events: auto; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.card {
  width: 100%;
  max-width: 350px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 22px 18px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.card h2 { margin: 0; font-size: 25px; font-weight: 900; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.goal-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.goal-row .goal { font-size: 20px; padding: 9px 13px; }
.goal-row .goal img { width: 30px; height: 30px; }
.hard-tag { align-self: center; padding: 5px 12px; border-radius: 999px; background: rgba(255, 106, 76, 0.2); color: #ffab94; font-weight: 800; font-size: 13px; }
.sub { margin: 0; color: var(--ink-soft); }
.big-num { font-size: 46px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.seed-gain { font-size: 20px; font-weight: 900; color: #b6f5a8; min-height: 4px; }
.seed-gain:empty { display: none; }
.result-stars { font-size: 44px; letter-spacing: 6px; color: var(--gold); min-height: 10px; }
.result-stars:empty { display: none; }
.result-stars .off { color: rgba(255, 255, 255, 0.15); }
.result-stars span { display: inline-block; animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.result-stars span:nth-child(2) { animation-delay: 0.15s; }
.result-stars span:nth-child(3) { animation-delay: 0.3s; }

.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opt {
  appearance: none;
  font: inherit;
  color: var(--ink);
  padding: 4px 4px 7px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}
.opt canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: 11px; display: block; }
.opt.sel { border-color: var(--gold); background: rgba(255, 209, 102, 0.14); }

.set-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); font-weight: 700; }
.set-row select { font: inherit; color: var(--ink); background: #245440; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.switch { appearance: none; width: 46px; height: 26px; margin: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.18); position: relative; cursor: pointer; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch:checked { background: #5ccf6b; }
.switch:checked::after { transform: translateX(20px); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#toasts { position: fixed; top: calc(70px + var(--sat)); left: 0; right: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; font-weight: 800; animation: pop 0.3s ease, fade 0.4s ease 2.2s reverse forwards; }

/* power-ups */
#hud .spacer { pointer-events: none; }
.boosters { display: flex; justify-content: center; gap: 10px; width: 100%; max-width: 420px; margin: 0 auto; }
.booster {
  appearance: none;
  font: inherit;
  color: var(--ink);
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 0 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.booster:active { transform: scale(0.96); }
.booster .ico { font-size: 22px; line-height: 1.1; }
.booster .nm { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.booster .cnt {
  position: absolute;
  top: -7px;
  right: 8px;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 99px;
  background: var(--gold);
  color: #4a2d00;
  font-size: 12px;
  font-weight: 900;
}
.booster.empty .cnt { background: #3fa9ff; color: #fff; }
.booster.active { border-color: var(--gold); background: rgba(255, 209, 102, 0.22); animation: pulse 1s ease-in-out infinite; }

/* garden switcher */
.gnav { display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 900; }
.gnav span { min-width: 150px; text-align: center; }
.icon-btn.small { width: 34px; height: 34px; border-radius: 11px; font-size: 20px; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.btn.secondary:disabled { opacity: 0.45; }
.rescue-opts { display: flex; flex-direction: column; gap: 10px; }

/* test ads (web build) */
.ad-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.88); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade 0.2s ease; }
.ad-box { width: 100%; max-width: 360px; background: #f4f6fb; color: #111; border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.ad-tag { align-self: flex-start; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; background: #111; color: #fff; padding: 4px 8px; border-radius: 6px; }
.ad-visual { aspect-ratio: 16 / 10; border-radius: 12px; background: repeating-linear-gradient(45deg, #dfe4f0, #dfe4f0 12px, #e9edf6 12px, #e9edf6 24px); display: grid; place-items: center; color: #556; font-weight: 700; }
.ad-count { font-weight: 700; color: #334; }
.ad-text { margin: 0; color: #334; line-height: 1.4; }
.ad-actions { display: flex; gap: 8px; }
.ad-btn { flex: 1; appearance: none; border: 0; font: inherit; font-weight: 800; padding: 12px; border-radius: 12px; background: #1a73e8; color: #fff; cursor: pointer; }
.ad-btn[disabled] { opacity: 0.45; cursor: default; }
.ad-btn.ghost { background: #e3e7f0; color: #334; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* settings: privacy link and anonymous install id */
.set-link { display: block; text-align: center; color: inherit; opacity: 0.75; font-size: 14px; margin: 10px 0 2px; }
.set-id { text-align: center; font-size: 11px; opacity: 0.55; margin: 6px 0 10px; user-select: all; word-break: break-all; }

/* the two o's of the logo are the blocks from the app icon */
.brand .blk { display: inline-block; width: 0.6em; height: 0.6em; margin: 0 0.03em; border-radius: 0.17em; vertical-align: 0; text-shadow: none; }
.brand .blk.r { background: linear-gradient(180deg, #ff5a5f 78%, #c94448 78%); }
.brand .blk.y { background: linear-gradient(180deg, #ffd23f 78%, #cc9a10 78%); }
