/* ========================================
   Birthday Card — Mobile-First Styles
   ======================================== */

:root {
  --bg-gradient-start: #ffecd2;
  --bg-gradient-end: #fcb69f;
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  --text-primary: #2d2d3a;
  --text-secondary: #6b6b80;
  --accent: #ff6b9d;
  --accent-dark: #e8527a;
  --accent-light: #ffd1e0;
  --input-border: #e0d6cf;
  --input-focus: #ff6b9d;
  --error: #e74c3c;
  --success: #27ae60;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans TC', sans-serif;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ===== Screen Management ===== */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.6s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   1. PASSWORD SCREEN
   ======================================== */
#screen-password {
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  flex-direction: column;
}
.password-container {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 380px;
  width: 100%;
  z-index: 1;
}

/* Envelope */
.envelope-icon { margin-bottom: 2rem; }
.envelope {
  position: relative;
  width: 100px; height: 72px;
  margin: 0 auto;
  animation: envelopeFloat 3s ease-in-out infinite;
}
.envelope-body {
  position: absolute; bottom: 0;
  width: 100px; height: 60px;
  background: #fff; border-radius: 6px;
  box-shadow: 0 4px 20px rgba(252, 182, 159, 0.4);
}
.envelope-flap {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  border-top: 36px solid #ffe0d0;
  transform-origin: top center;
  animation: flapWave 3s ease-in-out infinite;
}
.envelope-heart {
  position: absolute; bottom: 12px; left: 50%;
  transform: translateX(-50%);
  font-size: 1.8rem;
  animation: heartBeat 1.5s ease-in-out infinite;
}
@keyframes envelopeFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes flapWave {
  0%, 100% { transform: rotateX(0deg); }
  50% { transform: rotateX(15deg); }
}
@keyframes heartBeat {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.15); }
}

.password-title {
  font-size: 1.6rem; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem; letter-spacing: 0.5px;
}
.password-subtitle {
  font-size: 0.95rem; color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Code inputs */
.code-inputs { display: flex; justify-content: center; gap: 12px; margin-bottom: 0.5rem; }
.code-box {
  width: 56px; height: 64px;
  border: 2px solid var(--input-border); border-radius: 14px;
  text-align: center; font-size: 1.5rem; font-weight: 700;
  font-family: 'Noto Sans TC', sans-serif;
  color: var(--text-primary);
  background: var(--glass-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  outline: none; transition: all 0.25s ease;
  caret-color: var(--accent);
}
.code-box:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 4px var(--accent-light);
  transform: scale(1.05);
}
.code-box.shake { animation: shake 0.5s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.error-msg {
  font-size: 0.85rem; color: var(--error);
  min-height: 1.4em; margin-bottom: 1rem;
  transition: opacity 0.3s;
}

/* Primary button */
.btn-primary {
  display: inline-block;
  padding: 14px 36px; border: none; border-radius: 50px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 1rem; font-weight: 600;
  font-family: 'Noto Sans TC', sans-serif;
  cursor: pointer; transition: all 0.3s ease;
  box-shadow: 0 6px 24px rgba(255, 107, 157, 0.35);
  letter-spacing: 1px;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(255, 107, 157, 0.45);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary.loading {
  pointer-events: none; position: relative; color: transparent;
}
.btn-primary.loading::after {
  content: ''; position: absolute;
  width: 20px; height: 20px; top: 50%; left: 50%;
  margin: -10px 0 0 -10px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Floating particles */
.floating-particles {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.particle {
  position: absolute; border-radius: 50%; opacity: 0.25;
  animation: particleFloat linear infinite;
}
@keyframes particleFloat {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.25; }
  90% { opacity: 0.25; }
  100% { transform: translateY(-10vh) rotate(720deg); opacity: 0; }
}

/* ========================================
   2. AMOUNT SCREEN
   ======================================== */
#screen-amount {
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  flex-direction: column;
}
.amount-container {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 400px; width: 100%;
}
.amount-emoji {
  font-size: 4rem; margin-bottom: 1rem;
  animation: heartBeat 1.5s ease-in-out infinite;
}
.amount-title {
  font-size: 1.6rem; font-weight: 700;
  margin-bottom: 0.5rem;
}
.amount-subtitle {
  font-size: 1rem; color: var(--text-secondary);
  margin-bottom: 2rem; line-height: 1.6;
}
.amount-input-group { margin-bottom: 0.5rem; }
.amount-input-wrapper {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-bottom: 0.5rem;
}
.amount-prefix {
  font-size: 1.8rem; font-weight: 700;
  color: var(--accent-dark);
}
.amount-input {
  width: 200px; padding: 12px 16px;
  border: 2px solid var(--input-border); border-radius: 14px;
  font-size: 1.4rem; font-weight: 700;
  font-family: 'Noto Sans TC', sans-serif;
  color: var(--text-primary);
  background: var(--glass-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  outline: none; text-align: center;
  transition: all 0.25s ease;
}
.amount-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

/* ========================================
   3. CARD SCREEN
   ======================================== */
#screen-card {
  background: linear-gradient(160deg, #fdfbfb 0%, #ebedee 100%);
  align-items: flex-start;
  padding: 1.5rem;
}
.card-container {
  width: 100%; max-width: 440px;
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  background: var(--card-bg); border-radius: 24px;
  box-shadow: var(--card-shadow);
  animation: cardSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative; overflow: hidden;
}
.card-container::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--accent), #ffb347, var(--accent));
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card-header { text-align: center; margin-bottom: 1.5rem; }
.birthday-badge {
  font-size: 3.5rem; margin-bottom: 0.5rem;
  animation: badgeBounce 2s ease-in-out infinite;
}
@keyframes badgeBounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-5deg); }
  75% { transform: scale(1.1) rotate(5deg); }
}
.card-title {
  font-family: 'Dancing Script', cursive;
  font-size: 2rem; color: var(--accent-dark); line-height: 1.4;
}
.card-body { margin-bottom: 1.5rem; }
.card-message {
  font-size: 1rem; line-height: 2;
  color: var(--text-primary);
  white-space: pre-wrap; letter-spacing: 0.3px;
}
.card-message .char {
  display: inline-block; opacity: 0;
  animation: charFadeIn 0.05s forwards;
}
@keyframes charFadeIn { to { opacity: 1; } }

