:root{
  --cream:#f4e9d8;
  --paper:#efe1c9;
  --terracota:#c1633b;
  --terracota-deep:#a34e2c;
  --brown:#4a3324;
  --brown-deep:#2e2014;
  --soft-red:#a8453f;
  --burnt-pink:#c07a6b;
  --gold:#d9a441;
  --night:#1b2540;
  --night-deep:#101627;
  --ink:#2b1a14;
  --ink-soft:#5c4632;
  --shadow: 0 14px 34px rgba(30,16,8,.28);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --motion: 1;
}

*{ box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html,body{
  margin:0; padding:0; height:100%; overflow:hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--night);
  color: var(--cream);
  touch-action: manipulation;
  user-select: none;
}
h1,h2,h3{ font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif; margin:0; font-weight:600; letter-spacing:.2px; }
h1{ font-size: clamp(1.7rem, 6.4vw, 2.4rem); }
h2{ font-size: clamp(1.35rem, 5.2vw, 1.8rem); color: var(--gold); }
h3{ font-size: 1.1rem; color: var(--burnt-pink); font-style: italic; }

@media (prefers-reduced-motion: reduce){ :root{ --motion: 0; } }

*:focus-visible{ outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

#bg-canvas{ position:fixed; inset:0; width:100%; height:100%; z-index:0; pointer-events:none; }
#bg-canvas.day{ filter: none; }

/* ---------------- topbar ---------------- */
#topbar{
  position:fixed; top:0; left:0; right:0; z-index:50;
  display:flex; align-items:center; justify-content:space-between;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  pointer-events:none;
}
#topbar > *{ pointer-events:auto; }
#chapter-label{
  font-family:Georgia, 'Times New Roman', serif; font-style:italic; font-size:.82rem; color: var(--gold);
  background: rgba(20,12,6,.4); padding:6px 14px; border-radius:999px;
  opacity:0; transition: opacity .5s ease; max-width:68vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#chapter-label.show{ opacity:1; }

.icon-btn{
  width:44px; height:44px; border-radius:50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  color: var(--cream);
  font-size: 18px;
  display:flex; align-items:center; justify-content:center;
  backdrop-filter: blur(6px);
  cursor:pointer;
  transition: transform .15s ease, background .2s ease;
}
.icon-btn:active{ transform: scale(.9); background: rgba(255,255,255,.18); }
.icon-btn:disabled{ opacity:.25; cursor:default; }
.icon-btn:disabled:active{ transform:none; }

#back-btn{
  position:fixed; top: calc(62px + var(--safe-top)); left:14px; z-index:45;
  display:flex; align-items:center; gap:6px;
  background: rgba(20,12,6,.4); border:1px solid rgba(255,255,255,.14);
  color: var(--cream); font-size:.85rem; padding:8px 14px 8px 10px; border-radius:999px;
  cursor:pointer; opacity:0; pointer-events:none; transition: opacity .3s ease, transform .2s ease;
}
#back-btn.show{ opacity:1; pointer-events:auto; }
#back-btn:active{ transform: scale(.94); }

/* ---------------- app / scenes ---------------- */
#app{
  position:relative; z-index:5; height:100%; width:100%;
  display:flex; align-items:center; justify-content:center;
  padding: calc(64px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  overflow:hidden;
}
.scene{
  width:100%; max-width:540px; height:100%; max-height:900px;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:18px; text-align:center; position:relative;
  animation: sceneIn calc(.6s * var(--motion)) ease both;
}
@keyframes sceneIn{ from{ opacity:0; transform: translateY(calc(18px * var(--motion))); } to{ opacity:1; transform:none; } }

.scene-scroll{
  overflow-y:auto; -webkit-overflow-scrolling:touch; height:100%; width:100%;
  display:flex; flex-direction:column; align-items:center; padding-bottom:24px;
}
/* flex items must never shrink below their content — real overflow should
   scroll the container, not visually compress/overlap text and controls */
.scene-scroll > *{ flex-shrink:0; }
::-webkit-scrollbar{ display:none; }

