@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/fonts/cormorant-garamond.ttf') format('truetype');
  font-weight: 300 700;
  font-display: block;
}

:root {
  --gold: #d9b56a;
  --ivory: #f2e9d6;
  --ink: rgba(6, 18, 20, 0.62);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  color: var(--ivory);
  font-family: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
}
canvas#film { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; }

/* title card */
#title {
  position: fixed;
  left: 0; right: 0;
  top: 17vh;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(var(--rise, 10px));
  letter-spacing: 0.32em;
}
#title h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(22px, 3.5vw, 66px);
  max-width: 94vw;
  margin: 0 auto;
  line-height: 1.25;
  text-transform: uppercase;
  color: #2b2116;
  /* (a close bright halo first: the great tree's crown stands behind the title) */
  text-shadow: 0 0 5px rgba(255, 246, 228, 0.95), 0 0 12px rgba(255, 240, 214, 0.9), 0 0 26px rgba(255, 236, 200, 0.75), 0 0 48px rgba(255, 220, 170, 0.5);
  padding-left: 0.32em; /* optically centre tracked capitals */
}
#title .rule {
  display: block;
  width: min(220px, 30vw);
  height: 1px;
  margin: 1.1em auto 0;
  background: linear-gradient(90deg, transparent, #8a6424, transparent);
  opacity: 0.85;
}

/* loading: a single ticking hairline */
#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: #000;
  z-index: 10;
}
#loading .msg {
  font-size: 17px; font-style: italic; letter-spacing: 0.08em; color: var(--ivory); opacity: 0.55;
  min-height: 1.3em; text-align: center;
}
#loading .tick {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(217, 181, 106, 0.35);
  position: relative;
}
#loading .tick::after {
  content: '';
  position: absolute; left: 50%; top: 4px;
  width: 1px; height: 15px;
  background: var(--gold);
  transform-origin: 50% 15px;
  animation: tick 1s steps(2) infinite;
}
@keyframes tick { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #loading .tick::after { animation-duration: 4s; } }

/* controls */
#controls {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ink);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(217, 181, 106, 0.18);
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  z-index: 5;
  width: min(560px, calc(100vw - 24px));
}
body.ui-awake #controls, body.ended #controls, #controls:focus-within { opacity: 1; transform: translate(-50%, 0); }
body.clean #controls, body.clean #toast { display: none !important; }
.btn {
  appearance: none; border: 0; background: transparent; color: var(--ivory);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.btn svg { width: 19px; height: 19px; fill: currentColor; }
.btn:hover, .btn:focus-visible { color: var(--gold); background: rgba(255, 255, 255, 0.06); outline: none; }
.btn[aria-pressed='true'] { color: var(--gold); }
.scrub { position: relative; flex: 1; height: 26px; cursor: pointer; touch-action: none; }
.scrub::before, .scrub .fill {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px;
  background: rgba(242, 233, 214, 0.22); border-radius: 2px;
}
.scrub .fill { background: var(--gold); transform-origin: 0 50%; transform: scaleX(0); }
.scrub .knob {
  position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: var(--ivory); box-shadow: 0 0 6px rgba(255, 200, 120, 0.6);
}
.scrub:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.time { font-size: 15px; width: 36px; text-align: right; opacity: 0.8; font-variant-numeric: tabular-nums; }

#toast {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px; background: var(--ink); font-size: 16px;
  opacity: 0; transition: opacity 0.4s; pointer-events: none; z-index: 6;
}
#toast.show { opacity: 1; }

#gentle {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: min(440px, 88vw); padding: 22px 26px; border-radius: 14px;
  background: rgba(6, 18, 20, 0.86); border: 1px solid rgba(217, 181, 106, 0.3);
  text-align: center; font-size: 19px; z-index: 8;
}
#gentle p { margin: 0 0 16px; line-height: 1.35; }
#gentle button {
  font: inherit; color: var(--ivory); background: transparent; cursor: pointer;
  border: 1px solid rgba(217, 181, 106, 0.5); border-radius: 999px; padding: 6px 16px; margin: 0 5px;
}
#gentle button:first-child { background: rgba(217, 181, 106, 0.18); }