.card-divider {
  text-align: center; margin: 1.5rem 0;
  position: relative;
}
.card-divider::before, .card-divider::after {
  content: ''; position: absolute;
  top: 50%; width: calc(50% - 24px); height: 1px;
  background: linear-gradient(90deg, transparent, var(--input-border), transparent);
}
.card-divider::before { left: 0; }
.card-divider::after { right: 0; }
.card-divider span { font-size: 1.2rem; }

/* Gift question */
.card-gift-section { margin-top: 0.5rem; text-align: center; }
.question-block {
  background: linear-gradient(135deg, #fef9f4, #fff5f5);
  border-radius: 16px; padding: 1.2rem;
  border: 1px solid rgba(255, 107, 157, 0.12);
  margin-bottom: 0.5rem;
}
.question-label {
  font-size: 0.9rem; font-weight: 600;
  color: var(--accent-dark);
  margin-bottom: 0.6rem;
  display: flex; align-items: center; gap: 6px;
}
.question-label::before {
  content: 'Q'; display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.7rem; font-weight: 700;
}
.question-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--input-border); border-radius: 12px;
  font-size: 0.95rem; font-family: 'Noto Sans TC', sans-serif;
  color: var(--text-primary);
  background: rgba(255,255,255,0.8);
  outline: none; transition: border-color 0.25s, box-shadow 0.25s;
  resize: vertical; min-height: 44px;
}
.question-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ========================================
   4. THANKS / END SCREEN
   ======================================== */
#screen-end {
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  flex-direction: column;
}
.thanks-container {
  text-align: center; padding: 2rem;
  animation: fadeIn 0.8s ease;
}
.thanks-emoji {
  font-size: 5rem; margin-bottom: 1.5rem;
  animation: heartBeat 1.5s ease-in-out infinite;
}
.thanks-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.8rem; }
.thanks-subtitle { font-size: 1.1rem; color: var(--text-secondary); }

/* ========================================
   5. EXPIRED SCREEN
   ======================================== */
#screen-expired {
  background: linear-gradient(135deg, #2d2d3a 0%, #1a1a2e 100%);
  flex-direction: column;
}
.expired-container {
  text-align: center; padding: 2rem;
  animation: fadeIn 0.8s ease;
}
.expired-emoji {
  font-size: 5rem; margin-bottom: 1.5rem;
  animation: fireFlicker 1s ease-in-out infinite alternate;
}
@keyframes fireFlicker {
  from { transform: scale(1) rotate(-3deg); filter: brightness(1); }
  to { transform: scale(1.08) rotate(3deg); filter: brightness(1.2); }
}
.expired-title { font-size: 1.5rem; font-weight: 700; color: #fff; margin-bottom: 0.8rem; }
.expired-subtitle { font-size: 1rem; color: rgba(255,255,255,0.6); }

/* ========================================
   CONFIRM DIALOG
   ======================================== */
.confirm-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center; justify-content: center;
}
.confirm-overlay.active { display: flex; }
.confirm-dialog {
  background: #fff; border-radius: 20px;
  padding: 2rem 1.5rem; max-width: 320px; width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: cardSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.confirm-text {
  font-size: 1rem; font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 1.5rem; line-height: 1.6;
}
.confirm-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-confirm-yes {
  padding: 12px 24px; border: none; border-radius: 50px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-size: 0.95rem; font-weight: 600;
  font-family: 'Noto Sans TC', sans-serif;
  cursor: pointer; transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(255, 107, 157, 0.3);
}
.btn-confirm-yes:hover { transform: translateY(-1px); }
.btn-confirm-no {
  padding: 12px 24px; border: 1.5px solid var(--input-border);
  border-radius: 50px; background: transparent;
  color: var(--text-secondary); font-size: 0.95rem; font-weight: 500;
  font-family: 'Noto Sans TC', sans-serif;
  cursor: pointer; transition: all 0.25s ease;
}
.btn-confirm-no:hover { border-color: var(--accent); color: var(--accent); }

/* ========================================
   FLOATING HEARTS (Card Screen)
   ======================================== */
.floating-hearts {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.heart-particle {
  position: absolute; bottom: -30px;
  opacity: 0;
  animation: heartFloat linear infinite;
}
@keyframes heartFloat {
  0% { transform: translateY(0) rotate(0deg) scale(0.5); opacity: 0; }
  10% { opacity: 0.6; }
  50% { opacity: 0.4; }
  90% { opacity: 0.15; }
  100% { transform: translateY(-100vh) rotate(360deg) scale(1.2); opacity: 0; }
}

/* ========================================
   CONFETTI
   ======================================== */
.confetti-container {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
}
.confetti-piece {
  position: absolute; top: -10px;
  width: 10px; height: 10px; border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotateZ(0deg) rotateX(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotateZ(720deg) rotateX(360deg); opacity: 0; }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (min-width: 480px) {
  .password-title { font-size: 1.8rem; }
  .code-box { width: 62px; height: 70px; font-size: 1.7rem; }
  .card-container { padding: 2.5rem 2rem 3rem; }
  .card-title { font-size: 2.4rem; }
  .card-message { font-size: 1.05rem; }
}
