/* Theme: a luxury mithai box. Berry lacquer, blush tissue, gold foil. */
:root {
  color-scheme: dark;
  --berry-950: #22071A;
  --berry-900: #2C0A20;
  --berry-800: #3A0F29;
  --berry-700: #4A1535;
  --berry-600: #5E1D44;
  --gold: #E3C07E;
  --gold-hi: #F6DFA8;
  --gold-dk: #B68C46;
  --gold-line: rgba(227, 192, 126, .34);
  --gold-faint: rgba(227, 192, 126, .14);
  --foil-ink: rgba(182, 140, 70, .55);
  --blush: #FBE6EC;
  --blush-2: #F6D2DD;
  --ivory: #FFF8F2;
  /* text on berry */
  --t1: #FFF1F5;
  --t2: #EBC6D3;
  --t3: #C99BAF;
  /* ink on blush / ivory */
  --i1: #3A0F29;
  --i2: #6E3A54;
  --i3: #8A5E73;
  --rose-ink: #A0335E;
  --good: #9CCB8A;
  --bad: #F2899A;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Figtree", "Segoe UI", system-ui, sans-serif;
  --hand: "Caveat", "Segoe Print", cursive;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --lift: 0 20px 44px rgba(12, 1, 8, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--t1);
  background-color: var(--berry-800);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23E3C07E' stroke-opacity='.075'%3E%3Cpath d='M32 6 58 32 32 58 6 32Z'/%3E%3Cpath d='M32 20 44 32 32 44 20 32Z'/%3E%3C/g%3E%3Cg fill='%23E3C07E' fill-opacity='.09'%3E%3Ccircle cx='32' cy='32' r='2'/%3E%3Ccircle cx='0' cy='0' r='2'/%3E%3Ccircle cx='64' cy='0' r='2'/%3E%3Ccircle cx='0' cy='64' r='2'/%3E%3Ccircle cx='64' cy='64' r='2'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(180deg, #43122F 0%, #300B22 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  font-feature-settings: "tnum" 1;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.12; font-family: var(--serif); font-weight: 600; font-variation-settings: "SOFT" 100, "opsz" 96; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }

/* ---------- screens ---------- */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; animation: screen-in .45s var(--ease) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.center-col {
  width: 100%; max-width: 460px; margin: 0 auto;
  padding: 56px 20px 40px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px;
  flex: 1; justify-content: center;
}

.kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--gold); }
.lead { font-size: 17px; line-height: 1.5; color: var(--t2); max-width: 34ch; }
.hint { font-size: 14px; color: var(--t3); }
.small { font-size: 13px; color: var(--t3); }
.ink { color: var(--i2); }
.hint.ink { color: var(--i3); }
.err { min-height: 24px; font-family: var(--serif); font-size: 18px; font-weight: 500; color: var(--rose-ink); }
.hl { color: var(--gold); white-space: nowrap; }
.box .hl { color: var(--rose-ink); }

/* ---------- signature: blush tissue card with a double gold-foil frame ---------- */
.box {
  position: relative; width: 100%;
  background: var(--blush); color: var(--i1);
  border-radius: 28px; padding: 32px 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), var(--lift);
}
.box::before, .box::after { content: ""; position: absolute; pointer-events: none; }
.box::before { inset: 8px; border: 1px solid var(--foil-ink); border-radius: 20px; }
.box::after { inset: 12px; border: 1px solid rgba(182, 140, 70, .26); border-radius: 16px; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 14px 28px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 17px; font-weight: 600; position: relative; z-index: 1;
  transition: transform .14s var(--ease), filter .14s var(--ease), box-shadow .14s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: default; filter: saturate(.7); }