@media (max-width: 600px) {
  #title { top: 13vh; }
  .time { display: none; }
}

/* ---- film controls: explore popover --------------------------------------- */
#controls { position: fixed; }
#controls[hidden] { display: none; }
#controls .pop {
  position: absolute; right: 44px; bottom: calc(100% + 10px);
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: rgba(6, 18, 20, 0.86); border: 1px solid rgba(217, 181, 106, 0.3); border-radius: 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#controls .pop[hidden] { display: none; }
#controls .pop button {
  font: inherit; font-size: 18px; color: var(--ivory); background: transparent; border: 0; border-radius: 8px;
  padding: 6px 14px; text-align: left; cursor: pointer; white-space: nowrap;
}
#controls .pop button:hover, #controls .pop button:focus-visible { background: rgba(217, 181, 106, 0.16); color: var(--gold); outline: none; }

/* ---- landing ---------------------------------------------------------------- */
#landing {
  position: fixed; inset: 0; z-index: 9; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 46%, rgba(4, 12, 14, 0.22), rgba(3, 9, 10, 0.78) 72%);
  transition: opacity 0.7s ease; padding: 24px;
}
#landing.out { opacity: 0; pointer-events: none; }
#landing .inner { text-align: center; max-width: 760px; }
#landing h1 {
  margin: 0; font-weight: 400; text-transform: uppercase; letter-spacing: 0.3em; padding-left: 0.3em;
  font-size: clamp(26px, 4.4vw, 60px); line-height: 1.2; color: var(--ivory);
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.6), 0 0 2px rgba(0, 0, 0, 0.5);
}
#landing .rule { display: block; width: min(220px, 40vw); height: 1px; margin: 1em auto 0.9em; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
#landing .sub { margin: 0 auto 1.6em; font-size: clamp(17px, 1.8vw, 21px); line-height: 1.4; opacity: 0.88; font-style: italic; max-width: 560px; text-shadow: 0 1px 8px rgba(0,0,0,0.7); }
#landing .modes { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
#landing .modes button {
  font: inherit; color: var(--ivory); cursor: pointer; text-align: center;
  background: rgba(6, 18, 20, 0.6); border: 1px solid rgba(217, 181, 106, 0.42); border-radius: 14px;
  padding: 12px 22px 11px; min-width: 196px; display: flex; flex-direction: column; gap: 3px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background 0.25s, border-color 0.25s, transform 0.25s;
}
#landing .modes button b { font-weight: 500; font-size: 21px; letter-spacing: 0.04em; }
#landing .modes button span { font-size: 15px; opacity: 0.72; font-style: italic; }
#landing .modes button:hover, #landing .modes button:focus-visible { background: rgba(217, 181, 106, 0.2); border-color: var(--gold); outline: none; transform: translateY(-2px); }
#landing .note { margin-top: 1.5em; font-size: 15px; opacity: 0.62; }
body.landing #title { display: none; }
@media (max-width: 600px) {
  #landing .modes { flex-direction: column; align-items: stretch; }
  #landing .modes button { min-width: 0; }
  #landing h1 { letter-spacing: 0.18em; padding-left: 0.18em; }
}
@media (prefers-reduced-motion: reduce) { #landing, #landing .modes button { transition: none; } }

/* ---- interactive HUD ---------------------------------------------------------------- */
#hud { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 6; }
body.explore #hud { display: block; }
body.explore #title { display: none; }
body.explore.clean #hud > :not(.hud-photo):not(.hud-flash) { display: none; }
body.photo #hud > :not(.hud-photo):not(.hud-flash) { display: none !important; }
body.photo #touch .pad .boost { display: none; }
#hud button { pointer-events: auto; font: inherit; color: var(--ivory); cursor: pointer; }
#hud .hud-corner { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; }
#hud .hud-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(217, 181, 106, 0.28);
  background: var(--ink); display: grid; place-items: center; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#hud .hud-btn svg { width: 20px; height: 20px; }
#hud .hud-btn:hover, #hud .hud-btn:focus-visible { color: var(--gold); outline: none; border-color: var(--gold); }
#hud .hud-title {
  font-size: 16px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ivory); opacity: 0.92;
  padding: 6px 14px; border-radius: 999px; background: var(--ink); border: 1px solid rgba(217, 181, 106, 0.18);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
