@font-face { font-family: MoC; src: url(fonts/moc.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: Caveat; src: url(fonts/caveat.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Lora; src: url(fonts/lora.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Lora; src: url(fonts/lora-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: Lora; src: url(fonts/lora-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root { --red:#8a1c1c; --green:#2f5a3a; --gold:#c39b3d; --ink:#3b2a1e; --paper:#fdf1dc; --night:#14244a; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Lora, Georgia, serif; color: var(--ink); background: radial-gradient(ellipse at top, #22386b, var(--night) 60%, #0b1430); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.screen { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px 40px; }
[hidden] { display: none !important; }
h1, h2 { font-family: MoC, serif; font-weight: 700; margin: 0; }
.kicker { font-weight: 600; letter-spacing: .25em; font-size: 12px; color: #f3d58a; margin: 14px 0 4px; }
.lead { font-style: italic; margin: 6px 0 14px; }
.btn { display: block; width: 100%; font: 600 17px Lora, serif; color: #fff; background: var(--red); border: 0; border-radius: 999px; padding: 14px 18px; margin-top: 16px; cursor: pointer; box-shadow: 0 3px 0 #5d1010; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #5d1010; }
.btn.small { font-size: 15px; padding: 10px 14px; margin-top: 8px; }
.btn.ghost { background: #fff; color: var(--red); border: 2px solid var(--red); box-shadow: none; }
.link { background: none; border: 0; color: #f3d58a; font: 600 15px Lora, serif; text-decoration: underline; cursor: pointer; padding: 8px; }

/* gate */
.gate-card { background: var(--paper); border-radius: 22px; padding: 0 0 22px; overflow: hidden; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.45); border: 3px solid var(--gold); }
.gate-art { width: 100%; height: 300px; object-fit: cover; object-position: 50% 78%; display: block; }
.gate-card .kicker { color: var(--red); }
.gate-card h1 { color: var(--red); font-size: 40px; }
.gate-card form { text-align: left; padding: 0 22px; }
.gate-card label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 15px; }
.hint { font-weight: 400; font-style: italic; font-size: 13px; color: #6b5440; }
.gate-card input, .dlg input { width: 100%; font: 18px Lora, serif; padding: 12px 14px; border: 2px solid var(--gold); border-radius: 12px; background: #fff; color: var(--ink); }
.gate-card input:focus, .dlg input:focus { outline: 3px solid #f3d58a; }
#code { text-transform: uppercase; letter-spacing: .12em; }
.err { color: var(--red); font-weight: 600; min-height: 1.2em; margin: 10px 0 0; text-align: center; }
.fine { font-size: 13px; color: #6b5440; margin: 6px 22px 0; }

/* home */
.top { text-align: center; color: #fff6e0; padding: 8px 0 14px; }
.top h1 { font-size: 40px; text-shadow: 0 2px 10px rgba(0,0,0,.4); }
.stars { font-family: Caveat; font-size: 22px; color: #f3d58a; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.tile { position: relative; aspect-ratio: 1 / .8; border-radius: 12px; border: 0; cursor: pointer; background: var(--paper); color: var(--ink); font: 600 13px Lora, serif; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 0 rgba(0,0,0,.25); overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom right, transparent 49.3%, rgba(195,155,61,.55) 50%, transparent 50.7%), linear-gradient(to bottom left, transparent 49.3%, rgba(195,155,61,.55) 50%, transparent 50.7%); background-size: 100% 60%; background-repeat: no-repeat; }
.tile .num { font-family: MoC; font-size: 30px; color: var(--red); position: relative; }
.tile .lbl { position: relative; font-size: 11px; letter-spacing: .1em; }
.tile.read { background: #f5e6c8; }
.tile.read .num::after { content: " \2713"; font-size: 16px; color: var(--green); }
.tile.today { outline: 3px solid #f3d58a; animation: glow 1.6s ease-in-out infinite; }
.tile.locked { background: #3a4a72; color: #c9d2ea; box-shadow: none; cursor: default; }
.tile.locked .num { color: #c9d2ea; opacity: .7; }
.tile.locked::before { display: none; }
@keyframes glow { 50% { box-shadow: 0 0 22px 6px rgba(243,213,138,.75); } }
.foot { text-align: center; margin-top: 26px; }

/* envelope */
.back { position: relative; z-index: 3; background: rgba(255,255,255,.12); color: #fff6e0; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; padding: 8px 14px; font: 600 14px Lora, serif; cursor: pointer; }
.env-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 12vh; perspective: 900px; }
.envelope { position: relative; width: min(86vw, 420px); aspect-ratio: 1.55; cursor: pointer; }
.env-back { position: absolute; inset: 0; background: #e9d3a8; border-radius: 10px; }
.env-front { position: absolute; inset: 0; border-radius: 10px; background:
  linear-gradient(to top right, #f6e7c9 49.6%, transparent 50%) left bottom / 50.4% 100% no-repeat,
  linear-gradient(to top left, #f6e7c9 49.6%, transparent 50%) right bottom / 50.4% 100% no-repeat,
  linear-gradient(#f1dfbb, #f1dfbb) bottom / 100% 55% no-repeat; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 5%; box-shadow: 0 14px 30px rgba(0,0,0,.45); }
.env-to { font-family: Caveat; font-size: clamp(24px, 7vw, 34px); color: var(--ink); }
.env-from { font-size: 12px; letter-spacing: .12em; color: #8b7355; }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 58%; background: #e7cd98; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .7s ease-in, z-index 0s .35s; z-index: 2; }
.seal { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c43a3a, #7a1414 70%); color: #f3d58a; display: grid; place-items: center; font-size: 30px; z-index: 3; box-shadow: 0 3px 8px rgba(0,0,0,.4); transition: opacity .3s; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.08); } }
.envelope.open .seal { opacity: 0; animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.tap { color: #fff6e0; font-family: Caveat; font-size: 24px; margin-top: 22px; }
.env-wrap.gone { animation: sink .6s ease-in forwards; }
@keyframes sink { to { opacity: 0; transform: translateY(80px); } }

/* letter */
.letter { background: var(--paper); border-radius: 14px; overflow: hidden; margin-top: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.5); border: 2px solid var(--gold); animation: rise .8s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(120px) scale(.96); } }
.letter img.band { display: block; width: 100%; }
.letter .hero { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.letter .body { padding: 6px 26px 10px; font-size: 18px; line-height: 1.6; }
.letter .date { text-align: center; font-weight: 600; letter-spacing: .22em; font-size: 12px; color: var(--red); }
.letter h2 { text-align: center; color: var(--red); font-size: 32px; line-height: 1.1; margin: 4px 0 10px; }
.letter .speak { width:auto; display:block; margin: 0 auto 12px; padding: 9px 22px; }
.letter .greet { font-family: Caveat; font-size: 30px; }
.letter p { margin: 0 0 14px; }
.letter .spot { display: block; width: 62%; max-width: 260px; margin: 4px auto 14px; mix-blend-mode: multiply; -webkit-mask-image: radial-gradient(ellipse 50% 50% at center, #000 62%, transparent 100%); mask-image: radial-gradient(ellipse 50% 50% at center, #000 62%, transparent 100%); }
.letter .sign { font-family: Caveat; font-size: 34px; color: var(--red); text-align: right; margin: 0 6px 14px 0; }
.mission { border: 2px solid var(--gold); border-radius: 14px; background: rgba(255,255,255,.55); padding: 12px 14px; font-size: 16px; }
.mission b { color: var(--green); }
.done { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-weight: 600; cursor: pointer; }
.done input { width: 26px; height: 26px; accent-color: var(--green); }
.verse { text-align: center; font-style: italic; font-size: 14px; color: #6b5440; margin-top: 10px; }
.actions { display: flex; gap: 10px; padding: 0 26px 22px; }
.actions .btn { margin-top: 0; }
.speak.on { background: var(--green); box-shadow: 0 3px 0 #1d3a25; }

/* dialog */
dialog { border: 3px solid var(--gold); border-radius: 18px; padding: 0; max-width: 360px; width: 90vw; background: var(--paper); }
dialog::backdrop { background: rgba(5,10,30,.6); }
.dlg { padding: 20px; }
.dlg h2 { color: var(--red); font-size: 28px; margin-bottom: 10px; }
.dlg label { font-weight: 600; display: block; margin-bottom: 6px; }
.dlg p { font-size: 15px; }
.dlg hr { border: 0; border-top: 1px solid #d9c49a; margin: 16px 0; }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
