/* ==========================================================================
   BLOOMING MEMORIES — Vietnamese Women's Day (20/10) Greeting Website
   Elegant Floral Dream · Romantic Garden · Pearl Light · Premium Greeting
   ========================================================================== */

/* ==========================================================================
   1. CSS RESET & CUSTOM PROPERTIES
   ========================================================================== */

:root {
  /* ---- Primary Palette ---- */
  --pink-powder: #F7D7E5;
  --pink-peach: #F4AFC4;
  --pink-rose: #C94F78;
  --red-petal: #A83E63;
  --cream-ivory: #FFF6EB;
  --white-pearl: #FFFCF8;
  --sage-green: #A8B89A;
  --green-deep: #526B55;
  --champagne: #D8B16D;
  --mauve-light: #B69AB8;

  /* ---- Derived / Semantic Colors ---- */
  --bg-primary: #FFF6EB;
  --bg-secondary: #FFFCF8;
  --text-primary: #3D2B2B;
  --text-secondary: #6B4F4F;
  --text-muted: #9B7F7F;
  --accent: #C94F78;
  --accent-light: #F4AFC4;
  --accent-dark: #A83E63;
  --highlight: #D8B16D;
  --shadow-color: rgba(169, 62, 99, 0.1);

  /* ---- Typography ---- */
  --font-heading: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;

  /* ---- Spacing ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 40px;

  /* ---- Borders & Radii ---- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  /* ---- Transitions ---- */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.6s ease;
}

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

/* ==========================================================================
   2. BASE STYLES
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html,
body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(
    160deg,
    var(--cream-ivory) 0%,
    var(--pink-powder) 50%,
    var(--cream-ivory) 100%
  );
  background-attachment: fixed;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
textarea {
  font-family: inherit;
}

/* ==========================================================================
   3. FORM SCREEN
   ========================================================================== */

#form-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-md);
  overflow-y: auto;
  background: linear-gradient(
    160deg,
    var(--cream-ivory) 0%,
    var(--pink-powder) 50%,
    var(--cream-ivory) 100%
  );
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#form-screen.hidden {
  opacity: 0;
  transform: translateY(-30px);
  pointer-events: none;
}

/* ---- Form Container ---- */
.form-container {
  width: 100%;
  max-width: 420px;
  padding: var(--space-2xl) var(--space-xl);
  background: rgba(255, 252, 248, 0.92);
  border-radius: var(--radius-xl);
  box-shadow:
    0 8px 32px var(--shadow-color),
    0 2px 8px rgba(169, 62, 99, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
}

/* ---- Form Decor ---- */
.form-decor {
  font-size: 2.8rem;
  text-align: center;
  margin-bottom: var(--space-xs);
  animation: gentle-pulse 3s ease-in-out infinite;
  display: block;
}

/* ---- Form Title ---- */
.form-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-align: center;
  margin-bottom: var(--space-xs);
  line-height: 1.3;
}

/* ---- Form Date ---- */
.form-date {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.04em;
  line-height: 1.2;
  margin-bottom: var(--space-sm);
}

/* ---- Form Intro ---- */
.form-intro {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-lg);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---- Form Groups ---- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

/* ---- Input Fields ---- */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid transparent;
  background: var(--cream-ivory);
  border-radius: var(--radius-md);
  font-size: 1rem;
  color: var(--text-primary);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  outline: none;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group textarea:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(244, 175, 196, 0.25);
}

.form-group input[type="text"]::placeholder,
.form-group input[type="number"]::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

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

/* ---- Field Error ---- */
.field-error {
  display: block;
  color: var(--red-petal);
  font-size: 0.8rem;
  min-height: 1.2em;
  margin-top: var(--space-xs);
  line-height: 1.4;
}

/* ---- Photo Upload Section ---- */
.photo-upload-section {
  border: 2px dashed var(--pink-peach);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  text-align: center;
  background: rgba(247, 215, 229, 0.2);
  transition: border-color var(--transition-normal), background var(--transition-normal);
  margin-bottom: var(--space-md);
}