.btn-primary {
  color: var(--berry-900);
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 58%, #D3AA62 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65), inset 0 -1px 0 rgba(120, 80, 20, .3), 0 8px 20px rgba(12, 1, 8, .35);
}
.btn-soft { color: var(--t1); background: rgba(255, 241, 245, .06); box-shadow: inset 0 0 0 1px var(--gold-line); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; flex: none;
  display: grid; place-items: center;
  color: var(--gold); background: rgba(255, 241, 245, .06);
  box-shadow: inset 0 0 0 1px var(--gold-line);
  transition: background-color .14s var(--ease), transform .14s var(--ease);
}
.icon-btn:active { transform: scale(.94); }
.mute { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 40; background: rgba(44, 10, 32, .75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }

/* ---------- gulab jamun character ---------- */
.gj {
  --s: 40px;
  position: relative; display: inline-block; flex: none;
  width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle at 33% 28%, #F2AA6C 0 4%, #C76E36 16%, #8E3818 46%, #5C1E0A 76%, #3E1206 100%);
  box-shadow:
    inset calc(var(--s) * -.06) calc(var(--s) * -.09) calc(var(--s) * .16) rgba(30, 6, 0, .55),
    inset calc(var(--s) * .03) calc(var(--s) * .05) calc(var(--s) * .1) rgba(255, 190, 130, .22),
    0 calc(var(--s) * .08) calc(var(--s) * .2) rgba(12, 1, 8, .35);
}
.gj::before {
  content: ""; position: absolute; left: 19%; top: 13%; width: 30%; height: 17%;
  border-radius: 50%; background: rgba(255, 240, 220, .85); transform: rotate(-28deg);
}
.gj::after {
  content: ""; position: absolute; right: 20%; bottom: 17%; width: 10%; height: 6%;
  border-radius: 50%; background: rgba(255, 210, 150, .35); transform: rotate(-30deg);
}
.gj i { position: absolute; display: block; }
.gj .eye { top: 42%; width: 10%; height: 12%; background: #1E0803; border-radius: 50%; }
.gj .eye::after { content: ""; position: absolute; width: 40%; height: 36%; left: 16%; top: 14%; background: #fff; border-radius: 50%; }
.gj .eye.l { left: 31%; } .gj .eye.r { right: 31%; }
.gj .blush { top: 57%; width: 15%; height: 8%; background: #F58FA9; opacity: .8; border-radius: 50%; }
.gj .blush.l { left: 15%; } .gj .blush.r { right: 15%; }
.gj .mouth {
  left: 50%; top: 55%; width: 16%; height: 10%; transform: translateX(-50%);
  border: calc(var(--s) * .028) solid #1E0803; border-top: 0; border-radius: 0 0 999px 999px;
}
.gj.shock .mouth { width: 11%; height: 13%; top: 58%; border-radius: 50%; border: 0; background: #1E0803; }
.gj.shock .eye { height: 14%; top: 39%; }
.gj.happy { animation: hop .5s var(--ease) 2; }
.gj.happy .eye { height: 5%; top: 46%; border-radius: 999px 999px 0 0; background: none; border: calc(var(--s) * .028) solid #1E0803; border-bottom: 0; }
.gj.happy .eye::after { display: none; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-18%); } }

/* the gold foil mithai cup it sits in */
.seat { --s: 120px; position: relative; display: inline-block; width: calc(var(--s) * 1.3); height: calc(var(--s) * 1.16); }
.seat .gj .eye { top: 33%; }
.seat .gj .blush { top: 47%; }
.seat .gj .mouth { top: 45%; }
.seat .gj.shock .eye { top: 30%; }
.seat .gj.shock .mouth { top: 47%; }
.seat .gj.happy .eye { top: 37%; }
.seat .gj { position: absolute; top: 0; left: calc(50% - var(--s) / 2); }
.seat::after {
  content: ""; position: absolute; left: 14%; right: 14%; bottom: calc(var(--s) * -.06); height: calc(var(--s) * .12);
  border-radius: 50%; background: rgba(12, 1, 8, .4); filter: blur(calc(var(--s) * .05)); z-index: 0;
}
.cup {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--s) * .54); z-index: 1;
  background: repeating-linear-gradient(90deg, #F6DFA8 0 6%, #CFA45A 6% 8.5%, #EBCB86 8.5% 14.5%, #C69A50 14.5% 17%);
  clip-path: polygon(0 0, 100% 0, 87% 100%, 13% 100%);
}
.cup::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .35) 0%, rgba(255, 255, 255, 0) 30%, rgba(90, 50, 10, .25) 100%);
}
.cup-rim {
  position: absolute; left: -3%; right: -3%; bottom: calc(var(--s) * .5); height: calc(var(--s) * .1); z-index: 2;
  background: radial-gradient(circle at 50% 100%, #F6DFA8 0 62%, transparent 64%) 0 0 / calc(100% / 11) 100% repeat-x;
}

.hero-bob { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---------- lock ---------- */
.lock-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 36px 28px 28px; max-width: 400px; }
.lock-title { font-size: 34px; color: var(--i1); margin-top: 8px; }
#lock-form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; margin-top: 8px; position: relative; z-index: 1; }
#lock-input {
  font: inherit; font-size: 17px; text-align: center; min-height: 48px;
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--foil-ink);
  background: var(--ivory); color: var(--i1); outline: none;
  transition: box-shadow .14s var(--ease), border-color .14s var(--ease);
}
#lock-input::placeholder { color: var(--i3); }
#lock-input:focus { border-color: var(--gold-dk); box-shadow: 0 0 0 4px rgba(227, 192, 126, .35); }
.shake { animation: shake .4s var(--ease); }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* ---------- intro ---------- */
.big-name { font-size: 88px; line-height: .95; color: var(--gold); font-weight: 600; font-variation-settings: "SOFT" 100, "opsz" 144; letter-spacing: -.02em; }
.rules { list-style: none; margin: 8px 0; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; text-align: left; max-width: 360px; }
.rules li { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 500; color: var(--i1); position: relative; z-index: 1; }
.rules span {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--gold-dk);
  box-shadow: inset 0 0 0 1px var(--foil-ink); background: var(--ivory);
}