p.line{
  font-size: clamp(1rem, 4vw, 1.18rem); line-height:1.55; margin:0; max-width:440px;
  opacity:0; animation: lineIn calc(.55s * var(--motion)) ease forwards;
  color: var(--cream);
}
p.line.small{ font-size:.9rem; color: var(--burnt-pink); }
p.line.tag{ font-size:.78rem; color: var(--gold); text-transform:uppercase; letter-spacing:1.6px; }
@keyframes lineIn{ from{ opacity:0; transform: translateY(calc(10px * var(--motion))); } to{ opacity:1; transform:none; } }

.btn{
  border:none; border-radius: 14px; padding: 15px 28px; font-family:system-ui, sans-serif;
  font-size: 1rem; font-weight:600; letter-spacing:.2px;
  background: linear-gradient(135deg, var(--terracota), var(--soft-red));
  color: #fff8ef; box-shadow: var(--shadow); cursor:pointer;
  min-height: 52px; min-width: 140px;
  transition: transform .15s ease, filter .2s ease;
}
.btn:active{ transform: scale(.96); filter: brightness(.95); }
.btn.ghost{ background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.28); box-shadow:none; color: var(--cream); }
.btn.small{ padding: 10px 18px; font-size: .92rem; min-height:44px; min-width:auto; border-radius:12px; }
.btn:disabled{ opacity:.35; cursor:default; }
.btn-row{ display:flex; gap:12px; flex-wrap:wrap; justify-content:center; }

.card{
  background: rgba(244,233,216,.06); border: 1px solid rgba(244,233,216,.14);
  border-radius: var(--radius); padding: 22px 20px; backdrop-filter: blur(8px); box-shadow: var(--shadow);
}

#fade-overlay{
  position:fixed; inset:0; background: var(--night-deep); opacity:0;
  pointer-events:none; z-index:100; transition: opacity .5s ease;
}
#fade-overlay.active{ opacity:1; pointer-events:auto; }

/* ---------------- pause menu ---------------- */
#pause-overlay{
  position:fixed; inset:0; z-index:200; background: rgba(16,10,5,.86);
  backdrop-filter: blur(4px);
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; transition: opacity .25s ease;
  padding: 20px;
}
#pause-overlay.open{ opacity:1; pointer-events:auto; }
.pause-panel{
  width:100%; max-width:360px; background: linear-gradient(160deg, #3a2a1c, #241811);
  border:1px solid rgba(255,255,255,.12); border-radius: 22px; padding: 26px 22px;
  display:flex; flex-direction:column; gap:12px; box-shadow: var(--shadow);
}
.pause-panel h2{ text-align:center; margin-bottom:6px; }
.pause-btn{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background: rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.1);
  color: var(--cream); border-radius:14px; padding:13px 16px; font-size:.98rem;
  cursor:pointer; text-align:left; width:100%; font-family:system-ui, sans-serif;
}
.pause-btn:active{ transform: scale(.98); }
.pause-btn .switch{ font-size:.82rem; color: var(--gold); }

