:root {
  --navy-950: #081427;
  --navy-900: #0E213C;
  --navy-800: #183456;
  --navy-700: #274872;
  --ivory: #FFF8EE;
  --ivory-dim: #E6DCC8;
  --gold: #E0C36A;
  --gold-soft: #F0DC9A;
  --line: rgba(255,248,238,.18);
  --danger: #E07070;
  --accent: var(--gold);
  --accent-soft: rgba(224,195,106,.22);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --font: "Manrope", system-ui, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}
  --surface: #152A4A;
#phone[data-world="kids"] {
  --accent: #2BB3A8;
  --accent-soft: rgba(43,179,168,.22);
  --navy-950: #0A2A2E;
  --navy-900: #0F3A3F;
  --navy-800: #165055;
  --surface: #1A5A5E;
}
#phone[data-world="young"] {
  --accent: #6B8CFF;
  --accent-soft: rgba(107,140,255,.22);
}
#phone[data-world="adults"] {
  --accent: #C48962;
  --accent-soft: rgba(196,137,98,.22);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: #050B16;
  color: var(--ivory);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { max-width: 100%; display: block; }
a { color: var(--gold-soft); }

#app {
  min-height: 100%; display: grid; place-items: center; padding: 12px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(224,195,106,.16), transparent 45%),
    radial-gradient(ellipse at 90% 100%, rgba(39,72,114,.45), transparent 42%),
    #050B16;
}
#phone {
  width: min(100%, 430px);
  height: min(100dvh - 24px, 900px);
  position: relative; border-radius: 28px; overflow: hidden;
  background: var(--navy-950);
  box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,248,238,.08);
}
#phone[data-world="kids"] {
  background: linear-gradient(180deg, #0F3A3F 0%, #0A2A2E 40%, #081820 100%);
}
#screen { position: absolute; inset: 0; overflow: hidden; }

/* Animations: NEVER start at opacity 0 with fill-mode both (breaks headless + slow devices) */
.fade { opacity: 1; }
.slide-in { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .fade { animation: rise .28s ease-out; }
}
@keyframes rise {
  from { transform: translateY(10px); opacity: .92; }
  to { transform: none; opacity: 1; }
}

.toast {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-bot));
  transform: translateX(-50%) translateY(16px); opacity: 0; pointer-events: none;
  background: rgba(24,52,86,.96); border: 1px solid var(--line); color: var(--ivory);
  padding: 10px 14px; border-radius: 999px; font-size: 13px; z-index: 40; transition: .25s; max-width: 90%;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal {
  position: absolute; inset: 0; background: rgba(5,11,22,.72); display: grid; place-items: center;
  z-index: 50; padding: 22px; backdrop-filter: blur(8px);
}
.modal.hide { display: none !important; }
.modal-card {
  width: 100%; max-width: 360px;
  background: linear-gradient(180deg, #1C3A5E, #122844);
  border: 1px solid rgba(224,195,106,.35); border-radius: 22px; padding: 20px;
  color: var(--ivory);
}
.ad-slot { position: absolute; inset: 0; z-index: 60; background: rgba(5,11,22,.9); display: grid; place-items: center; padding: 24px; }
.ad-slot.hide { display: none !important; }
.ad-inner { width: 100%; max-width: 320px; border: 1px dashed rgba(224,195,106,.45); border-radius: 18px; padding: 20px; text-align: center; background: var(--navy-900); }
.ad-label { display: inline-block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); border: 1px solid rgba(224,195,106,.4); padding: 4px 10px; border-radius: 999px; }

