:root {
  --ink: #111318;
  --paper: #f7f3ec;
  --soft: #efe8dd;
  --glass: rgba(255, 255, 255, 0.72);
  --line: rgba(17, 19, 24, 0.12);
  --muted: rgba(17, 19, 24, 0.64);
  --accent: #b9935a;
  --green: #247f6d;
  --danger: #d84b61;
  --night: #06070a;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.view {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: clamp(18px, 4vw, 48px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(1.015);
  transition: opacity 900ms var(--ease), transform 1000ms var(--ease), filter 900ms var(--ease);
  overflow: hidden;
}

.view.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.view.exit-glitch {
  filter: blur(8px) saturate(0.6);
  transform: scale(0.985) rotate(0.2deg);
}

.glass {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: var(--glass);
  box-shadow: 0 24px 80px rgba(17, 19, 24, 0.16);
  backdrop-filter: blur(28px) saturate(1.1);
}

.eyebrow,
.section-label {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 850;
  transition: transform 240ms var(--ease), box-shadow 240ms var(--ease), background 240ms var(--ease);
}

.button:hover {
  transform: translateY(-2px);
}

.button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(36, 127, 109, 0.35);
  outline-offset: 3px;
}

.button.primary {
  background: linear-gradient(135deg, #17191f, #343943);
  color: white;
  box-shadow: 0 18px 45px rgba(17, 19, 24, 0.24);
}

.button.secondary {
  background: rgba(17, 19, 24, 0.08);
  color: var(--ink);
}

.mesh {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(185, 147, 90, 0.26), transparent 28%),
    radial-gradient(circle at 80% 18%, rgba(36, 127, 109, 0.20), transparent 26%),
    radial-gradient(circle at 50% 85%, rgba(185, 147, 90, 0.18), transparent 30%),
    linear-gradient(135deg, #f9f6ef, #e9ece8 58%, #f3dfdf);
  animation: meshFloat 14s var(--ease) infinite alternate;
}

[data-view="portal"],
[data-view="verify"] {
  background: #f8f4ed;
}

.portal-card,
.verify-shell {
  position: relative;
  width: min(860px, 100%);
  border-radius: 28px;
  padding: clamp(26px, 5vw, 54px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 46px;
  color: var(--muted);
  font-weight: 850;
}

.sibling-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
  filter: drop-shadow(0 0 10px rgba(185, 147, 90, 0.5));
  animation: pulseMark 3s ease infinite;
}

.sibling-mark svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

@keyframes pulseMark {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.12); opacity: 1; }
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) repeat(2, minmax(160px, 0.65fr));
  gap: 22px;
  align-items: end;
}

.portal-grid h1 {
  margin: 0;
  font-size: clamp(3.4rem, 9vw, 8rem);
  line-height: 0.86;
}

.portal-grid h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.package-line {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 44px 0 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

.package-line svg,
.icon-button svg,
.warning-icon {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.package-line strong,
.package-line span {
  display: block;
}

.package-line span {
  color: var(--muted);
}

.fine-print {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.verification-steps {
  display: grid;
  gap: 12px;
  margin: 28px 0;
}

.verify-step {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 760;
}

.verify-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(17, 19, 24, 0.16);
  transition: background 260ms var(--ease), box-shadow 260ms var(--ease);
}

.verify-step.done .verify-dot {
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(36, 127, 109, 0.10);
}

.answer-form {
  margin-top: 28px;
}

.answer-form label {
  display: block;
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  font-weight: 850;
}

.answer-row {
  display: flex;
  gap: 10px;
}

.answer-row input {
  min-width: 0;
  flex: 1;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.error-text {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 780;
}

.birthday-view {
  display: block;
  background: linear-gradient(145deg, #fbf7ee, #edf4f0 54%, #f4e8e8);
  overflow: hidden;
  padding: 0 !important;
}

.birthday-scroll-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(18px, 4vw, 48px) clamp(18px, 4vw, 48px) 110px;
  box-sizing: border-box;
}

.birthday-copy {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  margin: 8svh auto 28px;
  text-align: center;
}

.birthday-copy h2,
.timeline-header h2,
.gallery-view h2 {
  margin: 0 auto 18px;
  max-width: 980px;
  font-size: clamp(3.2rem, 10vw, 8.6rem);
  line-height: 0.86;
}

.birthday-copy p:last-child {
  max-width: 660px;
  margin: 0 auto;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.7;
}

.cinematic-strip {
  position: relative;
  display: flex;
  gap: 18px;
  width: max-content;
  min-width: 100%;
  padding: 28px 8vw 120px;
  animation: stripDrift 35s linear infinite;
}

.photo-card {
  position: relative;
  width: clamp(210px, 24vw, 330px);
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 70px rgba(17, 19, 24, 0.16);
}

.photo-card img,
.gallery-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-card figcaption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px);
  font-weight: 820;
}

.floating {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(17, 19, 24, 0.88);
  color: white;
}

.floating:hover {
  transform: translate(-50%, -2px);
}

.timeline-view {
  display: block;
  background: #111318;
  color: white;
  overflow-y: auto;
  overflow-x: hidden;
}

.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background-image: radial-gradient(circle, rgba(255,255,255,0.42) 1px, transparent 1.5px);
  background-size: 42px 42px;
  animation: particleDrift 16s linear infinite;
}