.photo-upload-section:hover {
  border-color: var(--accent);
  background: rgba(247, 215, 229, 0.35);
}

.photo-upload-title {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 2px;
}

.photo-upload-title .optional-label {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.photo-upload-subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: var(--space-sm);
}

.btn-photo-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--white-pearl);
  color: var(--accent-dark);
  border: 1px solid var(--pink-peach);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-photo-add:hover {
  background: var(--pink-powder);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-photo-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  margin-top: var(--space-sm);
  background: transparent;
  color: var(--red-petal);
  border: 1px solid rgba(168, 62, 99, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-photo-clear:hover {
  background: rgba(168, 62, 99, 0.08);
  border-color: var(--red-petal);
}

/* ---- Photo Grid ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.photo-thumb-wrapper {
  position: relative;
  width: 70px;
  height: 70px;
}

.photo-thumb {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid white;
  box-shadow: 0 2px 8px var(--shadow-color);
}

.photo-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red-petal);
  color: #fff;
  border: 2px solid #fff;
  font-size: 0.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.photo-delete:hover {
  transform: scale(1.15);
}

/* ---- Start Button ---- */
.btn-start {
  display: block;
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--pink-rose) 0%, var(--red-petal) 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: var(--space-lg);
  transition: transform var(--transition-fast), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
  min-height: 52px;
  letter-spacing: 0.02em;
}

.btn-start:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(201, 79, 120, 0.35);
}

.btn-start:active {
  transform: scale(0.98);
}

.btn-start:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Shimmer animation for start button */
.btn-start::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 100%
  );
  animation: shimmer 3s ease-in-out infinite;
}

.btn-start:disabled::after {
  animation: none;
}

/* ---- Privacy Note ---- */
.privacy-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-md);
  line-height: 1.4;
}

/* ==========================================================================
   4. STAGE SCREEN
   ========================================================================== */

#stage-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 10;
}

#stage-screen.hidden {
  display: none;
}

#stage-screen:not(.hidden) {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   5. CANVAS CONTAINER
   ========================================================================== */

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   6. FOG CANVAS
   ========================================================================== */

#fog-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: crosshair;
  transition: opacity 0.8s ease;
}

#fog-canvas.fog-cleared {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   7. TOP BAR
   ========================================================================== */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 12px var(--space-md);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.top-bar-text {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--white-pearl);
  text-shadow:
    0 1px 4px rgba(61, 43, 43, 0.4),
    0 0 16px rgba(201, 79, 120, 0.25);
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.top-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   8. WISH PANEL
   ========================================================================== */

.wish-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 45vh;
  background: rgba(255, 252, 248, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 30px rgba(169, 62, 99, 0.15);
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.wish-panel.hidden {
  transform: translateY(100%);
  pointer-events: none;
}

/* ---- Wish Header ---- */
.wish-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wish-header-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-dark);
}

/* ---- Icon button for collapse toggle ---- */
.btn-icon-sm {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  background: var(--cream-ivory);
  border: 1px solid var(--pink-peach);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent-dark);
  padding: 0;
  transition: transform var(--transition-normal), background var(--transition-fast);
  /* Touch target expansion via padding on parent or pseudo */
  position: relative;
}

/* Expand touch target to at least 44x44 */
.btn-icon-sm::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
}

.btn-icon-sm:hover {
  background: var(--pink-powder);
}

.btn-icon-sm.rotated {
  transform: rotate(180deg);
}

/* ---- Wish Body ---- */
.wish-body {
  padding-top: 12px;
}

