:root {
  --pink-100: #fff0f3;
  --pink-200: #ffd6e0;
  --pink-300: #ffb3c6;
  --pink-400: #ff6b9d;
  --pink-500: #ff3d7f;
  --pink-600: #e8256e;
  --rose: #c44569;
  --warm-brown: #5c3d2e;
  --cream: #fff8f0;
  --gold: #ffd93d;
  --soft-shadow: 0 8px 32px rgba(255, 107, 157, 0.18);
  --btn-radius: 16px;
  --font-main: "Huninn", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-display: "Sour Gummy", "Huninn", "Noto Sans TC", sans-serif;
  --font-handwriting: "Huninn", "Noto Sans TC", "PingFang TC", sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  color: var(--warm-brown);
  background: linear-gradient(135deg, #fff0f3 0%, #ffd6e0 50%, #ffb3c6 100%);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ===== Heart Rain ===== */
.heart-rain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.rain-heart {
  position: absolute;
  bottom: -40px;
  font-size: 20px;
  opacity: 0.6;
  animation: heartFall linear forwards;
  pointer-events: none;
  color: var(--pink-400);
}

@keyframes heartFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 0.6;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    transform: translateY(-110vh) rotate(360deg) scale(0.5);
    opacity: 0;
  }
}

/* ===== Scenes ===== */
.scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.6s;
}

.scene.is-active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  z-index: 2;
}

/* ===== Scene: Loading ===== */
.scene-loading {
  background: transparent;
}

.loading-content {
  text-align: center;
  position: relative;
}

.loading-hearts {
  position: relative;
  height: 120px;
  width: 200px;
  margin: 0 auto 20px;
}

.floating-heart {
  position: absolute;
  font-size: 28px;
  animation: floatUp 2.5s ease-in-out infinite;
  color: var(--pink-500);
}

.fh-1 { left: 10%; animation-delay: 0s; font-size: 24px; color: #ff6b9d; }
.fh-2 { left: 30%; animation-delay: 0.3s; font-size: 32px; color: #ff3d7f; }
.fh-3 { left: 50%; animation-delay: 0.6s; font-size: 20px; color: #e8256e; }
.fh-4 { left: 70%; animation-delay: 0.9s; font-size: 28px; color: #ff6b9d; }
.fh-5 { left: 85%; animation-delay: 1.2s; font-size: 22px; color: #ff3d7f; }

@keyframes floatUp {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-60px) scale(1.2);
    opacity: 1;
  }
}

.loading-text {
  margin-bottom: 30px;
}

.loading-line {
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 700;
  color: var(--rose);
  opacity: 0;
  animation: fadeInUp 0.8s ease forwards;
  font-family: var(--font-display);
}

.loading-line-1 {
  animation-delay: 0.3s;
}

.loading-line-2 {
  animation-delay: 0.8s;
  font-size: clamp(22px, 6vw, 34px);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-spinner {
  margin-top: 10px;
}

.spinner-heart {
  font-size: 36px;
  animation: spinBounce 1.2s ease-in-out infinite;
  display: inline-block;
  color: var(--pink-500);
}

@keyframes spinBounce {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(15deg) scale(1.15); }
  50% { transform: rotate(0deg) scale(1); }
  75% { transform: rotate(-15deg) scale(1.15); }
}

/* ===== Scene: Password ===== */
.scene-password {
  background: transparent;
}

.password-content {
  text-align: center;
  width: min(90vw, 380px);
}

.lock-container {
  margin-bottom: 24px;
}

.lock-icon {
  font-size: 72px;
  display: inline-block;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: gentleBounce 2s ease-in-out infinite;
  color: var(--pink-500);
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.lock-icon.shake {
  animation: lockShake 0.5s ease;
}

@keyframes lockShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-10px) rotate(-5deg); }
  40% { transform: translateX(10px) rotate(5deg); }
  60% { transform: translateX(-6px) rotate(-3deg); }
  80% { transform: translateX(6px) rotate(3deg); }
}

.lock-icon.unlocking {
  animation: unlockPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes unlockPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3) rotate(-10deg); }
  70% { transform: scale(0.9) rotate(5deg); }
  100% { transform: scale(1.1) rotate(0); }
}

.password-title {
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 900;
  color: var(--rose);
  margin-bottom: 8px;
  font-family: var(--font-display);
}

.password-hint {
  font-size: clamp(13px, 3.5vw, 16px);
  color: var(--pink-500);
  margin-bottom: 28px;
  opacity: 0.8;
}

