:root {
  --bg: #090812;
  --bg-deep: #05040c;
  --card: rgba(255, 255, 255, 0.1);
  --stroke: rgba(255, 255, 255, 0.14);
  --text: #fff7fb;
  --muted: rgba(255,255,255,0.72);
  --accent: #ff6ca9;
  --accent-2: #ff8fd0;
  --accent-3: #a28cff;
  --gold: #ffd8a8;
  --shadow: 0 30px 80px rgba(0,0,0,.38);
  --radius: 28px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  overflow: hidden;
  background: radial-gradient(circle at top, #20172f 0%, #0b0a14 40%, #040309 100%);
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }
.viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}
.background-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, rgba(255, 108, 169, 0.18), transparent 28%),
              radial-gradient(circle at 80% 30%, rgba(162, 140, 255, 0.18), transparent 24%),
              radial-gradient(circle at 50% 85%, rgba(255, 216, 168, 0.08), transparent 26%),
              linear-gradient(180deg, #141120 0%, var(--bg) 50%, var(--bg-deep) 100%);
}
.stars,
.noise,
.emoji-stream,
.space-glow {
  position: absolute;
  inset: 0;
}
.stars {
  background-image:
    radial-gradient(circle at 14% 22%, rgba(255,255,255,.7) 0 1px, transparent 1.4px),
    radial-gradient(circle at 72% 18%, rgba(255,255,255,.75) 0 1.2px, transparent 1.7px),
    radial-gradient(circle at 28% 74%, rgba(255,255,255,.65) 0 .9px, transparent 1.3px),
    radial-gradient(circle at 82% 78%, rgba(255,255,255,.6) 0 1px, transparent 1.5px),
    radial-gradient(circle at 54% 40%, rgba(255,255,255,.55) 0 .9px, transparent 1.3px),
    radial-gradient(circle at 6% 86%, rgba(255,255,255,.45) 0 1.1px, transparent 1.6px);
  background-size: 380px 380px, 440px 440px, 320px 320px, 480px 480px, 280px 280px, 520px 520px;
  opacity: .7;
  animation: starsDrift 18s linear infinite;
}
.space-glow {
  filter: blur(50px);
  opacity: .38;
}
.glow-one {
  background: radial-gradient(circle, rgba(255, 120, 180, 0.8) 0, transparent 58%);
  width: 32vw;
  height: 32vw;
  left: -8vw;
  top: -10vw;
  animation: glowFloatOne 10s ease-in-out infinite;
}
.glow-two {
  background: radial-gradient(circle, rgba(150, 130, 255, 0.78) 0, transparent 58%);
  width: 26vw;
  height: 26vw;
  right: -5vw;
  bottom: -8vw;
  animation: glowFloatTwo 12s ease-in-out infinite;
}
.emoji-stream { pointer-events: none; }
.emoji-particle {
  position: absolute;
  left: var(--left);
  top: -12vh;
  font-size: var(--size);
  opacity: .78;
  filter: drop-shadow(0 8px 18px rgba(255, 85, 136, 0.22));
  animation: emojiFall var(--duration) linear infinite;
  animation-delay: var(--delay);
  transform: translate3d(0, 0, 0) rotate(0deg);
}
.emoji-particle.soft { opacity: .48; }
.noise {
  opacity: .1;
  background-image: radial-gradient(rgba(255,255,255,.25) .7px, transparent .7px);
  background-size: 14px 14px;
  mix-blend-mode: soft-light;
}
.site-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  transform-origin: center center;
  transition: transform .7s cubic-bezier(.2,.8,.2,1), width .7s ease, height .7s ease;
}
.site-shell.rotated-mobile {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vh;
  height: 100vw;
  transform: rotate(90deg) translateY(-100%);
  transform-origin: top left;
}
.rotation-toast {
  position: fixed;
  inset: 18px 18px auto 18px;
  z-index: 50;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.rotation-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  max-width: 460px;
  background: rgba(12, 11, 20, 0.84);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.rotation-card p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.phone-icon { width: 44px; height: 44px; display: grid; place-items: center; }
.phone-frame {
  width: 20px; height: 34px; border: 2px solid #fff; border-radius: 8px; position: relative;
  animation: rotatePhone 1.85s ease-in-out infinite;
}
.phone-frame::after {
  content: ""; position: absolute; inset: 7px 4px; border-radius: 4px; background: rgba(255,255,255,.16);
}
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }
.scene { position: absolute; inset: 0; display: none; }
.scene.active { display: block; }
.scene-inner {
  position: absolute;
  inset: 0;
  padding: 40px clamp(22px, 4vw, 52px) 46px;
}
.glass-card {
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.07));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  border-radius: var(--radius);
}
.entry-card,
.admin-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 760px);
  padding: 30px;
}
.entry-card h1,
.admin-wrap h2 {
  margin: 10px 0 8px;
  font-size: clamp(30px, 4vw, 56px);
  line-height: .98;
  letter-spacing: -.045em;
}
.entry-subtitle,
.book-hint,
.entry-message,
.final-small {
  color: var(--muted);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .28em;
  font-size: 11px;
  color: rgba(255,255,255,.58);
}
.entry-form,
.admin-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}
.admin-form {
  grid-template-columns: 1fr 1fr auto;
  margin-bottom: 16px;
}
input {
  width: 100%;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.08);
  color: #fff;
  outline: none;
}
input::placeholder { color: rgba(255,255,255,.45); }
.primary-btn,
.ghost-btn,
.entry-form button,
.admin-form button {
  padding: 14px 18px;
  border-radius: 18px;
  color: #fff;
  transition: transform .25s ease, opacity .25s ease, background .25s ease, box-shadow .25s ease;
}
.primary-btn,
.entry-form button,
.admin-form button {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: 0 12px 30px rgba(157,124,255,.24);
}
.ghost-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.primary-btn:hover,
.ghost-btn:hover,
.entry-form button:hover,
.admin-form button:hover {
  transform: translateY(-2px);
}
.entry-message {
  min-height: 26px;
  margin-top: 12px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: .4s ease;
}
.entry-message.is-visible { opacity: 1; transform: translateY(0); }
.admin-header,
.book-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.table-wrap {
  overflow: auto;
  border-radius: 22px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.codes-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.codes-table th,
.codes-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
}
.codes-table th { color: rgba(255,255,255,.62); font-size: 12px; text-transform: uppercase; letter-spacing: .14em; }
.code-actions { display: flex; gap: 8px; }
.progress-bar {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 22px;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
  z-index: 5;
}
.progress-fill {
  width: 20%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transition: width .55s ease;
}
.iphone-text,
.book-caption,
.hero-chip,
.hero-big,
.message-line,
.final-small,
.final-big,
.book-stage,
.book-hint,
.book-controls button {
  opacity: 0;
  transform: translateY(22px) scale(.985);
  filter: blur(14px);
  transition: opacity .72s cubic-bezier(.22,1,.36,1), transform .72s cubic-bezier(.22,1,.36,1), filter .72s cubic-bezier(.22,1,.36,1);
}
.is-visible {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  filter: blur(0) !important;
}
.hero-scene,
.final-scene,
.iphone-scene,
.heart-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hero-sequence {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}
.hero-chip,
.hero-big {
  letter-spacing: -.05em;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(180deg, #fff, #ffd8f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-chip {
  font-size: clamp(34px, 7vw, 72px);
}
.hero-big {
  font-size: clamp(28px, 5.8vw, 56px);
}
.intro-emoji-heart {
  position: relative;
  width: min(48vw, 360px);
  height: min(48vw, 320px);
  margin: 26px auto 18px;
}
.intro-heart-core {
  position: absolute;
  inset: 0;
}
.intro-heart-emoji {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: clamp(14px, 1.8vw, 24px);
  transform: translate3d(var(--sx), var(--sy), 0) scale(.3) rotate(var(--sr));
  opacity: 0;
  filter: drop-shadow(0 6px 14px rgba(255, 56, 119, 0.26));
  animation: introEmojiCollect 1.25s cubic-bezier(.22,1,.36,1) forwards;
  animation-delay: var(--delay);
}
.intro-bow {
  position: absolute;
  right: 12%;
  top: 6%;
  font-size: clamp(32px, 4.6vw, 58px);
  filter: drop-shadow(0 10px 24px rgba(255, 116, 173, 0.35));
  animation: bowPop .8s cubic-bezier(.22,1,.36,1) forwards;
}
.book-scene {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 18px;
}
.counter-pill {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.84);
  white-space: nowrap;
}
.book-caption {
  align-self: center;
  max-width: min(90vw, 860px);
  padding: 18px 22px;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.18;
  letter-spacing: -.03em;
  color: #fff;
  text-align: center;
}
.book-stage {
  position: relative;
  width: min(100%, 1120px);
  margin: 0 auto;
  min-height: min(58vh, 520px);
  perspective: 2200px;
  transform-style: preserve-3d;
}
.book-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.book {
  position: relative;
  width: min(100%, 1100px);
  height: min(58vh, 520px);
  display: grid;
  align-items: stretch;
  justify-content: center;
  transform-style: preserve-3d;
}
.book::before {
  content: "";
  position: absolute;
  inset: 16px 0;
  left: 50%;
  width: 2px;
  background: linear-gradient(180deg, rgba(0,0,0,.28), rgba(255,255,255,.26), rgba(0,0,0,.24));
  transform: translateX(-50%);
  z-index: 4;
  opacity: .56;
}
.book.single-book { width: min(64vw, 420px); }
.book-spread,
.book-single {
  display: grid;
  gap: 0;
  width: 100%;
  height: 100%;
}
.book-spread { grid-template-columns: 1fr 1fr; }
.book-single { grid-template-columns: 1fr; }
.book-page {
  position: relative;
  overflow: hidden;
  background: #fff5f8;
  box-shadow: 0 24px 70px rgba(0,0,0,.24);
}
.book-page.left {
  border-radius: 24px 0 0 24px;
  transform-origin: right center;
}
.book-page.right {
  border-radius: 0 24px 24px 0;
  transform-origin: left center;
}
.book-single .book-page { border-radius: 24px; }
.book-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.14), transparent 26%, rgba(0,0,0,.08));
  pointer-events: none;
}
.book-page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.book-shadow {
  position: absolute;
  inset: auto 8% -18px 8%;
  height: 42px;
  background: radial-gradient(circle, rgba(0,0,0,.35) 0, rgba(0,0,0,0) 70%);
  filter: blur(8px);
  z-index: 0;
}
.book-layer.enter-next { animation: bookLayerInNext .8s cubic-bezier(.22,1,.36,1) both; }
.book-layer.exit-next { animation: bookLayerOutNext .8s cubic-bezier(.22,1,.36,1) both; }
.book-layer.enter-prev { animation: bookLayerInPrev .8s cubic-bezier(.22,1,.36,1) both; }
.book-layer.exit-prev { animation: bookLayerOutPrev .8s cubic-bezier(.22,1,.36,1) both; }
.book-hint {
  text-align: center;
  font-size: 14px;
}
.book-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.heart-container {
  position: relative;
  width: min(100%, 1080px);
  height: min(68vh, 620px);
  margin-top: 16px;
}
.heart-photo {
  position: absolute;
  width: clamp(82px, 12vw, 132px);
  aspect-ratio: .76 / 1;
  object-fit: cover;
  border-radius: 20px;
  border: 3px solid rgba(255,255,255,.92);
  box-shadow: 0 16px 36px rgba(0,0,0,.24), 0 0 0 1px rgba(255,255,255,.18) inset;
  transition: transform 1.4s cubic-bezier(.2,.86,.2,1), left 1.4s cubic-bezier(.2,.86,.2,1), top 1.4s cubic-bezier(.2,.86,.2,1), opacity 1s ease;
}
.heart-photo.heart-locked {
  box-shadow: 0 20px 42px rgba(255, 95, 165, 0.26), 0 0 0 1px rgba(255,255,255,.2) inset;
}
.center-head {
  width: 100%;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  margin-bottom: 6px;
}
.message-screen {
  width: min(86vw, 760px);
  min-height: min(56vh, 460px);
  padding: 26px;
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.08));
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.message-lines {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.message-line {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 22px;
  font-size: clamp(22px, 3.2vw, 34px);
  line-height: 1.12;
  letter-spacing: -.03em;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
}
.message-line:nth-child(2n) {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255,109,169,.26), rgba(165,142,255,.22));
}
.final-scene { perspective: 1600px; }
.fly-words {
  position: absolute;
  inset: 0;
  perspective: 1600px;
  overflow: hidden;
}
.fly-word {
  position: absolute;
  left: 50%;
  top: 50%;
  font-weight: 700;
  letter-spacing: -.04em;
  color: rgba(255,255,255,.78);
  transform-style: preserve-3d;
  animation: flyWord 4.8s ease-in-out infinite;
  text-shadow: 0 10px 24px rgba(255, 108, 169, .16);
}
.final-core {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.final-small { font-size: clamp(16px, 2vw, 24px); letter-spacing: .18em; text-transform: uppercase; }
.final-big {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .02em;
  font-size: clamp(36px, 6.8vw, 86px);
  font-weight: 800;
  line-height: .98;
  letter-spacing: -.06em;
}
.final-big .char {
  display: inline-block;
  background: linear-gradient(180deg, #fff, #ffd8ef 55%, #ffc2dc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 18px 36px rgba(255,105,160,.22);
  animation: finalChar 1.8s cubic-bezier(.22,1,.36,1) forwards, finalPulse 2.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 60ms), calc(var(--i) * 60ms + 1.9s);
  opacity: 0;
  transform: translateY(70px) rotateX(80deg) scale(.75);
}
#restartBtn { margin-top: 22px; position: relative; z-index: 2; }

@keyframes starsDrift {
  from { transform: translate3d(0,0,0); }
  to { transform: translate3d(-40px, 22px, 0); }
}
@keyframes glowFloatOne {
  0%,100% { transform: translate3d(0,0,0); }
  50% { transform: translate3d(8vw, 5vh, 0) scale(1.06); }
}
@keyframes glowFloatTwo {
  0%,100% { transform: translate3d(0,0,0); }
  50% { transform: translate3d(-6vw, -4vh, 0) scale(1.08); }
}
@keyframes emojiFall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg); opacity: 0; }
  10% { opacity: .78; }
  100% { transform: translate3d(var(--drift), 118vh, 0) rotate(var(--spin)); opacity: 0; }
}
@keyframes rotatePhone {
  0%, 25% { transform: rotate(0deg); }
  45%, 80% { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}
@keyframes introEmojiCollect {
  0% {
    opacity: 0;
    transform: translate3d(var(--sx), var(--sy), 0) scale(.25) rotate(var(--sr));
  }
  15% { opacity: 1; }
  100% {
    opacity: 1;
    transform: translate3d(var(--tx), var(--ty), 0) scale(1) rotate(0deg);
  }
}
@keyframes bowPop {
  0% { opacity: 0; transform: scale(.4) rotate(-22deg); }
  60% { opacity: 1; transform: scale(1.15) rotate(8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes bookLayerInNext {
  0% { opacity: 0; transform: translateX(6%) rotateY(-16deg) scale(.97); }
  100% { opacity: 1; transform: translateX(0) rotateY(0deg) scale(1); }
}
@keyframes bookLayerOutNext {
  0% { opacity: 1; transform: translateX(0) rotateY(0deg) scale(1); }
  100% { opacity: 0; transform: translateX(-7%) rotateY(18deg) scale(.98); }
}
@keyframes bookLayerInPrev {
  0% { opacity: 0; transform: translateX(-6%) rotateY(16deg) scale(.97); }
  100% { opacity: 1; transform: translateX(0) rotateY(0deg) scale(1); }
}
@keyframes bookLayerOutPrev {
  0% { opacity: 1; transform: translateX(0) rotateY(0deg) scale(1); }
  100% { opacity: 0; transform: translateX(7%) rotateY(-18deg) scale(.98); }
}
@keyframes flyWord {
  0% { transform: translate3d(var(--x), var(--y), -520px) rotateX(54deg) scale(.2); opacity: 0; }
  18% { opacity: .85; }
  100% { transform: translate3d(0, 0, 460px) rotateX(0deg) scale(1.18); opacity: 0; }
}
@keyframes finalChar {
  to { opacity: 1; transform: translateY(0) rotateX(0deg) scale(1); }
}
@keyframes finalPulse {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.03); }
}

@media (max-width: 980px) {
  .book {
    height: min(54vh, 420px);
  }
  .book-caption {
    font-size: clamp(16px, 2vw, 22px);
  }
}
@media (max-width: 720px) {
  .entry-form,
  .admin-form {
    grid-template-columns: 1fr;
  }
  .entry-card,
  .admin-wrap {
    width: min(94vw, 760px);
    padding: 22px;
  }
  .scene-inner { padding: 40px 18px 28px; }
  .book {
    height: min(48vh, 320px);
  }
  .book-page.left { border-radius: 18px 0 0 18px; }
  .book-page.right { border-radius: 0 18px 18px 0; }
  .book-single .book-page { border-radius: 18px; }
  .book-controls { flex-wrap: wrap; }
  .message-line { max-width: 100%; }
}