/* ---------- map ---------- */
.map-head {
  position: sticky; top: 0; z-index: 20;
  padding: 16px 68px 16px 20px;
  background: rgba(44, 10, 32, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gold-faint);
}
.map-head-in { max-width: 780px; margin: 0 auto; }
.map-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.map-head h2 { font-size: 20px; }
.jar-label { font-size: 13px; color: var(--t3); white-space: nowrap; }
.jar { height: 6px; border-radius: 3px; background: rgba(255, 241, 245, .1); overflow: hidden; }
.jar-fill { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--gold-dk), var(--gold-hi)); transition: width .9s var(--ease); }

.map-world { position: relative; width: 100%; max-width: 480px; margin: 0 auto; }
.trail { position: absolute; inset: 0; pointer-events: none; }
.trail path { fill: none; stroke-linecap: round; }
.trail-base { stroke: rgba(227, 192, 126, .38); stroke-width: 3; stroke-dasharray: 1 11; }
.trail-done { stroke: var(--gold); stroke-width: 5; }

.node {
  position: absolute; transform: translate(-50%, calc(var(--disc, 64px) / -2));
  background: none; border: 0; padding: 0; width: var(--node-w, 140px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 2;
}
.node-disc {
  position: relative; width: var(--disc, 64px); height: var(--disc, 64px); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--berry-700); color: rgba(227, 192, 126, .6);
  box-shadow: inset 0 0 0 1.5px var(--gold-line), 0 10px 24px rgba(12, 1, 8, .35);
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  transition: transform .18s var(--ease);
}
.node-disc img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; border-radius: 50%; }
.node-done .node-disc { overflow: hidden; }
.node:active .node-disc { transform: scale(.95); }
.node-done .node-disc { box-shadow: 0 0 0 3px var(--gold), 0 10px 24px rgba(12, 1, 8, .4); }
.node-current .node-disc {
  background: var(--blush); color: var(--berry-800);
  box-shadow: inset 0 0 0 3px var(--gold), 0 12px 28px rgba(12, 1, 8, .45);
}
.node-current .node-disc::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--gold); animation: ring 2.4s var(--ease) infinite;
}
@keyframes ring { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.45); opacity: 0; } }
.node-check {
  position: absolute; top: -2px; right: calc(50% - var(--disc, 64px) / 2 - 6px);
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: var(--berry-900); box-shadow: 0 0 0 2px var(--berry-800);
}
.node-label {
  background: rgba(44, 10, 32, .78); box-shadow: inset 0 0 0 1px var(--gold-faint);
  border-radius: 10px; padding: 4px 12px; font-size: 14px; font-weight: 500; line-height: 1.3; max-width: 160px; color: var(--t1);
}
.node-locked .node-label { color: var(--t3); }
.node-game { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--t3); margin-top: -2px; }
.node-cake { transform: translate(-50%, calc(var(--cake, 86px) / -2)); }
.node-cake .node-disc { width: var(--cake, 86px); height: var(--cake, 86px); }
.node-cake.node-locked .node-disc { opacity: .75; }

