:root {
  --accent: #3fd0ff;
  --bg: #0b1022;
  --ink: #f4f7ff;
  --muted: #b4bddb;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { margin: 0; }

.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; min-width: 44px; padding: 0 24px; border-radius: 16px; border: 2px solid var(--accent);
  background: var(--accent); color: #0b0d1a; font: 700 1.05rem system-ui, sans-serif;
  text-decoration: none; cursor: pointer; box-shadow: 0 5px 0 rgba(0, 0, 0, .4);
  touch-action: manipulation;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.big { min-height: 60px; padding: 0 36px; font-size: 1.3rem; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn:focus-visible { outline-color: #fff; box-shadow: 0 0 0 6px #0b1022, 0 0 0 9px #fff; outline: none; }

/* Full-screen scenes: no page scroll */
body.scene { position: fixed; inset: 0; width: 100%; height: 100dvh; overflow: hidden; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.overlay {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: max(24px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  pointer-events: none; text-align: center;
}
.overlay > * { pointer-events: auto; }
.brand { font-size: clamp(1.8rem, 6vw, 2.8rem); letter-spacing: .08em; font-weight: 800; pointer-events: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .7); }

/* Surprise page */
.surprise { justify-content: flex-end; gap: 14px; }
.surprise .spacer { flex: 1; pointer-events: none; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.reveal { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 560px;
  visibility: hidden; opacity: 0; transform: translateY(16px);
  transition: opacity .6s, transform .6s, visibility 0s .6s; }
.reveal.in { visibility: visible; opacity: 1; transform: none; transition: opacity .6s, transform .6s; }
.card { width: 100%; max-height: 38dvh; overflow: auto; padding: 16px 18px; border-radius: 20px;
  background: rgba(11, 16, 34, .82); border: 2px solid var(--accent); backdrop-filter: blur(4px); }
.card h1 { font-size: clamp(1.3rem, 5vw, 1.8rem); color: var(--accent); overflow-wrap: anywhere; }
.card p { margin: 8px 0 0; font-size: clamp(1.1rem, 4.4vw, 1.4rem); white-space: pre-wrap; overflow-wrap: anywhere; }
.panel { margin: auto; max-width: 420px; padding: 24px; border-radius: 20px; background: rgba(11, 16, 34, .9);
  border: 2px solid var(--accent); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.panel[hidden] { display: none; }
#again[hidden], #tap[hidden] { display: none; }

/* Maker page */
.maker-page { min-height: 100dvh; background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 28%, var(--bg)), var(--bg) 70%) fixed; }
.maker { max-width: 480px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.maker-head { display: flex; align-items: center; gap: 8px; }
.maker-head h1 { font-size: 1.4rem; }
.back { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-size: 1.5rem;
  color: var(--ink); text-decoration: none; border-radius: 12px; }
.field { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field legend { font-weight: 700; padding: 0; display: flex; justify-content: space-between; }
.count { color: var(--muted); font-weight: 400; font-size: .85rem; }
input[type=text], textarea {
  width: 100%; background: #151c38; color: var(--ink); border: 2px solid #4a5688; border-radius: 12px;
  padding: 12px; font: inherit; font-size: 16px; min-height: 48px; resize: none;
}
input[type=text]:focus-visible, textarea:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-color: var(--accent); }
.moods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.moods input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 12px; text-align: center; border-radius: 14px; border: 2px solid #4a5688;
  background: #151c38; font-weight: 700; cursor: pointer; }
.moods .chip { justify-content: center; }
.moods input:checked + .chip { background: var(--chip); border-color: var(--chip); color: #0b0d1a; }
.moods input:focus-visible + .chip { outline: 3px solid #fff; outline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }
.status { margin: 0; min-height: 1.4em; color: var(--muted); }

.preview { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
.preview[hidden] { display: none; }
.preview .close { margin: 10px 16px; align-self: flex-end; }
.frame-host { flex: 1; min-height: 0; }
.frame-host iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .reveal, .reveal.in { transition: none; transform: none; }
  .btn:active { transform: none; }
}

/* Home: particle field. body.static = no WebGL (list of captions), body.live = field running */
body.home { background: #05070f; }
.home-main { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 72px 20px 40px; text-align: center; }
.home .brand { font-size: clamp(2.2rem, 10vw, 4.2rem); letter-spacing: .06em; pointer-events: auto; }
.forms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 1.1rem; color: var(--ink); }
.home #c, .home .vignette, .home .caption, .home .dots { display: none; }
body.home.live { position: fixed; inset: 0; width: 100%; height: 100dvh; overflow: hidden; }
.live #c { display: block; touch-action: none; cursor: crosshair; }
.live .vignette { display: block; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(0, 0, 0, .62) 100%); }
.live .forms { display: none; }
.live .home-main { position: fixed; inset: 0; min-height: 0; padding: 0; pointer-events: none; display: block; }
.live .caption { display: block; position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); margin: 0; padding: 0 20px;
  min-height: 2.9em; font-size: clamp(1rem, 2.5vw, 1.45rem); line-height: 1.4; letter-spacing: .04em; text-align: center; color: var(--ink);
  text-shadow: 0 0 14px rgba(5, 7, 15, .95), 0 2px 4px rgba(0, 0, 0, .8); opacity: 0; transition: opacity .5s; font-variant-numeric: tabular-nums; }
.live .caption.on { opacity: 1; }
.live .dots { display: flex; position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); justify-content: center; pointer-events: none; }
.dot { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; position: relative; pointer-events: auto; touch-action: manipulation; }
.dot::before { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: #8e9acb; transition: transform .3s, background .3s, box-shadow .3s; }
.dot[aria-current="true"]::before { background: #fff; transform: scale(1.5); box-shadow: 0 0 12px #3fd0ff; }
.dot:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.surprise-link { position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); z-index: 2;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted);
  font-size: .95rem; letter-spacing: .03em; text-decoration: none; text-shadow: 0 0 8px #05070f; }
.surprise-link:hover { color: var(--ink); text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  .live .caption, .dot::before { transition: none; }
}
