:root {
  --primary: #ff4d6d;
  --primary-light: #ff85a1;
  --primary-dark: #c9184a;
  --secondary: #ffb3c1;
  --accent: #fff0f3;
  --text-main: #2b2d42;
  --text-light: #595d75;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  --font-title: 'Playfair Display', serif;
  --font-body: 'Outfit', sans-serif;
  --font-script: 'Great Vibes', cursive;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: #fff5f7;
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Ambient Background */
.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: radial-gradient(circle at 50% 50%, #fff0f3 0%, #ffcad4 100%);
  overflow: hidden;
}

.cursor-light {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255, 77, 109, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: floating 20s infinite alternate;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: var(--primary-light);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--secondary);
  bottom: -150px;
  right: -150px;
  animation-delay: -5s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: #fbc4ab;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 30s;
}

@keyframes floating {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(50px, 50px) scale(1.1);
  }
}

.typing-line {
  margin: 0;
  padding: 8px 0;
  line-height: 1.6;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  color: var(--text-light);
  font-weight: 400;
  min-height: 1.6em;
  position: relative;
  opacity: 0;
  transform: translateY(10px);
}

/* Typing cursor effect */
.typing-active::after {
  content: '|';
  position: absolute;
  margin-left: 2px;
  color: var(--primary);
  animation: blink 0.7s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* Loader */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.loader-content {
  text-align: center;
}

.reveal-text {
  font-family: var(--font-title);
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: var(--primary);
}

.progress-bar {
  width: 200px;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
}

.progress {
  width: 0%;
  height: 100%;
  background: var(--primary);
}

/* Main Container */
.main-container {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
}

/* Card Styling */
#card-wrapper {
  perspective: 2000px;
  width: 100%;
  max-width: 900px;
  height: 600px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#card {
  width: 800px;
  height: 550px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 3D Depth Enhancements */
#card-front::after,
#card-inside::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

#card-front,
#card-inside {
  position: absolute;
  width: 50%;
  height: 100%;
  left: 50%;
  top: 0;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 0 15px 15px 0;
  overflow: hidden;
}

#card-inside {
  z-index: 1;
  background: #fffafa;
  border-radius: 0 15px 15px 0;
  border-left: 1px solid rgba(0, 0, 0, 0.05);
}

#card-front {
  z-index: 2;
  transform-origin: left;
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 0 15px 15px 0;
  position: relative;
}

#card-front::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(105deg,
      transparent 20%,
      rgba(255, 255, 255, 0.1) 40%,
      rgba(255, 255, 255, 0.4) 45%,
      rgba(255, 255, 255, 0.1) 50%,
      transparent 70%);
  background-size: 200% 100%;
  animation: glint 5s infinite;
  pointer-events: none;
}

@keyframes glint {
  0% {
    background-position: -200% 0;
  }

  20% {
    background-position: 200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* Card Front Content */
.front-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  padding: 40px;
  text-align: center;
  backface-visibility: hidden;
}

.main-title {
  font-family: var(--font-title);
  font-size: 3.5rem;
  line-height: 1.1;
  margin-bottom: 30px;
}

.main-title .highlight {
  font-family: var(--font-script);
  font-size: 4rem;
  color: var(--secondary);
  display: block;
  margin-top: 10px;
}

/* Card Inside Content */
.inside-content {
  padding: 40px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.wish-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 20px;
}

.wish-text {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-light);
}

.wish-text p {
  margin-bottom: 15px;
}

.signed {
  margin-top: 20px;
  font-size: 1.2rem;
  font-weight: 600;
}

.signed .name {
  font-family: var(--font-script);
  font-size: 2.8rem;
  color: var(--primary);
  display: inline-block;
  margin-top: 5px;
}

.heart-icon {
  color: var(--primary);
  display: inline-block;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.heart-icon:hover {
  transform: scale(1.5) rotate(15deg);
}

.heart-pulse {
  animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }
}

/* Card Front Inside (The back of the cover) */
.card-front_inside {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  transform: rotateY(180deg);
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
}

.polaroid-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.polaroid {
  background: #fff;
  padding: 15px 15px 60px 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transform: rotate(-3deg);
  width: 80%;
}

.img-frame {
  width: 100%;
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  background-color: #eee;
}

.polaroid-caption {
  font-family: var(--font-script);
  font-size: 1.8rem;
  text-align: center;
  margin-top: 15px;
  color: var(--text-main);
}

/* Interaction States */
#card.is-open {
  transform: translateX(10%) rotateX(5deg);
}

#card.is-open #card-front {
  transform: rotateY(-180deg);
}

/* Buttons */
.card-controls {
  position: absolute;
  bottom: 30px;
  right: 30px;
  z-index: 10;
}

.btn-interact {
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  padding: 12px 25px;
  border-radius: 30px;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.btn-interact:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

#close {
  display: none;
}

#card.is-open #open {
  display: none;
}

#card.is-open #close {
  display: block;
}

.mini-surprise-btn {
  margin-top: 25px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 25px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 15px rgba(255, 77, 109, 0.3);
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  width: fit-content;
}

.mini-surprise-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 77, 109, 0.4);
  background: var(--primary-dark);
}

.mini-surprise-btn .icon {
  font-size: 1.1rem;
}

/* Navigation Hint (Unlock Button) */
.navigation-hint {
  margin-top: 50px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 1s cubic-bezier(0.23, 1, 0.32, 1);
  text-align: center;
  pointer-events: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-is-open .navigation-hint {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition-delay: 0.8s;
  /* Appears shortly after card starts opening */
}

.divider {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 15px;
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--primary-light);
  border-radius: 50%;
  opacity: 0.5;
}