.marker { position: absolute; z-index: 5; transform: translate(-50%, -100%); background: none; border: 0; padding: 0; }
.marker .gj { animation: bob 2.4s ease-in-out infinite; }

/* ---------- level ---------- */
.level-head { display: flex; align-items: center; gap: 16px; padding: 16px 68px 8px 16px; max-width: 520px; width: 100%; margin: 0 auto; }
.level-head .kicker { margin-bottom: 4px; }
.level-head h2 { font-size: 24px; }
.instr { text-align: center; font-size: 15px; color: var(--t2); padding: 8px 20px 16px; max-width: 460px; margin: 0 auto; }
.game { width: 100%; max-width: 460px; margin: 0 auto; padding: 0 16px 32px; display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* framed boards share one look: gold rim + soft foil halo */
.pz-board, .scratch, .catch-cv {
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 8px rgba(227, 192, 126, .1), var(--lift);
}

/* puzzle */
.pz-top { display: flex; align-items: center; gap: 16px; width: 100%; max-width: 360px; text-align: left; }
.pz-preview { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; object-position: 50% 30%; box-shadow: 0 0 0 2px var(--gold); flex: none; }
.pz-moves { font-weight: 600; color: var(--t1); }
.pz-moves b { color: var(--gold); }
.pz-board { position: relative; border-radius: 16px; overflow: hidden; background: var(--berry-700); margin-top: 8px; }
.pz-tile {
  position: absolute; top: 0; left: 0; border: 0; padding: 0; background-repeat: no-repeat;
  transition: transform .28s var(--ease), filter .14s var(--ease);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 242, .85);
}
.pz-tile.sel { z-index: 3; outline: 3px solid var(--gold-hi); outline-offset: -3px; filter: brightness(1.1); }
.pz-board.solved .pz-tile { box-shadow: none; transition: box-shadow .4s var(--ease); }

/* quiz */
.quiz { width: 100%; }
.quiz-count { font-size: 13px; color: var(--t3); margin-bottom: 8px; text-align: center; }
.quiz-q { font-size: 24px; text-align: center; margin-bottom: 20px; line-height: 1.25; color: var(--t1); }
.quiz-opts { display: flex; flex-direction: column; gap: 12px; }
.quiz-opt {
  display: block; width: 100%; text-align: left; border: 0;
  padding: 16px 20px; border-radius: 16px; font-size: 17px; font-weight: 500;
  background: var(--blush); color: var(--i1);
  box-shadow: inset 0 0 0 1px rgba(182, 140, 70, .35), 0 6px 16px rgba(12, 1, 8, .28);
  transition: box-shadow .14s var(--ease), transform .14s var(--ease), background-color .14s var(--ease);
}
.quiz-opt:active { transform: scale(.98); }
.quiz-opt.right { background: #E7F2DF; box-shadow: inset 0 0 0 2px #86B874, 0 6px 16px rgba(12, 1, 8, .28); }
.quiz-opt.wrong { background: #F2D3DC; color: var(--i3); animation: shake .4s var(--ease); }
.quiz-feedback { min-height: 64px; margin-top: 16px; text-align: center; font-family: var(--serif); font-size: 21px; font-weight: 500; line-height: 1.3; }
.quiz-feedback.good { color: var(--gold-hi); }
.quiz-feedback.bad { color: var(--bad); }

/* catch */
.catch-hud { display: flex; justify-content: space-between; align-items: baseline; width: 100%; max-width: 420px; }
.catch-score { font-size: 18px; font-weight: 600; color: var(--t1); }
.catch-score b { font-family: var(--serif); font-size: 24px; color: var(--gold); }
.catch-wrap { position: relative; margin-top: 8px; }
.catch-cv { display: block; border-radius: 20px; touch-action: none; background: linear-gradient(180deg, #FBE9EE 0%, #F3D0DC 100%); }
.catch-start { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(58, 15, 41, .3); border-radius: 20px; }

/* scratch */
.scratch { position: relative; border-radius: 20px; overflow: hidden; margin-top: 8px; }
.scratch img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.scratch canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; transition: opacity .7s var(--ease); }

/* ---------- reveal ---------- */
.polaroid {
  margin: 4px 0; background: var(--ivory); padding: 14px 14px 16px; width: min(320px, 84vw);
  box-shadow: 0 30px 60px rgba(12, 1, 8, .5); transform: rotate(-2deg);
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: 50% 30%; background: var(--blush-2); }
.polaroid figcaption { font-family: var(--hand); font-size: 30px; font-weight: 700; margin-top: 8px; color: var(--i1); }
.drop-in { animation: drop-in .7s var(--ease) both; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-40px) rotate(6deg); } to { opacity: 1; transform: rotate(-2deg); } }
.reveal-text { display: contents; }
#reveal-kicker { order: -1; }
.meta { font-size: 14px; color: var(--t3); font-weight: 500; }
.story { font-size: 18px; line-height: 1.6; max-width: 36ch; min-height: 3em; color: var(--t1); }

/* ---------- finale ---------- */
.finale-title { font-size: 34px; color: var(--t1); }
.cake-box { width: min(330px, 88vw); margin: 4px 0; }
.cake { width: 100%; height: auto; display: block; overflow: visible; filter: drop-shadow(0 24px 30px rgba(12, 1, 8, .45)); }
.flame-in { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker .16s ease-in-out infinite alternate; transition: opacity .25s, transform .25s; }
@keyframes flicker { from { transform: scale(1, 1) rotate(-3deg); } to { transform: scale(.92, 1.08) rotate(3deg); } }
.flame-glow { transition: opacity .3s; }
.candle.out .flame-in { opacity: 0; animation: none; transform: scale(.2); }
.candle.out .flame-glow { opacity: 0; }
.smoke { opacity: 0; }
.candle.out .smoke { animation: smoke 1.8s ease-out forwards; }
@keyframes smoke { 0% { opacity: .8; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-30px); } }
.flame-hit { cursor: pointer; }
.finale-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wind { width: 200px; height: 6px; border-radius: 3px; background: rgba(255, 241, 245, .1); overflow: hidden; opacity: 0; transition: opacity .3s; }
.wind.on { opacity: 1; }
.wind-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-dk), var(--gold-hi)); }

