/* ── Hollow Pines Farm ─────────────────────────────────────────────────── */

:root {
  color-scheme: dark;
  --ink: #f6f1e4;
  --ink-dim: #c9bfa8;
  --panel: rgba(38, 30, 24, 0.78);
  --panel-solid: #2b231c;
  --edge: rgba(255, 244, 214, 0.16);
  --gold: #ffd06b;
  --leaf: #8fd05a;
  --water: #66c2e8;
  --danger: #ff8f6b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  --ui: clamp(12px, 1.45vmin + 8px, 17px);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #101820;
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#stage { position: fixed; inset: 0; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.dragging { cursor: grabbing; }

.hidden { display: none !important; }

/* ── generic panels ─────────────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  backdrop-filter: blur(9px) saturate(1.2);
  -webkit-backdrop-filter: blur(9px) saturate(1.2);
  box-shadow: var(--shadow);
  padding: 0.5em 0.75em;
}

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0.12em 0.34em;
  margin: 0 0.1em;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.11);
  font: inherit;
  font-size: 0.86em;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
}

button {
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 0.45em 0.9em;
  cursor: pointer;
  transition: background 0.13s, transform 0.08s, border-color 0.13s;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.17); border-color: rgba(255, 244, 214, 0.34); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.38; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, #8fd05a, #5f9c36);
  border-color: rgba(255, 255, 255, 0.32);
  color: #12200a;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.6em 1.5em;
  font-size: 1.05em;
}
button.primary:hover { background: linear-gradient(180deg, #a3e06c, #6cae3e); }

/* ── HUD ────────────────────────────────────────────────────────────────── */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(8px, 1.6vmin, 18px);
  padding-top: max(clamp(8px, 1.6vmin, 18px), env(safe-area-inset-top));
  gap: 0.6em;
}
#hud button { pointer-events: auto; }

.hud-row { display: flex; gap: 0.6em; align-items: flex-start; }
.hud-bottom { align-items: flex-end; justify-content: space-between; }

.stats { display: flex; gap: 1.1em; align-items: center; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat b { font-size: 1.12em; font-weight: 700; letter-spacing: 0.01em; }
.stat i { font-style: normal; font-size: 0.74em; color: var(--ink-dim); letter-spacing: 0.05em; text-transform: uppercase; }
.stat.gold b { color: var(--gold); }
.stat.gold b::after { content: " ⛁"; font-size: 0.8em; opacity: 0.8; }

.gauge {
  display: block;
  width: 5.2em;
  height: 0.52em;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin-bottom: 0.22em;
  border: 1px solid rgba(255, 255, 255, 0.13);
}
.gauge.wide { width: 9em; }
.gauge > span { display: block; height: 100%; width: 0%; border-radius: 99px; transition: width 0.25s ease-out; }
#water-fill { background: linear-gradient(90deg, #4aa8d8, var(--water)); }
#goal-fill { background: linear-gradient(90deg, #d8a13a, var(--gold)); }

.goal { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.goal i { font-style: normal; font-size: 0.74em; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.goal b { font-size: 0.84em; color: var(--gold); }

.icon-buttons { margin-left: auto; display: flex; gap: 0.35em; padding: 0.35em; }
.icon-buttons button { width: 2.1em; height: 2.1em; padding: 0; border-radius: 9px; font-size: 1em; }
.icon-buttons button.off { opacity: 0.42; }

/* seed bar */
.seeds { display: flex; gap: 0.4em; padding: 0.4em; pointer-events: auto; }
.seed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1em;
  min-width: 4.4em;
  padding: 0.42em 0.5em 0.36em;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.24);
  cursor: pointer;
  line-height: 1.15;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.seed:hover { background: rgba(255, 255, 255, 0.12); }
.seed .swatch { width: 1.5em; height: 1.5em; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.45); }
.seed .nm { font-size: 0.78em; font-weight: 600; }
.seed .ct { font-size: 0.72em; color: var(--ink-dim); }
.seed .ct.none { color: #8b8272; }
.seed.sel { background: rgba(143, 208, 90, 0.25); border-color: var(--leaf); transform: translateY(-3px); }
.seed.locked { opacity: 0.44; cursor: default; }
.seed .key { position: absolute; }

.prompt {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55em 1em;
  border-radius: 99px;
  background: rgba(20, 15, 10, 0.8);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  font-weight: 600;
  animation: rise 0.16s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* toasts */
#toast-rail {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  pointer-events: none;
}
.toast {
  padding: 0.42em 0.95em;
  border-radius: 99px;
  background: rgba(20, 15, 10, 0.84);
  border: 1px solid var(--edge);
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  animation: toast 2.4s ease-out forwards;
}
.toast.good { color: var(--leaf); }
.toast.coin { color: var(--gold); }
.toast.bad { color: var(--danger); }
@keyframes toast {
  0% { opacity: 0; transform: translateY(10px) scale(0.96); }
  12% { opacity: 1; transform: none; }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* ── overlays ───────────────────────────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 8, 6, 0.55), rgba(8, 6, 4, 0.85));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 5;
}

