:root {
  --do: #edeee3;
  --do-deep: #e1e3d4;
  --ink: #283a5e;
  --ink-soft: rgba(40, 58, 94, 0.72);
  --ink-faint: rgba(40, 58, 94, 0.14);
  --sen: #e07a93;
  --la: #557a5c;
  --mai: #e2b33c;
  --son: #b8382a;
  --enamel: #2f5d57;
  --enamel-dark: #1f413c;
  --dial: #f2e8cf;
  --brass: #b98b3a;
  --night-1: #17233d;
  --night-2: #283a5e;
  --night-3: #435a86;

  --f-display: "Fraunces", "Georgia", serif;
  --f-ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-hand: "Patrick Hand", "Segoe Print", cursive;
  --f-crt: "VT323", ui-monospace, monospace;

  --gutter: max(16px, env(safe-area-inset-left));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--do);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body.is-night {
  background: var(--night-1);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2.5px solid var(--sen);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* paper grain over everything, like a riso print */
.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.55;
  background-size: 220px 220px;
}

body.is-night .grain {
  opacity: 0.6;
}

/* ---------- chrome ---------- */

.chrome {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: var(--gutter);
  z-index: 40;
  display: flex;
  gap: 8px;
}

.chip {
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid currentColor;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.2s, color 0.2s;
  background: rgba(237, 238, 227, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.chip svg {
  width: 20px;
  height: 20px;
}

.chip:hover {
  background: #e3e5d8;
}

body.on-dark .chip {
  color: var(--do);
  background: rgba(23, 35, 61, 0.55);
}

body.on-dark .chip:hover {
  background: rgba(23, 35, 61, 0.8);
}

/* ---------- scenes ---------- */

.scene {
  position: fixed;
  inset: 0;
  display: none;
  overflow: hidden;
}

.scene.is-active {
  display: block;
}

.scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll::-webkit-scrollbar {
  display: none;
}

.stack {
  min-height: 100%;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(72px + env(safe-area-inset-top)) var(--gutter) calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--do);
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  padding: 14px 24px;
  border-radius: 14px 18px 15px 17px / 17px 14px 18px 15px;
  box-shadow: 4px 4px 0 var(--sen);
  cursor: pointer;
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
  min-height: 48px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--sen);
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--sen);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink-faint);
}

.btn.ghost:active {
  box-shadow: 1px 1px 0 var(--ink-faint);
}

.on-dark .btn {
  border-color: var(--do);
  background: var(--do);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--sen);
}

.on-dark .btn.ghost {
  background: transparent;
  color: var(--do);
  box-shadow: 4px 4px 0 rgba(237, 238, 227, 0.18);
}

.linkish {
  background: none;
  border: none;
  padding: 6px 2px;
  font-family: var(--f-hand);
  font-size: 19px;
  color: var(--ink-soft);
  text-decoration: underline wavy rgba(224, 122, 147, 0.7);
  text-underline-offset: 6px;
  cursor: pointer;
}

.on-dark .linkish {
  color: rgba(237, 238, 227, 0.8);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

/* ---------- welcome ---------- */

#scene-welcome {
  background: radial-gradient(120% 80% at 50% 110%, rgba(224, 122, 147, 0.16), transparent 60%), var(--do);
}

body.is-night #scene-welcome {
  background: radial-gradient(120% 70% at 50% 115%, rgba(224, 122, 147, 0.22), transparent 60%),
    linear-gradient(180deg, var(--night-1), var(--night-2));
  color: var(--do);
}

.welcome .kicker {
  font-family: var(--f-hand);
  font-size: 22px;
  color: var(--ink-soft);
  margin: 0;
}

body.is-night .welcome .kicker,
body.is-night .welcome .context {
  color: rgba(237, 238, 227, 0.78);
}

.welcome h1 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(56px, 17vw, 120px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0;
  font-variation-settings: "opsz" 144;
  overflow-wrap: anywhere;
}

.welcome h1 .ch {
  display: inline-block;
  will-change: transform;
}

.welcome .from {
  font-family: var(--f-hand);
  font-size: 22px;
  margin: 0;
}

.welcome .context {
  margin: 0;
  color: var(--ink-soft);
  max-width: 36ch;
}

.welcome .lede {
  margin: 0;
  max-width: 38ch;
  font-size: 17px;
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.name-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid currentColor;
  background: transparent;
  font-family: var(--f-display);
  font-size: clamp(34px, 10vw, 52px);
  padding: 6px 2px;
  border-radius: 0;
}

.name-input::placeholder {
  color: currentColor;
  opacity: 0.32;
}