.wish-content {
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.wish-loading {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.95rem;
  padding: var(--space-sm) 0;
}

/* ---- Wish Actions ---- */
.wish-actions {
  display: flex;
  gap: 10px;
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.wish-actions button {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wish-actions button:hover {
  transform: translateY(-1px);
}

.wish-actions button:active {
  transform: translateY(0);
}

.btn-copy {
  background: var(--cream-ivory);
  color: var(--accent-dark);
  border: 1px solid var(--pink-peach);
}

.btn-copy:hover {
  background: var(--pink-powder);
}

.btn-new {
  background: var(--cream-ivory);
  color: var(--green-deep);
  border: 1px solid var(--sage-green);
}

.btn-new:hover {
  background: rgba(168, 184, 154, 0.15);
}

/* ---- Collapsed State ---- */
.wish-panel.collapsed .wish-body {
  display: none;
}

/* ==========================================================================
   9. SKIP FOG BUTTON (Căn chính giữa màn hình)
   ========================================================================== */

.btn-skip {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  z-index: 30;
  padding: 12px 24px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.92);
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--pink-peach);
  box-shadow: 0 8px 24px rgba(201, 79, 120, 0.3);
  cursor: pointer;
  min-height: 46px;
  min-width: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-normal), transform var(--transition-fast), background var(--transition-fast);
}

.btn-skip:hover {
  transform: translate(-50%, -50%) scale(1.06);
  background: #ffffff;
}

.btn-skip.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.92);
}

/* ==========================================================================
   10. LIGHTBOX
   ========================================================================== */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.lightbox.hidden {
  display: none;
}

#lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ==========================================================================
   11. ANIMATIONS
   ========================================================================== */

/* ---- Float Up (petals, hearts, bokeh) ---- */
@keyframes float-up {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 1;
  }
  25% {
    transform: translateY(-30vh) translateX(15px) rotate(45deg);
    opacity: 0.9;
  }
  50% {
    transform: translateY(-60vh) translateX(-10px) rotate(90deg);
    opacity: 0.7;
  }
  75% {
    transform: translateY(-90vh) translateX(20px) rotate(135deg);
    opacity: 0.4;
  }
  100% {
    transform: translateY(-120vh) translateX(-5px) rotate(180deg);
    opacity: 0;
  }
}

/* ---- Shimmer (button highlight sweep) ---- */
@keyframes shimmer {
  0% {
    left: -100%;
  }
  50% {
    left: 100%;
  }
  100% {
    left: 100%;
  }
}

/* ---- Gentle Pulse ---- */
@keyframes gentle-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* ---- Fade In ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---- Slide Up ---- */
@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---- Sparkle ---- */
@keyframes sparkle {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* ==========================================================================
   12. FLOATING DECORATIONS
   ========================================================================== */

.petal,
.heart-float,
.bokeh {
  position: fixed;
  pointer-events: none;
  z-index: 5;
}

/* ---- Petals ---- */
.petal {
  width: 12px;
  height: 16px;
  background: var(--pink-peach);
  border-radius: 50% 0 50% 50%;
  opacity: 0.6;
  animation: float-up linear infinite;
}

.petal:nth-child(odd) {
  background: var(--pink-powder);
  opacity: 0.5;
  width: 10px;
  height: 14px;
}

.petal:nth-child(3n) {
  background: var(--accent-light);
  opacity: 0.45;
  width: 14px;
  height: 18px;
}

/* ---- Hearts ---- */
.heart-float {
  font-size: 14px;
  opacity: 0.5;
  animation: float-up linear infinite;
  color: var(--pink-rose);
}

.heart-float:nth-child(even) {
  font-size: 10px;
  opacity: 0.35;
  color: var(--accent-light);
}

/* ---- Bokeh ---- */
.bokeh {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(216, 177, 109, 0.6) 0%,
    rgba(216, 177, 109, 0) 70%
  );
  opacity: 0.5;
  animation: float-up linear infinite, sparkle 2s ease-in-out infinite;
}

.bokeh:nth-child(odd) {
  width: 12px;
  height: 12px;
  opacity: 0.4;
  background: radial-gradient(
    circle,
    rgba(244, 175, 196, 0.5) 0%,
    rgba(244, 175, 196, 0) 70%
  );
}

/* ==========================================================================
   13. RESPONSIVE DESIGN
   ========================================================================== */