.timeline-header {
  position: relative;
  z-index: 2;
  width: min(1100px, 100%);
  margin: 0 auto 30px;
  padding-top: 6svh;
}

.timeline-header h2 {
  margin-left: 0;
  color: white;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  color: white;
  cursor: pointer;
}

.timeline-track {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  width: min(1100px, 100%);
  margin: 0 auto;
}

.timeline-card {
  min-height: 330px;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  transform: translateY(28px);
  opacity: 0;
  animation: riseIn 800ms var(--ease) forwards;
}

.timeline-card img {
  width: 100%;
  height: 76%;
  object-fit: cover;
}

.timeline-card p {
  margin: 0;
  padding: 14px;
  color: rgba(255,255,255,0.78);
  font-weight: 720;
}

.timeline-end {
  position: relative;
  z-index: 2;
  width: min(720px, 100%);
  margin: 42px auto 7svh;
  text-align: center;
}

.timeline-end p {
  color: white;
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 1;
}

.generator-view {
  background: radial-gradient(circle at 22% 18%, rgba(185,147,90,0.24), transparent 28%), linear-gradient(135deg, #f7f3ec, #e7ebe9);
}

.generator-window {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(320px, 690px);
  width: min(1120px, 100%);
  min-height: 620px;
  border: 1px solid rgba(17,19,24,0.12);
  border-radius: 28px;
  overflow: hidden;
  background: rgba(255,255,255,0.60);
  box-shadow: 0 30px 100px rgba(17,19,24,0.16);
  backdrop-filter: blur(24px);
}

.generator-controls {
  padding: clamp(24px, 4vw, 40px);
  border-right: 1px solid var(--line);
}

.generator-controls h2 {
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  line-height: 0.92;
}

.metric {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  color: var(--ink);
}

.meter {
  height: 10px;
  margin: 28px 0 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(17,19,24,0.10);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transition: width 900ms var(--ease);
}

#generatorStatus {
  min-height: 28px;
  color: var(--muted);
  font-weight: 780;
}

.generator-stage {
  position: relative;
  overflow: hidden;
}

.generator-photo {
  position: absolute;
  width: 190px;
  height: 250px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 24px 65px rgba(17,19,24,0.18);
  animation: orbit 12s linear infinite;
}

.failure-view,
.recovery-view,
.final-gift-view,
.final-card-view {
  background: #07080c;
  color: white;
}

.desktop-dialog {
  width: min(860px, 100%);
  overflow: hidden;
  border-radius: 18px;
  background: rgba(24, 27, 34, 0.88);
}

.dialog-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.dialog-bar span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f57;
}

.dialog-bar span:nth-child(2) {
  background: #ffbd2e;
}

.dialog-bar span:nth-child(3) {
  background: #28c840;
}

.dialog-bar strong {
  margin-left: 8px;
  color: rgba(255,255,255,0.68);
  font-size: 0.86rem;
}

.dialog-body {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 20px;
  padding: clamp(24px, 4vw, 42px);
}

.warning-icon {
  color: #ffbd2e;
}

.dialog-body h2 {
  margin: 0 0 22px;
  color: white;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 26px;
}

dt {
  color: rgba(255,255,255,0.52);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  color: white;
  font-weight: 850;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dialog-actions .secondary {
  background: rgba(255,255,255,0.10);
  color: white;
}

.recovery-console {
  width: min(920px, 100%);
  min-height: 560px;
  max-height: 70svh;
  overflow-y: auto;
  padding: 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  background: #050608;
  box-shadow: 0 30px 110px rgba(0,0,0,0.44);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#recoveryLog {
  display: grid;
  gap: 12px;
  color: #b8ffe8;
  line-height: 1.5;
}

.log-line {
  opacity: 0;
  transform: translateY(8px);
  animation: riseIn 260ms var(--ease) forwards;
}

.log-line.warn {
  color: #ffd37b;
}

.log-line.danger {
  color: #ff8396;
}

.unlock-shell {
  width: min(520px, 100%);
  text-align: center;
}

#pdfDownloadStage,
#decryptionStage {
  background: rgba(14, 16, 22, 0.82) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(28px) saturate(1.1) !important;
}