.name-input:focus-visible {
  outline: none;
  border-bottom-color: var(--sen);
}

.falling {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.falling i {
  position: absolute;
  top: -40px;
  width: 16px;
  height: 20px;
  border-radius: 80% 0 70% 30%;
  opacity: 0.8;
  animation: fall linear infinite;
}

@keyframes fall {
  0% {
    transform: translate3d(0, -40px, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(var(--drift, 60px), 110vh, 0) rotate(560deg);
  }
}

/* ---------- meter ---------- */

#scene-meter {
  background: radial-gradient(90% 60% at 50% 40%, #3b5d72 0%, var(--night-1) 75%);
  color: var(--do);
}

.meter-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(64px + env(safe-area-inset-top)) var(--gutter) calc(24px + env(safe-area-inset-bottom));
}

.meter-intro {
  margin: 0;
  max-width: 34ch;
  text-align: center;
  font-family: var(--f-hand);
  font-size: 21px;
  line-height: 1.35;
  color: rgba(237, 238, 227, 0.86);
}

.machine {
  position: relative;
  width: min(360px, 92vw);
  padding: 18px 18px 20px;
  border-radius: 26px 26px 30px 30px;
  background: linear-gradient(170deg, #3d7369 0%, var(--enamel) 45%, var(--enamel-dark) 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22), inset 0 -6px 0 rgba(0, 0, 0, 0.25), 0 22px 40px rgba(0, 0, 0, 0.45);
  will-change: transform;
}

.machine::before,
.machine::after {
  content: "";
  position: absolute;
  top: 12px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6d894, var(--brass) 60%, #7b5a1f);
}

.machine::before {
  left: 12px;
}

.machine::after {
  right: 12px;
}

.plate {
  margin: 0 18px 14px;
  padding: 7px 10px 6px;
  text-align: center;
  border-radius: 6px;
  background: linear-gradient(180deg, #e7c77a, var(--brass) 55%, #9a7330);
  color: #3a2a0c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 2px 0 rgba(0, 0, 0, 0.3);
}

.plate strong {
  display: block;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.15;
}

.plate small {
  font-size: 11px;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

.gauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gauge {
  background: radial-gradient(circle at 50% 30%, #fffaf0, var(--dial) 70%);
  border-radius: 14px;
  padding: 6px 6px 4px;
  box-shadow: inset 0 0 0 3px #8a6a2c, inset 0 4px 8px rgba(0, 0, 0, 0.25);
  color: #3a2a0c;
  text-align: center;
}

.gauge svg {
  display: block;
  width: 100%;
  height: auto;
}

.gauge span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-top: -2px;
}

.crt {
  position: relative;
  margin-top: 14px;
  height: 112px;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 50%, #0d2a1e, #04130d 80%);
  box-shadow: inset 0 0 0 3px #10251d, inset 0 0 24px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.12);
  overflow: hidden;
  padding: 8px 12px;
  font-family: var(--f-crt);
  font-size: 19px;
  line-height: 1.12;
  color: #9ef5a9;
  text-shadow: 0 0 6px rgba(120, 255, 150, 0.65);
}

.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.crt-lines {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}

.crt-lines div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crt-lines .warn {
  color: #ffb4a2;
  text-shadow: 0 0 8px rgba(255, 110, 80, 0.8);
}

.crt.glitch {
  animation: glitch 0.12s steps(2) infinite;
}

@keyframes glitch {
  0% {
    transform: translate(0, 0);
    filter: hue-rotate(0deg);
  }
  50% {
    transform: translate(-2px, 1px);
    filter: hue-rotate(70deg) saturate(2);
  }
  100% {
    transform: translate(2px, -1px);
  }
}

.controls {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.lamp {
  justify-self: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9c8a, #8c1d12 70%);
  box-shadow: 0 0 0 4px #1b3632, inset 0 -3px 4px rgba(0, 0, 0, 0.4);
  opacity: 0.5;
}

.lamp.on {
  opacity: 1;
  box-shadow: 0 0 0 4px #1b3632, 0 0 24px 6px rgba(255, 90, 60, 0.75);
}

.vent {
  justify-self: center;
  width: 44px;
  height: 30px;
  background: repeating-linear-gradient(0deg, #142c28 0 3px, #2c564f 3px 6px);
  border-radius: 6px;
  position: relative;
}

.pad {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #f6d894, var(--brass) 55%, #6f5019);
  box-shadow: 0 6px 0 #4a3510, 0 10px 20px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s, box-shadow 0.1s;
}

.pad.down {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #4a3510, 0 4px 10px rgba(0, 0, 0, 0.4);
}

.pad svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pad-label {
  text-align: center;
  margin-top: 12px;
  font-family: var(--f-hand);
  font-size: 19px;
  color: var(--dial);
}

.steam {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  filter: blur(3px);
  pointer-events: none;
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: #fffdf6;
  opacity: 0;
  pointer-events: none;
}

.burst-petal {
  position: fixed;
  z-index: 46;
  width: 22px;
  height: 28px;
  border-radius: 80% 0 70% 30%;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- garden ---------- */

#scene-garden {
  background: radial-gradient(80% 32% at 50% 100%, rgba(246, 196, 160, 0.4), transparent 70%),
    linear-gradient(180deg, #d4e6ee 0%, #eae8ec 34%, #f6e6e3 62%, #f5ebd6 100%);
}

body.is-night #scene-garden {
  background: radial-gradient(75% 30% at 50% 100%, rgba(236, 160, 150, 0.3), transparent 70%),
    radial-gradient(50% 22% at 22% 92%, rgba(242, 193, 78, 0.12), transparent 70%),
    linear-gradient(180deg, #141f38 0%, var(--night-2) 46%, #3d4d7e 76%, #5d5486 100%);
}

/* the supporting garden: drawn once, swayed by CSS, never in front of her flower */
.flora {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#flora-front {
  z-index: 1;
}

.bgp {
  position: absolute;
  aspect-ratio: 300 / 520;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  animation: bgsway var(--d, 5s) ease-in-out var(--delay, 0s) infinite alternate;
  will-change: transform;
}

.bgp-in {
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
  transform: scale(0.15);
  opacity: 0;
  transition: transform 1.5s var(--ease-out) var(--in, 0s), opacity 1s ease var(--in, 0s);
}

.bgp.in .bgp-in {
  transform: scale(1);
}

.bgp.instant .bgp-in {
  transition: none;
}

.bgp svg,
.bokeh svg {
  display: block;
  width: 100%;
  height: 100%;
}

.bgp img,
.bokeh img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

/* colour and brightness are baked into each image; only opacity is left to the compositor */
.bgp.far .bgp-in {
  --o: 0.82;
}

.bgp.near .bgp-in {
  --o: 0.96;
}

.bgp.in .bgp-in {
  opacity: var(--o, 1);
}

@keyframes bgsway {
  from {
    transform: translateX(-50%) rotate(-2.5deg);
  }
  to {
    transform: translateX(-50%) rotate(2.5deg);
  }
}

.bokeh {
  position: absolute;
  opacity: 0;
  transition: opacity 2.2s ease 1.4s;
}

#flora-front.in .bokeh {
  opacity: 0.6;
}

/* visitors */
#fauna {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.bf,
.df,
.bird {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.bf {
  width: 34px;
  height: 28px;
  pointer-events: auto;
  cursor: pointer;
}

.bf::before,
.df::before {
  content: "";
  position: absolute;
  inset: -14px;
}

.bf .w {
  transform-box: view-box;
  transform-origin: 20px 16px;
  animation: flap var(--flap, 0.24s) ease-in-out infinite alternate;
}

.bf.rest .w {
  animation: rest 1.7s ease-in-out infinite alternate;
}

@keyframes flap {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0.18);
  }
}

@keyframes rest {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0.55);
  }
}

.df {
  width: 60px;
  height: 60px;
  pointer-events: auto;
  cursor: pointer;
}

.df .dw {
  animation: shimmer 0.07s linear infinite alternate;
}

@keyframes shimmer {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

.bird {
  width: 26px;
  height: 12px;
}

.bird .bw {
  transform-box: view-box;
  transform-origin: 15px 7px;
  animation: bflap var(--flap, 0.36s) ease-in-out infinite alternate;
}

@keyframes bflap {
  from {
    transform: scaleY(1);
  }
  to {
    transform: scaleY(-0.5);
  }
}

.ff {
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: #fff6c8;
  box-shadow: 0 0 10px 3px rgba(255, 236, 150, 0.6);
  animation: twinkle 2.4s ease-in-out infinite;
  will-change: transform;
}

@keyframes twinkle {
  50% {
    opacity: 0.25;
  }
}


.sky-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 40% at 50% 46%, var(--wash, rgba(224, 122, 147, 0.22)), transparent 70%);
}

.orb {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: var(--gutter);
  width: 52px;
  height: 52px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  z-index: 3;
}

.orb svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hills {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 30%;
  pointer-events: none;
}

.sway {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: sway 4.5s ease-in-out infinite alternate;
}

@keyframes sway {
  from {
    transform: rotate(-4deg);
  }
  to {
    transform: rotate(4deg);
  }
}

.motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.motes i {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff6c8;
  box-shadow: 0 0 10px 3px rgba(255, 236, 150, 0.55);
  opacity: 0;
  animation: drift 7s ease-in-out infinite;
}

body:not(.is-night) .motes i {
  background: #f6e7a6;
  box-shadow: none;
  width: 4px;
  height: 4px;
}

@keyframes drift {
  0% {
    transform: translate(0, 0);
    opacity: 0;
  }
  20% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.7;
  }
  100% {
    transform: translate(var(--dx, 30px), var(--dy, -80px));
    opacity: 0;
  }
}

.plant-svg {
  position: absolute;
  left: 50%;
  bottom: 2%;
  height: 84%;
  width: auto;
  aspect-ratio: 400 / 640;
  max-width: 100%;
  transform: translateX(-50%);
  overflow: visible;
  touch-action: pan-y;
  /* her flower repaints every frame; keep that off the layers around it */
  will-change: transform;
}

.plant-svg .petal {
  cursor: pointer;
}

.garden-top {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  padding: 0 var(--gutter);
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.garden-name {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(40px, 11vw, 76px);
  line-height: 1;
  margin: 0;
  letter-spacing: -0.01em;
}

.garden-latin {
  margin: 6px 0 0;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
}

body.is-night .garden-top {
  color: var(--do);
}

body.is-night .garden-latin {
  color: rgba(237, 238, 227, 0.7);
}

.note {
  position: absolute;
  left: 50%;
  top: calc(170px + env(safe-area-inset-top));
  width: min(420px, calc(100% - 32px));
  transform: translateX(-50%);
  z-index: 4;
  padding: 14px 18px 16px;
  background: #fbfaf3;
  color: var(--ink);
  font-family: var(--f-hand);
  font-size: 21px;
  line-height: 1.32;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 12px 24px -10px rgba(23, 35, 61, 0.35);
  pointer-events: none;
  opacity: 0;
}

.note::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 70px;
  height: 20px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(226, 179, 60, 0.45);
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: var(--f-hand);
  font-size: 20px;
  color: var(--ink-soft);
  pointer-events: none;
  z-index: 3;
}

body.is-night .hint {
  color: rgba(237, 238, 227, 0.8);
}

.hint span {
  display: inline-block;
  animation: breathe 2.2s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    transform: translateY(-4px);
    opacity: 0.6;
  }
}