/* ---------------- confirm modal ---------------- */
#confirm-overlay{
  position:fixed; inset:0; z-index:300; background: rgba(16,10,5,.9);
  display:flex; align-items:center; justify-content:center; padding:20px;
  opacity:0; pointer-events:none; transition: opacity .25s ease;
}
#confirm-overlay.open{ opacity:1; pointer-events:auto; }
.confirm-panel{
  width:100%; max-width:340px; background: linear-gradient(160deg, #3a2a1c, #241811);
  border:1px solid rgba(255,255,255,.14); border-radius:20px; padding:24px 20px;
  display:flex; flex-direction:column; gap:16px; text-align:center; box-shadow: var(--shadow);
}

/* ---------------- memories gallery ---------------- */
#memories-overlay{
  position:fixed; inset:0; z-index:250; background: rgba(16,10,5,.92);
  display:flex; flex-direction:column; padding: calc(20px + var(--safe-top)) 18px calc(20px + var(--safe-bottom));
  opacity:0; pointer-events:none; transition: opacity .25s ease;
}
#memories-overlay.open{ opacity:1; pointer-events:auto; }
.memories-grid{
  display:grid; grid-template-columns: repeat(2, 1fr); gap:16px; overflow-y:auto; padding: 10px 4px 20px;
  flex:1;
}
.polaroid{
  background:#fdf8ef; border-radius:6px; padding:8px 8px 22px; box-shadow: var(--shadow);
  transform: rotate(var(--tilt, -2deg)); display:flex; flex-direction:column; gap:6px;
}
.polaroid .frame{
  aspect-ratio: 1/1; border-radius:2px; overflow:hidden; background: linear-gradient(160deg, #d8c4a0, #b99b70);
  display:flex; align-items:center; justify-content:center; font-size:2rem;
}
.polaroid .frame img{ width:100%; height:100%; object-fit:cover; }
.polaroid figcaption{ color:#4a3324; font-family:Georgia, 'Times New Roman', serif; font-style:italic; font-size:.78rem; text-align:center; }
.polaroid.locked{ opacity:.3; filter: grayscale(1); }

/* ---------------- title / intro ---------------- */
.title-mark{ font-size: 3.2rem; animation: pulse calc(2s * var(--motion)) ease-in-out infinite; }
@keyframes pulse{ 0%,100%{ transform: scale(1); } 50%{ transform: scale(1.08); } }

.save-choice{ display:flex; flex-direction:column; gap:10px; width:100%; max-width:300px; }

/* ---------------- phone / chat ---------------- */
.phone{
  width: 250px; max-width: 68vw; background: #241811; border-radius: 32px;
  border: 6px solid #3a2a1c; padding: 16px 12px; box-shadow: var(--shadow);
  display:flex; flex-direction:column; gap:10px; min-height: 320px;
}
.phone .notch{ width:56px; height:6px; border-radius:4px; background:#3a2a1c; align-self:center; }
.chat-bubble{
  align-self:flex-start; background: linear-gradient(135deg, var(--terracota), var(--soft-red));
  color:#fff8ef; padding:10px 14px; border-radius: 16px 16px 16px 4px; font-size:.88rem; max-width:85%;
  opacity:0; animation: lineIn calc(.4s * var(--motion)) ease forwards;
}
.chat-bubble.her{ align-self:flex-end; background: rgba(255,255,255,.14); border-radius: 16px 16px 4px 16px; }
.chat-status{ font-size:.7rem; color: rgba(244,233,216,.4); text-align:right; }
.date-badge{ align-self:center; background: rgba(255,255,255,.1); padding: 4px 12px; border-radius: 999px; font-size:.7rem; color: var(--gold); letter-spacing:1px; }
.typing-dots span{ display:inline-block; width:5px; height:5px; border-radius:50%; background: rgba(255,255,255,.6); margin:0 1px; animation: bounce 1s infinite; }
.typing-dots span:nth-child(2){ animation-delay:.15s; }
.typing-dots span:nth-child(3){ animation-delay:.3s; }
@keyframes bounce{ 0%,60%,100%{ transform: translateY(0); } 30%{ transform: translateY(-4px); } }

/* ---------------- cinema ---------------- */
.cinema-room{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; width:100%; max-width:420px; }
.movie-card{
  background: rgba(0,0,0,.32); border: 2px solid rgba(255,255,255,.14); border-radius: 16px; padding: 16px 10px;
  cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:6px;
  transition: transform .15s ease, border-color .2s ease; position:relative; color: var(--cream);
}
.movie-card:active{ transform: scale(.96); }
.movie-card.seen{ border-color: var(--gold); }
.movie-card .emoji{ font-size:2rem; }
.movie-card .tick{ position:absolute; top:6px; right:8px; color: var(--gold); font-size:.9rem; }

/* ---------------- map ---------------- */
.map{ position:relative; width:100%; max-width:420px; height:320px; background: linear-gradient(160deg, rgba(244,233,216,.06), transparent); border-radius: 22px; border: 1px dashed rgba(244,233,216,.2); }
.map-pin{ position:absolute; display:flex; flex-direction:column; align-items:center; gap:4px; cursor:pointer; transform: translate(-50%,-50%); }
.map-pin .dot{ font-size: 1.9rem; animation: floaty calc(3s * var(--motion)) ease-in-out infinite; filter: drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.map-pin.done .dot{ filter: drop-shadow(0 0 10px var(--gold)); }
.map-pin span.label{ font-size:.7rem; background: rgba(20,12,6,.5); padding:2px 8px; border-radius:999px; color: var(--cream); }
@keyframes floaty{ 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-8px); } }

/* ---------------- airbnb ---------------- */
.airbnb-room{
  width:100%; max-width:380px; height:250px; border-radius:20px;
  background: linear-gradient(160deg, #4a3320, #2a1c14); position:relative; overflow:hidden;
  display:flex; align-items:center; justify-content:center; transition: filter 1s ease;
}
.airbnb-room.dark{ filter: brightness(.28) saturate(.6); }
.airbnb-room .flicker{ position:absolute; inset:0; background: rgba(255,0,0,.08); opacity:0; pointer-events:none; }
.airbnb-room.dark .flicker{ animation: flicker calc(.4s * var(--motion)) steps(2) infinite; }
@keyframes flicker{ 0%{opacity:0;} 50%{opacity:.5;} 100%{opacity:.1;} }

/* ---------------- projects (papers) ---------------- */
.idea-field{ position:relative; width:100%; max-width:440px; height:340px; }
.idea-paper{
  position:absolute; background: #efe1c9; color:#2e2014; border-radius: 4px; padding: 10px 16px;
  font-size:.88rem; font-family:Georgia, 'Times New Roman', serif; cursor:pointer; box-shadow: 0 6px 14px rgba(0,0,0,.3);
  animation: drift calc(6s * var(--motion)) ease-in-out infinite; transition: background .2s ease, transform .2s ease;
}
.idea-paper.popped{ background: linear-gradient(135deg, var(--terracota), var(--soft-red)); color:#fff8ef; transform: scale(1.12) rotate(0deg) !important; }
@keyframes drift{ 0%,100%{ transform: translate(0,0) rotate(var(--rot,-3deg)); } 50%{ transform: translate(6px,-10px) rotate(var(--rot,-3deg)); } }

/* ---------------- plaza / zumba ---------------- */
.plaza{ width:100%; max-width:420px; height:290px; position:relative; background: linear-gradient(180deg, rgba(217,164,65,.14), transparent); border-radius: 20px; overflow:hidden; }
.stage-char{ position:absolute; bottom:14px; width:70px; }
.tia{ position:absolute; bottom:14px; width:46px; opacity:.9; }
.her-hide{ position:absolute; bottom:14px; width:56px; transition: opacity .3s ease; }

/* ---------------- character SVG + poses ---------------- */
.char-svg{ width:70px; height:auto; overflow:visible; }
.char-svg .char-arm, .char-svg .char-leg{ transform-origin: top center; }

.char-walk .char-leg-l{ animation: legswing calc(.6s * var(--motion)) ease-in-out infinite; }
.char-walk .char-leg-r{ animation: legswing calc(.6s * var(--motion)) ease-in-out infinite reverse; }
.char-walk .char-arm-l{ animation: armswing calc(.6s * var(--motion)) ease-in-out infinite reverse; }
.char-walk .char-arm-r{ animation: armswing calc(.6s * var(--motion)) ease-in-out infinite; }
@keyframes legswing{ 0%,100%{ transform: rotate(-16deg); } 50%{ transform: rotate(16deg); } }
@keyframes armswing{ 0%,100%{ transform: rotate(14deg); } 50%{ transform: rotate(-14deg); } }

.char-dance{ animation: dancebody calc(.5s * var(--motion)) ease-in-out infinite; }
.char-dance .char-arm-l{ animation: armswing calc(.4s * var(--motion)) ease-in-out infinite; }
.char-dance .char-arm-r{ animation: armswing calc(.4s * var(--motion)) ease-in-out infinite reverse; }
@keyframes dancebody{ 0%,100%{ transform: rotate(-8deg) translateY(0); } 50%{ transform: rotate(8deg) translateY(-6px); } }

.char-wave .char-arm-r{ animation: wave calc(.9s * var(--motion)) ease-in-out infinite; }
@keyframes wave{ 0%,100%{ transform: rotate(0deg); } 50%{ transform: rotate(-50deg); } }

.char-laugh .char-mouth{ transform-origin: center; animation: laugh calc(.4s * var(--motion)) ease-in-out infinite; }
@keyframes laugh{ 0%,100%{ transform: scaleY(1); } 50%{ transform: scaleY(1.6); } }

.char-surprised .char-eye{ animation: surprise calc(.6s * var(--motion)) ease-in-out infinite alternate; }
@keyframes surprise{ from{ r:2.6; } to{ r:4.2; } }

/* ---------------- house exploration ---------------- */
.house-illustration{ width: min(320px, 80vw); margin: 0 auto; }
.house-svg{ width:100%; height:auto; }
.house-window, .house-upper, .house-lower, .house-roof, .house-porch{ transition: opacity .8s ease, fill .8s ease; }
.house-scaffold rect{ animation: scaffoldpulse calc(1.6s * var(--motion)) ease-in-out infinite; }
@keyframes scaffoldpulse{ 0%,100%{ opacity:.5; } 50%{ opacity:1; } }

.room-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; width:100%; max-width:420px; }
.room-card{
  background: rgba(244,233,216,.07); border:1px solid rgba(244,233,216,.16); border-radius:16px; padding:16px 10px;
  cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:6px; color: var(--cream);
}
.room-card.visited{ border-color: var(--gold); }
.room-card .emoji{ font-size:1.8rem; }

.key-glow{ font-size: 3.2rem; animation: keyglow calc(1.6s * var(--motion)) ease-in-out infinite; cursor:pointer; }
@keyframes keyglow{ 0%,100%{ filter: drop-shadow(0 0 6px var(--gold)); transform: scale(1); } 50%{ filter: drop-shadow(0 0 20px var(--gold)); transform: scale(1.1); } }

.door-emoji{ font-size:4.6rem; transition: transform .3s ease; }
.door-emoji.shake{ animation: shake .4s ease; }
@keyframes shake{ 0%,100%{ transform: translateX(0); } 25%{ transform: translateX(-8px); } 75%{ transform: translateX(8px); } }

/* ---------------- ending ---------------- */
.walk-scene{ width:100%; max-width:420px; height:200px; position:relative; overflow:hidden; border-radius:20px; background: linear-gradient(180deg, rgba(217,164,65,.12), transparent); }
.walk-char{ position:absolute; bottom:20px; left:8%; }
.walk-char.walking{ animation: walk 4s linear forwards; }
@keyframes walk{ from{ left:8%; } to{ left:78%; } }
.house-old-mini{ position:absolute; bottom:6px; right:4%; width:88px; }

.final-heart{ font-size: 4.4rem; animation: finalPulse calc(2s * var(--motion)) ease-in-out infinite; }
@keyframes finalPulse{ 0%,100%{ transform: scale(1); opacity:.9; } 50%{ transform: scale(1.14); opacity:1; } }

/* ---------------- fotos e vídeo reais (discretos) ---------------- */
.bg-memory{
  position:absolute; inset:0; z-index:-1; overflow:hidden; border-radius: inherit;
  pointer-events:none;
}
.bg-memory video, .bg-memory img{
  width:100%; height:100%; object-fit:cover;
  filter: blur(2px) saturate(.7) brightness(.55);
  opacity:.32;
}
.bg-memory::after{
  content:''; position:absolute; inset:0;
  background: linear-gradient(180deg, rgba(27,37,64,.5), rgba(16,22,39,.85));
}

.memory-reveal{
  width: min(260px, 74vw); border-radius:10px; padding:10px 10px 26px;
  background:#fdf8ef; box-shadow: var(--shadow); position:relative;
  cursor:pointer;
}
.memory-reveal .frame{ aspect-ratio: 9/13; border-radius:3px; overflow:hidden; position:relative; background:#000; }
.memory-reveal .frame img, .memory-reveal .frame video{ width:100%; height:100%; object-fit:cover; display:block; }
.memory-reveal figcaption{ color:#4a3324; font-family:Georgia, 'Times New Roman', serif; font-style:italic; font-size:.8rem; text-align:center; margin-top:6px; }
.memory-reveal .play-badge{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  background: rgba(0,0,0,.28); transition: opacity .25s ease;
}
.memory-reveal .play-badge span{
  width:52px; height:52px; border-radius:50%; background: rgba(255,255,255,.92);
  color:#2e2014; display:flex; align-items:center; justify-content:center; font-size:1.3rem;
  box-shadow: 0 6px 14px rgba(0,0,0,.35);
}
.memory-reveal.playing .play-badge{ opacity:0; pointer-events:none; }

/* ---------------- particles ---------------- */
.leaf-particle{ position:absolute; pointer-events:none; opacity:.5; }

@media (min-width: 700px){ .scene{ max-height: 760px; } }
