/* === CSS Custom Properties === */
:root {
  --rose: #e8446d;
  --rose-dark: #c9325a;
  --rose-light: #fce4ec;
  --cream: #fffaf5;
  --gold: #d4a853;
  --charcoal: #2d2428;
  --warm-gray: #8a7e82;
  --captcha-blue: #4285f4;
  --captcha-bg: #e8e8e8;
  --success-green: #00c853;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--charcoal);
  background: var(--cream);
}

/* === Stage Layout === */
.stage {
  display: none;
  min-height: 100dvh;
  width: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.stage.active {
  display: flex;
}

.stage.fade-out {
  animation: fadeOut 300ms ease forwards;
}

.stage.fade-in {
  animation: fadeIn 300ms ease forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* === Buttons === */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

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

.btn-primary {
  background: var(--rose);
  color: #fff;
  box-shadow: 0 4px 14px rgba(232, 68, 109, 0.35);
}

.btn-primary:hover {
  background: var(--rose-dark);
}

.btn-primary:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: #eee;
  color: #666;
}

/* === Language Toggle === */
.lang-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(232, 68, 109, 0.15);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lang-toggle:hover {
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.lang-option {
  color: var(--warm-gray);
  transition: color 0.2s;
  cursor: pointer;
  padding: 2px 0;
}

.lang-option.active {
  color: var(--rose);
}

.lang-separator {
  color: var(--warm-gray);
  opacity: 0.3;
  pointer-events: none;
}

@media (max-width: 767px) {
  .lang-toggle {
    top: 10px;
    right: 10px;
    padding: 4px 11px;
    font-size: 0.75rem;
  }
}

/* === Cookie Banner === */
.cookie-banner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  animation: fadeIn 400ms ease;
}

.cookie-banner.dismissed {
  animation: fadeOut 400ms ease forwards;
  pointer-events: none;
}

.cookie-card {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 32px;
  width: 100%;
  max-width: 500px;
  text-align: center;
  animation: slideUp 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cookie-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.cookie-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}

.cookie-sub {
  font-size: 0.9rem;
  color: var(--warm-gray);
  margin-bottom: 20px;
}

.cookie-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.cookie-reject {
  transition: transform 0.1s, opacity 0.3s;
}

.cookie-reject.evading {
  position: fixed;
  z-index: 1001;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* === Stage 1: Landing === */
.hearts-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  left: var(--x);
  bottom: -40px;
  font-size: 1.4rem;
  opacity: 0.25;
  animation: floatUp 7s ease-in-out var(--delay) infinite;
}

@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.25; }
  90% { opacity: 0.25; }
  100% { transform: translateY(-100dvh) rotate(30deg); opacity: 0; }
}

.landing-content {
  text-align: center;
  padding: 20px;
}

.landing-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 12px;
  line-height: 1.2;
}

.landing-sub {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  color: var(--warm-gray);
  margin-bottom: 40px;
}

.landing-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
}

.btn-yes {
  background: var(--rose);
  color: #fff;
  font-size: 1.15rem;
  padding: 16px 40px;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(232, 68, 109, 0.4);
  animation: shimmer 2.5s ease-in-out infinite, pulseGlow 2s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { box-shadow: 0 4px 20px rgba(232, 68, 109, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(232, 68, 109, 0.7), 0 0 40px rgba(232, 68, 109, 0.2); }
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.btn-no {
  background: #eee;
  color: #888;
  padding: 14px 28px;
  border-radius: 50px;
  transition: transform 0.1s, font-size 0.3s, padding 0.3s, opacity 0.3s;
}

.btn-no.evading {
  position: fixed;
  z-index: 100;
}

.btn-no.shrink-1 { transform: scale(0.8); }
.btn-no.shrink-2 { transform: scale(0.6); }

.no-gone-text {
  font-family: 'Caveat', cursive;
  font-size: 0.95rem;
  color: var(--warm-gray);
  margin-top: 16px;
  animation: fadeIn 500ms ease;
}

/* === Stage 2: reCAPTCHA === */
#stage-2 {
  background: var(--captcha-bg);
}

.captcha-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  width: min(420px, 92vw);
  overflow: hidden;
}

.captcha-header {
  background: var(--captcha-blue);
  color: #fff;
  padding: 14px 16px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.captcha-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  background: #ddd;
}

.captcha-tile {
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: #f5f5f5;
}

.captcha-tile video,
.captcha-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: transparent;
  pointer-events: none;
  transition: background 0.3s;
}

.tile-overlay.wrong {
  background: rgba(220, 50, 50, 0.45);
}

.tile-overlay.wrong::after {
  content: '❌';
  font-size: 2.2rem;
  animation: bounceIn 400ms ease;
}

.tile-overlay.correct {
  background: rgba(0, 200, 83, 0.4);
}

.tile-overlay.correct::after {
  content: '✓';
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  animation: bounceIn 400ms ease;
}

.tile-overlay.dog-msg {
  background: rgba(0, 0, 0, 0.7);
  font-size: 0.75rem;
  color: #fff;
  padding: 8px;
  text-align: center;
  line-height: 1.3;
}

