:root {
  --bg: #120d15;
  --card: rgba(24, 15, 29, 0.74);
  --line: rgba(255, 255, 255, 0.12);
  --white: #fff7fb;
  --text: #f7eef6;
  --muted: rgba(247, 238, 246, 0.74);
  --pink: #ffb7d2;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.36);
  --safe-top: max(env(safe-area-inset-top), 16px);
  --safe-bottom: max(env(safe-area-inset-bottom), 18px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; }
body { overflow: hidden; }
html, body, .app, .story-screen, .image-stage { min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; }
.hidden { display: none !important; }
.app { min-height: 100vh; background: radial-gradient(circle at top, #2c1c34 0%, #140f18 42%, #0d0910 100%); }
.setup-screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 24px 16px; }
.setup-screen.active { display: flex; }
.setup-backdrop { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(15,10,18,.25), rgba(15,10,18,.85)), radial-gradient(circle at 20% 20%, rgba(255,161,204,.18), transparent 30%), radial-gradient(circle at 80% 15%, rgba(255,212,144,.14), transparent 24%), radial-gradient(circle at 50% 100%, rgba(255,120,166,.18), transparent 30%); }
.setup-card { position: relative; z-index: 1; width: min(100%, 460px); padding: 22px 18px 18px; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.glass-card { background: var(--card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.eyebrow { margin: 0 0 6px; color: var(--pink); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; }
h1 { margin: 0 0 8px; font-family: "Cormorant Garamond", serif; font-size: 42px; line-height: .98; font-weight: 700; }
.setup-copy { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.field-grid { display: grid; gap: 12px; }
.field-grid .field:last-child { margin-top: 2px; }
.field span { display: block; margin: 0 0 7px; font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); color: var(--white); border-radius: 16px; padding: 14px; outline: none; }
.field input::placeholder { color: rgba(255,255,255,.38); }
.field input:focus, .field select:focus { border-color: rgba(255,183,210,.6); box-shadow: 0 0 0 3px rgba(255,143,183,.18); }
.setup-actions { display: grid; gap: 10px; margin-top: 16px; }
.primary-btn, .secondary-btn, .choice-btn { appearance: none; border: none; border-radius: 999px; cursor: pointer; transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease; }
.primary-btn:active, .secondary-btn:active, .choice-btn:active, .tap-advance:active { transform: scale(.98); }
.primary-btn { min-height: 52px; padding: 13px 18px; color: #2a0f1c; font-weight: 700; background: linear-gradient(135deg, #ffd8e8, #ff9fc3 55%, #ff7aa9); box-shadow: 0 16px 34px rgba(255,122,169,.26); }
.secondary-btn { min-height: 52px; padding: 13px 18px; color: var(--text); font-weight: 600; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); }
.setup-status { min-height: 20px; margin: 12px 4px 0; color: var(--muted); font-size: 13px; }
.story-screen { position: fixed; inset: 0; display: none; background: #08070b; }
.story-screen.active { display: block; }
.image-stage { position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; background: #09070b; }
.scene-image { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; opacity: 0; transform: scale(1.03); transition: opacity .56s ease, transform 1.6s ease; }
.scene-image.loaded { opacity: 1; transform: scale(1); }
.stage-vignette { position: absolute; inset: 0; background: radial-gradient(circle, transparent 40%, rgba(0,0,0,.22) 78%, rgba(0,0,0,.52) 100%); pointer-events: none; }
.stage-gradient { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(8,7,11,.18) 0%, rgba(8,7,11,.06) 26%, rgba(8,7,11,.12) 55%, rgba(8,7,11,.48) 100%); pointer-events: none; }
.loading-overlay { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: linear-gradient(to bottom, rgba(10,8,13,.82), rgba(15,10,18,.9)); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.loading-inner { text-align: center; padding: 24px 26px; border-radius: 24px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.04); box-shadow: 0 18px 44px rgba(0,0,0,.24); }
.loading-title { margin: 0 0 8px; font-family: "Cormorant Garamond", serif; font-size: 30px; color: #fff2f8; }
.loading-sub { margin: 0; color: var(--muted); font-size: 14px; }
.creator-badge { position: absolute; z-index: 9; max-width: min(48vw, 170px); padding: 9px 12px; border-radius: 16px; background: rgba(18,12,18,.82); border: 1px solid rgba(255,255,255,.16); color: var(--white); box-shadow: 0 12px 28px rgba(0,0,0,.25); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.creator-badge .badge-label { display: block; font-size: 10px; color: rgba(255,255,255,.72); letter-spacing: .12em; text-transform: uppercase; }
.creator-badge .badge-name { display: block; margin-top: 2px; font-size: 15px; font-weight: 700; }
.dialogue-layer { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
.bubble { position: absolute; max-width: min(50vw, 280px); padding: 14px 16px 15px; border-radius: 22px; line-height: 1.42; font-size: clamp(14px, 1.7vh, 15px); letter-spacing: .01em; color: #24131b; box-shadow: 0 16px 34px rgba(0,0,0,.26); border: 1px solid rgba(255,255,255,.3); opacity: 0; transform: translateY(14px) scale(.98); animation: bubbleIn .42s cubic-bezier(.2,.8,.2,1) forwards; }
.bubble::before { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 6px; bottom: 10px; background: inherit; border-right: inherit; border-bottom: inherit; z-index: -1; left: var(--tail-left, 18px); right: var(--tail-right, auto); transform: rotate(45deg); }
.bubble-male { background: linear-gradient(135deg, rgba(255,232,241,.98), rgba(255,211,226,.95)); }
.bubble-female { background: linear-gradient(135deg, rgba(255,246,250,.98), rgba(255,232,242,.95)); box-shadow: 0 16px 34px rgba(0,0,0,.24), 0 0 0 1px rgba(255,255,255,.08) inset; }
.bubble .speaker { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #8a355e; }
.choices-layer { position: absolute; right: max(14px, calc(env(safe-area-inset-right) + 10px)); bottom: calc(var(--safe-bottom) + clamp(96px, 12vh, 124px)); z-index: 16; display: grid; gap: 10px; width: min(40vw, 176px); justify-items: stretch; }
.choice-name { padding: 0 8px 2px; text-align: center; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,240,247,.94); text-shadow: 0 4px 14px rgba(0,0,0,.36); }
.choice-btn { min-height: 46px; padding: 10px 14px; color: #fff8fb; font-weight: 700; letter-spacing: .01em; text-align: center; background: linear-gradient(135deg, rgba(78,40,88,.94), rgba(108,54,90,.96)); border: 1px solid rgba(255,255,255,.16); box-shadow: 0 14px 30px rgba(0,0,0,.28); }
.choice-btn.secondary-choice { background: linear-gradient(135deg, rgba(56,34,70,.92), rgba(83,46,72,.94)); }
.tap-advance { position: absolute; left: 50%; bottom: calc(var(--safe-bottom) + clamp(20px, 4.5vh, 38px)); transform: translateX(-50%); min-height: 44px; min-width: 160px; padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); background: rgba(14,12,18,.72); color: rgba(255,255,255,.96); z-index: 18; cursor: pointer; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 14px 32px rgba(0,0,0,.34); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; animation: tapPulse 1.9s ease-in-out infinite; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes tapPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@media (min-width: 700px) { .image-stage { max-width: 520px; margin: 0 auto; box-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 24px 70px rgba(0,0,0,.45); } }


@media (max-height: 760px) {
  .bubble { max-width: min(56vw, 280px); font-size: 14px; }
  .choices-layer { right: 16px; bottom: calc(var(--safe-bottom) + 108px); }
  .tap-advance { bottom: calc(var(--safe-bottom) + 28px); }
}

@media (max-width: 380px) {
  .creator-badge { max-width: 52vw; }
  .choices-layer { width: min(35vw, 128px); right: 14px; }
  .tap-advance { min-width: 150px; padding: 10px 16px; }
}


@media (max-height: 760px) {
  .choices-layer { bottom: calc(var(--safe-bottom) + clamp(112px, 16vh, 146px)); }
  .choice-name { font-size: 12px; }
}
.end-actions {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + clamp(18px, 4vh, 34px));
  transform: translateX(-50%);
  z-index: 19;
  width: min(78vw, 240px);
}

.end-btn {
  width: 100%;
  min-height: 52px;
  padding: 13px 18px;
  border-radius: 999px;
  background: rgba(20, 16, 26, 0.78);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 14px 32px rgba(0,0,0,.34);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@media (max-height: 760px) {
  .end-actions { bottom: calc(var(--safe-bottom) + 26px); }
}


@media (max-width: 420px) {
  .bubble {
    max-width: min(44vw, 220px);
    padding: 13px 14px;
  }

  .choices-layer {
    width: min(38vw, 146px);
    right: max(12px, calc(env(safe-area-inset-right) + 8px));
  }
}

@media (max-height: 740px) {
  .bubble-female {
    max-width: min(38vw, 164px);
  }
}

/* ---------- setup panels: login / creator / invalid link ---------- */
.panel.hidden { display: none !important; }
.field span em { font-style: normal; opacity: .7; }
.link-result { display: flex; gap: 8px; margin-top: 14px; }
.link-result input { flex: 1; min-width: 0; border: 1px solid rgba(255,183,210,.4); background: rgba(255,255,255,.06); color: var(--white); border-radius: 14px; padding: 12px; font-size: 14px; }
.copy-btn { appearance: none; border: none; border-radius: 14px; padding: 0 16px; font-weight: 700; color: #2a0f1c; background: #ffd8e8; cursor: pointer; }
.admin-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }
.admin-footer a, .link-btn { color: var(--pink); text-decoration: none; background: none; border: none; padding: 6px 0; cursor: pointer; font-weight: 600; }
.admin-footer a:hover, .link-btn:hover { text-decoration: underline; }
.preview-badge { position: absolute; top: calc(var(--safe-top) + 10px); right: 12px; z-index: 20; padding: 6px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #2a0f1c; background: rgba(255,216,232,.92); }

/* ---------- "Idea 2 of 5" offer progress ---------- */
.offer-progress { padding: 9px 10px 10px; border-radius: 16px; text-align: center; background: rgba(14,12,18,.72); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 24px rgba(0,0,0,.28); animation: bubbleIn .42s cubic-bezier(.2,.8,.2,1) both; }
.offer-count { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--pink); }
.offer-dots { display: flex; justify-content: center; gap: 6px; margin: 7px 0 6px; }
.offer-dots .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.25); }
.offer-dots .dot.done { background: rgba(255,183,210,.55); }
.offer-dots .dot.current { background: var(--pink); box-shadow: 0 0 0 3px rgba(255,183,210,.25); }
.offer-hint { font-size: 12px; line-height: 1.3; color: rgba(255,247,251,.9); }

/* ---------- end screen: discovery card ---------- */
.end-actions { width: min(86vw, 300px); display: grid; gap: 10px; }
.discover-card { padding: 14px 14px 12px; border-radius: 20px; background: rgba(14,12,18,.78); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 14px 32px rgba(0,0,0,.34); color: var(--white); animation: bubbleIn .5s cubic-bezier(.2,.8,.2,1) both; }
.discover-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.discover-row strong { color: var(--white); font-size: 15px; }
.discover-row.small { margin-top: 10px; }
.discover-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.chip { padding: 6px 4px; border-radius: 10px; font-size: 11.5px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.found { background: rgba(255,183,210,.22); border: 1px solid rgba(255,183,210,.5); color: #ffe3ef; }
.chip.locked { background: rgba(255,255,255,.05); border: 1px dashed rgba(255,255,255,.22); color: rgba(255,255,255,.5); }
.discover-hint { margin: 10px 0 0; font-size: 12.5px; line-height: 1.35; color: rgba(255,247,251,.85); text-align: center; }
.end-btn { color: var(--white); font-weight: 700; }
.end-btn.replay-btn { color: #2a0f1c; background: linear-gradient(135deg, #ffd8e8, #ff9fc3 55%, #ff7aa9); border: none; }
.end-btn.back-btn { min-height: 44px; font-size: 14px; }
/* Keep the centred button in place while it's pressed (previous rule dropped translateX). */
.tap-advance:active { transform: translateX(-50%) scale(.98); }
/* Let the setup card scroll on short phones instead of being clipped. */
.setup-screen { overflow-y: auto; -webkit-overflow-scrolling: touch; align-items: safe center; }
.setup-card { margin: auto 0; }