/* envelope + letter */
.letter-zone { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 8px; }
.envelope { position: relative; width: 280px; height: 180px; border: 0; padding: 0; background: none; perspective: 800px; filter: drop-shadow(0 20px 30px rgba(12, 1, 8, .45)); }
.env-back { position: absolute; inset: 0; background: #E7A6BB; border-radius: 12px; }
.env-front { position: absolute; inset: 0; border-radius: 12px; background: var(--blush-2); clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%); z-index: 2; }
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 62%; background: #EDB6C6;
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; z-index: 3;
  transition: transform .6s var(--ease), z-index 0s .3s;
}
.envelope::after { content: ""; position: absolute; inset: 6px; border: 1px solid var(--foil-ink); border-radius: 8px; z-index: 4; pointer-events: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.env-seal { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); z-index: 5; transition: opacity .3s; }
.envelope.open .env-seal { opacity: 0; }
.env-label { position: absolute; left: 0; right: 0; bottom: 16px; z-index: 5; font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--rose-ink); }
.env-tap { font-size: 14px; color: var(--t3); }

.letter {
  position: relative; width: 100%; max-width: 420px; text-align: left;
  background:
    repeating-linear-gradient(180deg, transparent 0 39px, rgba(182, 140, 70, .22) 39px 40px),
    var(--ivory);
  border-radius: 8px; padding: 44px 24px 32px;
  box-shadow: 0 30px 60px rgba(12, 1, 8, .5);
  font-family: "Kalam", var(--hand); font-size: 20px; line-height: 40px; color: var(--i1);
  animation: rise .8s var(--ease) both;
}
.letter::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--foil-ink); border-radius: 4px; pointer-events: none; }
@keyframes rise { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
.letter p { margin: 0 0 40px; }
.letter .to { font-weight: 700; color: var(--rose-ink); }
.letter .sign { margin: 0; text-align: right; }
.letter .sign b { font-size: 26px; color: var(--rose-ink); }
.letter .polaroid { margin: 4px auto 32px; transform: rotate(2deg); width: min(280px, 76vw); box-shadow: 0 16px 32px rgba(58, 15, 41, .25); }
.letter-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- toast + confetti ---------- */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--berry-950); color: var(--t1); padding: 12px 20px; border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--gold-line), 0 12px 30px rgba(0, 0, 0, .35);
  font-size: 15px; line-height: 1.4; max-width: min(90vw, 380px); width: max-content; text-align: center;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