/* ---- Small Mobile (≤480px) ---- */
@media (max-width: 480px) {
  .form-container {
    padding: var(--space-lg) var(--space-md);
    border-radius: 20px;
  }

  .form-title {
    font-size: 1.5rem;
  }

  .form-date {
    font-size: 2.4rem;
  }

  .form-intro {
    font-size: 0.88rem;
  }

  .form-group input[type="text"],
  .form-group textarea {
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  .btn-start {
    padding: 14px;
    font-size: 1rem;
  }

  .wish-panel {
    max-height: 50vh;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .wish-header-title {
    font-size: 1.05rem;
  }

  .wish-content {
    font-size: 0.95rem;
  }

  .wish-actions button {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .top-bar-text {
    font-size: 0.85rem;
  }
}

/* ---- Tablet & Desktop (≥768px) ---- */
@media (min-width: 768px) {
  .form-container {
    max-width: 480px;
    padding: 48px 40px;
  }

  .form-title {
    font-size: 2rem;
  }

  .form-date {
    font-size: 3.4rem;
  }

  .wish-panel {
    max-height: 40vh;
    max-width: 600px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .wish-panel.hidden {
    transform: translateX(-50%) translateY(100%);
  }

  .top-bar-text {
    font-size: 1.05rem;
  }
}

/* ---- Landscape Orientation ---- */
@media (orientation: landscape) and (max-height: 500px) {
  #form-screen {
    align-items: flex-start;
    padding-top: var(--space-md);
  }

  .form-container {
    padding: var(--space-lg) var(--space-xl);
    max-height: 95vh;
    max-height: 95dvh;
    overflow-y: auto;
  }

  .form-date {
    font-size: 2rem;
    margin-bottom: var(--space-xs);
  }

  .form-intro {
    margin-bottom: var(--space-sm);
    font-size: 0.85rem;
  }

  .wish-panel {
    max-height: 60vh;
    max-width: 360px;
    right: 0;
    left: auto;
    bottom: 0;
    top: auto;
    border-radius: var(--radius-xl) 0 0 0;
  }

  .wish-panel.hidden {
    transform: translateX(100%);
  }
}

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

  .petal,
  .heart-float,
  .bokeh {
    display: none;
  }

  .btn-start::after {
    animation: none;
    display: none;
  }

  #form-screen {
    transition: none;
  }

  .wish-panel {
    transition: none;
  }
}

/* ==========================================================================
   14. SCROLLBAR STYLING
   ========================================================================== */

/* ---- Webkit Scrollbar (wish panel) ---- */
.wish-panel::-webkit-scrollbar {
  width: 5px;
}

.wish-panel::-webkit-scrollbar-track {
  background: transparent;
}

.wish-panel::-webkit-scrollbar-thumb {
  background: var(--pink-peach);
  border-radius: var(--radius-pill);
}

.wish-panel::-webkit-scrollbar-thumb:hover {
  background: var(--pink-rose);
}

/* ---- Firefox Scrollbar ---- */
.wish-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--pink-peach) transparent;
}

/* ---- Form Container Scrollbar (landscape) ---- */
.form-container::-webkit-scrollbar {
  width: 4px;
}

.form-container::-webkit-scrollbar-track {
  background: transparent;
}

.form-container::-webkit-scrollbar-thumb {
  background: var(--pink-powder);
  border-radius: var(--radius-pill);
}

.form-container {
  scrollbar-width: thin;
  scrollbar-color: var(--pink-powder) transparent;
}

/* ==========================================================================
   15. UTILITY CLASSES
   ========================================================================== */

.hidden:not(#form-screen):not(.wish-panel):not(.top-bar):not(.btn-skip) {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.slide-up {
  animation: slideUp 0.5s ease forwards;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   16. VIDEO-STYLE STAGE & MOBILE-OPTIMIZED WISH CARD UPGRADES
   ========================================================================== */

#stage-screen {
  background: radial-gradient(circle at 50% 42%, #591834 0%, #2d0b1a 60%, #16040c 100%);
  touch-action: none;
}

/* Cho phép vuốt ngón tay liên tục trên màn sương điện thoại mà không bị ngắt */
#fog-canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stage-status-label {
  position: fixed;
  top: 66%;
  left: 50%;
  width: 88%;
  max-width: 420px;
  transform: translateX(-50%);
  z-index: 25;
  color: #ffe3ec;
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.4;
  text-shadow: 0 2px 12px rgba(255, 77, 136, 0.85);
  pointer-events: none;
  transition: opacity 0.5s ease;
  text-align: center;
}