.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 12;
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + var(--safe-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(8,20,39,.92), transparent);
}
.topbar .sp { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255,248,238,.1); border: 1px solid var(--line); font-size: 15px; color: var(--ivory);
}
.coin {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; color: var(--ivory);
  padding: 8px 12px; border-radius: 999px; background: rgba(224,195,106,.18); border: 1px solid rgba(224,195,106,.45);
}
.coin .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, var(--gold) 50%, #9a7a28); box-shadow: inset 0 0 0 1.5px #9a7a28;
}
.world-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 55%, white);
  color: var(--ivory); font-size: 12px; font-weight: 800; letter-spacing: .04em;
}
.btn {
  display: block; width: 100%; text-align: center; font-weight: 800; border-radius: 16px; padding: 14px 16px;
  background: linear-gradient(135deg, var(--gold), #C9A44A);
  color: #0A1424; box-shadow: 0 10px 28px rgba(224,195,106,.28);
}
.btn.secondary {
  background: rgba(255,248,238,.1); color: var(--ivory); box-shadow: none;
  border: 1px solid rgba(255,248,238,.22);
}
.btn.ghost { background: transparent; color: var(--ivory-dim); box-shadow: none; border: 1px solid var(--line); margin-top: 8px; }
.btn:disabled { opacity: .45; }
.chip {
  display: inline-flex; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: rgba(255,248,238,.14); border: 1px solid var(--line); color: var(--ivory);
}

.page {
  position: absolute; inset: 0; overflow: auto;
  padding: calc(18px + var(--safe-top)) 18px calc(24px + var(--safe-bot));
  background: transparent;
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brand-row img {
  width: 56px; height: 56px; border-radius: 16px; object-fit: cover;
  border: 2px solid rgba(224,195,106,.55);
  box-shadow: 0 0 0 3px rgba(224,195,106,.15), 0 8px 24px rgba(0,0,0,.35);
}
.brand-row h1 {
  font-family: var(--serif); font-size: 32px; margin: 0; font-weight: 700;
  color: var(--ivory); letter-spacing: .01em;
}
.brand-row p { margin: 2px 0 0; color: var(--ivory-dim); font-size: 13px; }
.sec {
  margin: 18px 0 10px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-soft); font-weight: 800;
}
.muted { color: var(--ivory-dim); line-height: 1.45; }

/* World picker cards with posters */
.world-grid { display: grid; gap: 14px; }
.world-card {
  position: relative; text-align: left; min-height: 148px; padding: 0;
  border-radius: 22px; overflow: hidden;
  border: 1px solid rgba(255,248,238,.2);
  box-shadow: 0 14px 32px rgba(0,0,0,.35);
  background: var(--navy-800) center/cover no-repeat;
}
.world-card .wc-ov {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(8,20,39,.88) 0%, rgba(8,20,39,.55) 45%, rgba(8,20,39,.25) 100%);
}
.world-card .wc-body { position: relative; z-index: 1; padding: 18px 16px; min-height: 148px; display: flex; flex-direction: column; justify-content: flex-end; }
.world-card .wtitle {
  font-family: var(--serif); font-size: 30px; margin: 0 0 4px; color: #FFF8EE; font-weight: 700;
  text-shadow: 0 2px 12px rgba(0,0,0,.45);
}
.world-card .wsub { color: #F0E6D4; font-size: 13px; font-weight: 600; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
.world-card .badge {
  margin-top: 10px; align-self: flex-start;
  background: rgba(0,0,0,.35); border-color: rgba(255,248,238,.25); color: #FFF8EE;
}
.world-card.locked { filter: grayscale(.35) brightness(.7); }
.world-card.locked::after {
  content: "Locked"; position: absolute; top: 12px; right: 12px; z-index: 2;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: rgba(0,0,0,.45); color: var(--ivory); padding: 4px 8px; border-radius: 999px;
}

.story-card {
  width: 100%; text-align: left; border-radius: 22px; overflow: hidden; position: relative;
  min-height: 240px; border: 1px solid rgba(255,248,238,.2);
  background: #183456 center/cover no-repeat; margin-bottom: 12px;
  box-shadow: 0 16px 36px rgba(0,0,0,.35);
}
.story-card .ov {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,20,39,.15) 0%, rgba(8,20,39,.35) 40%, rgba(8,20,39,.88) 100%);
}
.story-card .body { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 1; }
.story-card h3 {
  font-family: var(--serif); font-size: 30px; margin: 6px 0 6px; font-weight: 700; color: #FFF8EE;
  text-shadow: 0 2px 14px rgba(0,0,0,.5);
}
.story-card small, .story-card .muted { color: #F0E6D4 !important; text-shadow: 0 1px 8px rgba(0,0,0,.45); }

.nav-dock {
  position: sticky; bottom: 0; margin: 18px -18px calc(-8px - var(--safe-bot));
  padding: 12px 18px calc(12px + var(--safe-bot));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: linear-gradient(180deg, transparent, rgba(8,20,39,.97) 26%);
}
.nav-dock button { padding: 10px 4px; border-radius: 14px; font-size: 11px; color: var(--ivory-dim); font-weight: 800; }
.nav-dock button.on { color: #0A1424; background: var(--gold); }

.profile-list { display: grid; gap: 10px; }
.profile-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px;
  border: 1px solid var(--line); background: rgba(255,248,238,.07); text-align: left; color: var(--ivory);
}
.profile-card .av {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 50%, white); color: var(--ivory);
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pin-pad button {
  padding: 16px 0; border-radius: 14px; background: rgba(255,248,238,.1); border: 1px solid var(--line);
  font-size: 18px; font-weight: 800; color: var(--ivory);
}
.pin-dots { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
.pin-dots span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--gold); }
.pin-dots span.on { background: var(--gold); }

