:root { --bg: #05060f; --ink: #eef1f8; --dim: #8f97ad; --cyan: #8ef0ff; --pink: #ff7ad9; --violet: #b58cff; --mint: #9dffb8; --lcd: #a7c48a; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

/* backdrop */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.holo { position: absolute; width: 90vmax; height: 90vmax; left: 50%; top: 50%; border-radius: 50%; filter: blur(70px); opacity: .65; transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg, #4a7bff, #ff6ad5, #7affd9, #b58cff, #ffd36a, #4a7bff); animation: spin 38s linear infinite; }
.holo2 { width: 60vmax; height: 60vmax; opacity: .35; animation-duration: 26s; animation-direction: reverse; filter: blur(90px); mix-blend-mode: screen; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; opacity: .35; }
.bg::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(5,6,15,.85) 100%); }

/* top */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; padding-top: max(14px, env(safe-area-inset-top)); }
.logo { margin: 0; font: 400 15px "Silkscreen", monospace; letter-spacing: 3px;
  background: linear-gradient(180deg, #fff 0%, #cfd8e8 42%, #6b7a99 50%, #e9eef8 60%, #fff 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbtns { display: flex; gap: 8px; }
.ib { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: var(--ink); cursor: pointer; backdrop-filter: blur(8px); font-size: 16px; }
.ib.off { color: var(--dim); text-decoration: line-through; }

/* stages */
.stage { position: relative; z-index: 2; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 70px 16px 84px; }
.stage[hidden] { display: none; }
.tilt { perspective: 1100px; position: relative; }
.pshadow { position: absolute; left: 10%; right: 10%; bottom: -4%; height: 12%; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(0,0,0,.75), rgba(0,0,0,0) 70%); filter: blur(10px); transform: translate(0, 0) scale(1); transition: transform .12s ease-out; }
.phone { position: relative; width: min(290px, 88vw, 31svh); aspect-ratio: 260 / 612; touch-action: none; user-select: none; -webkit-user-select: none; transform-style: preserve-3d; transition: transform .12s ease-out; animation: bob 6s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -6px; } }
.phone > svg, .phone .side { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.phone #phoneSvg { position: relative; }
.side { transform: translateZ(calc(var(--i) * -3.2px)); pointer-events: none; }
.lcd { position: absolute; left: 17.692%; top: 18.301%; width: 64.615%; height: 15.686%; image-rendering: pixelated; image-rendering: crisp-edges; box-shadow: inset 0 0 0 1px rgba(0,0,0,.4), inset 0 3px 8px rgba(0,0,0,.45); pointer-events: none; transform: translateZ(0.6px); }
.glass { position: absolute; left: 14.6%; top: 16.2%; width: 70.8%; height: 20.1%; border-radius: 4px; pointer-events: none; transform: translateZ(1px);
  background: linear-gradient(118deg, rgba(255,255,255,.28) 0%, rgba(255,255,255,.1) 28%, rgba(255,255,255,0) 44%, rgba(255,255,255,0) 70%, rgba(255,255,255,.08) 100%); mix-blend-mode: screen; }
.env { position: absolute; inset: 0; pointer-events: none; transform: translateZ(.5px); mix-blend-mode: screen; opacity: .75;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 612'%3E%3Cpath d='M60,2 L200,2 C232,2 250,24 250,60 L254,540 C255,585 235,610 170,610 L90,610 C25,610 5,585 6,540 L10,60 C10,24 28,2 60,2 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 612'%3E%3Cpath d='M60,2 L200,2 C232,2 250,24 250,60 L254,540 C255,585 235,610 170,610 L90,610 C25,610 5,585 6,540 L10,60 C10,24 28,2 60,2 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  background: linear-gradient(112deg, transparent 0%, rgba(142,240,255,.0) 28%, rgba(142,240,255,.38) 40%, rgba(255,255,255,.5) 46%, rgba(255,122,217,.35) 53%, transparent 66%); background-size: 260% 100%; background-position: var(--sx, 50%) 0; }
.glow { position: absolute; left: 12%; top: 14%; width: 76%; height: 24%; border-radius: 40%; background: var(--lcd); filter: blur(28px); opacity: .35; transform: translateZ(2px); transition: opacity .6s; pointer-events: none; }
.glow.off { opacity: .05; }
.crown { position: absolute; left: 50%; top: -8.5%; width: 64%; transform: translateX(-50%) translateZ(22px) rotate(-3deg); pointer-events: none; filter: drop-shadow(0 6px 8px rgba(0,0,0,.5)); }
.key { cursor: pointer; outline: none; }
.key .cap { transition: transform .05s; }
.key.pressed .cap, .key:active .cap { transform: translateY(1.2px); }
.key.pressed .cap[fill="url(#gKey)"], .key:active .cap[fill="url(#gKey)"] { fill: url(#gKeyP); }
.key.pressed .cap[fill="url(#gNavi)"], .key:active .cap[fill="url(#gNavi)"] { fill: url(#gNaviP); }
.key:focus-visible .cap { stroke: var(--cyan); stroke-width: 2.5; }

/* floating chrome pieces */
.deco { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.d { position: absolute; left: var(--x); top: var(--y); width: var(--w); transform: translate(calc(var(--px, 0px) * var(--z)), calc(var(--py, 0px) * var(--z))); will-change: transform; }
.d img { display: block; width: 100%; height: auto; transform: rotate(var(--r)); animation: floaty 7s ease-in-out infinite; animation-delay: calc(var(--t) * -1); filter: drop-shadow(0 18px 22px rgba(0,0,0,.55)); opacity: calc(.45 + var(--z) * .5); }
@keyframes floaty { 0%, 100% { translate: 0 0; } 50% { translate: 0 -14px; } }
.d-sparkle3, .d-sparkle2 { z-index: 3; }
.d-sparkle3 img, .d-sparkle2 img { animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { transform: rotate(var(--r)) scale(1); opacity: .9; } 50% { transform: rotate(calc(var(--r) + 20deg)) scale(.75); opacity: .5; } }
.d-drip img { animation: none; }
.hint { margin: 0; color: var(--dim); font-size: 13px; text-align: center; max-width: 380px; min-height: 2.9em; display: flex; align-items: center; justify-content: center; }
.hint b { color: var(--ink); }
.hint.faded { opacity: .45; }
.cta { border: 0; border-radius: 999px; padding: 13px 34px; font-weight: 700; font-size: 16px; color: #0b0e1a; cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), #6aa3ff 50%, var(--pink)); box-shadow: 0 10px 30px rgba(110,160,255,.35), inset 0 1px 0 rgba(255,255,255,.7); transition: transform .15s, box-shadow .15s; }
.cta:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(110,160,255,.5), inset 0 1px 0 rgba(255,255,255,.7); }
.cta:active { transform: translateY(0); }
.cta[disabled] { opacity: .45; cursor: default; transform: none; }

/* result */
.stage--result { gap: 14px; animation: rise .5s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.eyebrow { margin: 0; font: 400 11px "Silkscreen", monospace; letter-spacing: 2px; color: var(--dim); text-transform: uppercase; }
.hero { position: relative; width: min(504px, 92vw); aspect-ratio: 504 / 288; border-radius: 10px; overflow: hidden; background: #1b2419; box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 30px 60px rgba(0,0,0,.6), 0 0 80px rgba(167,196,138,.18); }
.hero img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.hero-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 400 13px "Silkscreen", monospace; color: var(--lcd); letter-spacing: 2px; background: #1b2419; }
.hero-busy[hidden] { display: none; }
.from-row input { width: min(320px, 80vw); text-align: center; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: var(--ink); padding: 9px 14px; font-size: 15px; outline: none; }
.from-row input:focus { border-color: var(--cyan); }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.act { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); color: var(--ink); border-radius: 999px; padding: 10px 20px; cursor: pointer; text-decoration: none; font-size: 14px; backdrop-filter: blur(8px); transition: background .15s, transform .15s; }
.act:hover { background: rgba(255,255,255,.14); transform: translateY(-1px); }
.act.primary { background: linear-gradient(135deg, var(--cyan), #6aa3ff 50%, var(--pink)); color: #0b0e1a; border-color: transparent; font-weight: 700; }
.act[disabled] { opacity: .4; cursor: default; }
.note { margin: 0; color: var(--dim); font-size: 13px; text-align: center; max-width: 380px; }
.back { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 14px; padding: 8px; }
.back:hover { color: var(--ink); }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(5,6,15,.72); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: min(560px, 100%); background: rgba(16,18,32,.9); border: 1px solid rgba(255,255,255,.14); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; align-items: center; animation: rise .3s ease-out; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.preview { width: 100%; display: flex; justify-content: center; }
.preview img, .preview video { max-width: 100%; max-height: 55vh; border-radius: 8px; image-rendering: pixelated; }
.sheet-title { margin: 0; font-weight: 700; }
.howto { margin: 0; padding: 0 0 0 18px; color: var(--ink); line-height: 1.8; align-self: stretch; }
.howto b { color: var(--cyan); }
.busy { cursor: progress; }

/* envelope flying off the phone */
.fly { position: fixed; z-index: 10; width: 60px; height: 44px; pointer-events: none; image-rendering: pixelated; animation: fly 1.3s cubic-bezier(.3,.8,.4,1) forwards; }
@keyframes fly { 0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(-50%, calc(-50% - 60vh)) scale(1.4) rotate(12deg); opacity: 0; } }

@media (max-width: 700px) {
  .d { display: none; }
  .d-disco, .d-heart, .d-star, .d-sparkle, .d-balloon-dog, .d-saturn, .d-butterfly, .d-sparkle3, .d-star-outline, .d-bow, .d-heart-outline { display: block; }
  .d img { opacity: .95; }
  .d-heart-outline { --x: -6vw; --y: 12vh; --w: 26vw; --z: .5; } .d-disco { --x: 70vw; --y: 7vh; --w: 32vw; --z: .5; } .d-heart { --x: 74vw; --y: 42vh; --w: 30vw; --z: .7; }
  .d-star { --x: 5vw; --y: 80vh; --w: 16vw; } .d-sparkle { --x: 84vw; --y: 28vh; --w: 13vw; } .d-balloon-dog { --x: -8vw; --y: 50vh; --w: 34vw; --z: .6; } .d-saturn { --x: 56vw; --y: 70vh; --w: 46vw; --z: .4; }
  .d-butterfly { --x: -3vw; --y: 26vh; --w: 25vw; } .d-sparkle3 { --x: 66vw; --y: 22vh; --w: 9vw; } .d-star-outline { --x: 80vw; --y: 60vh; --w: 18vw; } .d-bow { --x: 2vw; --y: 66vh; --w: 20vw; }
  .logo { font-size: 12px; letter-spacing: 2px; } .stage { padding-top: 66px; gap: 12px; } .phone { width: min(82vw, 33svh); } .crown { width: 50%; top: -5.5%; } .cta { padding: 12px 30px; }
  .hint { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .holo, .phone { animation: none; } }