.password-input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.password-input {
  width: 180px;
  height: 56px;
  border: 3px solid var(--pink-300);
  border-radius: 28px;
  font-size: 24px;
  font-family: var(--font-main);
  font-weight: 700;
  letter-spacing: 12px;
  text-align: center;
  color: var(--rose);
  background: rgba(255, 255, 255, 0.8);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  touch-action: manipulation;
}

.password-input:focus {
  border-color: var(--pink-500);
  box-shadow: 0 0 0 4px rgba(255, 61, 127, 0.15);
}

.password-input.error {
  border-color: #ff4444;
  animation: inputShake 0.4s ease;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.password-submit {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color: white;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(255, 61, 127, 0.3);
  flex-shrink: 0;
}

.password-submit:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(255, 61, 127, 0.4);
}

.password-submit:active {
  transform: scale(0.95);
}

.password-error {
  min-height: 24px;
  margin-top: 16px;
  font-size: clamp(13px, 3.5vw, 15px);
  color: #ff4444;
  font-weight: 500;
}

.lock-decorations {
  margin-top: 32px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.deco {
  font-size: 24px;
  animation: decoFloat 3s ease-in-out infinite;
  color: var(--pink-400);
}

.deco-1 { animation-delay: 0s; color: var(--pink-500); }
.deco-2 { animation-delay: 0.5s; color: var(--pink-400); }
.deco-3 { animation-delay: 1s; color: var(--gold); }

@keyframes decoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(5deg); }
}

/* ===== Scene: Question ===== */
.scene-question {
  background: transparent;
}

.question-content {
  text-align: center;
  width: min(92vw, 440px);
  padding: 20px;
}

.question-gif {
  margin-bottom: 16px;
}

.cute-character {
  display: inline-block;
  animation: charBounce 1.5s ease-in-out infinite;
}

.char-body {
  font-size: clamp(56px, 15vw, 90px);
  display: block;
  color: var(--pink-400);
}

@keyframes charBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.question-text {
  margin-bottom: 36px;
}

.q-line-1 {
  display: block;
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 900;
  color: var(--rose);
  animation: fadeInUp 0.6s ease 0.2s both;
  font-family: var(--font-display);
}

.q-line-2 {
  display: block;
  font-size: clamp(30px, 8vw, 48px);
  font-weight: 900;
  color: var(--pink-600);
  animation: fadeInUp 0.6s ease 0.5s both;
  font-family: var(--font-display);
}

/* ===== Buttons ===== */
.buttons-container {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  position: relative;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 36px;
  border: none;
  border-radius: var(--btn-radius);
  font-family: var(--font-display);
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease,
              opacity 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 5;
}

.btn-yes {
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color: white;
  box-shadow: 0 6px 24px rgba(255, 61, 127, 0.35);
}

.btn-yes:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 32px rgba(255, 61, 127, 0.45);
}

.btn-yes:active {
  transform: scale(0.96);
}

.btn-no {
  background: white;
  color: var(--rose);
  border: 2px solid var(--pink-300);
  box-shadow: 0 4px 16px rgba(255, 107, 157, 0.15);
}

.btn-no:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 157, 0.25);
}

.btn-no:active {
  transform: scale(0.96);
}

.btn.escape {
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  pointer-events: none;
}

.btn.no-jumping {
  position: fixed !important;
  z-index: 100;
  pointer-events: none !important;
  transition: left 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              top 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.3s ease;
}

.btn.yes-big {
  transform: scale(1.4);
  font-size: clamp(22px, 6vw, 30px);
  padding: 20px 48px;
}

.btn.yes-bigger {
  transform: scale(1.7);
  font-size: clamp(26px, 7vw, 36px);
  padding: 24px 56px;
}

/* ===== Scene: Form ===== */
.scene-form {
  background: transparent;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-content {
  width: min(92vw, 420px);
  padding: 20px 0;
}

.form-header {
  text-align: center;
  margin-bottom: 28px;
}

.form-header-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 10px;
  animation: charBounce 1.5s ease-in-out infinite;
  color: var(--pink-500);
}

.form-title {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 900;
  color: var(--rose);
  margin-bottom: 6px;
  font-family: var(--font-display);
}

.form-subtitle {
  font-size: clamp(18px, 5vw, 24px);
  color: var(--pink-500);
  font-weight: 500;
  font-family: var(--font-handwriting);
}

.date-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 700;
  color: var(--rose);
}

.label-icon {
  font-size: 18px;
  color: var(--pink-400);
}

.form-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--pink-200);
  border-radius: 14px;
  font-family: var(--font-main);
  font-size: clamp(15px, 4vw, 17px);
  color: var(--warm-brown);
  background: rgba(255, 255, 255, 0.85);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.form-input:focus {
  border-color: var(--pink-400);
  box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.12);
}