.creator .preview-stage {
  height: 320px; border-radius: 22px; overflow: hidden; position: relative; margin: 10px 0 14px;
  background: radial-gradient(circle at 50% 20%, var(--accent-soft), transparent 55%), linear-gradient(180deg, var(--navy-800), var(--navy-950));
  border: 1px solid var(--line);
}
.creator .preview-stage img {
  position: absolute; left: 50%; bottom: -6%; transform: translateX(-50%); height: 108%; width: auto; max-width: none;
  filter: drop-shadow(0 18px 28px rgba(0,0,0,.45));
}
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,248,238,.07);
  font-size: 13px; font-weight: 700; color: var(--ivory);
}
.opt.on { border-color: var(--gold); background: rgba(224,195,106,.2); color: #FFF8EE; }
.opt .cost { color: var(--gold); margin-left: 6px; font-size: 11px; }

.stage { position: absolute; inset: 0; background: #000; overflow: hidden; }
.bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.15), transparent 28%, rgba(0,0,0,.45) 58%, rgba(0,0,0,.82)); pointer-events: none; }
#sprites { position: absolute; inset: 0; pointer-events: none; }
.spr {
  position: absolute; bottom: 18%; height: 68%; width: auto; max-width: 78%;
  opacity: 1; filter: drop-shadow(0 16px 22px rgba(0,0,0,.4));
}
.spr.on { opacity: 1; }
.spr.p-l { left: -4%; }
.spr.p-r { right: -4%; left: auto; }
.spr.p-c { left: 50%; transform: translateX(-50%); }
.spr.dim { filter: brightness(.6) saturate(.9) drop-shadow(0 16px 22px rgba(0,0,0,.4)); }
.spr.talk { filter: brightness(1.06) drop-shadow(0 0 16px color-mix(in srgb, var(--accent) 40%, transparent)); }
.tap-layer { position: absolute; inset: 0; z-index: 5; }
.dialogue { position: absolute; left: 12px; right: 12px; bottom: calc(16px + var(--safe-bot)); z-index: 8; }
.bubble {
  background: rgba(14,33,60,.94); border: 1px solid rgba(224,195,106,.28); border-radius: 20px;
  padding: 14px 16px 16px; min-height: 96px; position: relative; color: var(--ivory);
}
.bubble .name {
  display: inline-block; font-family: var(--serif); font-size: 16px; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 45%, white); color: var(--ivory);
}
.bubble .name.nar { color: var(--gold-soft); background: rgba(255,248,238,.08); }
.bubble .text { font-size: 15.5px; line-height: 1.45; color: #FFF8EE; }
.bubble .cont { position: absolute; right: 14px; bottom: 10px; color: var(--gold-soft); font-size: 12px; }
.choices { position: absolute; left: 12px; right: 12px; bottom: calc(16px + var(--safe-bot)); z-index: 9; display: grid; gap: 8px; }
.choices .ttl { text-align: center; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); font-weight: 800; }
.choice {
  text-align: left; padding: 14px; border-radius: 16px; background: rgba(14,33,60,.94);
  border: 1px solid rgba(255,248,238,.2); font-weight: 700; line-height: 1.35; color: #FFF8EE;
}
.choice.prem { border-color: rgba(224,195,106,.65); background: linear-gradient(135deg, rgba(224,195,106,.18), rgba(14,33,60,.94)); }
.choice .cost { float: right; color: var(--gold); font-size: 12px; font-weight: 800; }
.rel-bar { position: absolute; top: calc(58px + var(--safe-top)); right: 12px; z-index: 10; display: grid; gap: 6px; }
.rel-pill {
  display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: 11px; font-weight: 800;
  background: rgba(8,20,39,.82); border: 1px solid var(--line); color: var(--ivory);
}
.rel-pill .heart { color: var(--gold); }

.note {
  margin: 12px 0; padding: 12px 14px; border-radius: 14px; font-size: 13px; line-height: 1.4; color: var(--ivory);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 45%, white);
}
.footer-links { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; }
.footer-links a { color: var(--ivory-dim); text-decoration: none; }

.branch-map { font-size: 12px; color: var(--ivory); }
.branch-map .node {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; background: rgba(255,248,238,.05);
}
.branch-map .node b { font-family: var(--serif); font-size: 15px; color: var(--gold-soft); }
.branch-map .edge { color: var(--ivory-dim); margin-left: 8px; display: block; }

/* Shot mode: freeze motion */
html.shot-mode .fade,
html.shot-mode .spr,
html.shot-mode .dialogue,
html.shot-mode .choices { animation: none !important; transition: none !important; opacity: 1 !important; }
