:root {
  --bg: #1b3427;
  --bg-deep: #14281e;
  --cream: #eef0df;
  --muted: #a9bba0;
  --accent: #d4e0a8;
  --line: rgba(238, 240, 223, 0.14);
  --glass: rgba(255, 255, 255, 0.05);
  --display: "Cormorant Garamond", Georgia, serif;
  --body: "DM Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--cream);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: lining-nums;
  background:
    radial-gradient(900px 600px at 50% 18%, #2d5039 0%, transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%) fixed;
  background-color: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, figure, blockquote, ol { margin: 0; }
em { color: var(--accent); }

svg { flex: none; }
.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.8rem 1.7rem;
  color: var(--bg);
  font: 500 1rem var(--body);
  text-decoration: none;
  background: #f1ecd8;
  border: 1.5px solid #f1ecd8;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.btn svg { width: 1.25rem; height: 1.25rem; }
.btn:hover { background: #fff8e4; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .tab:focus-visible, .more:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn-small { min-height: 40px; padding: 0.45rem 1.1rem; font-size: 0.92rem; color: var(--cream); background: transparent; border-color: var(--line); }
.btn-small:hover { background: var(--glass); }

.hero {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-areas: "top" "stat" "titles" "stage" "actions";
  gap: 0.6rem;
  min-height: 100vh;
  min-height: 100svh;
  padding: max(0.9rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  overflow: hidden;
  text-align: center;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; }
.brand svg { width: 1.2rem; height: 1.2rem; color: var(--accent); }

.stat {
  grid-area: stat;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin-top: 0.3rem;
}
.stat-num { font: 300 clamp(3.6rem, 19vw, 5.2rem) / 1 var(--display); color: var(--accent); }
.stat-label { color: var(--muted); font-size: 0.82rem; line-height: 1.3; letter-spacing: 0.14em; text-align: left; text-transform: uppercase; }

.titles { grid-area: titles; }
.eyebrow { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.24em; text-transform: uppercase; }
.names { margin: 0.1rem 0; font: 300 clamp(2.9rem, 14.5vw, 4.4rem) / 1.05 var(--display); letter-spacing: -0.01em; }
.names em { font-weight: 300; }
.forest-name { font: italic 400 clamp(1.6rem, 7vw, 2.3rem) / 1.15 var(--display); color: var(--accent); }
.tagline { margin-top: 0.4rem; color: var(--muted); font-size: 0.98rem; }
.tagline em { color: var(--cream); font-family: var(--display); font-size: 1.15em; }

.venue { display: none; }

.stage { grid-area: stage; position: relative; min-height: 330px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.stage canvas:active { cursor: grabbing; }

.stage::before {
  content: "";
  position: absolute;
  inset: 8% 4% 18%;
  background: radial-gradient(ellipse at 50% 55%, rgba(6, 16, 10, 0.5), transparent 68%);
  pointer-events: none;
}

.blessing {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: 2%;
  width: min(86%, 400px);
  padding: 1rem 1.2rem 1.1rem;
  text-align: center;
  background: rgba(17, 35, 26, 0.84);
  border: 1px solid rgba(238, 240, 223, 0.22);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateX(-50%);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none;
}
.blessing.is-out { opacity: 0; transform: translate(-50%, 8px); }
.blessing-label { color: var(--accent); font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase; }
.blessing-name { margin-top: 0.25rem; font: 400 clamp(1.5rem, 6vw, 1.9rem) / 1.15 var(--display); }
.blessing-trees { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.15rem; color: var(--accent); font-size: 0.92rem; }
.blessing-trees svg { width: 1.1rem; height: 1.1rem; }
.blessing-note {
  display: -webkit-box;
  margin-top: 0.55rem;
  overflow: hidden;
  font: italic 400 clamp(1.1rem, 4.4vw, 1.3rem) / 1.3 var(--display);
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.actions { grid-area: actions; display: grid; justify-items: center; gap: 0.6rem; padding-top: 0.4rem; }
.hint { color: var(--muted); font-size: 0.8rem; }

.board {
  width: min(100% - 2rem, 1200px);
  margin: 1.5rem auto 0;
  padding: 1.6rem 1.25rem 1.25rem;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.board-head { display: grid; gap: 1rem; }
.board h2 { display: flex; align-items: center; gap: 0.7rem; font: 400 clamp(2rem, 8vw, 2.7rem) / 1.1 var(--display); }
.board h2 svg { width: 1.9rem; height: 1.9rem; color: var(--accent); }

.tabs { display: flex; gap: 1.6rem; border-bottom: 1px solid var(--line); }
.tab {
  margin-bottom: -1px;
  padding: 0.5rem 0 0.7rem;
  color: var(--muted);
  font: 500 1rem var(--body);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab.is-active { color: var(--cream); border-bottom-color: var(--accent); }

.rows { padding: 0; list-style: none; }
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--muted);
  font: 400 1.5rem var(--display);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}
.avatar.is-first { color: var(--bg); background: var(--accent); }
.who { display: grid; min-width: 0; }
.who strong { overflow: hidden; font: 400 1.4rem / 1.2 var(--display); text-overflow: ellipsis; white-space: nowrap; }
.who small { overflow: hidden; color: var(--muted); font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; }
.count { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--accent); }
.count b { font: 400 2rem / 1 var(--display); }
.count svg { width: 1.6rem; height: 1.6rem; }

.empty { padding: 1.5rem 0 0.5rem; color: var(--muted); font-style: italic; text-align: center; }
.more { display: block; margin: 1rem auto 0; padding: 0.5rem 1.2rem; color: var(--cream); font: 500 0.95rem var(--body); background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.board-foot { margin-top: 1.2rem; color: var(--muted); font-size: 0.95rem; }

footer { padding: 3rem 1rem max(3rem, env(safe-area-inset-bottom)); color: var(--muted); font-size: 0.9rem; text-align: center; }
.footer-names { color: var(--cream); font: 300 2rem / 1.2 var(--display); }

#gift-dialog { width: min(92vw, 460px); max-height: 90dvh; padding: 0; color: var(--cream); background: #1b3427; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 30px 90px #0008; }
#gift-dialog::backdrop { background: #08140dbb; backdrop-filter: blur(4px); }
#gift-dialog { overflow-y: auto; scrollbar-width: none; }
#gift-dialog::-webkit-scrollbar { display: none; }
.gift-form { display: grid; gap: 1.2rem; padding: 2rem 1.5rem 1.5rem; }
.gift-form .eyebrow { padding-right: 2rem; }
.gift-form h2 { font: 400 2.5rem / 1.1 var(--display); }
.gift-price { margin-top: -0.6rem; color: var(--accent); }
.gift-form label { color: var(--muted); }
.gift-detail { width: 100%; box-sizing: border-box; padding: .8rem 1rem; color: var(--cream); background: var(--glass); border: 1px solid var(--line); border-radius: 12px; font: 400 1rem/1.5 var(--body); }
textarea.gift-detail { resize: vertical; }
.gift-detail:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.gift-close { position: absolute; top: 0.5rem; right: 0.6rem; width: 40px; height: 40px; color: var(--cream); font-size: 1.7rem; background: transparent; border: 0; cursor: pointer; }
.quantity-control { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 0.75rem; }
.quantity-control button, .quantity-control input { min-height: 52px; color: var(--cream); background: var(--glass); border: 1px solid var(--line); border-radius: 12px; font: 500 1.5rem var(--body); text-align: center; }
.quantity-control button { cursor: pointer; }
.quantity-control input { width: 100%; min-width: 0; appearance: textfield; -moz-appearance: textfield; }
.quantity-control input::-webkit-inner-spin-button, .quantity-control input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.gift-total { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.gift-total strong { font: 400 2rem var(--display); overflow-wrap: anywhere; }
.gift-submit { width: 100%; }
.gift-note { color: var(--muted); font-size: 0.85rem; text-align: center; }
.gift-error { color: #f6d6cf; font-size: 0.85rem; }
.gift-close:focus-visible, .quantity-control button:focus-visible, .quantity-control input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

@media (min-width: 900px) and (orientation: landscape) {
  .hero {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "top top top" "venue titles stat" "stage stage stage" "actions actions actions";
    gap: 0.4rem 2rem;
    height: 100vh;
    height: 100svh;
    min-height: 600px;
    padding: 1.2rem 2.5rem 1.4rem;
  }
  .venue { display: block; align-self: center; justify-self: start; color: var(--cream); font: 400 1.5rem / 1.25 var(--display); text-align: left; }
  .venue span { color: var(--muted); font: 400 0.8rem var(--body); letter-spacing: 0.2em; text-transform: uppercase; }
  .stat { flex-direction: column; align-items: flex-end; gap: 0.2rem; justify-self: end; margin: 0; }
  .stat-num { font-size: clamp(4rem, min(8vw, 15vh), 8rem); }
  .stat-label { text-align: right; }
  .stat-label br { display: none; }
  .names { font-size: clamp(3.4rem, min(6vw, 11vh), 7.5rem); }
  .forest-name { font-size: clamp(1.7rem, min(2.6vw, 4.6vh), 3rem); }
  .tagline { margin-top: 0.2rem; font-size: 1.05rem; }
  .stage { min-height: 0; }
  .blessing { bottom: 3%; width: min(44%, 520px); padding: 1.2rem 1.6rem 1.3rem; }
  .blessing-name { font-size: clamp(2rem, 3.2vw, 2.8rem); }
  .blessing-note { font-size: clamp(1.3rem, 1.9vw, 1.7rem); }
  .blessing-trees { font-size: 1.05rem; }
  .actions { grid-auto-flow: column; align-items: center; justify-content: center; gap: 1.4rem; }
  .board { margin-top: 2rem; padding: 2.5rem 3rem 2rem; }
  .board-head { grid-template-columns: 1fr auto; align-items: end; }
  .tabs { border-bottom: 0; }
  .avatar { width: 64px; height: 64px; font-size: 1.8rem; }
  .who strong { font-size: 1.8rem; }
  .who small { font-size: 1.05rem; }
  .count b { font-size: 2.6rem; }
  .count svg { width: 2rem; height: 2rem; }
}

@media (max-width: 380px) {
  .names { font-size: 2.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
