:root {
  --bg1: #220018;
  --bg2: #7b1034;
  --bg3: #ff5f8f;
  --white: #fff7fb;
  --muted: rgba(255,255,255,.80);
  --glass: rgba(255,255,255,.13);
  --glass-border: rgba(255,255,255,.25);
  --shadow: 0 24px 80px rgba(0,0,0,.35);
  --radius: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg1); }
body {
  min-height: 100dvh;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--white);
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 150, 190, .42), transparent 26%),
    radial-gradient(circle at 80% 5%, rgba(255, 216, 230, .26), transparent 28%),
    linear-gradient(145deg, var(--bg1), var(--bg2) 52%, #3b001e);
}

.noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .08; z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

#particles { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.app { position: relative; z-index: 3; height: 100dvh; width: 100vw; overflow: hidden; }
.screen {
  position: absolute; inset: 0; display: none; padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  align-items: center; justify-content: center; overflow: hidden;
}
.screen.active { display: flex; animation: fadeIn .7s ease both; }
.screen-scroll {
  width: 100%; height: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; padding-bottom: calc(98px + var(--safe-bottom));
}
.narrow-scroll { max-width: 960px; margin: 0 auto; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }

.glass-card {
  width: min(680px, 100%); padding: clamp(24px, 6vw, 50px); border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255,255,255,.18), rgba(255,255,255,.08));
  border: 1px solid var(--glass-border); box-shadow: var(--shadow); backdrop-filter: blur(18px);
  text-align: center;
}
.reveal-card { animation: rise .9s cubic-bezier(.2,.9,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } }
.badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 12px;
}
h1 { font-size: clamp(38px, 8vw, 72px); line-height: .94; margin: 22px 0 14px; letter-spacing: -0.06em; }
h2 { font-size: clamp(28px, 6vw, 48px); line-height: 1.02; margin: 12px 0; letter-spacing: -0.04em; }
h3 { margin: 8px 0 8px; font-size: 22px; }
p { color: var(--muted); font-size: 17px; line-height: 1.6; }
.subtitle { font-size: 20px; max-width: 560px; margin-inline: auto; }
.hint, .micro { font-size: 13px; opacity: .78; }
.actions-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