#hud .hud-title:empty { display: none; }
#hud .hud-swap {
  position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top));
  font-size: 16px; padding: 7px 16px; border-radius: 999px; background: var(--ink);
  border: 1px solid rgba(217, 181, 106, 0.32); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); letter-spacing: 0.03em;
}
#hud .hud-swap:hover, #hud .hud-swap:focus-visible { color: var(--gold); border-color: var(--gold); outline: none; }
#hud .hud-bottom { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 9px; width: min(640px, 92vw); }
#hud .hud-hint {
  font-size: 20px; font-weight: 500; font-style: italic; text-align: center; min-height: 1.3em; line-height: 1.3; max-width: 100%;
  color: #fbf4e4; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75), 0 0 10px rgba(0, 0, 0, 0.55); opacity: 0.97;
  /* the same dark glass as the other controls, so the line reads over a lit bloom or a lantern, by day or night */
  padding: 6px 24px; border-radius: 999px;
  background: rgba(5, 14, 16, 0.58); border: 1px solid rgba(217, 181, 106, 0.14);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
}
#hud .hud-hint:empty { background: none; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; }
#hud .hud-hint.in { animation: hintIn 0.6s ease; }
@keyframes hintIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 0.97; transform: none; } }
#hud .hud-gauge { display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 12px; border-radius: 999px; background: var(--ink); border: 1px solid rgba(217, 181, 106, 0.2); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#hud .cells { display: flex; gap: 3px; }
#hud .cells i {
  --k: 0; width: 13px; height: 15px; display: block;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: linear-gradient(to top, #ffb648 calc(var(--k) * 100%), rgba(242, 233, 214, 0.16) calc(var(--k) * 100%));
  filter: drop-shadow(0 0 calc(var(--k) * 4px) rgba(255, 170, 60, 0.9));
}
#hud .honey { font-size: 15px; opacity: 0.85; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
#hud .honey b { font-weight: 600; color: var(--gold); margin-right: 1px; }
#hud .honey.bump b { animation: bump 0.9s ease-out; }
#hud .honey.done { color: var(--gold); opacity: 1; }
@keyframes bump { 0% { transform: scale(1.6); text-shadow: 0 0 12px rgba(255, 190, 90, 0.95); } 100% { transform: none; text-shadow: none; } }
#hud .hud-arrow { position: absolute; left: 0; top: 0; width: 28px; height: 28px; color: var(--gold); opacity: 0; transition: opacity 0.4s; filter: drop-shadow(0 0 6px rgba(0,0,0,0.8)); }
#hud .hud-arrow svg { width: 28px; height: 28px; }
#hud .hud-panel, #hud .hud-help {
  position: absolute; pointer-events: auto; background: rgba(6, 18, 20, 0.88); border: 1px solid rgba(217, 181, 106, 0.3);
  border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#hud .hud-panel { left: max(14px, env(safe-area-inset-left)); top: calc(max(12px, env(safe-area-inset-top)) + 48px); padding: 14px; display: flex; flex-direction: column; gap: 12px; width: min(320px, calc(100vw - 28px)); }
