:root {
  --bg-soft: #ececec;
  --panel-border: #d7d7d7;
  --text-main: #2b2b2b;
  --blue: #2f88e8;
  --blue-soft: #5ea9f5;
  --pink-1: #ffd9e8;
  --pink-2: #ffc5db;
  --pink-3: #ff9ec5;
  --rose: #f06595;
  --white: #ffffff;
  --shadow: 0 16px 40px rgba(134, 60, 94, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  color: var(--text-main);
  background: var(--bg-soft);
  line-height: 1.35;
}

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
}

.panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.985);
  transition: opacity 280ms ease, transform 280ms ease, visibility 280ms ease;
  pointer-events: none;
  padding: max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  pointer-events: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Step 1 */
#step1 {
  background: #d9d9d9;
}

.captcha-card {
  width: min(460px, 94vw);
  background: var(--white);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

.captcha-checkline {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  flex: 1;
  min-height: 44px;
  touch-action: manipulation;
}

.captcha-checkline input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-visual {
  width: 30px;
  height: 30px;
  border: 2px solid #c6c6c6;
  background: #fff;
  display: grid;
  place-items: center;
  border-radius: 2px;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.checkmark {
  width: 20px;
  height: 20px;
  color: #2f9e44;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 220ms ease, transform 220ms ease;
}

.captcha-checkline input:checked + .check-visual {
  border-color: #7cb676;
  background: #f4fff4;
}

.captcha-checkline input:checked + .check-visual .checkmark {
  opacity: 1;
  transform: scale(1);
}

.captcha-label {
  font-size: clamp(1rem, 3.5vw, 1.35rem);
  line-height: 1.1;
}

.captcha-brand {
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
  width: 92px;
  flex-shrink: 0;
}

.logo-box {
  width: 34px;
  height: 34px;
  background: radial-gradient(circle at 28% 30%, #8ec6ff 10%, #2e86e6 70%);
  border-radius: 8px;
  position: relative;
}

.logo-box::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.95);
  top: 8px;
  left: 8px;
}

.brand-text {
  display: grid;
  gap: 2px;
}

.brand-text strong {
  font-size: 0.73rem;
  color: #777;
  font-weight: 600;
}

.brand-text small {
  font-size: 0.58rem;
  color: #999;
}

.captcha-card.loading .check-visual {
  border-color: #66b3ff;
  background: #edf6ff;
  animation: pulse 850ms linear infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(94, 169, 245, 0.4);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(94, 169, 245, 0);
  }
}

/* Step 2 */
#step2 {
  background: #efefef;
}

.image-captcha-card {
  width: min(460px, 95vw);
  border: 1px solid var(--panel-border);
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
}

.image-captcha-header {
  background: linear-gradient(135deg, #388eea 0%, #5ba8f0 100%);
  color: white;
  padding: 14px 16px;
}

.image-captcha-header p {
  margin: 0;
  font-size: 0.95rem;
}

.image-captcha-header h2 {
  margin: 2px 0 0;
  font-size: 1.5rem;
  line-height: 1;
}

.image-grid {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.image-tile {
  position: relative;
  border: 2px solid #d9d9d9;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: #f9f9f9;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  touch-action: manipulation;
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
}

.image-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(56, 142, 234, 0.24);
  opacity: 0;
  transition: opacity 120ms ease;
}

.image-tile.selected {
  border-color: var(--blue);
}

.image-tile.selected::after {
  opacity: 1;
}

.image-tile .tile-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 120ms ease, transform 120ms ease;
}

.image-tile.selected .tile-check {
  opacity: 1;
  transform: scale(1);
}

.image-captcha-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 12px;
}

.image-captcha-footer p {
  margin: 0;
  font-size: 0.9rem;
  color: #606060;
}

#submitBtn {
  border: none;
  background: linear-gradient(135deg, #3f95ea, #2e7fd9);
  color: #fff;
  font-weight: 700;
  padding: 10px 20px;
  min-height: 44px;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
  touch-action: manipulation;
}

#submitBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#submitBtn:not(:disabled):hover {
  transform: translateY(-1px);
}

#selectionHint.error {
  color: #d9480f;
}

/* Step 3 */
#step3 {
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.85) 0 12%, rgba(255, 255, 255, 0) 30%),
    radial-gradient(circle at 78% 16%, rgba(255, 255, 255, 0.7) 0 10%, rgba(255, 255, 255, 0) 27%),
    linear-gradient(155deg, var(--pink-1), var(--pink-2) 44%, #ffd1dd 68%, #ffe0ef);
}