.garden-next {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
}

.garden-next.shown {
  pointer-events: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom));
  z-index: 48;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--do);
  font-family: var(--f-hand);
  font-size: 19px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

/* ---------- herbarium card ---------- */

#scene-card {
  background: var(--do-deep);
}

body.is-night #scene-card {
  background: linear-gradient(180deg, var(--night-1), var(--night-2));
}

.sheet {
  position: relative;
  background: #f7f5ea;
  color: var(--ink);
  padding: 22px 22px 26px;
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 26px 50px -24px rgba(23, 35, 61, 0.55);
}

.sheet .tape {
  position: absolute;
  width: 84px;
  height: 22px;
  background: rgba(226, 179, 60, 0.42);
}

.sheet .tape.a {
  top: -9px;
  left: 18px;
  transform: rotate(-6deg);
}

.sheet .tape.b {
  top: -9px;
  right: 18px;
  transform: rotate(5deg);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.specimen {
  display: grid;
  grid-template-columns: 38% 1fr;
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.specimen-art {
  filter: saturate(0.82) sepia(0.12);
}

.specimen-art svg {
  width: 100%;
  height: auto;
  display: block;
}

.sci-name {
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(24px, 6.4vw, 32px);
  line-height: 1.05;
  margin: 0;
  overflow-wrap: anywhere;
}

.sci-meaning {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.sci-variety {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.sci-variety i {
  white-space: nowrap;
  font-family: var(--f-display);
  font-size: 15px;
  color: var(--ink);
}

.fields {
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.fields div {
  display: grid;
  gap: 1px;
}

.fields dt {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
}

.fields dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
}

.fields ul {
  margin: 0;
  padding-left: 18px;
}

.field-notes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--ink-faint);
}

.field-notes h3 {
  margin: 0 0 6px;
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  color: var(--ink-soft);
}

.field-notes p {
  margin: 0 0 4px;
  font-family: var(--f-hand);
  font-size: 20px;
  line-height: 1.3;
  color: #2c4a8a;
}

.status-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-row p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.status-row b {
  font-weight: 600;
}

.seal {
  flex: none;
  width: 78px;
  height: 78px;
  border: 2.5px solid var(--son);
  border-radius: 50%;
  color: var(--son);
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--f-display);
  font-size: 12px;
  line-height: 1.1;
  transform: rotate(-12deg);
  opacity: 0.85;
}

.seal b {
  display: block;
  font-size: 19px;
}

/* ---------- letter ---------- */

#scene-letter {
  background: radial-gradient(80% 50% at 50% 0%, #3b4f7a, transparent 70%), var(--night-1);
  color: var(--do);
}

.letter {
  position: relative;
  background: #fbf9f0;
  color: var(--ink);
  padding: 26px 22px 28px;
  border-radius: 2px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  font-family: var(--f-hand);
  font-size: 21px;
  line-height: 32px;
  background-image: repeating-linear-gradient(180deg, transparent 0 31px, rgba(40, 58, 94, 0.1) 31px 32px);
  background-position: 0 24px;
}

.letter-body {
  white-space: pre-wrap;
  margin: 0;
  min-height: 6em;
  cursor: pointer;
}

.letter-body .ch {
  opacity: 0;
}

.letter-sign {
  margin: 18px 0 0;
  text-align: right;
  font-size: 24px;
  opacity: 0;
}

.letter-kicker {
  margin: 0;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 20px;
  color: rgba(237, 238, 227, 0.85);
}

.fact {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(237, 238, 227, 0.62);
  max-width: 52ch;
}

.letter-actions {
  opacity: 0;
}

/* ---------- postcard modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(23, 35, 61, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px var(--gutter);
}

.modal.open {
  display: flex;
}

.modal-inner {
  width: min(420px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  color: var(--do);
}

.modal-inner img {
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  -webkit-touch-callout: default;
}

.modal-inner p {
  margin: 0;
  font-family: var(--f-hand);
  font-size: 18px;
}

/* ---------- creator ---------- */

#scene-create {
  background: var(--do);
}

