/* ============================================================
   The Night Web · Birthday Issue #1 — comic-book UI
   Red Spider-Man theme, halftone, ink panels, speech bubbles.
   ============================================================ */
:root {
  --red: #E62429;
  --red-hot: #ff3a48;
  --gold: #ffc21f;
  --blue: #1f4fff;
  --ink: #0b0608;
  --paper: #fff6e9;
  --cream: #ffe9c9;
  --dim: #e9b9bd;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #12060a; color: var(--paper); }
body { font-family: 'Comic Neue', system-ui, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }

/* halftone + vignette over the 3D world ---------------------------------- */
#halftone {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .5; mix-blend-mode: multiply;
  background-image: radial-gradient(rgba(70,0,10,.55) 1.1px, transparent 1.3px);
  background-size: 7px 7px;
}
#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(125% 95% at 50% 40%, transparent 42%, rgba(20,2,6,.5) 78%, rgba(10,1,3,.92) 100%);
}

/* ============================ UI ======================================== */
#ui { position: fixed; inset: 0; z-index: 5; }
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: max(5vh,26px) 6vw;
  text-align: center; opacity: 1; transition: opacity .8s ease; }
.panel.hidden { opacity: 0; pointer-events: none; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 1.05rem; max-width: 42rem; }
.stack.wide { max-width: 47rem; }