.hint-text {
  font-family: var(--font-body);
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.next-page-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 15px;
  background: white;
  padding: 12px 30px;
  border-radius: 50px;
  box-shadow: 0 10px 25px rgba(255, 77, 109, 0.2);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid rgba(255, 77, 109, 0.1);
}

.btn-text {
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 1.1rem;
}

.arrow-circle {
  width: 35px;
  height: 35px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
}

.next-page-btn:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 35px rgba(255, 77, 109, 0.3);
}

.next-page-btn:hover .arrow-circle {
  transform: translateX(5px);
  background: var(--primary-dark);
}

/* Audio Player */
.audio-player {
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 100;
}

.music-btn {
  background: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.music-btn:hover {
  transform: scale(1.05);
}

/* Responsive Adjustments */
@media (max-width: 1100px) {
  #card {
    width: 650px;
    height: 480px;
  }

  .main-title {
    font-size: 2.8rem;
  }

  .main-title .highlight {
    font-size: 3.2rem;
  }
}

@media (max-width: 850px) {
  .main-container {
    padding: 10px;
  }

  #card-wrapper {
    perspective: 1500px;
    height: auto;
    padding: 20px 0;
  }

  #card {
    width: 100%;
    max-width: 350px;
    /* Force a more portrait-like card on mobile */
    height: 500px;
    transform: none !important;
  }

  #card-front,
  #card-inside {
    width: 100%;
    left: 0;
    border-radius: 15px;
  }

  #card.is-open {
    transform: translateX(0) !important;
  }

  #card.is-open #card-front {
    transform: rotateY(-160deg);
    /* Slightly less to keep it visible on mobile sides if needed */
  }

  .main-title {
    font-size: 2.2rem;
  }

  .main-title .highlight {
    font-size: 3rem;
  }

  .inside-content {
    padding: 25px;
  }

  .wish-title {
    font-size: 1.8rem;
  }

  .wish-text {
    font-size: 1rem;
  }

  .polaroid {
    width: 90%;
    padding: 10px 10px 40px 10px;
  }

  .polaroid-caption {
    font-size: 1.4rem;
  }
}

@media (max-height: 700px) and (min-width: 850px) {
  #card {
    height: 450px;
  }

  .main-title {
    font-size: 2.8rem;
  }
}

@media (max-width: 400px) {
  #card {
    max-width: 300px;
    height: 420px;
  }

  .main-title {
    font-size: 1.8rem;
  }

  .main-title .highlight {
    font-size: 2.22rem;
  }
}

/* 4K and 8K Screens */
@media (min-width: 2500px) {
  html {
    font-size: 24px;
  }

  #card-wrapper {
    max-width: 1400px;
    height: 900px;
  }

  #card {
    width: 1300px;
    height: 850px;
  }

  .orb-1 {
    width: 800px;
    height: 800px;
  }

  .orb-2 {
    width: 1000px;
    height: 1000px;
  }

  .orb-3 {
    width: 600px;
    height: 600px;
  }
}

@media (min-width: 3800px) {
  html {
    font-size: 32px;
  }

  #card-wrapper {
    max-width: 2000px;
    height: 1200px;
  }

  #card {
    width: 1800px;
    height: 1100px;
  }

  .cursor-light {
    width: 1200px;
    height: 1200px;
  }
}

/* Cake/Candle simplified animation */
.cake-container {
  margin-top: 20px;
}

.candle {
  width: 8px;
  height: 40px;
  background: #fff;
  margin: 0 auto;
  position: relative;
  border-radius: 4px;
}

.flame {
  width: 12px;
  height: 18px;
  background: #ff9d00;
  border-radius: 50% 50% 20% 20%;
  position: absolute;
  top: -20px;
  left: -2px;
  animation: flicker 0.1s infinite alternate;
  box-shadow: 0 0 10px #ff9d00;
}

@keyframes flicker {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  100% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* Ending Scene */
#ending-scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(10px);
  transition: all 1.5s ease;
}

#ending-scene.active {
  opacity: 1;
  visibility: visible;
}

.ending-content {
  text-align: center;
  color: white;
}

.ending-title {
  font-family: var(--font-title);
  font-size: 3rem;
  margin-bottom: 20px;
}

/* Fun Surprise Section */
#fun-surprise {
  margin: 60px 0;
  text-align: center;
  opacity: 0;
  transform: translateY(30px);
  transition: all 1s ease;
}

#fun-surprise.visible {
  opacity: 1;
  transform: translateY(0);
}

.surprise-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.surprise-text {
  font-family: var(--font-body);
  color: var(--text-light);
  font-size: 1.1rem;
  margin-bottom: 30px;
}

.pulse-glow {
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.4);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(255, 77, 109, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 77, 109, 0);
  }
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  width: 90%;
  max-width: 1000px;
  height: 80vh;
  background: white;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  transform: scale(0.9);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 30px;
  background: white;
  border: none;
  cursor: pointer;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.modal-close:hover {
  transform: rotate(90deg);
  background: var(--primary);
  color: white;
}

.modal-body {
  width: 100%;
  height: 100%;
}

#fun-iframe {
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) {
  .modal-container {
    width: 95%;
    height: 90vh;
  }
}

.ending-sub {
  font-family: var(--font-body);
  font-size: 1.2rem;
  margin-bottom: 40px;
  opacity: 0.8;
}

.ending-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.secondary-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 10px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.3s ease;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: white;
}

.explore-btn {
  transform: scale(1.1);
  box-shadow: 0 15px 35px rgba(255, 77, 109, 0.5);
}

.explore-btn:hover {
  transform: scale(1.15) translateY(-5px);
}