: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: 1300px; position: relative; animation: arrive 1.1s cubic-bezier(.2,.9,.3,1.1) both; }
@keyframes arrive { from { opacity: 0; transform: translateY(60px) scale(.86) rotateY(-28deg); } }
.pshadow { position: absolute; left: 12%; right: 12%; bottom: -3%; height: 9%; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(0,0,0,.75), rgba(0,0,0,0) 70%); filter: blur(10px); }
.phone { position: relative; width: min(300px, 86vw, calc((100svh - 210px) / 2.354)); aspect-ratio: 260 / 612; touch-action: manipulation; user-select: none; -webkit-user-select: none; transform-style: preserve-3d; animation: bob 6s ease-in-out infinite 1.2s; }
@keyframes bob { 50% { translate: 0 -6px; } }
.base, .lid { position: absolute; left: 0; width: 100%; transform-style: preserve-3d; }
.base { top: 46.732%; height: 53.268%; }
.lid { top: 0; height: 49.02%; transform-origin: 50% 100%; transform: rotateX(0deg); transition: transform .9s cubic-bezier(.3,1.3,.45,1); }
.phone.closed .lid { transform: rotateX(-180deg); transition-timing-function: cubic-bezier(.5,0,.3,1); transition-duration: .7s; }
.face, .slice { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.slice { transform: translateZ(var(--z)); pointer-events: none; }
.lid-front, .lid-back { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; transform-style: preserve-3d; }
.lid-front { transform: translateZ(.6px); }
.lid-back { transform: translateZ(-7.5px) rotateX(180deg); }
.lcd { position: absolute; left: 6.923%; top: 12.667%; width: 86.154%; height: 71.111%; box-sizing: border-box; padding: 4.2% 4.2% 3.8%; background-color: #a7c48a; border-radius: 3px; 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); cursor: pointer; touch-action: none; transform: translateZ(.5px); }
.kbd { position: absolute; left: 6.923%; top: 12.667%; width: 86.154%; height: 60%; opacity: 0; font-size: 16px; border: 0; padding: 0; resize: none; pointer-events: none; color: transparent; background: transparent; caret-color: transparent; transform: translateZ(.4px); }
.outer { position: absolute; left: 31.538%; top: 30.667%; width: 36.923%; height: 30.333%; image-rendering: pixelated; pointer-events: none; transform: translateZ(.5px); border-radius: 2px; }
.glow { position: absolute; left: 3%; top: 9%; width: 94%; height: 80%; border-radius: 30%; background: var(--lcd); filter: blur(30px); opacity: .32; transform: translateZ(-1px); transition: opacity .6s; pointer-events: none; }
.glow.off, .phone.closed .glow { opacity: 0; }
.env { position: absolute; inset: 0; pointer-events: none; transform: translateZ(.8px); mix-blend-mode: screen; opacity: .7;
  background: linear-gradient(112deg, transparent 0%, rgba(142,240,255,0) 28%, rgba(142,240,255,.36) 40%, rgba(255,255,255,.48) 46%, rgba(255,122,217,.32) 53%, transparent 66%); background-size: 260% 100%; background-position: var(--sx, 50%) 0; }
.env-lid { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 300'%3E%3Cpath d='M32,4 H228 C246,4 256,15 256,34 V282 C256,293 250,300 238,300 H22 C10,300 4,293 4,282 V34 C4,15 14,4 32,4 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 300'%3E%3Cpath d='M32,4 H228 C246,4 256,15 256,34 V282 C256,293 250,300 238,300 H22 C10,300 4,293 4,282 V34 C4,15 14,4 32,4 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.env-base { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 326'%3E%3Cpath d='M20,2 H240 C251,2 256,8 256,18 V284 C256,310 238,324 212,324 H48 C22,324 4,310 4,284 V18 C4,8 9,2 20,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 326'%3E%3Cpath d='M20,2 H240 C251,2 256,8 256,18 V284 C256,310 238,324 212,324 H48 C22,324 4,310 4,284 V18 C4,8 9,2 20,2 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat; opacity: .5; }
.crown { position: absolute; left: 50%; top: -16%; width: 62%; transform: translateX(-50%) translateZ(18px) rotate(-3deg); pointer-events: none; filter: drop-shadow(0 6px 8px rgba(0,0,0,.5)); }
.flipzone { position: absolute; left: 4%; right: 4%; border: 0; background: transparent; cursor: pointer; transform: translateZ(14px); -webkit-tap-highlight-color: transparent; }
.phone.closed .flipzone { top: 44%; bottom: 0; }
.phone:not(.closed) .flipzone { top: 47.2%; height: 3.6%; left: 8%; right: 8%; cursor: n-resize; }
.flipzone:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; border-radius: 20px; }
.phone.closed .tapme { opacity: 1; }
.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(#gRing)"], .key:active .cap[fill="url(#gRing)"] { fill: url(#gKeyP); }
.key.pressed .cap[fill="url(#gOk)"], .key:active .cap[fill="url(#gOk)"] { fill: url(#gOkP); }
.key:focus-visible .cap { stroke: var(--cyan); stroke-width: 2.5; }
.klabel { transition: fill .4s; }
.phone.lit:not(.closed) .klabel:not(.heart) { fill: #2f8cff; }
.phone.lit:not(.closed) .klabel.sub { fill: #4f9dff; }

/* 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, .act.primary {
  position: relative; isolation: isolate; border: 0; border-radius: 999px; padding: 14px 34px; font-weight: 800; font-size: 16px; letter-spacing: .2px; cursor: pointer;
  color: #1b2236; text-shadow: 0 1px 0 rgba(255,255,255,.85);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255,255,255,.95) 0%, rgba(255,255,255,0) 55%),
    linear-gradient(180deg, #ffffff 0%, #e6eaf2 18%, #b9c2d3 46%, #8e99b0 54%, #c9d1df 78%, #f4f6fa 100%);
  box-shadow:
    inset 0 2px 1px rgba(255,255,255,.95), inset 0 -3px 6px rgba(70,82,110,.45), inset 0 0 0 1px rgba(255,255,255,.55),
    0 0 0 1.5px rgba(36,45,66,.55), 0 10px 22px rgba(0,0,0,.45), 0 2px 3px rgba(0,0,0,.35);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.cta::after, .act.primary::after {
  content: ''; position: absolute; left: 12%; right: 12%; top: 3px; height: 42%; border-radius: 999px; pointer-events: none; z-index: -1;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.08));
}
.cta::before, .act.primary::before {
  content: ''; position: absolute; inset: -3px; border-radius: 999px; z-index: -2; pointer-events: none; opacity: .55;
  background: linear-gradient(110deg, rgba(142,240,255,.0) 20%, rgba(142,240,255,.55) 40%, rgba(255,255,255,.7) 50%, rgba(255,122,217,.5) 60%, rgba(255,122,217,0) 80%);
  background-size: 250% 100%; animation: sheen 4.5s ease-in-out infinite; filter: blur(3px);
}
@keyframes sheen { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0% 0; } }
.cta:hover, .act.primary:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.05); }
.cta:active, .act.primary:active { transform: translateY(1px) scale(.98);
  box-shadow: inset 0 2px 5px rgba(60,72,100,.55), inset 0 -1px 1px rgba(255,255,255,.7), 0 0 0 1.5px rgba(36,45,66,.55), 0 4px 10px rgba(0,0,0,.4); }
.cta[disabled] { opacity: .55; cursor: default; transform: none; filter: grayscale(.4); }

/* 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(400px, 84vw, 44svh); aspect-ratio: 90 / 86; 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[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(86vw, calc((100svh - 176px) / 2.354)); } .crown { width: 54%; top: -13%; } .cta { padding: 12px 30px; }
  .hint { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .holo, .phone { animation: none; } }

.stage--phone { padding: 58px 16px 34px; gap: 10px; }
.stage--phone .side { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stage--phone .hint { font-size: 12.5px; min-height: 2.7em; max-width: 340px; }
@media (min-aspect-ratio: 5/4) and (min-width: 760px) {
  .stage--phone { --pw: min(330px, calc((100svh - 100px) / 2.354)); padding: 56px 32px 24px; }
  .stage--phone .phone { width: var(--pw); }
  .stage--phone .side { position: absolute; left: calc(50% + var(--pw) / 2 + 56px); top: 50%; transform: translateY(-50%); align-items: flex-start; width: min(300px, calc(50% - var(--pw) / 2 - 76px)); }
  .stage--phone .hint { text-align: left; justify-content: flex-start; font-size: 14px; color: #b9c0d4; }
  .d-heart { --x: 77vw !important; --y: 64vh !important; --w: 8vw !important; } .d-bow { --x: 90vw !important; --y: 80vh !important; } .d-saturn { --x: 63vw !important; --y: 82vh !important; }
}
@media (max-width: 480px) { .stage--phone { padding-top: 54px; padding-bottom: 56px; } .stage--phone .phone { width: min(86vw, calc((100svh - 232px) / 2.354)); } }

.dock { display: flex; align-items: center; justify-content: center; gap: 6px; }
.dk { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 54px; padding: 7px 0 5px; border-radius: 16px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: var(--ink); cursor: pointer; backdrop-filter: blur(8px); transition: background .15s, transform .15s; }
.dk span { font-size: 10.5px; letter-spacing: .2px; color: #cdd4e6; }
.dk:hover { background: rgba(255,255,255,.15); transform: translateY(-1px); }
.dk:active { transform: translateY(1px); }
.dock .cta { white-space: nowrap; padding: 13px 18px; font-size: 14.5px; margin: 0 2px; }
@media (max-width: 400px) { .dk { width: 48px; } .dock { gap: 4px; } .dock .cta { padding: 12px 12px; font-size: 13.5px; } }
@media (min-aspect-ratio: 5/4) and (min-width: 760px) {
  .dock { flex-wrap: wrap; justify-content: flex-start; max-width: 300px; }
  .dock .cta { order: -1; width: 100%; margin: 0 0 6px; }
}

.stage--result { gap: 10px; padding-top: 56px; padding-bottom: 32px; }
.stage--result .actions { flex-wrap: nowrap; gap: 6px; }
.stage--result .act { padding: 9px 14px; font-size: 13.5px; }
@media (max-width: 380px) { .stage--result .act { padding: 9px 11px; font-size: 13px; } }

/* mobile comfort */
html, body { overscroll-behavior: none; }
.phone, .phone * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.stage--phone { touch-action: manipulation; }
.ib.pill { width: auto; border-radius: 999px; padding: 0 13px 0 11px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.ib svg { display: block; }
@media (max-width: 360px) { .ib.pill span { display: none; } .ib.pill { padding: 0 9px; } }
/* full screen mode */
.fs-exit { position: fixed; z-index: 30; top: max(10px, env(safe-area-inset-top)); right: 10px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.28); background: rgba(10,12,24,.55); color: #fff; display: none; align-items: center; justify-content: center; backdrop-filter: blur(8px); cursor: pointer; }
.fs-tip { position: fixed; z-index: 30; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; width: max-content; max-width: 90vw; text-align: center; font-size: 12px; color: #cdd4e6; background: rgba(10,12,24,.7); padding: 7px 12px; border-radius: 999px; backdrop-filter: blur(8px); }
.fs-tip[hidden] { display: none; }
body.focus .fs-exit { display: flex; }
body.focus .top, body.focus .stage--phone .side, body.focus .deco, body.focus .pshadow { display: none !important; }
body.focus .stage--phone { padding: max(8px, env(safe-area-inset-top)) 6px max(8px, env(safe-area-inset-bottom)); gap: 0; }
body.focus .stage--phone .phone, body.focus .phone { width: min(calc(100vw - 12px), calc((100svh - 16px) / 2.354)) !important; animation: none; }
body.focus .tilt { animation: none; }