.card {
  width: min(560px, 100%);
  max-height: 92%;
  overflow-y: auto;
  background: linear-gradient(180deg, #35291f, #241c16);
  border: 1px solid var(--edge);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: clamp(1em, 3vmin, 1.9em);
}
.card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6em; }
.card h2 { margin: 0; font-size: 1.4em; letter-spacing: 0.01em; }
.card h3 {
  margin: 1.1em 0 0.45em;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  font-weight: 700;
}
.card section:first-of-type h3 { margin-top: 0.2em; }
.close { width: 2em; height: 2em; padding: 0; border-radius: 50%; line-height: 1; }

/* title */
.title-card { text-align: center; width: min(500px, 100%); }
.title-card h1 {
  margin: 0.1em 0 0.05em;
  font-size: clamp(2.2em, 7vmin, 3.4em);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.title-card h1 span { display: block; font-size: 0.62em; color: var(--leaf); letter-spacing: 0.16em; text-transform: uppercase; }
.tagline { color: var(--ink-dim); margin: 0.9em 0 1.5em; line-height: 1.5; }
.title-actions { display: flex; gap: 0.7em; justify-content: center; flex-wrap: wrap; }
.keyhints {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em 1.1em;
  margin: 1.6em 0 0;
  padding: 0;
  font-size: 0.82em;
  color: var(--ink-dim);
}
.loadnote { margin: 1.1em 0 0; font-size: 0.8em; color: var(--ink-dim); min-height: 1.2em; }

/* shop + summary rows */
.rows { display: flex; flex-direction: column; gap: 0.38em; }
.row {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.5em 0.7em;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.row .swatch { width: 1.35em; height: 1.35em; border-radius: 50%; flex: none; border: 1px solid rgba(255, 255, 255, 0.4); }
.row .label { flex: 1; min-width: 0; }
.row .label b { display: block; font-weight: 650; }
.row .label i { font-style: normal; font-size: 0.78em; color: var(--ink-dim); }
.row .price { color: var(--gold); font-weight: 700; white-space: nowrap; }
.row button { white-space: nowrap; }
.row.empty { justify-content: center; color: var(--ink-dim); font-size: 0.9em; font-style: italic; }
.row.owned .price { color: var(--leaf); }

.card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.3em;
  padding-top: 0.8em;
  border-top: 1px solid var(--edge);
  color: var(--ink-dim);
  font-size: 0.85em;
}
.card footer b { font-size: 1.35em; color: var(--gold); }

/* help */
.steps { margin: 0.2em 0 1em; padding-left: 1.2em; line-height: 1.65; }
.steps li { margin-bottom: 0.18em; }
.warn {
  margin: 0 0 1.2em;
  padding: 0.65em 0.9em;
  border-radius: 11px;
  background: rgba(255, 143, 107, 0.13);
  border: 1px solid rgba(255, 143, 107, 0.3);
  color: #ffd0bf;
  font-size: 0.9em;
}
.keys { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.keys td { padding: 0.3em 0; vertical-align: middle; }
.keys td:last-child { color: var(--ink-dim); text-align: right; }

/* summary */
.summary-card { width: min(420px, 100%); text-align: center; }
.summary-card h2 { margin-bottom: 0.8em; color: var(--gold); }
.summary-card .rows { text-align: left; margin-bottom: 1.3em; }
.summary-card .row { justify-content: space-between; }

/* screen fade for sleeping */
#fade {
  position: absolute;
  inset: 0;
  background: #06070a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 8;
}
#fade.on { opacity: 1; }

.noscript { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; }

/* narrow screens: stack the HUD so it never covers the field */
@media (max-width: 620px) {
  .stats { gap: 0.8em; }
  .goal { display: none; }
  .seed { min-width: 3.6em; }
  .hud-bottom { flex-direction: column-reverse; align-items: stretch; gap: 0.5em; }
  .prompt { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
