:root {
  color-scheme: dark;
  --sky: #251a37;
  --room-glow: #4d365a;
  --seam: #654c7b;
  --deep: #1e152c;
  --cream: #fff4dc;
  --paper: #ffefd1;
  --ink: #2c2440;
  --lilac: #d9c9ee;
  --teal: #65c9af;
  --coral: #ff9a85;
  --orange: #ffa66f;
  --focus: #2d7866;
  --seasonal: var(--coral);
  --stripe: #548b80;
  --body: system-ui, sans-serif;
  --display: Georgia, "Times New Roman", serif;
  font-family: var(--body);
  color: var(--cream);
  background: var(--sky);
  background-image: radial-gradient(ellipse at 22% 16%, var(--room-glow), transparent 67%);
  accent-color: var(--teal);
}

:root[data-theme="spring"] { --sky: #142b26; --room-glow: #305444; --seam: #537564; --seasonal: #bce4af; --stripe: #608b66; }
:root[data-theme="summer"] { --sky: #152e3d; --room-glow: #265a61; --seam: #517882; --seasonal: #ffcf88; --stripe: #a76651; }
:root[data-theme="autumn"] { --sky: #332224; --room-glow: #603b31; --seam: #855e50; --seasonal: #ffb281; --stripe: #98614f; }
:root[data-theme="winter"] { --sky: #152337; --room-glow: #344c71; --seam: #5c7496; --seasonal: #c1dcef; --stripe: #627da0; }
:root[data-theme="easter"] { --sky: #2e2343; --room-glow: #59406c; --seam: #80658d; --seasonal: #ead2ff; --stripe: #7a659c; }
:root[data-theme="halloween"] { --sky: #21182d; --room-glow: #4e345d; --seam: #79547b; --seasonal: #ffc186; --stripe: #a56147; }
:root[data-theme="christmas"] { --sky: #102926; --room-glow: #294b3b; --seam: #4d7463; --seasonal: #ffadab; --stripe: #477e69; }
:root[data-theme="new-year"] { --sky: #171c38; --room-glow: #424168; --seam: #706e9c; --seasonal: #ffda91; --stripe: #7f699e; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: grid; grid-template-rows: auto auto 1fr; min-height: 100dvh; margin: 0; }
body::before {
  content: "";
  display: block;
  height: .45rem;
  background: repeating-linear-gradient(132deg, var(--seasonal) 0 1.35rem, var(--cream) 1.35rem 2.05rem, var(--stripe) 2.05rem 3.4rem, var(--cream) 3.4rem 4.1rem);
}

button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
::selection { color: var(--deep); background: var(--teal); }

.frame { width: min(74rem, calc(100% - 7rem)); margin-inline: auto; }
.skip-link { position: fixed; top: .7rem; left: .7rem; z-index: 2; transform: translateY(-160%); opacity: 0; padding: .6rem .85rem; background: var(--paper); color: var(--ink); }
.skip-link:focus { transform: none; opacity: 1; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; min-height: clamp(3rem, 8.5dvh, 5.15rem); border-bottom: 1px solid var(--seam); }
.brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; color: var(--cream); text-decoration: none; }
.brand img { width: 2.6rem; height: auto; }
.brand span { font-weight: 850; font-size: 1.2rem; letter-spacing: .09em; line-height: 1; }
.brand small { display: block; margin-top: .32rem; font-size: .7rem; font-weight: 720; letter-spacing: .14em; }
.masthead .policy-trigger { gap: .25rem; min-height: 2.75rem; margin-inline-start: auto; padding-inline: .25rem; background: transparent; color: var(--lilac); font-size: .89rem; font-weight: 650; line-height: 1.35; }
.masthead .policy-trigger:hover:enabled { background: var(--room-glow); color: var(--cream); }
.policy-trigger svg { flex: none; stroke: currentColor; }
.episode-tag { position: relative; flex: 0 0 7.3rem; align-self: flex-start; margin: .4rem 0 0; transform: rotate(7deg); transform-origin: center top; filter: drop-shadow(0 .22rem .2rem #130d2680); }
.episode-tag::after { content: ""; position: absolute; top: -.85rem; left: 50%; width: .12rem; height: 1.44rem; border-radius: 1rem; background: #cc775f; transform: rotate(-12deg); }
.episode-tag-face { position: relative; display: grid; justify-items: center; gap: .12rem; padding: .75rem .28rem .36rem; clip-path: polygon(15% 0, 85% 0, 100% 20%, 100% 100%, 0 100%, 0 20%); background: color-mix(in srgb, var(--seasonal) 54%, var(--paper)); color: var(--ink); font-size: .69rem; font-weight: 680; line-height: 1.12; text-align: center; }
.episode-tag-face::before { content: ""; position: absolute; top: .34rem; left: calc(50% - .16rem); width: .32rem; aspect-ratio: 1; border-radius: 50%; background: var(--deep); }
.episode-tag time { font: 700 1.64rem/.97 var(--display); font-variant-numeric: lining-nums tabular-nums; }

.layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); align-items: center; gap: clamp(1.5rem, 6vw, 6.5rem); padding-block: clamp(.85rem, 3dvh, 2.5rem); }
.intro { display: grid; justify-items: start; align-content: center; gap: clamp(.55rem, 1.55dvh, 1.25rem); }
.intro h1 { font: 700 clamp(2.5rem, min(5.45vw, 6.7dvh), 5.7rem)/.97 var(--display); letter-spacing: -.04em; margin: 0; }
.intro h1 em { color: var(--seasonal); font-weight: 500; }
.intro > p { color: var(--lilac); font-size: clamp(.875rem, 1.6vw, 1.1rem); line-height: 1.45; max-width: 41ch; margin: 0; }
.watch, #letter { scroll-margin-top: 1.25rem; }
.watch { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: .35rem .7rem; width: 100%; padding-top: clamp(.35rem, 1.25dvh, .8rem); border-top: 1px solid var(--seam); }
.watch h2 { margin: 0; font-size: .9rem; font-weight: 740; }
.channels { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: .7rem; margin: 0; padding: 0; list-style: none; }
.channels [data-platform="youtube"] { --glyph: #ff9a85; --tile: #4a2d41; }
.channels [data-platform="instagram"] { --glyph: #e3b9f4; --tile: #483256; }
.channels [data-platform="tiktok"] { --glyph: #9be2d0; --tile: #293f46; }
.channels [data-platform="x"] { --glyph: #f3edf8; --tile: #332f41; }
.channels [data-platform="threads"] { --glyph: #c6cdfc; --tile: #363657; }
.channel-icon { position: relative; display: grid; place-items: center; width: clamp(2.75rem, min(15vw, 7.2dvh), 4rem); aspect-ratio: 1; border: 1px solid color-mix(in srgb, var(--glyph) 30%, var(--tile)); border-radius: .75rem; background: color-mix(in srgb, var(--tile) 65%, var(--room-glow)); color: var(--glyph); transition: transform .18s ease, border-color .18s ease; }
.channel-icon svg { width: clamp(1.5rem, 7.5vw, 2rem); height: auto; }
:root:is([data-theme="winter"], [data-theme="christmas"]) .channel-icon::before {
  content: "";
  position: absolute;
  inset: -2px -1px auto;
  height: .55rem;
  border-radius: .75rem .75rem 55% 60%;
  background:
    radial-gradient(ellipse at 26% 0, #eff8ff 0 64%, transparent 67%) 16% 100% / .83rem .46rem no-repeat,
    radial-gradient(ellipse at 50% 0, #d3ebff 0 66%, transparent 69%) 79% 100% / 1.03rem .47rem no-repeat,
    linear-gradient(#f7fcff, #d3ebff) top / 100% .32rem no-repeat;
  pointer-events: none;
}
a.channel-icon:hover { transform: translateY(-3px); border-color: var(--glyph); }
span.channel-icon { opacity: .74; }
.channels-pending { grid-column: 2; grid-row: 1; margin: 0; color: var(--lilac); font-size: .77rem; line-height: 1.35; }
.reception { position: relative; width: min(100%, 57dvh); margin: 0; }
.reception > img { display: block; width: 100%; height: auto; }
.gaia-bubble { position: absolute; z-index: 1; top: -.7rem; right: .65rem; max-width: min(12rem, 44%); margin: 0; padding: .47rem .65rem; border: 1px solid #d4ab8d; border-radius: .65rem; background: var(--cream); color: var(--ink); box-shadow: 0 .22rem .48rem #18102050; font-size: .8rem; font-weight: 670; line-height: 1.27; opacity: 0; visibility: hidden; transform: translateY(.3rem) scale(.96); transition: opacity .23s ease, transform .23s ease, visibility .23s; pointer-events: none; }
.gaia-bubble::after { content: ""; position: absolute; bottom: -.3rem; left: 1.1rem; width: .55rem; aspect-ratio: 1; border-right: 1px solid #d4ab8d; border-bottom: 1px solid #d4ab8d; background: inherit; transform: rotate(45deg); }
.gaia-bubble[data-visible] { opacity: 1; visibility: visible; transform: none; }
.season-postmark { position: absolute; top: 5%; left: 22%; width: 12%; max-width: 4.35rem; color: var(--seasonal); transform: rotate(-12deg); }
.season-postmark g { display: none; }
[data-theme="spring"] .season-postmark [data-theme="spring"],
[data-theme="summer"] .season-postmark [data-theme="summer"],
[data-theme="autumn"] .season-postmark [data-theme="autumn"],
[data-theme="winter"] .season-postmark [data-theme="winter"],
[data-theme="easter"] .season-postmark [data-theme="easter"],
[data-theme="halloween"] .season-postmark [data-theme="halloween"],
[data-theme="christmas"] .season-postmark [data-theme="christmas"],
[data-theme="new-year"] .season-postmark [data-theme="new-year"] { display: block; }
.reception-attire { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.reception-attire > g { display: none; }
:root[data-theme="spring"] [data-attire="spring"],
:root[data-theme="summer"] [data-attire="summer"],
:root[data-theme="autumn"] [data-attire="autumn"],
:root[data-theme="winter"] [data-attire="winter"],
:root[data-theme="easter"] [data-attire="easter"],
:root[data-theme="halloween"] [data-attire="halloween"],
:root[data-theme="christmas"] [data-attire="christmas"],
:root[data-theme="new-year"] [data-attire="new-year"] { display: block; }
:root:is([data-theme="winter"], [data-theme="christmas"]) .reception-snow {
  display: block;
  opacity: .76;
  animation: reception-snowfall 2.2s linear 2;
}
@keyframes reception-snowfall {
  0% { transform: translateY(-15px); opacity: .38; }
  75% { opacity: .76; }
  100% { transform: translateY(19px); opacity: .38; }
}
.paper-plane { position: absolute; z-index: 2; width: 13%; aspect-ratio: 3 / 2; top: 56%; left: 72%; opacity: 0; pointer-events: none; }
.reception[data-delivered="true"] .paper-plane { opacity: 1; }
.plane-paper { position: absolute; inset: 0; filter: drop-shadow(0 .12rem .13rem #291e4780); }
.paper-plane[data-heading="left"] .plane-paper { transform: scaleX(-1); }
.plane-paper > span { position: absolute; inset: 0; clip-path: var(--folded); background: var(--paper-tone); }
.plane-wing-far {
  --unfolded: polygon(3% 7%, 97% 7%, 97% 52%, 3% 52%);
  --folded: polygon(5% 40%, 96% 8%, 38% 61%, 5% 40%);
  --paper-tone: #fff5dd;
}
.plane-crease {
  --unfolded: polygon(3% 49%, 97% 49%, 97% 54%, 3% 54%);
  --folded: polygon(38% 61%, 96% 8%, 49% 74%, 38% 86%);
  --paper-tone: #b67c77;
}
.plane-wing-near {
  --unfolded: polygon(3% 51%, 97% 51%, 97% 93%, 3% 93%);
  --folded: polygon(38% 61%, 96% 8%, 72% 94%, 49% 74%);
  --paper-tone: #f5d3a4;
}
.layout:has(.letter[data-scene="sending"]) .plane-paper > span { animation: fold-paper .36s ease-in-out both; }
.layout:has(.letter[data-scene="sending"]) .plane-wing-near { animation-delay: .06s; }

.letter {
  display: grid;
  position: relative;
  isolation: isolate;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  min-width: 0;
  padding: clamp(1rem, min(3vw, 4dvh), 2.6rem);
  border-radius: .3rem;
  box-shadow: .5rem .8rem 0 -.13rem #c96e62, 0 1.4rem 2.6rem #160e2566;
}

.letter::before { content: ""; position: absolute; inset: .4rem; border: 1px solid #e6c7a6; border-radius: .18rem; pointer-events: none; z-index: -1; }
.letter-content, .receipt { grid-area: 1 / 1; min-width: 0; }
.letter[data-scene="delivered"] .letter-content { visibility: hidden; }
.letter :focus-visible { outline-color: var(--focus); }
.letter-heading { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.letter h2 { font: 700 clamp(2rem, 3.6vw, 3.1rem)/1 var(--display); letter-spacing: -.035em; margin: 0; }
.postage { width: clamp(2.3rem, min(5.4vw, 8dvh), 4.6rem); aspect-ratio: 1; flex-shrink: 0; background: #f3987c; display: grid; place-items: center; border: 4px dotted var(--paper); outline: 1px solid #ac655b; outline-offset: -5px; transform: rotate(8deg); }
.postage img { width: 72%; height: auto; }
.scene-letter-label { display: block; font-size: .9rem; font-weight: 750; margin: clamp(.35rem, 1.4dvh, 1rem) 0 .4rem; }
textarea { display: block; width: 100%; height: clamp(4.6rem, 22dvh, 12rem); padding: .48rem .72rem; border: 1px solid #a37875; border-radius: .22rem .22rem 0 0; resize: none; line-height: 1.5rem; color: var(--ink); background: repeating-linear-gradient(0deg, #fff9ea 0 calc(1.5rem - 1px), #eadac0 calc(1.5rem - 1px) 1.5rem) 0 .5rem / 100% 1.5rem; caret-color: #865050; }
textarea::placeholder { color: #715761; opacity: 1; }
textarea:focus-visible { outline-offset: 2px; }
.letter[data-scene="sending"] textarea { opacity: .32; transition: opacity .24s ease; }
.letter[data-scene="sending"] textarea::placeholder { opacity: 0; }
.letter-note { margin: clamp(.35rem, 1.2dvh, .9rem) 0 clamp(.5rem, 1.5dvh, 1.1rem); max-width: 47ch; font-size: .83rem; color: #5d4754; line-height: 1.35; }
#play-letter { margin-top: clamp(.5rem, 1.4dvh, 1rem); }
button { display: inline-flex; align-items: center; justify-content: center; gap: .65rem; min-height: 3rem; border: 1px solid transparent; border-radius: .25rem; background: var(--ink); color: var(--cream); padding: .52rem 1rem; font-weight: 760; cursor: pointer; }
button:hover:enabled { background: #4a365d; }
button:disabled { opacity: .74; cursor: wait; }
button svg { stroke: var(--teal); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.privacy-link { display: inline; min-height: auto; border: 0; padding: .15rem 0; background: transparent; color: inherit; font: inherit; font-weight: 670; text-decoration: underline; text-underline-offset: .17em; text-align: left; }
.privacy-link:hover:enabled { background: transparent; text-decoration-thickness: 2px; }

.receipt { visibility: hidden; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: clamp(.85rem, 2.5dvh, 1.5rem); }
.letter[data-scene="delivered"] .receipt { visibility: visible; }
.letter .receipt h2 { padding: .4em .55em; border: 3px double #a84952; border-radius: .15em; color: #873c4a; font-size: clamp(1.45rem, 3vw, 2.35rem); transform: rotate(-4deg); }
.letter[data-scene="delivered"] .receipt h2 { animation: stamp-receipt .24s ease-out both; }
.scene-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem 1.1rem; }
.scene-actions a { display: inline-flex; align-items: center; padding: .52rem 1rem; min-height: 3rem; border-radius: .25rem; background: var(--ink); color: var(--cream); font-weight: 760; text-decoration: none; }
.scene-actions a:hover { background: #4a365d; }
.scene-actions .privacy-link { min-height: 2.75rem; }

.policy { width: min(33rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: clamp(1.1rem, 4vw, 2rem); overflow: auto; border: 1px solid #b78680; border-radius: .6rem; background: var(--paper); color: var(--ink); box-shadow: 0 1rem 4rem #120a22aa; }
.policy::backdrop { background: #1a1029c9; }
.policy-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.policy h2 { margin: .35rem 0 0; font: 700 clamp(1.45rem, 5vw, 2.15rem)/1.1 var(--display); }
.policy h3 { margin: 1.1rem 0 .24rem; font-size: .97rem; }
.policy p { margin: 0; color: #5d4754; font-size: .89rem; line-height: 1.55; }
.policy .policy-external { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid #cca493; }
.policy a { color: #583a66; text-underline-offset: .17em; }
.policy-close { min-width: 2.75rem; min-height: 2.75rem; padding: .45rem; }
.policy :focus-visible { outline-color: var(--focus); }

@keyframes stamp-receipt {
  from { opacity: 0; transform: rotate(-7deg) scale(1.12); }
  to { opacity: 1; transform: rotate(-4deg) scale(1); }
}

@keyframes fold-paper {
  from { clip-path: var(--unfolded); background: #fff5dd; }
  to { clip-path: var(--folded); background: var(--paper-tone); }
}

@media (max-width: 980px) {
  .frame { width: calc(100% - 4rem); }
}

@media (max-width: 820px), (min-width: 640px) and (max-height: 480px) {
  .frame { width: min(34rem, calc(100% - 2.5rem)); }
  .masthead { gap: .65rem; }
  .layout { grid-template-columns: minmax(0, 1fr); align-content: center; gap: clamp(.85rem, 2.7dvh, 1.5rem); }
  .intro { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: center; column-gap: .45rem; }
  .intro h1 { font-size: clamp(1.35rem, min(6.8vw, 5.65dvh), 3.35rem); }
  .intro > p, .watch { grid-column: 1 / -1; }
  .reception { grid-column: 2; grid-row: 1; width: 100%; margin-block-start: 2.45rem; }
  .gaia-bubble { top: auto; right: 0; bottom: calc(100% + .28rem); width: max(100%, 7.4rem); max-width: 9.2rem; padding: .27rem .4rem; font-size: .67rem; }
  .gaia-bubble::after { left: 48%; }
  textarea { height: clamp(4.6rem, 16dvh, 10rem); }
}

@media (max-width: 350px) {
  .frame { width: calc(100% - 1.8rem); }
  .masthead .policy-trigger { font-size: .76rem; }
  .masthead { gap: .35rem; }
  .episode-tag { flex-basis: 6.25rem; transform: rotate(4deg); }
  .episode-tag-face { font-size: .64rem; }
  .gaia-bubble { min-width: 8rem; }
  .brand { gap: .3rem; }
  .brand img { width: 2.3rem; }
  .brand span { font-size: 1.05rem; }
  .brand small { font-size: .62rem; }
  .channels { gap: .6rem; }
  .letter h2 { font-size: 1.75rem; }
  .scene-actions { gap: .5rem; }
  .scene-actions a { padding-inline: .75rem; }
}

@media (max-width: 820px) and (max-height: 650px) {
  .layout { padding-block: .65rem .8rem; }
  .letter { padding: .75rem; }
  textarea { height: 4rem; }
  #play-letter { min-height: 2.75rem; }
}

@media (min-width: 640px) and (max-height: 480px) {
  .frame { width: min(74rem, calc(100% - 2.5rem)); }
  .layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intro h1 { font-size: clamp(1.35rem, 5.85dvh, 1.8rem); }
  .letter h2 { font-size: 1.9rem; }
  textarea { height: 4.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
  :root:is([data-theme="winter"], [data-theme="christmas"]) .reception-snow { animation-name: none; }
}