#hud .hud-panel[hidden], #hud .hud-help[hidden], #hud .hud-photo[hidden] { display: none; }
#hud .seg { display: flex; border: 1px solid rgba(217, 181, 106, 0.35); border-radius: 999px; overflow: hidden; }
#hud .seg button { flex: 1; background: transparent; border: 0; padding: 7px 0; font-size: 17px; }
#hud .seg button[aria-checked='true'] { background: rgba(217, 181, 106, 0.24); color: var(--gold); }
#hud .tod { display: flex; align-items: center; gap: 8px; }
#hud .tod .ico { width: 20px; height: 20px; color: var(--gold); opacity: 0.85; }
#hud .tod .ico svg { width: 20px; height: 20px; }
#hud .tod input { flex: 1; accent-color: #d9b56a; pointer-events: auto; }
#hud .row { display: flex; gap: 8px; flex-wrap: wrap; }
#hud .row button { flex: 1; font-size: 16px; padding: 6px 8px; border-radius: 999px; background: transparent; border: 1px solid rgba(217, 181, 106, 0.3); white-space: nowrap; }
#hud .row button[aria-pressed='true'] { color: var(--gold); border-color: var(--gold); }
#hud .row button:hover, #hud .seg button:hover { color: var(--gold); }
#hud .hud-help { left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 18px 24px; width: min(520px, calc(100vw - 28px)); max-height: 80vh; overflow: auto; }
#hud .hud-help h2 { margin: 0 0 10px; font-weight: 400; font-size: 21px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
#hud .hud-help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 17px; }
#hud .hud-help dt { color: var(--gold); white-space: nowrap; }
#hud .hud-help dd { margin: 0; opacity: 0.9; }
#hud .hud-help .foot { margin: 12px 0 0; font-size: 14px; opacity: 0.6; font-style: italic; }
#hud .hud-photo { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; border-radius: 999px; background: var(--ink); border: 1px solid rgba(217, 181, 106, 0.25); pointer-events: auto; font-size: 15px; white-space: nowrap; }
#hud .hud-photo button { background: transparent; border: 1px solid rgba(217, 181, 106, 0.45); border-radius: 999px; padding: 5px 12px; font-size: 15px; }
#hud .hud-flash { position: absolute; inset: 0; background: #fff8ea; opacity: 0; }
#hud .hud-flash.go { animation: flash 0.5s ease-out; }
@keyframes flash { 0% { opacity: 0.55; } 100% { opacity: 0; } }
body.locked #hud .hud-swap, body.locked #hud .hud-corner { opacity: 0.55; }