.create h2 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(32px, 8.5vw, 46px);
  line-height: 1.05;
  margin: 0;
}

.create .sub {
  margin: 6px 0 0;
  color: var(--ink-soft);
}

.preview {
  height: 320px;
  padding-bottom: 26px;
  margin: 0 -16px;
  position: relative;
  background: radial-gradient(50% 50% at 50% 55%, rgba(224, 122, 147, 0.18), transparent 70%);
}

.preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--f-display);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 16px;
}

.form {
  display: grid;
  gap: 22px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > label,
.field > legend,
.field-label {
  font-weight: 600;
  font-size: 15px;
  padding: 0;
}

fieldset.field {
  border: none;
  margin: 0;
  padding: 0;
}

.hint-text {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: -2px 0 0;
}

.input,
.textarea {
  width: 100%;
  border: 1.5px solid rgba(40, 58, 94, 0.35);
  background: #f8f8f1;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  min-height: 48px;
}

.input:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--sen);
  box-shadow: 0 0 0 3px rgba(224, 122, 147, 0.25);
}

.input.big {
  font-family: var(--f-display);
  font-size: 26px;
}

.textarea {
  min-height: 150px;
  resize: vertical;
  font-family: var(--f-hand);
  font-size: 20px;
  line-height: 1.4;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips label {
  position: relative;
}

.chips input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.chips span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1.5px solid rgba(40, 58, 94, 0.35);
  border-radius: 21px;
  font-size: 15px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.chips input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--do);
}

.chips input:focus-visible + span {
  outline: 2.5px solid var(--sen);
  outline-offset: 2px;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.jokes {
  display: grid;
  gap: 8px;
}

.form-error {
  color: var(--son);
  font-size: 14px;
  margin: 0;
  min-height: 1em;
}

.result {
  display: none;
  gap: 12px;
  padding: 18px;
  border-radius: 16px;
  background: #f8f8f1;
  border: 1.5px dashed rgba(40, 58, 94, 0.35);
}

.result.shown {
  display: grid;
}

.result p {
  margin: 0;
}

.link-box {
  font-size: 13px;
  word-break: break-all;
  max-height: 5.4em;
  overflow: hidden;
  color: var(--ink-soft);
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .falling,
  .motes,
  #fauna {
    display: none;
  }
  .bgp {
    animation: none;
  }
  .sway,
  .hint span {
    animation: none;
  }
}

@media (min-width: 900px) {
  .plant-svg {
    height: 88%;
  }
  .note {
    left: auto;
    right: 6vw;
    top: 38%;
    transform: none;
    width: 340px;
  }
  .orb {
    left: 8vw;
    top: 10vh;
    width: 72px;
    height: 72px;
  }
}