.form-input::placeholder {
  color: var(--pink-300);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.4) sepia(1) saturate(3) hue-rotate(320deg);
  cursor: pointer;
}

.form-submit {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--btn-radius);
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color: white;
  font-family: var(--font-display);
  font-size: clamp(17px, 4.5vw, 20px);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  box-shadow: 0 6px 24px rgba(255, 61, 127, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}

.form-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(255, 61, 127, 0.45);
}

.form-submit:active {
  transform: scale(0.97);
}

.submit-heart {
  display: inline-block;
  animation: spinBounce 1.2s ease-in-out infinite;
  color: white;
}

.form-submit.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ===== Scene: Success ===== */
.scene-success {
  background: transparent;
}

.success-content {
  text-align: center;
  position: relative;
}

.success-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.success-heart {
  position: absolute;
  font-size: 24px;
  animation: successFloat 3s ease-in-out infinite;
  color: var(--pink-400);
}

.sh-1 { top: 5%; left: 10%; animation-delay: 0s; font-size: 20px; color: #ff6b9d; }
.sh-2 { top: 15%; right: 15%; animation-delay: 0.4s; font-size: 28px; color: #ff3d7f; }
.sh-3 { top: 60%; left: 5%; animation-delay: 0.8s; font-size: 22px; color: #e8256e; }
.sh-4 { top: 70%; right: 10%; animation-delay: 1.2s; font-size: 26px; color: #ff6b9d; }
.sh-5 { bottom: 15%; left: 20%; animation-delay: 1.6s; font-size: 18px; color: #ff3d7f; }
.sh-6 { bottom: 10%; right: 20%; animation-delay: 2s; font-size: 32px; color: var(--gold); }

@keyframes successFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
  50% { transform: translateY(-15px) rotate(10deg); opacity: 1; }
}

.success-icon {
  font-size: 72px;
  margin-bottom: 16px;
  animation: successPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--pink-500);
}

@keyframes successPop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.success-title {
  font-size: clamp(24px, 7vw, 36px);
  font-weight: 900;
  color: var(--rose);
  margin-bottom: 12px;
  animation: fadeInUp 0.6s ease 0.3s both;
  font-family: var(--font-display);
}

.success-text {
  font-size: clamp(18px, 5vw, 24px);
  color: var(--pink-500);
  line-height: 1.7;
  font-weight: 500;
  animation: fadeInUp 0.6s ease 0.5s both;
  font-family: var(--font-handwriting);
}

.success-character {
  font-size: 64px;
  margin-top: 24px;
  animation: charBounce 1.5s ease-in-out infinite;
  color: var(--pink-500);
}

/* ===== Custom Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(92, 61, 46, 0.35);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

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

.modal-box {
  width: min(88vw, 340px);
  background: white;
  border-radius: 24px;
  padding: 36px 28px 28px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(255, 107, 157, 0.25);
  transform: scale(0.8) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.is-visible .modal-box {
  transform: scale(1) translateY(0);
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 14px;
  color: var(--pink-500);
}

.modal-message {
  font-size: clamp(18px, 5vw, 22px);
  color: var(--warm-brown);
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 22px;
  font-family: var(--font-handwriting);
}

.modal-button {
  padding: 12px 40px;
  border: none;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--pink-400), var(--pink-500));
  color: white;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 61, 127, 0.3);
  transition: transform 0.2s;
  touch-action: manipulation;
}

.modal-button:hover {
  transform: scale(1.05);
}

.modal-button:active {
  transform: scale(0.96);
}

/* ===== Responsive ===== */
@media (max-height: 600px) {
  .lock-icon {
    font-size: 56px;
  }

  .loading-hearts {
    height: 80px;
  }

  .question-gif {
    margin-bottom: 8px;
  }

  .char-body {
    font-size: clamp(44px, 12vw, 64px);
  }

  .question-text {
    margin-bottom: 24px;
  }

  .buttons-container {
    min-height: 64px;
  }

  .btn {
    padding: 12px 28px;
    font-size: clamp(16px, 4.5vw, 20px);
  }
}

@media (max-width: 380px) {
  .password-input {
    width: 150px;
    font-size: 20px;
  }

  .password-submit {
    width: 48px;
    height: 48px;
  }

  .buttons-container {
    flex-direction: column;
    gap: 14px;
  }

  .btn {
    width: 200px;
  }
}

@media (min-width: 768px) {
  .heart-rain .rain-heart {
    font-size: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
