:root {
  --pink: #ff6fa5;
  --purple: #7b5cff;
  --violet: #a06cff;
  --gold: #ffd166;
  --ink: #2b1f4a;
  --card-bg: rgba(255, 255, 255, 0.92);
  --radius: 22px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, #ffd6e8 0%, #d9c6ff 45%, #b9a4ff 100%);
  overflow-x: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Decorative floating balloons */
.bg-decor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.balloon {
  position: absolute;
  font-size: clamp(2rem, 8vw, 3.2rem);
  opacity: 0.55;
  animation: float 9s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.08));
}
.b1 { left: 6%;  top: 70%; animation-delay: 0s; }
.b2 { left: 80%; top: 60%; animation-delay: 1.5s; }
.b3 { left: 20%; top: 15%; animation-delay: 3s; }
.b4 { left: 72%; top: 10%; animation-delay: 4.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-26px) rotate(3deg); }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  display: none;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 20px;
}

.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: screenIn 0.5s ease both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px 24px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(80, 40, 120, 0.25), 0 2px 8px rgba(80,40,120,0.1);
  backdrop-filter: blur(6px);
}

.emoji-top {
  font-size: clamp(2.6rem, 10vw, 3.4rem);
  line-height: 1;
  margin-bottom: 6px;
}

.spin-emoji {
  display: inline-block;
  animation: wiggle 1.8s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

.title {
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  margin: 0 0 8px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: 0.98rem;
  line-height: 1.45;
  color: #4a3c6e;
  margin: 0 0 22px;
}

.final-subtitle {
  margin-bottom: 18px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.code-input {
  width: 100%;
  font-size: 1.4rem;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  padding: 16px 12px;
  border-radius: 14px;
  border: 2px solid #e3d6ff;
  background: #fbf9ff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-input::placeholder {
  letter-spacing: 0.15em;
  color: #b7a9d9;
  font-weight: 600;
  font-size: 0.95rem;
}

.code-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.15);
}

.code-input.shake {
  animation: shake 0.4s;
  border-color: #ff5c7a;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 15px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  box-shadow: 0 10px 24px rgba(123, 92, 255, 0.35);
}

.error-msg, .status-msg {
  min-height: 22px;
  margin: 14px 0 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.error-msg {
  color: #e2355d;
}

.status-msg.ok {
  color: #2fb380;
}
.status-msg.warn {
  color: #e2355d;
}
.status-msg.info {
  color: #7b5cff;
}

/* Hint box */
.hint-box {
  background: linear-gradient(135deg, #fff4e0, #ffe6f0);
  border: 2px dashed #ffb6d5;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
  text-align: center;
  animation: hintIn 0.4s ease both;
}

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

.hint-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e2355d;
  margin-bottom: 6px;
}

.hint-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}

/* Progress dots */
.progress-wrap {
  margin-bottom: 22px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e3d6ff;
  transition: background 0.3s, transform 0.3s;
}

.dot.filled {
  background: linear-gradient(135deg, var(--gold), var(--pink));
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(255, 150, 90, 0.5);
}

.progress-text {
  font-size: 0.9rem;
  color: #6a5a94;
  font-weight: 600;
}

/* Final screen */
.card-final {
  padding-top: 28px;
}

.gift-reveal {
  border-radius: 18px;
  overflow: hidden;
  margin: 0 auto 16px;
  max-width: 100%;
  box-shadow: 0 16px 36px rgba(80, 40, 120, 0.3);
  animation: giftPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.2s;
  opacity: 0;
}

@keyframes giftPop {
  from { opacity: 0; transform: scale(0.6) rotate(-6deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.gift-photo {
  display: block;
  width: 100%;
  height: auto;
}

.final-note {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--pink);
  margin: 4px 0 0;
}

@media (max-width: 360px) {
  .card {
    padding: 26px 16px 22px;
  }
  .code-input {
    letter-spacing: 0.22em;
    font-size: 1.2rem;
  }
}

@media (max-height: 640px) {
  .balloon { display: none; }
}