/* ---------- mouse / trackpad ---------- */
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.05); }
  .btn-soft:hover, .icon-btn:hover { background-color: rgba(255, 241, 245, .12); }
  .node:hover .node-disc { transform: scale(1.05); }
  .quiz-opt:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--gold), 0 6px 16px rgba(12, 1, 8, .28); }
  .pz-tile:hover { filter: brightness(1.08); }
  .envelope:hover .env-flap { transform: rotateX(16deg); }
  .envelope.open:hover .env-flap { transform: rotateX(180deg); }
}
.keys { display: none; }
@media (hover: hover) and (pointer: fine) { .keys { display: inline; } }

/* ---------- tablet + laptop ---------- */
@media (min-width: 768px) {
  .center-col { max-width: 660px; padding-top: 64px; gap: 20px; }
  .kicker { font-size: 15px; }
  .lead { font-size: 20px; }
  .hint { font-size: 15px; }
  .btn { font-size: 18px; padding: 16px 32px; min-height: 56px; }
  .icon-btn { width: 48px; height: 48px; }
  .mute { top: 18px; right: 18px; }

  .lock-box { max-width: 480px; padding: 48px 40px 36px; }
  .lock-title { font-size: 44px; }
  #lock-form { max-width: 340px; }

  .big-name { font-size: 128px; }
  .rules { max-width: 600px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; padding: 32px; }
  .rules li { font-size: 17px; }

  .map-head { padding: 20px 84px 18px 24px; }
  .map-head h2 { font-size: 26px; }
  .jar-label { font-size: 15px; }
  .jar { height: 8px; border-radius: 4px; }
  .map-world { max-width: 780px; }
  .node-label { font-size: 16px; padding: 6px 16px; max-width: 200px; }
  .node-game { font-size: 14px; }
  .node-disc { font-size: 32px; }
  .node-check { width: 30px; height: 30px; }

  .level-head { max-width: 780px; padding: 24px 84px 8px 24px; }
  .level-head h2 { font-size: 32px; }
  .instr { font-size: 17px; max-width: 640px; }
  .game { max-width: 780px; gap: 20px; }

  .pz-top { max-width: 540px; }
  .pz-preview { width: 80px; height: 80px; }
  .pz-moves { font-size: 18px; }

  .quiz { max-width: 680px; }
  .quiz-q { font-size: 32px; margin-bottom: 28px; }
  .quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .quiz-opt { font-size: 18px; padding: 20px 24px; min-height: 80px; }
  .quiz-feedback { font-size: 26px; margin-top: 20px; }

  .catch-hud { max-width: 720px; }
  .catch-score { font-size: 20px; }
  .catch-score b { font-size: 28px; }

  .polaroid { width: min(440px, 80vw); }
  .polaroid figcaption { font-size: 36px; }
  .meta { font-size: 16px; }
  .story { font-size: 21px; }

  .finale-title { font-size: 48px; }
  .cake-box { width: max(280px, min(460px, 88vw, calc((100dvh - 320px) * 1.05))); }
  .envelope { width: 360px; height: 230px; }
  .env-label { font-size: 24px; }
  .letter { max-width: 620px; padding: 52px 44px 40px; font-size: 24px; line-height: 44px;
    background: repeating-linear-gradient(180deg, transparent 0 43px, rgba(182, 140, 70, .22) 43px 44px), var(--ivory); }
  .letter::before { inset: 12px; }
  .letter p { margin-bottom: 44px; }
  .letter .sign b { font-size: 30px; }
  .letter .polaroid { width: min(360px, 70vw); }
}

/* wide + short screens: photo beside the story */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .reveal-col { flex-direction: row; max-width: 1000px; gap: 64px; text-align: left; }
  .reveal-col .polaroid { flex: none; width: min(420px, calc(100dvh - 190px)); }
  .reveal-text { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; flex: 1; }
  .reveal-text .story { max-width: 38ch; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