.stage-status-label.hidden {
  opacity: 0;
}

/* Box lời chúc trong suốt — kéo lên gần tên hơn (bottom lớn hơn) và cho phép
   cuộn bên trong thay vì cắt cụt nội dung (overflow-y: auto thay vì hidden) */
.wish-panel {
  bottom: 4vh;
  left: 50%;
  right: auto;
  width: 92%;
  max-width: 450px;
  max-height: 74vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 22px 18px;
  transform: translateX(-50%) translateY(0);
  background: rgba(38, 8, 22, 0.32); /* Trong suốt thấy rõ trái tim bay đằng sau */
  border: 1px solid rgba(255, 182, 201, 0.36);
  border-radius: 22px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45), 0 0 24px rgba(255, 92, 138, 0.16);
  color: #fff6eb;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.wish-panel.hidden {
  transform: translateX(-50%) translateY(120%);
}

.wish-header {
  display: none;
}

.wish-body {
  padding-top: 0;
}

.wish-content {
  white-space: normal !important;
  line-height: 1.55;
  font-size: 0.88rem;
}

.wish-card-inner {
  text-align: center;
  color: #fff8fa;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wish-badge {
  display: inline-block;
  padding: 3px 13px;
  border-radius: 999px;
  background: rgba(255, 182, 201, 0.14);
  border: 1px solid rgba(255, 182, 201, 0.32);
  color: #ffccd9;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.wish-heart-icon {
  font-size: 1.3rem;
  line-height: 1.1;
  margin-bottom: 6px;
}

.wish-subtitle {
  font-family: var(--font-heading);
  font-style: italic;
  color: #f4afc4;
  font-size: 0.82rem;
  margin: 0 0 4px;
}

.wish-recipient-name {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: #ffffff;
  text-shadow: 0 0 14px rgba(255, 107, 157, 0.65);
  margin: 0 0 8px;
  line-height: 1.2;
}

.wish-divider {
  font-size: 0.68rem;
  margin-bottom: 10px;
  opacity: 0.85;
}

/* Giữ chiều cao tối thiểu ổn định khi đang gõ chữ để Box không phình ngược lên che mất Tên */
.wish-main-paragraph {
  font-size: 0.86rem;
  line-height: 1.6;
  color: #ffeef3;
  margin-bottom: 14px;
  min-height: 4.4em;
  text-align: center;
}