/* ---- the garden's finale, the sound nudge, small additions ------------------------ */
#hud .hud-finale {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%); width: min(920px, 96vw); text-align: center; padding: 34px 20px 30px;
  pointer-events: none; opacity: 0; transition: opacity 1.6s ease;
  /* a soft dark pool behind the card, so it reads over the brightest bloom */
  background: radial-gradient(closest-side, rgba(3, 10, 12, 0.62), rgba(3, 10, 12, 0.34) 62%, rgba(3, 10, 12, 0));
}
#hud .hud-finale.on { opacity: 1; }
#hud .hud-finale h2 {
  margin: 0; font-weight: 400; font-size: clamp(24px, 4.6vw, 46px); letter-spacing: 0.24em; text-transform: uppercase; padding-left: 0.24em;
  color: #fbf4e4; text-shadow: 0 0 26px rgba(255, 190, 100, 0.5), 0 2px 10px rgba(0, 0, 0, 0.9);
}
#hud .hud-finale .rule { display: block; width: min(220px, 40vw); height: 1px; margin: 0.9em auto; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
#hud .hud-finale p { margin: 0; font-size: clamp(17px, 2.4vw, 22px); font-weight: 500; font-style: italic; letter-spacing: 0.04em; color: #fbf4e4; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.7); }
#hud .hud-nudge {
  position: absolute; left: 50%; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 92px); transform: translate(-50%, 8px);
  width: max-content; max-width: 94vw;
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 18px; border-radius: 999px;
  background: rgba(5, 14, 16, 0.78); border: 1px solid rgba(217, 181, 106, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 18px; font-style: italic; white-space: nowrap; max-width: 94vw;
  opacity: 0; pointer-events: none; transition: opacity 0.7s ease, transform 0.7s ease;
}
#hud .hud-nudge.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#hud .hud-nudge button { background: rgba(217, 181, 106, 0.2); border: 1px solid var(--gold); border-radius: 999px; padding: 5px 14px; font-size: 16px; font-style: normal; color: var(--gold); }
#hud .hud-nudge button.quiet { background: transparent; border-color: transparent; color: var(--ivory); opacity: 0.7; padding: 5px 9px; }
#hud .hud-nudge button:hover, #hud .hud-nudge button:focus-visible { background: rgba(217, 181, 106, 0.34); outline: none; }
#hud .row[hidden] { display: none; }
#hud .row button.warn { color: #f0b9a0; border-color: #f0b9a0; }
body[data-input=touch] #hud .hud-nudge { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px); font-size: 17px; }
/* held in portrait, the touch controls fill the lower screen: the offer sits above them */
@media (orientation: portrait) { body[data-input=touch] #hud .hud-nudge { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 264px); } }
@media (orientation: landscape) and (max-height: 500px) { #hud .hud-nudge { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 120px); } }
@media (max-width: 600px) { #hud .hud-nudge { white-space: normal; justify-content: center; flex-wrap: wrap; border-radius: 22px; padding: 8px 12px; row-gap: 6px; } #hud .hud-nudge span { flex-basis: 100%; text-align: center; } }
@media (prefers-reduced-motion: reduce) { #hud .hud-finale, #hud .hud-nudge { transition-duration: 0.01s; } #hud .honey.bump b { animation: none; } }

/* ---- touch controls ---------------------------------------------------------- */
#touch { display: none; position: fixed; inset: auto 0 0 0; height: 0; z-index: 7; pointer-events: none; }
#touch.show { display: block; }
body.photo #touch .pad { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 52px); }
#touch .stick {
  position: fixed; left: max(22px, env(safe-area-inset-left)); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 96px);
  width: 128px; height: 128px; pointer-events: auto; touch-action: none;
}
#touch .ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(217, 181, 106, 0.42); background: radial-gradient(circle, rgba(6, 18, 20, 0.35), rgba(6, 18, 20, 0.15)); }
#touch .nub { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(242, 233, 214, 0.22); border: 1px solid rgba(217, 181, 106, 0.7); box-shadow: 0 0 12px rgba(255, 190, 110, 0.25); }
#touch .pad { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(22px, env(safe-area-inset-bottom)) + 92px); display: grid; grid-template-columns: 58px 58px; grid-template-rows: 58px 58px; gap: 10px; pointer-events: auto; }
#touch .tb { width: 58px; height: 58px; border-radius: 50%; border: 1px solid rgba(217, 181, 106, 0.45); background: rgba(6, 18, 20, 0.45); color: var(--ivory); display: grid; place-items: center; touch-action: none; -webkit-user-select: none; user-select: none; }
#touch .tb svg { width: 26px; height: 26px; }
#touch .tb.on { background: rgba(217, 181, 106, 0.32); color: var(--gold); }
#touch .tb[data-b=up] { grid-column: 2; grid-row: 1; }
#touch .tb[data-b=down] { grid-column: 2; grid-row: 2; }
#touch .tb.boost { grid-column: 1; grid-row: 2; }
body[data-input=touch] #hud .hud-bottom { bottom: max(14px, env(safe-area-inset-bottom)); }
body[data-input=touch] #hud .hud-hint { font-size: 17px; }
@media (max-width: 600px) {
  #hud .hud-title { display: none; }
  #hud .hud-swap { font-size: 15px; padding: 7px 13px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #touch .stick { bottom: max(16px, env(safe-area-inset-bottom)); }
  #touch .pad { bottom: max(16px, env(safe-area-inset-bottom)); }
  #hud .hud-bottom { width: min(420px, 50vw); }
}