.eyebrow { font-family: 'Bangers', cursive; letter-spacing: .18em; font-size: 1.05rem; margin: 0;
  color: var(--gold); text-shadow: 2px 2px 0 #7a0a12, -1px -1px 0 #000; }
.display { font-family: 'Bangers', cursive; font-weight: 400; font-size: clamp(3rem, 12vw, 8rem);
  line-height: .84; letter-spacing: .02em; margin: .06em 0; color: #fff;
  -webkit-text-stroke: 3px #0b0608;
  text-shadow: 6px 6px 0 var(--red), 10px 10px 0 rgba(0,0,0,.35); }
.title { font-family: 'Anton', sans-serif; font-weight: 400; font-size: clamp(1.9rem, 6vw, 3.5rem);
  letter-spacing: .01em; margin: 0; color: #fff; text-transform: uppercase;
  -webkit-text-stroke: 1.5px #0b0608; text-shadow: 3px 3px 0 var(--red), 6px 6px 0 rgba(0,0,0,.3); }
.lede { font-size: clamp(1rem, 1.6vw, 1.18rem); line-height: 1.6; color: var(--cream); margin: 0;
  font-weight: 700; text-shadow: 0 2px 10px rgba(20,2,6,.9); }
.fineprint { font-family: 'Rajdhani'; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; color: #d38f96; margin: .2rem 0 0; }

/* buttons ---------------------------------------------------------------- */
.btn { font-family: 'Bangers', cursive; font-size: 1.35rem; letter-spacing: .06em; color: #fff; cursor: pointer;
  margin-top: .4rem; padding: .5em 1.4em; border-radius: 14px; background: var(--red);
  border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); transition: transform .12s, box-shadow .12s, filter .12s; }
.btn:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--ink); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }
.btn-gold { background: var(--gold); color: #3a1400; text-decoration: none; display: inline-block; font-size: 1.6rem; }

/* submit slots (comic panels) -------------------------------------------- */
.slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; width: 100%; margin: .3rem 0; }
.slot { position: relative; aspect-ratio: 3/4; border-radius: 8px; cursor: pointer; overflow: hidden;
  border: 3px solid var(--ink); background: #22101a; box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  display: grid; place-items: center; transition: transform .12s; }
.slot:hover { transform: translate(-1px,-2px); }
.slot .plus { font-family: 'Bangers'; font-size: 2rem; color: var(--gold); }
.slot .idx { position: absolute; top: 4px; left: 7px; font-family: 'Bangers'; font-size: .95rem; color: #fff; text-shadow: 1px 1px 0 #000; z-index: 2; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot.filled { border-color: var(--gold); }
.slot .remove { position: absolute; top: 4px; right: 5px; width: 22px; height: 22px; border-radius: 4px; border: 2px solid #000;
  background: var(--red); color: #fff; cursor: pointer; font-size: .95rem; line-height: 1; display: none; z-index: 3; }
.slot.filled .remove { display: block; }
/* review states on re-upload */
.slot.approved { border-color: #24c07a; cursor: default; }
.slot.approved::after { content: '✔ KEPT'; position: absolute; inset: auto 0 0 0; font-family: 'Bangers'; font-size: .8rem;
  background: #24c07a; color: #063; padding: 2px 0; }
.slot.rejected { border-color: var(--red-hot); border-style: dashed; }
.slot .reason { position: absolute; inset: auto 0 0 0; background: rgba(180,10,20,.92); color: #fff; font-size: .62rem;
  font-weight: 700; padding: 3px 4px; line-height: 1.15; z-index: 2; }

.field { display: flex; flex-direction: column; gap: .3rem; align-items: center; width: 100%; }
.field span { font-family: 'Rajdhani'; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .74rem; color: var(--dim); }
.field input { width: min(22rem, 90%); text-align: center; color: var(--ink); background: var(--cream);
  border: 3px solid var(--ink); border-radius: 10px; padding: .55em 1.1em; font-family: 'Comic Neue'; font-weight: 700; font-size: .98rem; outline: none; }
.err { color: var(--gold); font-weight: 700; font-size: .9rem; min-height: 1.1em; margin: 0; text-shadow: 1px 1px 0 #000; }

/* rubber stamp (waiting) ------------------------------------------------- */
.stamp { font-family: 'Anton', sans-serif; font-size: clamp(1.4rem,3.4vw,2.2rem); line-height: .95; color: #ff5765;
  border: 5px solid #ff5765; border-radius: 8px; padding: .3em .6em; transform: rotate(-9deg); letter-spacing: .04em;
  text-transform: uppercase; box-shadow: inset 0 0 0 2px rgba(255,87,101,.4); opacity: .92; }

/* access gate · crack the web ------------------------------------------- */
.gate-card { position: relative; width: min(30rem, 92vw); text-align: center;
  background: rgba(10,4,8,.82); border: 3px solid var(--ink); border-radius: 18px;
  padding: 3.2rem 1.6rem 1.7rem; box-shadow: 6px 6px 0 rgba(0,0,0,.5), 0 0 40px rgba(230,36,41,.25);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.gate-card.shake { animation: shake .4s; }
@keyframes shake { 10%,90%{transform:translateX(-2px)} 30%,70%{transform:translateX(6px)} 50%{transform:translateX(-8px)} }
.gate-spider { position: absolute; top: -84px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; }
.gate-spider .thread { width: 2px; height: 60px; background: linear-gradient(#fff,rgba(255,255,255,.2)); }
.gate-spider .bug { font-size: 2rem; margin-top: -4px; animation: dangle 3s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(230,36,41,.7)); }
@keyframes dangle { 0%,100%{transform:rotate(-6deg)} 50%{transform:rotate(6deg)} }
.gate-scramble { font-family: 'Rajdhani', monospace; letter-spacing: .3em; color: var(--red-hot);
  font-size: 1.1rem; margin: .3rem 0 .8rem; opacity: .85; min-height: 1.2em; text-shadow: 0 0 10px rgba(255,58,72,.6); }
.gate-prompt { color: var(--cream); font-weight: 700; font-size: .98rem; line-height: 1.5; margin: 0 0 1rem; }
.gate-clue { font-family: 'Bangers', cursive; letter-spacing: .05em; color: var(--gold); font-size: 1.2rem;
  margin-bottom: 1rem; text-shadow: 2px 2px 0 #7a0a12; }
#gate-input { width: 100%; text-align: center; font-family: 'Rajdhani', monospace; font-weight: 700;
  font-size: 1.35rem; letter-spacing: .12em; color: #fff; background: rgba(0,0,0,.45);
  border: 2px solid var(--red); border-radius: 10px; padding: .6em .8em; outline: none; }
#gate-input:focus { border-color: var(--gold); box-shadow: 0 0 16px rgba(255,194,31,.35); }
.gate-card .btn { margin-top: 1rem; width: 100%; }
.gate-card.cracked { border-color: #24c07a; box-shadow: 6px 6px 0 rgba(0,0,0,.5), 0 0 44px rgba(36,192,122,.5); }

/* speech bubble ---------------------------------------------------------- */
.speech { position: relative; background: var(--paper); color: var(--ink); border: 4px solid var(--ink);
  border-radius: 22px; padding: 1.05rem 1.5rem; max-width: 34rem; box-shadow: 6px 6px 0 rgba(0,0,0,.45);
  font-family: 'Comic Neue'; font-weight: 700; font-size: clamp(1rem,1.7vw,1.3rem); line-height: 1.5; }
.speech p { margin: 0; }
.speech .tail { position: absolute; left: 26%; bottom: -22px; width: 0; height: 0;
  border-left: 16px solid transparent; border-right: 22px solid transparent; border-top: 26px solid var(--ink); }
.speech .tail::after { content: ''; position: absolute; left: -12px; top: -30px; width: 0; height: 0;
  border-left: 11px solid transparent; border-right: 15px solid transparent; border-top: 18px solid var(--paper); }
.speech.static { box-shadow: 5px 5px 0 rgba(0,0,0,.4); }
/* compact bubble for the long finale message so it all fits on screen */
.speech.finale { font-size: clamp(.9rem,1.35vw,1.08rem); line-height: 1.4; max-width: 42rem; padding: .85rem 1.4rem; }

/* STORY layout: bubble at top, content at bottom, couple (WebGL) between.
   space-between keeps the bubble and the title from ever overlapping. */
#story { display: flex; flex-direction: column; justify-content: space-between; align-items: center; }
#speech { position: relative; z-index: 6; margin: 0 auto; flex: 0 0 auto; }
.story-lower { display: flex; flex-direction: column; align-items: center; gap: .8rem;
  width: 100%; max-width: 62rem; margin: 0 auto; flex: 0 0 auto;
  position: relative; z-index: 6; }

/* reveal comic panel (just the framed memory now) ------------------------ */
.reveal-panel { display: flex; justify-content: center; }
.panel-frame { width: clamp(180px, 24vw, 250px); aspect-ratio: 3/4; border-radius: 6px; overflow: hidden;
  border: 4px solid var(--ink); background: #180a12; box-shadow: 6px 6px 0 rgba(0,0,0,.5); }
.panel-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* countdown -------------------------------------------------------------- */
.countdown { display: flex; flex-direction: column; gap: .6rem; align-items: center; }
.cd-label { font-family: 'Bangers'; letter-spacing: .1em; font-size: 1.15rem; color: var(--gold); margin: 0; text-shadow: 2px 2px 0 #7a0a12; }
.cd-clock { display: flex; gap: .7rem; }
.cd-clock > div { min-width: 4.2rem; padding: .5rem .3rem; border-radius: 10px; background: var(--paper); border: 3px solid var(--ink);
  display: flex; flex-direction: column; gap: .1rem; box-shadow: 3px 3px 0 rgba(0,0,0,.4); }
.cd-clock b { font-family: 'Anton'; font-size: 2rem; color: var(--red); font-variant-numeric: tabular-nums; line-height: 1; }
.cd-clock span { font-family: 'Rajdhani'; font-weight: 700; font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: #7a3b2f; }

/* finale strip (host images) + gallery (memories) + cta ------------------ */
.strip-label { font-family: 'Bangers', cursive; letter-spacing: .05em; font-size: 1.05rem; margin: .1rem 0 -.2rem;
  color: var(--gold); text-shadow: 2px 2px 0 #7a0a12; }
.couple-strip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.couple-strip img { width: clamp(84px,11vw,126px); aspect-ratio: 16/10; object-fit: cover; border-radius: 5px;
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.5); filter: saturate(1.15) contrast(1.08);
  opacity: 0; transform: translateY(18px) rotate(var(--r,0deg)); animation: rise .8s cubic-bezier(.2,.8,.2,1) forwards; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.gallery img { width: clamp(66px,9vw,102px); aspect-ratio: 3/4; object-fit: cover; border-radius: 6px;
  border: 4px solid var(--ink); box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  opacity: 0; transform: translateY(22px) rotate(var(--r,0deg)); animation: rise .8s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes rise { to { opacity: 1; transform: translateY(0) rotate(var(--r,0deg)); } }
.finale-cta { display: flex; flex-direction: column; align-items: center; gap: .7rem; }
.cta-teaser { font-family: 'Bangers'; font-size: clamp(1.2rem,2.6vw,1.7rem); color: #fff; margin: 0;
  letter-spacing: .03em; text-shadow: 2px 2px 0 var(--red), 4px 4px 0 rgba(0,0,0,.3); }

/* progress dots ---------------------------------------------------------- */
.dots { display: flex; gap: 9px; justify-content: center; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #3a1620; border: 2px solid var(--ink); transition: all .3s; }
.dots i.on { background: var(--red); box-shadow: 0 0 10px var(--red-hot); }

/* preview banner --------------------------------------------------------- */
.preview-banner { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 20;
  font-family: 'Bangers'; letter-spacing: .06em; font-size: .95rem; color: #3a1400; background: var(--gold);
  padding: .25em 1em; border-radius: 999px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.4); }

.hidden { display: none !important; }

@media (max-width: 680px) {
  /* Each phase becomes a top-aligned, vertically SCROLLABLE column so the
     countdown / dots / button never fall off the bottom of a phone. */
  .panel { display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
    padding: 7vh 5vw calc(9vh + env(safe-area-inset-bottom, 0px)); }
  /* short panels stay centred; tall ones scroll from the top without clipping */
  #enter .stack, #waiting .stack, #submit .stack { margin: auto 0; }

  .display { font-size: clamp(2.6rem, 15vw, 4.6rem); }
  .slots { gap: 7px; }
  .field input { width: 100%; }

  /* story: bubble and content stacked with real spacing (no overlap) */
  #story { justify-content: flex-start; gap: 1.4rem; }
  #speech { position: relative; margin: 0; max-width: 92vw; }
  .speech.finale { font-size: .92rem; }
  .story-lower { gap: .7rem; }
  .panel-frame { width: clamp(160px, 52vw, 200px); }
  .cd-clock { gap: .4rem; }
  .cd-clock > div { min-width: 3.3rem; padding: .45rem .2rem; }
  .cd-clock b { font-size: 1.7rem; }
  .couple-strip img { width: clamp(78px, 26vw, 112px); }
  .gallery img { width: clamp(66px, 24vw, 96px); }
}
@media (prefers-reduced-motion: reduce) { .stamp { transform: none; } }