#decryptionStage {
  border-color: rgba(216, 75, 97, 0.28) !important;
}

.unlock-shell p {
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(2.4rem, 6vw, 5rem);
  line-height: 0.96;
}

.final-card {
  width: min(720px, 100%);
  border-radius: 30px;
  padding: clamp(30px, 7vw, 70px);
  text-align: center;
}

#finalMessage {
  display: grid;
  gap: 16px;
  font-family: "Newsreader", Georgia, serif;
  color: white;
  font-size: clamp(2rem, 5.8vw, 5.4rem);
  line-height: 0.98;
}

#finalMessage span {
  opacity: 0;
  transform: translateY(18px);
  animation: riseIn 760ms var(--ease) forwards;
}

.gallery-view {
  position: static;
  display: block;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overflow-x: hidden;
}

.gallery-view header {
  width: min(1040px, 100%);
  margin: 0 auto 30px;
  padding-top: 4svh;
  text-align: center;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  width: min(1120px, 100%);
  margin: 0 auto 8svh;
}

.gallery-grid figure {
  margin: 0;
  overflow: hidden;
  border-radius: 24px;
  aspect-ratio: 4 / 5;
  box-shadow: 0 20px 70px rgba(17, 19, 24, 0.13);
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.balloon,
.cake {
  position: fixed;
  z-index: 4;
  pointer-events: none;
}

.balloon {
  width: 38px;
  height: 50px;
  border-radius: 50% 50% 45% 45%;
  background: linear-gradient(145deg, #f9d7a4, #b9935a);
  animation: balloonFloat 8s var(--ease) infinite alternate;
}

.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 48px;
  width: 1px;
  height: 64px;
  background: rgba(17,19,24,0.24);
}

.cake {
  right: 36px;
  bottom: 34px;
  width: 88px;
  height: 62px;
  border-radius: 12px 12px 16px 16px;
  background: linear-gradient(#fff1dd 0 34%, #b9935a 34% 100%);
  box-shadow: 0 18px 42px rgba(17,19,24,0.18);
}

.cake::before {
  content: "";
  position: absolute;
  left: 42px;
  top: -26px;
  width: 6px;
  height: 24px;
  border-radius: 3px;
  background: #111318;
}

.cake::after {
  content: "";
  position: absolute;
  left: 39px;
  top: -34px;
  width: 12px;
  height: 14px;
  border-radius: 50% 50% 50% 0;
  background: #ffbd2e;
  transform: rotate(-35deg);
  box-shadow: 0 0 22px rgba(255, 189, 46, 0.6);
}

@keyframes meshFloat {
  to {
    transform: translate3d(2%, -2%, 0) scale(1.04);
  }
}

@keyframes stripDrift {
  to {
    transform: translateX(-18%);
  }
}

@keyframes particleDrift {
  to {
    background-position: 42px 84px;
  }
}

@keyframes riseIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes orbit {
  from {
    transform: rotate(0deg) translateX(110px) rotate(0deg);
  }
  to {
    transform: rotate(360deg) translateX(110px) rotate(-360deg);
  }
}

@keyframes balloonFloat {
  to {
    transform: translateY(-28px) translateX(12px);
  }
}

@media (max-width: 820px) {
  .portal-grid,
  .generator-window,
  .dialog-body {
    grid-template-columns: 1fr;
  }

  .portal-grid h1 {
    font-size: clamp(3.4rem, 18vw, 6rem);
  }

  .answer-row,
  .dialog-actions {
    flex-direction: column;
  }

  .generator-window {
    min-height: auto;
  }

  .generator-stage {
    min-height: 400px;
  }

  dl {
    grid-template-columns: 1fr;
  }
}

/* Scrollability and layout centering overrides */
.final-gift-view,
.final-card-view {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 8svh clamp(18px, 4vw, 48px) !important;
}

.final-gift-view > *,
.final-card-view > * {
  margin: auto 0 !important;
}

/* Light mode bright transition for final success screen */
.final-card-view {
  background: linear-gradient(145deg, #fbf7ee, #edf4f0 54%, #f4e8e8) !important;
  color: var(--ink) !important;
}

.final-card {
  background: rgba(255, 255, 255, 0.72) !important;
  border: 1px solid rgba(17, 19, 24, 0.12) !important;
  color: var(--ink) !important;
  box-shadow: 0 24px 80px rgba(17, 19, 24, 0.08) !important;
  backdrop-filter: blur(28px) saturate(1.1) !important;
}

#finalMessage {
  color: var(--ink) !important;
}

#finalMessage span {
  color: var(--ink) !important;
}
