:root {
  --bg: #0a0e2a;
  --bg2: #1a1440;
  --ink: #ffffff;
  --muted: #b8c0e6;
  --pink: #ff6bb3;
  --purple: #8b5cf6;
  --gold: #ffd166;
  --cyan: #5ee0ff;
  --panel: rgba(20, 22, 58, 0.82);
  --font-head: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- scenes ---------- */
.scene {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.7s ease;
  padding: 24px;
  z-index: 2;
}
.scene.active { opacity: 1; pointer-events: auto; }

.center-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; max-width: 520px; width: 100%; }

.hidden { display: none !important; }

/* ---------- typography ---------- */
.eyebrow { font-family: var(--font-head); color: var(--cyan); letter-spacing: 2px; font-size: 13px; text-transform: uppercase; }

.title {
  font-family: var(--font-head);
  font-size: clamp(34px, 9vw, 64px);
  line-height: 1.05;
  font-weight: 700;
  text-shadow: 0 0 30px rgba(139, 92, 246, 0.55);
}
.grad {
  background: linear-gradient(90deg, var(--pink), var(--purple), var(--cyan));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.h2 { font-family: var(--font-head); font-size: clamp(28px, 7vw, 44px); font-weight: 600; }

.subtitle { color: var(--muted); font-size: clamp(15px, 4vw, 19px); }

.hint { color: var(--muted); font-size: 14px; letter-spacing: 1px; }

/* ---------- slide to start ---------- */
.slide { width: min(340px, 88vw); margin-top: 12px; position: relative; cursor: grab; touch-action: none; }
.slide-track {
  position: relative; height: 66px; border-radius: 40px;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.slide-label {
  color: var(--muted); font-family: var(--font-head); font-size: 15px; letter-spacing: 0.5px;
  transition: opacity 0.3s; padding: 0 12px 0 64px;
}
.slide-handle {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 58px; height: 58px;
  background: linear-gradient(180deg, #fff1b8, #ffb703);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  box-shadow: 0 0 24px rgba(255, 200, 60, 0.85);
  transition: filter 0.12s;
}
.slide-handle.dragging { filter: brightness(1.15) drop-shadow(0 0 14px rgba(255, 220, 90, 0.95)); }

/* ---------- outfit ---------- */
#avatar { border-radius: 24px; background: radial-gradient(circle at 50% 30%, rgba(139,92,246,0.25), transparent 70%); max-width: 100%; height: auto; display: block; }
.pickers { display: flex; flex-direction: column; gap: 10px; width: min(320px, 90vw); }
.picker {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px; padding: 10px 14px;
}
.opt { display: flex; flex-direction: column; align-items: center; flex: 1; }
.opt-label { font-family: var(--font-head); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.opt-name { font-family: var(--font-head); font-size: 19px; font-weight: 600; }
.nav {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff; font-size: 24px; line-height: 1; cursor: pointer;
  box-shadow: 0 3px 12px rgba(139,92,246,0.4);
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-head); font-weight: 600; font-size: 18px;
  border: none; border-radius: 40px; cursor: pointer; letter-spacing: 0.5px;
  padding: 14px 30px; color: #fff;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 6px 22px rgba(255, 107, 179, 0.45);
}
.btn-skip {
  background: rgba(255,255,255,0.08); color: var(--muted);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 40px;
  font-family: var(--font-head); font-size: 15px; padding: 9px 18px; cursor: pointer;
}

/* ---------- captions ---------- */
.caption-box { display: flex; flex-direction: column; align-items: center; gap: 22px; max-width: 560px; }
.caption {
  font-family: var(--font-head); font-size: clamp(22px, 6vw, 38px); font-weight: 600;
  line-height: 1.35; text-shadow: 0 2px 24px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.scene.active .caption { opacity: 1; transform: translateY(0); }

.treasure-note { font-family: var(--font-head); color: var(--gold); font-size: clamp(17px, 4.5vw, 22px); }

/* ---------- game hud ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 0; gap: 12px; z-index: 3;
}
.hud-pill {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 40px; padding: 8px 16px; font-family: var(--font-head); font-size: 16px;
}
.hud-pill b { color: var(--gold); }
.game-hint {
  position: absolute; top: 46%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 92vw;
  color: #fff; font-family: var(--font-head);
  font-size: clamp(24px, 6vw, 40px); font-weight: 600; letter-spacing: 1px; line-height: 1.3;
  text-shadow: 0 0 22px rgba(94,224,255,0.9), 0 2px 6px rgba(0,0,0,0.5);
  pointer-events: none; text-align: center;
  animation: hintPop 3.2s ease forwards;
}
@keyframes hintPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  22%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
}
#scene-game { touch-action: none; }

/* ---------- letter ---------- */
.letter-wrap { perspective: 1200px; width: min(680px, 94vw); margin: auto; }
#scene-letter { overflow-y: auto; align-items: flex-start; }
.letter {
  position: relative; width: 100%; padding: 24px;
  background:
    radial-gradient(1.5px 1.5px at 12% 20%, #ffd166 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 30% 8%, #ffffff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 52% 14%, #5ee0ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 74% 10%, #ffd166 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 90% 22%, #ffffff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 95% 46%, #5ee0ff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 88% 70%, #ffd166 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 74% 88%, #ffffff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 52% 92%, #5ee0ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 30% 90%, #ffd166 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 12% 74%, #ffffff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 7% 44%, #5ee0ff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 40% 50%, #ffffff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 62% 62%, #ffffff 50%, transparent 51%),
    linear-gradient(180deg, #0b1030, #131a4a);
  color: #fff; border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.16);
  box-shadow: 0 30px 70px rgba(0,0,0,0.55);
  text-align: left;
  transform: translateY(-130vh) rotate(-2deg);
}
.letter::before {
  content: ""; position: absolute; inset: 7px;
  border: 1px solid rgba(255,255,255,0.14); border-radius: 11px;
  pointer-events: none;
}
.corner { position: absolute; color: #ffd166; font-size: 16px; pointer-events: none; z-index: 2; text-shadow: 0 0 8px rgba(255,209,102,0.7); }
.corner.c1 { top: 10px; left: 12px; } .corner.c2 { top: 10px; right: 12px; color: #5ee0ff; text-shadow: 0 0 8px rgba(94,224,255,0.7); }
.corner.c3 { bottom: 12px; left: 12px; } .corner.c4 { bottom: 12px; right: 12px; color: #5ee0ff; text-shadow: 0 0 8px rgba(94,224,255,0.7); }
.deco-saturn { position: absolute; top: 16px; left: 15px; width: 30px; height: 30px; z-index: 2; pointer-events: none; }
.deco-saturn::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 54px; height: 18px;
  transform: translate(-50%, -50%) rotate(-26deg);
  border: 3px solid #c9a4ff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.deco-saturn::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #7fd0ff, #2f76d8 68%, #1d4f9c);
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
}
.deco-cloud {
  position: absolute; left: 10px; right: 10px; bottom: 8px; height: 22px; z-index: 2;
  background:
    radial-gradient(circle at 18% 100%, #aee6ff 62%, transparent 63%),
    radial-gradient(circle at 50% 100%, #aee6ff 62%, transparent 63%),
    radial-gradient(circle at 82% 100%, #aee6ff 62%, transparent 63%);
  opacity: 0.95; pointer-events: none;
}
.star { position: absolute; pointer-events: none; z-index: 2; }
.star.s1 { color: #ffd166; font-size: 12px; top: 34%; left: 6%; text-shadow: 0 0 7px rgba(255,209,102,0.8); }
.star.s2 { color: #5ee0ff; font-size: 10px; top: 64%; right: 7%; text-shadow: 0 0 7px rgba(94,224,255,0.8); }
.star.s3 { color: #ffffff; font-size: 9px; top: 20%; right: 24%; }
.divider { text-align: center; color: #e2b64f; letter-spacing: 8px; margin: 22px 0 16px; }
.letter.drop { animation: letterDrop 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
@keyframes letterDrop { to { transform: translateY(0) rotate(0); } }

.letter-seal {
  position: absolute; top: -18px; right: 26px; width: 46px; height: 46px;
  border-radius: 50%; background: linear-gradient(135deg, var(--pink), #e63946);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: 0 4px 14px rgba(230,57,70,0.5);
  z-index: 3;
  animation: sealPop 0.5s 1s ease backwards;
}
@keyframes sealPop { from { transform: scale(0); } to { transform: scale(1); } }

.letter-inner {
  font-family: "Poppins", var(--font-body); font-size: clamp(13.5px, 3.2vw, 15.5px); line-height: 1.8;
  background: #fffdf7; color: #4a3a52;
  padding: 40px;
  border-radius: 255px 20px 225px 20px / 20px 225px 20px 255px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14), inset 0 -8px 22px rgba(214,185,140,0.2);
  transform-origin: top; transform: scaleY(0);
  position: relative; z-index: 1;
}
.letter.unfold .letter-inner { animation: unfold 1.2s 0.8s ease forwards; }
@keyframes unfold { to { transform: scaleY(1); } }

.letter-inner p { margin-bottom: 14px; }
.letter-inner .salute { font-weight: 700; }
.letter-inner .quote { font-style: italic; color: #8b5cf6; }
.letter-inner .love { font-weight: 700; color: #ff6bb3; font-size: 1.08em; }
.letter-inner .love-heart { text-align: center; font-size: 24px; line-height: 1; margin-top: 14px; }
.letter-inner .sign { margin-top: 26px; margin-bottom: 0; color: #6b5f77; }
.letter-inner .sign-name { font-family: var(--font-head); font-size: 1.25em; font-weight: 600; color: #4a3a52; }

/* ---------- landscape hint (mobile portrait) ---------- */
.rotate-hint {
  position: fixed; inset: 0; z-index: 200;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 32px;
  background: radial-gradient(circle at 50% 30%, #1a1440, #0a0e2a);
  color: #fff;
}
.rotate-hint.show { display: flex; }
.rotate-phone { font-size: 64px; animation: phoneRock 1.8s ease-in-out infinite; }
@keyframes phoneRock {
  0%, 30%, 100% { transform: rotate(0deg); }
  45%, 80% { transform: rotate(90deg); }
}
.rotate-title { font-family: var(--font-head); font-size: 26px; font-weight: 700; }
.rotate-sub { color: var(--muted); font-size: 15px; }

/* ---------- letter hint: small, pinned top-right ---------- */
#letterHint {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 14px;
  margin: 0; font-size: 11px; letter-spacing: 0.4px;
  color: rgba(184, 192, 230, 0.72); z-index: 4; pointer-events: none;
}

/* ---------- portrait tweaks: letter (near full-screen) ---------- */
@media (orientation: portrait) {
  .letter-wrap { width: 100%; }
  .letter-inner { padding: 22px 16px; font-size: 13.5px; line-height: 1.6; }
  .letter-inner p { margin-bottom: 10px; }
  .letter-inner .sign { margin-top: 18px; }
  .letter-seal { right: 18px; }
}
