  :root {
    --ink: #f8e7c4; --page: #120a1c; --brass: #d4a445;
    --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
    --deva: "Amita", "Tiro Devanagari Hindi", "Kohinoor Devanagari", serif;
    --script: "Pinyon Script", "Snell Roundhand", "Apple Chancery", cursive;
    --caps: "Cinzel", "Trajan Pro", "Optima", serif;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  /* The film carries its own palette, so these tokens hold in both themes. */
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ink: #f8e7c4; --page: #120a1c; } }
  :root[data-theme="dark"] { --ink: #f8e7c4; --page: #120a1c; }
  *, *::before, *::after { box-sizing: inherit; }
  html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
  body { margin: 0; min-height: 100%; background: var(--page); color: var(--ink); font-family: var(--serif); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
  html.locked, html.locked body { overflow: hidden; }
  img, svg, canvas { max-width: 100%; }

  #gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

  /* ---------- Gate overlay ---------- */
  .gate-ui { position: fixed; inset: 0; z-index: 10; transition: opacity .6s ease; }
  .gate-ui.gone { opacity: 0; pointer-events: none; }
  .gtext {
    position: absolute; left: 5%; right: 5%; top: calc(env(safe-area-inset-top, 0px) + 4.5svh);
    text-align: center; color: #f7e2b8; pointer-events: none;
  }
  .gtext > * { opacity: 0; transform: translateY(14px); animation: rise 1.1s cubic-bezier(.2,.8,.2,1) forwards; }
  .gtext > :nth-child(1) { animation-delay: .2s; } .gtext > :nth-child(2) { animation-delay: .55s; }
  .gtext > :nth-child(3) { animation-delay: .85s; } .gtext > :nth-child(4) { animation-delay: 1.05s; }
  .gtext > :nth-child(5) { animation-delay: 1.5s; }
  @keyframes rise { to { opacity: 1; transform: none; } }
  .ganesh { font-family: var(--deva); font-size: clamp(15px, 4.2vw, 20px); margin: 0 0 .7em; color: #e9c46a; text-shadow: 0 1px 8px rgba(0,0,0,.7); }
  .invitee { font-family: var(--caps); font-weight: 500; font-size: clamp(14px, 4.1vw, 20px); letter-spacing: .07em; margin: 0; line-height: 1.35; color: #fbe7c0; text-shadow: 0 2px 14px rgba(0,0,0,.75); }
  .host { font-style: italic; font-weight: 500; font-size: clamp(17px, 4.8vw, 24px); margin: .45em 0 0; color: #f6dfb2; text-shadow: 0 2px 12px rgba(0,0,0,.75); }
  .couple { font-family: var(--script); font-weight: 400; font-size: clamp(46px, 13.6vw, 96px); line-height: 1.2; white-space: nowrap; margin: .05em 0 0; padding: 0 .2em; filter: drop-shadow(0 0 18px rgba(255,190,90,.5)) drop-shadow(0 2px 6px rgba(0,0,0,.7)); }
  .flourish { display: block; width: min(62%, 260px); height: auto; margin: -.2em auto 0; overflow: visible; }
  .gold-text {
    background: linear-gradient(100deg, #b8862f 0%, #ffe9a8 18%, #d4a445 36%, #fff6d2 50%, #c99a3c 64%, #ffe39a 82%, #b8862f 100%) 0 0 / 200% 100% repeat-x;
    -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 5s linear infinite;
  }
  @keyframes shimmer { to { background-position: 200% 0; } }
  .gtext > .couple.gold-text { animation: rise 1.1s cubic-bezier(.2,.8,.2,1) 1.05s forwards, shimmer 5s linear infinite; }

  .enter { position: absolute; inset: 0; width: 100%; height: 100%; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .enter:focus-visible { outline: 3px solid #ffd98a; outline-offset: -6px; }
  .beckon { position: absolute; left: 50%; top: 60%; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity .8s ease .6s; }
  .ready .beckon { opacity: 1; }
  .beckon .halo { position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,226,150,.55), rgba(255,200,90,0) 65%); animation: halo 2.4s ease-in-out infinite; }
  .beckon .halo::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; border: 1px solid rgba(255,226,150,.9); animation: ring 2.4s ease-out infinite; }
  @keyframes halo { 0%, 100% { transform: scale(.8); opacity: .6; } 45% { transform: scale(1.05); opacity: 1; } }
  @keyframes ring { 0%, 40% { transform: scale(.4); opacity: 0; } 48% { opacity: 1; } 100% { transform: scale(2.3); opacity: 0; } }
  .beckon .rot { position: absolute; left: 0; top: 0; transform: rotate(-33deg); transform-origin: 0 0; }
  .beckon svg { position: absolute; left: -50.7px; top: 12px; width: 112px; max-width: none; height: auto; overflow: visible;
    animation: reach 2.4s cubic-bezier(.45,0,.3,1) infinite;
    filter: drop-shadow(0 0 10px rgba(255,205,120,.35)) drop-shadow(0 6px 8px rgba(0,0,0,.65)); }
  @keyframes reach { 0%, 100% { transform: translateY(16px); } 45% { transform: translateY(0); } 52% { transform: translateY(3px); } }
  .beckon .ln { fill: none; stroke: #f1d08a; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.9s cubic-bezier(.6,.1,.3,1) 1.2s forwards; }
  .beckon .ln.fine { stroke-width: 1.05; stroke: #e2b964; animation-delay: 2s; }
  .beckon .dot { fill: #e2b964; opacity: 0; animation: fadein .6s ease 2.6s forwards; }
  .beckon .skin { fill: rgba(28,12,6,.42); opacity: 0; animation: fadein .9s ease 1.6s forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes fadein { to { opacity: 1; } }
  .opening .beckon { opacity: 0; transition: opacity .25s; }
  .opening .gtext { opacity: 0; transition: opacity .9s ease; }

  .flash { position: fixed; inset: 0; z-index: 20; pointer-events: none; background: radial-gradient(circle at 50% 60%, #fffbe6, #ffe08a 50%, #ffc23a); opacity: 0; transition: opacity .55s ease; }

  /* Prototype-only: remove #proto before launch */
  .proto { position: fixed; z-index: 30; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 10px; display: flex; gap: 6px; font: 12px system-ui, sans-serif; }
  .proto button, .proto input { font: inherit; border-radius: 999px; border: 1px solid rgba(255,230,180,.45); background: rgba(20,8,24,.65); color: #fbe3b3; padding: 6px 10px; }
  .proto input { width: 150px; display: none; }
  .proto.editing input { display: block; }
  .proto button:focus-visible, .proto input:focus-visible { outline: 2px solid #ffc72c; outline-offset: 2px; }

  /* ---------- Story ---------- */
  .story { position: relative; z-index: 2; visibility: hidden; }
  .story.on { visibility: visible; }
  .chapter { position: relative; height: 215svh; }
  .pin {
    position: sticky; top: 0; height: 100svh; overflow: hidden; pointer-events: none;
    display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center;
    padding: calc(env(safe-area-inset-top, 0px) + 7svh) 6% calc(env(safe-area-inset-bottom, 0px) + 4svh);
    opacity: clamp(0, calc(1 - var(--x, 0) * 2.2), 1);
  }
  .pin::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 40%; background: var(--scrim-top, none); z-index: -1; opacity: clamp(0, calc(var(--tx, 0) * 1.5), 1); }
  .pin::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%; background: linear-gradient(transparent, rgba(10,4,10,.55)); z-index: -1; opacity: clamp(0, calc(var(--p, 0) * 5 - .6), 1); }
  .title {
    font-family: var(--script); font-weight: 400; font-size: clamp(4.4rem, 21vw, 8rem); line-height: 1.12; margin: 0; padding: 0 .25em;
    color: var(--tc); text-shadow: var(--ts);
    clip-path: inset(-.5em calc((1 - var(--tx, 0)) * 104%) -.6em -.4em);
    transform: translateY(calc((1 - var(--tx, 0)) * 18px));
  }
  .title.long { font-size: clamp(3.4rem, 15vw, 6.4rem); }
  .orn { display: block; width: min(46%, 190px); height: auto; margin: -.1em auto .2em; overflow: visible; color: var(--tc); opacity: clamp(0, calc(var(--tx, 0) * 4 - 2.6), 1); }
  .hi { font-family: var(--deva); font-size: clamp(1.35rem, 6.4vw, 2.2rem); margin: .25em 0 0; color: var(--tc); text-shadow: var(--ts); opacity: clamp(0, calc(var(--tx, 0) * 5 - 3.4), 1); }
  .lede { font-size: clamp(1.2rem, 5vw, 1.5rem); font-style: italic; font-weight: 500; line-height: 1.4; max-width: 28ch; margin: .6rem auto 0; color: var(--tc); text-shadow: var(--ts); opacity: clamp(0, calc(var(--tx, 0) * 5 - 3.9), 1); }
  .card {
    pointer-events: auto; width: min(100%, 380px);
    background: linear-gradient(rgba(24,10,16,.8), rgba(18,6,12,.9));
    border: 1px solid rgba(212,164,69,.65); border-radius: 18px;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,.8), inset 0 0 0 4px rgba(212,164,69,.12);
    padding: 1.1rem 1.3rem 1.2rem; color: #f8e7c4;
    --c: clamp(0, calc(var(--p, 0) * 8 - .9), 1);
    opacity: var(--c); transform: translateY(calc((1 - var(--c)) * 46px)) scale(calc(.96 + var(--c) * .04));
  }
  .details { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .4rem 1.1rem; font-size: 1.15rem; text-align: left; }
  .details dt { font-family: var(--caps); font-weight: 600; font-size: .82rem; letter-spacing: .14em; color: #ffd98a; align-self: center; }
  .details dd { margin: 0; font-style: italic; font-size: 1.2rem; }
  .dress { margin: .9rem 0 0; font-size: 1.12rem; font-style: italic; padding-top: .8rem; border-top: 1px solid rgba(212,164,69,.3); }
  .dress b { font-family: var(--caps); font-style: normal; font-size: .8rem; letter-spacing: .14em; color: #ffd98a; font-weight: 600; margin-right: .35em; }

  .savedate { position: relative; min-height: 115svh; padding: 16svh 7% 12svh; display: flex; flex-direction: column; align-items: center; text-align: center; }
  .savedate h2 { font-family: var(--script); font-weight: 400; font-size: clamp(3.6rem, 16vw, 6.4rem); margin: 0; line-height: 1.15; padding: 0 .25em; }
  .savedate .lede { color: var(--ink); opacity: .9; text-shadow: none; }
  .scratch { position: relative; width: min(88%, 360px); margin: 2rem 0 0; border-radius: 18px; overflow: hidden; background: #fff7e6; color: #4a1a14; box-shadow: 0 20px 50px -20px rgba(0,0,0,.8); }
  .dates { list-style: none; margin: 0; padding: 1.4rem 1.4rem 1.2rem; text-align: left; display: grid; gap: .6rem; font-size: 1.15rem; }
  .dates li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid rgba(74,26,20,.15); padding-bottom: .5rem; }
  .dates li:last-child { border-bottom: 0; }
  .dates b { font-family: var(--caps); font-weight: 600; font-size: .9rem; letter-spacing: .1em; } .dates span { font-style: italic; }
  .scratch canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; transition: opacity .9s ease; }
  .scratch canvas.done { opacity: 0; pointer-events: none; }
  .count { display: flex; gap: .7rem; margin: 2rem 0 .4rem; opacity: .4; transition: opacity 1s; }
  .count.live { opacity: 1; }
  .unit { display: flex; flex-direction: column; align-items: center; min-width: 4.2rem; }
  .digits { font-family: var(--caps); font-size: 2.3rem; font-weight: 500; line-height: 1; padding: .5rem .55rem; border-radius: 10px; background: linear-gradient(#5a2230, #2a0f18); box-shadow: inset 0 -1px 0 rgba(255,255,255,.08), 0 8px 18px -8px rgba(0,0,0,.8); perspective: 200px; }
  .digits span { display: inline-block; }
  .digits span.flip { animation: flip .5s cubic-bezier(.3,1.4,.5,1); }
  @keyframes flip { from { transform: rotateX(-90deg); opacity: .3; } to { transform: none; opacity: 1; } }
  .unit small { margin-top: .5rem; font-family: var(--caps); font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; opacity: .85; }
  .sample { font-size: .95rem; font-style: italic; opacity: .65; margin: .4rem 0 0; }
  .confetti { position: absolute; left: 50%; top: 45%; width: 10px; height: 7px; border-radius: 50% 40%; background: var(--c); animation: burst 1.6s cubic-bezier(.2,.7,.3,1) forwards; pointer-events: none; z-index: 3; }
  @keyframes burst { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } to { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(360deg) scale(1); opacity: 0; } }
  .next { position: relative; padding: 2.4rem 7% calc(3rem + env(safe-area-inset-bottom, 0px)); text-align: center; font-size: 1.1rem; font-style: italic; opacity: .85; }
  .next p { margin: 0 auto; max-width: 34ch; }

  .thread { position: fixed; z-index: 5; left: calc(env(safe-area-inset-left, 0px) + 9px); top: 20%; bottom: 20%; width: 2px; background: rgba(212,164,69,.3); opacity: 0; transition: opacity .8s; pointer-events: none; }
  .thread.on { opacity: 1; }
  .thread i { position: absolute; left: 50%; top: var(--p, 0%); width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%); background: #ffd98a; box-shadow: 0 0 10px 3px rgba(255,200,100,.75); }

  /* ---------- Fallback when WebGL is unavailable ---------- */
  .nogl #gl { display: none; }
  .nogl .gate-ui { background: #120a1c var(--gate-img) 50% 100% / auto 100% no-repeat; }
  .nogl .pin { background: var(--fg-img) 50% 50% / cover no-repeat, var(--bg-img) 50% 50% / cover no-repeat; }

  @media (prefers-reduced-motion: reduce) {
    .hand svg, .ripple, .gold-text { animation: none !important; }
    .gtext > * { animation-duration: .01ms !important; }
  }