.love-card {
  position: relative;
  z-index: 2;
  --letter-margin: 52px;
  --rule-gap: 40px;
  width: min(640px, 92vw);
  text-align: left;
  font-family: "Cormorant Garamond", "Georgia", serif;
  color: #4a3029;
  background:
    linear-gradient(
      90deg,
      transparent 0 calc(var(--letter-margin) - 1px),
      rgba(216, 90, 118, 0.34) calc(var(--letter-margin) - 1px) calc(var(--letter-margin) + 1px),
      transparent calc(var(--letter-margin) + 1px)
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(120, 155, 201, 0.22) 0 1px,
      transparent 1px var(--rule-gap)
    ),
    linear-gradient(180deg, #fffef8 0%, #fff9ec 100%);
  background-position: 0 0, 0 22px, 0 0;
  border: 1px solid #e8dcc3;
  border-radius: 12px;
  padding: clamp(30px, 6vw, 54px) clamp(24px, 5vw, 52px) clamp(34px, 6vw, 56px) clamp(70px, 11vw, 98px);
  box-shadow:
    0 24px 52px rgba(115, 66, 84, 0.24),
    0 1px 0 rgba(255, 255, 255, 0.82) inset;
  transform: rotate(-1deg);
}

.love-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(rgba(117, 84, 53, 0.08) 0.6px, transparent 0.8px);
  background-size: 3px 3px;
  opacity: 0.2;
  pointer-events: none;
}

.love-card::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #f1e7cf 0%, #f7efd9 52%, rgba(255, 255, 255, 0) 52%);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  box-shadow: -2px 2px 8px rgba(112, 83, 57, 0.14);
  border-top-right-radius: 12px;
  pointer-events: none;
}

.love-card > * {
  position: relative;
  z-index: 1;
}

.pill {
  display: table;
  margin: 0 auto 20px;
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  color: #8b4f64;
  background: rgba(255, 239, 217, 0.9);
  border: 1px dashed #d4a3b5;
}

.love-card h2 {
  margin: 0 0 4px;
  text-align: center;
  color: #a61e4d;
  font-family: "Great Vibes", "Brush Script MT", cursive;
  font-weight: 400;
  font-size: clamp(2.7rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
}

.message {
  margin: 18px 0 0;
  max-width: none;
  color: #53342d;
  font-family: "Caveat", "Segoe Print", cursive;
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.36;
  letter-spacing: 0.01em;
}

.signature {
  margin: 24px 0 0;
  color: #8f3550;
  text-align: right;
  padding-right: 4px;
  font-size: clamp(2rem, 5vw, 2.7rem);
  font-family: "Great Vibes", "Brush Script MT", cursive;
}

.floating-hearts {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.floating-hearts span {
  position: absolute;
  bottom: -30px;
  left: var(--x);
  width: 22px;
  height: 22px;
  background: var(--pink-3);
  transform: rotate(45deg);
  opacity: 0.6;
  animation: float var(--d) ease-in infinite;
  animation-delay: var(--delay);
}

.floating-hearts span::before,
.floating-hearts span::after {
  content: "";
  position: absolute;
  width: inherit;
  height: inherit;
  border-radius: 50%;
  background: inherit;
}

.floating-hearts span::before {
  left: -50%;
}

.floating-hearts span::after {
  top: -50%;
}

@keyframes float {
  0% {
    transform: translateY(0) rotate(45deg) scale(0.6);
    opacity: 0;
  }
  10% {
    opacity: 0.68;
  }
  100% {
    transform: translateY(-112vh) rotate(45deg) scale(1);
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: max(14px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .captcha-card {
    width: min(450px, 96vw);
    padding: 14px;
    gap: 10px;
  }

  .captcha-label {
    font-size: 1.05rem;
  }

  .captcha-brand {
    width: 76px;
  }

  .image-captcha-card {
    width: min(450px, 96vw);
  }

  .image-grid {
    gap: 6px;
    padding: 6px;
  }

  .image-tile .tile-check {
    width: 22px;
    height: 22px;
  }

  .image-captcha-header h2 {
    font-size: 1.33rem;
  }

  .image-captcha-footer {
    flex-direction: column;
    align-items: stretch;
  }

  #submitBtn {
    width: 100%;
  }

  .pill {
    font-size: 0.74rem;
  }
}

@media (max-width: 420px) {
  .captcha-card {
    padding: 12px;
  }

  .check-visual {
    width: 28px;
    height: 28px;
  }

  .captcha-label {
    font-size: 0.98rem;
  }

  .image-captcha-header {
    padding: 12px 12px;
  }

  .image-captcha-header p {
    font-size: 0.87rem;
  }

  .image-captcha-header h2 {
    font-size: 1.18rem;
  }

  .image-captcha-footer p {
    font-size: 0.84rem;
  }

  .love-card {
    --letter-margin: 38px;
    --rule-gap: 33px;
    width: min(620px, 96vw);
    border-radius: 10px;
    padding: 18px 12px 22px 52px;
    transform: rotate(-0.45deg);
  }

  .pill {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
  }

  .message {
    margin-top: 10px;
    font-size: clamp(1.35rem, 6.4vw, 1.75rem);
    line-height: 1.34;
  }

  .signature {
    margin-top: 16px;
    font-size: clamp(1.85rem, 8vw, 2.2rem);
  }
}