.tile-overlay.dog-msg::after {
  content: 'He says he loves you… but just as a friend. 🐾';
  font-size: 0.75rem;
  animation: fadeIn 400ms ease;
}

.tile-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s;
}

.tile-lock.hidden {
  opacity: 0;
  pointer-events: none;
}

.captcha-tile.shake {
  animation: tileShake 400ms ease;
}

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.boyfriend-tile.glow {
  animation: bfPulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 12px var(--rose), 0 0 24px rgba(232, 68, 109, 0.4);
  z-index: 1;
}

@keyframes bfPulse {
  0%, 100% { box-shadow: 0 0 8px var(--rose), 0 0 16px rgba(232, 68, 109, 0.3); }
  50% { box-shadow: 0 0 16px var(--rose), 0 0 32px rgba(232, 68, 109, 0.5); }
}

.captcha-status {
  padding: 8px 16px;
  font-size: 0.9rem;
  min-height: 36px;
  color: var(--warm-gray);
  text-align: center;
}

.captcha-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid #eee;
}

.captcha-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #999;
}

.recaptcha-logo {
  font-size: 1.1rem;
}

.btn-verify {
  background: var(--captcha-blue);
  color: #fff;
  font-size: 0.85rem;
  padding: 10px 24px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-verify:disabled {
  background: #b0b0b0;
  cursor: not-allowed;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* === Inline Tile Video === */
.captcha-tile.playing {
  z-index: 2;
  box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.captcha-tile.tile-flipped video,
.captcha-tile.tile-flipped img {
  transform: scaleX(-1);
}

.captcha-tile.tile-zoomed-out video,
.captcha-tile.tile-zoomed-out img {
  object-fit: cover;
  transform: scale(0.85);
}

/* === Stage 3: Puzzle === */
#stage-3 {
  background: var(--captcha-bg);
}

.puzzle-container {
  padding: 3px;
}

.puzzle-area {
  position: relative;
  width: 100%;
  aspect-ratio: auto;
  overflow: visible;
  touch-action: none;
}

.puzzle-bg {
  width: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.puzzle-target {
  position: absolute;
  border: 2px dashed rgba(232, 68, 109, 0.0);
  border-radius: 4px;
  transition: border-color 0.3s;
}

.puzzle-target.hint {
  border-color: rgba(232, 68, 109, 0.5);
  box-shadow: 0 0 12px rgba(232, 68, 109, 0.3);
}

.puzzle-piece {
  position: absolute;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: none;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.3));
}

.puzzle-piece.snapped {
  cursor: default;
  filter: none;
  animation: snapBounce 400ms ease;
}

@keyframes snapBounce {
  0% { transform: scale(1.1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.puzzle-area.sparkle::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(212, 168, 83, 0.3) 0%, transparent 70%);
  animation: sparkleGlow 1s ease-out forwards;
  pointer-events: none;
}

@keyframes sparkleGlow {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

.puzzle-hint {
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--warm-gray);
  text-align: center;
}

/* === Stage 4: Terms & Conditions === */
#stage-4 {
  background: var(--captcha-bg);
  padding: 20px;
}

.tc-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  width: min(420px, 92vw);
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tc-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.tc-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  font-size: 0.88rem;
  line-height: 1.6;
  max-height: 50dvh;
  -webkit-overflow-scrolling: touch;
}

.tc-content h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tc-content h4 {
  font-size: 0.92rem;
  margin-top: 16px;
  margin-bottom: 6px;
  color: var(--charcoal);
}

.tc-content p {
  margin-bottom: 10px;
  color: #444;
}

.tc-footer {
  padding: 14px 20px;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tc-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  cursor: pointer;
  min-height: 44px;
}

.tc-check-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--rose);
}

.tc-check-label input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Stage 5: Finale === */
#stage-5 {
  background: var(--cream);
}

.finale-content {
  text-align: center;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.finale-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--success-green);
  padding: 10px 20px;
  border: 2px solid var(--success-green);
  border-radius: 50px;
  display: inline-block;
}

.finale-badge.show {
  animation: bounceIn 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.finale-heading {
  font-family: 'Playfair Display', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1.2;
}

.finale-heading.show {
  animation: fadeSlideUp 600ms ease forwards;
}

.finale-heart {
  font-size: 3.5rem;
}

.finale-heart.show {
  animation: heartbeat 1.2s ease-in-out infinite;
}

.finale-message {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: var(--warm-gray);
  max-width: 320px;
  line-height: 1.5;
}

.finale-message.show {
  animation: fadeSlideUp 600ms ease forwards;
}

.hide {
  opacity: 0;
}

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

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
}

/* === Desktop === */
@media (min-width: 768px) {
  .landing-title {
    font-size: 3.2rem;
  }

  .landing-sub {
    font-size: 1.8rem;
  }

  .finale-heading {
    font-size: 3rem;
  }

  .cookie-card {
    border-radius: 20px;
    margin-bottom: 40px;
  }
}