.wish-mini-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 4px 0 12px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.hidden-grid {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.wish-mini-item {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 182, 201, 0.22);
  border-radius: 12px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.wish-mini-item .mini-icon {
  font-size: 0.85rem;
}

.wish-mini-item strong {
  font-size: 0.78rem;
  color: #ffd6e4;
}

.wish-mini-item small {
  font-size: 0.68rem;
  color: #f7d7e5;
  line-height: 1.3;
}

.wish-footer-quote {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 0.76rem;
  color: #f4afc4;
  margin-top: 8px;
  transition: opacity 0.5s ease;
}

.wish-actions {
  justify-content: center;
  margin-top: 10px;
  gap: 8px;
}

.wish-actions button {
  padding: 5px 12px;
  min-height: 32px;
  font-size: 0.75rem;
  background: rgba(255, 246, 235, 0.14);
  color: #ffeef3;
  border: 1px solid rgba(255, 182, 201, 0.35);
}

/* ==========================================================================
   17. MOBILE COMPACT OVERRIDES (Tối ưu riêng cho màn hình điện thoại ≤ 600px)
   ========================================================================== */
@media (max-width: 600px) {
  /* Thu gọn Form ban đầu để vừa khít màn hình điện thoại không bị cắt đáy */
  .form-container {
    padding: 18px 16px;
    max-width: 92vw;
    border-radius: 18px;
  }

  .form-decor {
    font-size: 2rem;
    margin-bottom: 2px;
  }

  .form-title {
    font-size: 1.32rem;
  }

  .form-date {
    font-size: 2rem;
    margin-bottom: 4px;
  }

  .form-intro {
    font-size: 0.82rem;
    margin-bottom: 12px;
  }

  .form-group {
    margin-bottom: 10px;
  }

  .form-group label {
    font-size: 0.82rem;
    margin-bottom: 4px;
  }

  .form-group input[type="text"],
  .form-group input[type="number"] {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .photo-upload-section {
    padding: 10px;
    margin-bottom: 10px;
  }

  .btn-start {
    padding: 12px;
    min-height: 44px;
    font-size: 0.95rem;
    margin-top: 10px;
  }

  .privacy-note {
    margin-top: 8px;
    font-size: 0.7rem;
  }

  /* Box lời chúc trên điện thoại: kéo lên gần tên hơn (bottom lớn hơn),
     giãn rộng ra (padding/line-height/gap lớn hơn) và cho cuộn nếu vẫn
     chưa đủ chỗ, để không còn bị mất đoạn cuối (footer quote). */
  .wish-panel {
    bottom: 3vh;
    width: 93%;
    max-height: 70vh;
    overflow-y: auto;
    padding: 16px 16px 16px;
    border-radius: 18px;
  }

  .wish-recipient-name {
    font-size: 1.2rem;
    margin: 0 0 6px;
  }

  .wish-main-paragraph {
    font-size: 0.82rem;
    line-height: 1.55;
    margin-bottom: 10px;
    min-height: 4.8em;
  }

  .wish-mini-grid {
    gap: 8px;
    margin: 4px 0 10px;
  }

  .wish-mini-item {
    padding: 7px 8px;
    gap: 3px;
  }

  .wish-mini-item strong {
    font-size: 0.74rem;
  }

  .wish-mini-item small {
    font-size: 0.64rem;
  }

  .wish-footer-quote {
    font-size: 0.72rem;
    margin-top: 6px;
  }

  .wish-actions {
    margin-top: 8px;
  }

  .wish-actions button {
    padding: 4px 10px;
    min-height: 28px;
    font-size: 0.72rem;
  }
}

/* ==========================================================================
   18. HEART CURSOR & FALLING HEART TRAIL
   ========================================================================== */

/* Đổi con chuột mặc định trên máy tính thành hình trái tim hồng */
body,
#stage-screen,
#fog-canvas,
button,
input {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='%23ff4d88' stroke='%23fff6eb' stroke-width='1.8'><path d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/></svg>") 14 14, auto !important;
}

/* Các trái tim sinh ra khi di chuột hoặc giữ vuốt trên điện thoại */
.falling-heart-particle {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 9999;
  line-height: 1;
  will-change: transform, opacity;
  filter: drop-shadow(0 0 6px rgba(255, 77, 136, 0.7));
}

/* ==========================================================================
   19. FIX: ẨN HOÀN TOÀN BOX LỜI CHÚC KHI CHƯA XÓA SƯƠNG + BỎ THANH CUỘN
   ========================================================================== */

/* Box lời chúc: khi còn .hidden thì ẩn hẳn (không còn lấp ló ở đáy màn hình).
   visibility được trì hoãn để animation trượt lên vẫn mượt. */
.wish-panel {
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    visibility 0s linear 0s;
}

.wish-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.3s ease,
    visibility 0s linear 0.5s;
}

/* Bỏ thanh cuộn nhưng vẫn vuốt/cuộn được nội dung bên trong */
.wish-panel,
.form-container,
#form-screen {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge cũ */
}

.wish-panel::-webkit-scrollbar,
.form-container::-webkit-scrollbar,
#form-screen::-webkit-scrollbar {
  display: none;                /* Chrome, Safari, Android WebView */
  width: 0;
  height: 0;
}