button { font: inherit; cursor: pointer; border: 0; touch-action: manipulation; }
.primary-btn, .ghost-btn {
  min-height: 52px; padding: 0 24px; border-radius: 999px; margin: 8px 5px; font-weight: 900;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.primary-btn {
  color: #6b0028; background: linear-gradient(135deg, #fff, #ffd4e4); box-shadow: 0 14px 36px rgba(255, 105, 150, .24);
}
.primary-btn:active, .ghost-btn:active { transform: scale(.97); }
.primary-btn.small { min-height: 44px; padding: 0 18px; font-size: 15px; }
.ghost-btn { color: #fff; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.25); }
.hidden { display: none !important; }
.bottom-btn { display: block; width: min(420px, 100%); margin: 24px auto 0; }

.heart-big { font-size: 80px; filter: drop-shadow(0 12px 24px rgba(0,0,0,.25)); animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { transform: scale(1.11); } }
.heart-button {
  width: 92px; height: 92px; border-radius: 50%; color: white; font-size: 42px;
  background: linear-gradient(135deg, #ff336c, #ff8ab0); box-shadow: 0 22px 60px rgba(255, 51, 108, .38);
}

.polaroid-screen { align-items: stretch; justify-content: flex-start; flex-direction: column; padding: calc(12px + var(--safe-top)) 14px calc(12px + var(--safe-bottom)); }
.topbar, .game-header {
  width: min(960px, 100%); margin: 0 auto 12px; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-radius: 22px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(15px); font-weight: 900;
}
.topbar { position: sticky; top: 0; z-index: 15; }
.shake-box { width: min(960px, 100%); margin: 0 auto; text-align: center; padding: 8px 8px 2px; }
.phone-icon { font-size: 42px; animation: shakePhone 1.6s ease infinite; transform-origin: center bottom; }
@keyframes shakePhone { 0%,100%{transform:rotate(0)} 20%{transform:rotate(-8deg)} 40%{transform:rotate(8deg)} 60%{transform:rotate(-5deg)} 80%{transform:rotate(5deg)} }
.polaroid-stage {
  position: relative; min-height: 430px; width: min(960px, 100%); margin: 8px auto 0; display: grid; place-items: center; perspective: 1000px;
}
.polaroid {
  position: absolute; width: min(72vw, 330px); background: #fff; color: #37202a; padding: 12px 12px 18px;
  border-radius: 10px 10px 16px 16px; box-shadow: 0 26px 70px rgba(0,0,0,.34);
  transform: rotate(var(--rot)) translateY(18px) scale(.92); opacity: 0; animation: revealPhoto .85s cubic-bezier(.2,.9,.2,1) forwards;
  transform-origin: center 80%;
}
.polaroid img { width: 100%; height: 320px; object-fit: cover; border-radius: 6px; display: block; background: #eadde3; }
.polaroid p { color: #4e2736; margin: 12px 4px 0; text-align: center; font-size: 15px; line-height: 1.35; font-weight: 750; }
@keyframes revealPhoto {
  0% { filter: saturate(0) brightness(1.7); opacity: 0; transform: rotate(var(--rot)) translateY(46px) scale(.86); }
  55% { filter: saturate(.45) brightness(1.25); opacity: 1; }
  100% { filter: saturate(1) brightness(1); opacity: 1; transform: rotate(var(--rot)) translateY(0) scale(1); }
}
.done-card {
  width: min(580px, 100%); margin: 18px auto 0; text-align: center; padding: 18px;
  border-radius: 24px; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.22);
}
.floating-continue {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-bottom)); z-index: 60;
  width: min(430px, calc(100vw - 28px)); margin: 0;
  box-shadow: 0 20px 50px rgba(0,0,0,.35), 0 12px 34px rgba(255, 105, 150, .24);
  animation: floatButton .55s ease both;
}
@keyframes floatButton { from { opacity: 0; transform: translateX(-50%) translateY(14px); } }

.section-title { text-align: center; margin: 6px auto 20px; }
.section-title span, .mini-label { color: #ffd7e5; text-transform: uppercase; font-size: 12px; letter-spacing: .15em; font-weight: 900; }
.timeline { width: min(820px, 100%); margin: 0 auto; display: grid; gap: 14px; }
.chapter {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px; padding: 18px; border-radius: 26px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.20); box-shadow: 0 16px 50px rgba(0,0,0,.15);
}
.chapter-number {
  width: 58px; height: 58px; border-radius: 19px; display: grid; place-items: center;
  background: linear-gradient(135deg, #fff, #ffc6dc); color: #7b1034; font-weight: 950; font-size: 20px;
}
.chapter p { margin: 0; }

.game-screen { align-items: stretch; justify-content: flex-start; }
.game-scroll { padding-bottom: calc(110px + var(--safe-bottom)); }
.game-header h2 { margin: 5px 0 0; font-size: clamp(24px, 7vw, 40px); }
.score { min-width: 88px; text-align: center; padding: 10px 14px; border-radius: 18px; background: rgba(255,255,255,.18); font-size: 26px; font-weight: 950; }
.game-instruction { width: min(760px, 100%); text-align: center; margin: 0 auto 12px; }
.game-area {
  position: relative; width: min(860px, 100%); height: min(54dvh, 470px); min-height: 330px; overflow: hidden;
  margin: 0 auto; border-radius: 30px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.2); box-shadow: inset 0 0 80px rgba(255,255,255,.06);
}
.falling-heart {
  position: absolute; font-size: 38px; filter: drop-shadow(0 10px 15px rgba(0,0,0,.25)); animation: fall linear forwards;
  user-select: none; cursor: pointer; padding: 10px; margin: -10px; z-index: 5;
}
@keyframes fall { to { transform: translateY(620px) rotate(180deg); opacity: .18; } }
.qualities { width: min(860px, 100%); min-height: 48px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px auto; }
.quality-chip { padding: 8px 12px; border-radius: 999px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); font-weight: 850; animation: pop .25s ease both; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

.final-card { text-align: left; max-width: 760px; margin: 0 auto; }
.final-card h1, .final-card h2 { text-align: center; }
.final-card h1 { color: #fff; text-shadow: 0 12px 36px rgba(255, 76, 130, .45); }
.final-actions { text-align: center; }

.float-heart {
  position: fixed; bottom: -30px; z-index: 2; pointer-events: none; animation: floatUp linear forwards;
  opacity: .75; filter: blur(.1px);
}
@keyframes floatUp { to { transform: translateY(-110dvh) rotate(220deg); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 80; width: min(420px, calc(100vw - 28px)); padding: 12px 16px; border-radius: 18px;
  background: rgba(20,0,20,.76); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(14px);
  text-align: center; font-weight: 800; box-shadow: 0 18px 60px rgba(0,0,0,.30); animation: toastIn .35s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

@media (max-width: 560px) {
  .screen { padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bottom)); }
  .glass-card { padding: 24px 18px; }
  p { font-size: 15.5px; }
  h1 { font-size: clamp(36px, 12vw, 54px); }
  .subtitle { font-size: 17px; }
  .chapter { grid-template-columns: 1fr; }
  .polaroid-stage { min-height: 390px; }
  .polaroid { width: min(78vw, 300px); }
  .polaroid img { height: 285px; }
  .game-header { align-items: flex-start; gap: 12px; }
  .game-area { height: 48dvh; min-height: 320px; }
  .shake-box h2 { margin-bottom: 4px; }
  .shake-box p { margin: 5px 0; }
}

@media (max-height: 720px) and (max-width: 560px) {
  .phone-icon { font-size: 34px; }
  .shake-box { padding-top: 0; }
  .polaroid-stage { min-height: 345px; }
  .polaroid { width: min(68vw, 255px); }
  .polaroid img { height: 230px; }
  .topbar { padding: 10px 12px; }
}
