* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --primary-glow: #ff77aa;
  --secondary-glow: #a855f7;
  --gold-glow: #ffd700;
  --text-main: #ffffff;
  --bg-gradient: radial-gradient(circle at 50% 35%, #1e1035 0%, #0c0818 55%, #05030a 100%);
  --glass-bg: rgba(22, 14, 38, 0.65);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-blur: blur(18px);
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-gradient);
  font-family: 'Montserrat', 'Segoe UI', -apple-system, sans-serif;
  color: var(--text-main);
}

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

/* TOP HEADER & TITLE */
.top-header {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  pointer-events: auto;
  perspective: 1000px;
}

.title-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5), 0 0 25px rgba(255, 119, 170, 0.25);
  padding: 16px 36px;
  border-radius: 50px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.25s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.title-card:hover {
  transform: scale(1.03);
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.6), 0 0 35px rgba(255, 119, 170, 0.45);
}

.sparkle-icon {
  font-size: 14px;
  color: var(--gold-glow);
  display: inline-block;
  animation: twinkle 2s infinite ease-in-out;
  margin: 0 6px;
}

.main-title {
  font-family: 'Cinzel', 'Playfair Display', 'Georgia', serif;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 0%, #ffc5dc 40%, #ffd8a8 75%, #ffffff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 4s linear infinite;
  text-shadow: 0 0 25px rgba(255, 119, 170, 0.6);
}

.sub-title {
  font-size: 12px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 4px;
  font-weight: 300;
}

/* FLOATING CONTROLS DOCK */
.dock-container {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  width: auto;
  max-width: 95vw;
}

.dock {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(168, 85, 247, 0.2);
  padding: 10px 20px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.dock-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s ease;
  outline: none;
}

.dock-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 119, 170, 0.35);
}

.dock-btn.active {
  background: linear-gradient(135deg, rgba(255, 119, 170, 0.4), rgba(168, 85, 247, 0.4));
  border-color: #ff77aa;
  box-shadow: 0 0 15px rgba(255, 119, 170, 0.5);
}

/* PALETTE SELECTOR */
.palette-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.palette-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.palette-dot:hover {
  transform: scale(1.25);
  border-color: #ffffff;
  box-shadow: 0 0 12px currentColor;
}

.palette-dot.active {
  transform: scale(1.3);
  border-color: #ffffff;
  box-shadow: 0 0 16px #ffffff;
}

/* TOP-RIGHT QUICK ACTIONS */
.quick-tools {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 10;
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: #ffffff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.12);
  box-shadow: 0 0 20px rgba(255, 119, 170, 0.45);
}

.icon-btn.active {
  color: #ff77aa;
  border-color: #ff77aa;
}

/* HINT TOAST AT BOTTOM */
.hint-badge {
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ROMANTIC NOTE MODAL */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 4, 15, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.letter-card {
  width: 90%;
  max-width: 520px;
  background: linear-gradient(145deg, rgba(30, 20, 48, 0.95), rgba(18, 11, 30, 0.95));
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 24px;
  padding: 38px 32px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(255, 119, 170, 0.3);
  position: relative;
  transform: translateY(30px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-overlay.open .letter-card {
  transform: translateY(0) scale(1);
}

.letter-close {
  position: absolute;
  top: 18px;
  right: 20px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 22px;
  cursor: pointer;
  transition: color 0.2s;
}

.letter-close:hover {
  color: #ff77aa;
}

.letter-header {
  font-family: 'Cinzel', 'Playfair Display', serif;
  font-size: 22px;
  color: #ffd700;
  margin-bottom: 18px;
  text-align: center;
  letter-spacing: 2px;
}

.letter-body {
  font-family: 'Dancing Script', 'Brush Script MT', cursive;
  font-size: 22px;
  line-height: 1.65;
  color: #f7e6f0;
  margin-bottom: 24px;
  text-shadow: 0 0 10px rgba(255, 119, 170, 0.2);
}

.letter-signature {
  text-align: right;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: #ffb8d2;
  letter-spacing: 1px;
}

.letter-actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
}

.letter-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: #ffd700;
  border-radius: 30px;
  padding: 9px 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
}

.letter-action-btn:hover {
  background: rgba(255, 215, 0, 0.2);
  transform: scale(1.04);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.35);
}

.letter-seal {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, #e63946, #800f2f);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.5);
}

/* FLOATING LOVE WHISPERS */
.floating-whisper {
  position: fixed;
  pointer-events: none;
  font-family: 'Dancing Script', 'Brush Script MT', cursive;
  font-size: 24px;
  font-weight: 700;
  color: #fff0f5;
  text-shadow: 0 0 10px rgba(255, 119, 170, 0.9), 0 0 20px rgba(255, 215, 0, 0.7);
  z-index: 50;
  transform: translate(-50%, -50%);
  animation: whisperFloat 2.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  white-space: nowrap;
}

@keyframes whisperFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 0px) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -30px) scale(1.15);
  }
  75% {
    opacity: 0.95;
    transform: translate(-50%, -85px) scale(1.0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -135px) scale(0.9);
  }
}

/* ANIMATIONS */
@keyframes shine {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.25); }
}

/* WELCOME / NAME ENTRY MODAL */
.welcome-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, rgba(28, 14, 46, 0.78) 0%, rgba(8, 4, 16, 0.92) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, backdrop-filter 0.45s ease;
  padding: 16px;
}

.welcome-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.welcome-overlay.closing {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.03);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.welcome-card {
  width: 100%;
  max-width: 490px;
  max-height: 94vh;
  overflow-y: auto;
  background: linear-gradient(155deg, rgba(35, 20, 55, 0.94), rgba(16, 9, 28, 0.96));
  border: 1px solid rgba(255, 119, 170, 0.35);
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.8), 0 0 45px rgba(255, 119, 170, 0.28);
  border-radius: 28px;
  padding: 34px 28px 26px;
  text-align: center;
  position: relative;
  transform: translateY(25px) scale(0.96);
  transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.25);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 119, 170, 0.4) transparent;
}

.welcome-overlay.open .welcome-card {
  transform: translateY(0) scale(1);
}

.welcome-close-btn {
  position: absolute;
  top: 18px;
  right: 20px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 26px;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
  padding: 4px;
}

.welcome-close-btn:hover {
  color: #ff77aa;
  transform: scale(1.15);
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(247, 37, 133, 0.18);
  border: 1px solid rgba(247, 37, 133, 0.45);
  border-radius: 30px;
  padding: 6px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #ffd6e0;
  font-weight: 500;
  letter-spacing: 0.5px;
  animation: pulseGlow 2.5s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(247, 37, 133, 0.3); }
  50% { box-shadow: 0 0 22px rgba(247, 37, 133, 0.65); transform: scale(1.02); }
}

.welcome-flower-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle, #f72585, #4c0519);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 0 25px rgba(247, 37, 133, 0.6);
  position: relative;
}

.pulse-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 119, 170, 0.5);
  animation: ringPulse 2.4s infinite cubic-bezier(0.25, 0.8, 0.25, 1);
  pointer-events: none;
}

@keyframes ringPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.22); opacity: 0.2; }
  100% { transform: scale(1.4); opacity: 0; }
}

.welcome-title {
  font-family: 'Cinzel', 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 0%, #ffd6e0 50%, #ffe49e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 300;
  margin-bottom: 22px;
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #ffd700;
  padding-left: 4px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(10, 6, 18, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 4px 14px;
  transition: all 0.3s ease;
}

.input-wrapper:focus-within {
  border-color: #ff77aa;
  box-shadow: 0 0 20px rgba(255, 119, 170, 0.45), inset 0 0 10px rgba(255, 119, 170, 0.15);
  background: rgba(18, 10, 30, 0.85);
}

.input-icon {
  font-size: 16px;
  color: #ffd700;
  margin-right: 8px;
}

.name-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 17px;
  font-family: 'Playfair Display', 'Cinzel', 'Montserrat', serif;
  font-weight: 600;
  padding: 10px 4px;
  letter-spacing: 0.5px;
}

.name-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  font-family: 'Montserrat', sans-serif;
}

.palette-picker-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.palette-picker-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.7);
  padding-left: 4px;
}

.welcome-palettes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.palette-choice {
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
}

.palette-choice:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-2px);
}

.palette-choice.active {
  border-color: #ff77aa;
  background: rgba(247, 37, 133, 0.2);
  box-shadow: 0 0 14px rgba(247, 37, 133, 0.45);
}

.palette-choice-preview {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.palette-choice-name {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

.music-option-row {
  display: flex;
  align-items: center;
  padding: 4px 0;
}

.music-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  user-select: none;
}

.music-checkbox-label input {
  display: none;
}

.custom-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
}

.music-checkbox-label input:checked + .custom-check {
  background: #f72585;
  border-color: #f72585;
  box-shadow: 0 0 10px rgba(247, 37, 133, 0.6);
}

.music-checkbox-label input:checked + .custom-check::after {
  content: '✓';
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
}

.welcome-submit-btn {
  background: linear-gradient(135deg, #f72585 0%, #b5179e 50%, #7209b7 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  padding: 14px 24px;
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(247, 37, 133, 0.45);
  margin-top: 6px;
  outline: none;
}

.welcome-submit-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 35px rgba(247, 37, 133, 0.65), 0 0 20px rgba(255, 215, 0, 0.4);
}

.welcome-submit-btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-sparkle {
  font-size: 16px;
}

.welcome-quote {
  font-family: 'Dancing Script', cursive;
  font-size: 15.5px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 18px;
  line-height: 1.4;
}

/* TOAST NOTIFICATION */
.toast-message {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -40px);
  background: rgba(20, 12, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 119, 170, 0.35);
  color: #ffffff;
  padding: 12px 26px;
  border-radius: 30px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.5px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.25), opacity 0.35s ease;
  text-align: center;
  white-space: nowrap;
}

.toast-message.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
  .top-header {
    top: 68px;
    width: 92%;
  }
  .quick-tools {
    top: 14px;
    right: 50%;
    transform: translateX(50%);
    gap: 7px;
  }
  .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }
  .main-title {
    font-size: 22px;
    letter-spacing: 2px;
  }
  .title-card {
    padding: 10px 20px;
  }
  .welcome-card {
    padding: 28px 18px 22px;
  }
  .welcome-title {
    font-size: 22px;
  }
  .welcome-palettes {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }
  .palette-choice {
    padding: 6px 2px;
  }
  .palette-choice-preview {
    width: 18px;
    height: 18px;
  }
  .palette-choice-name {
    font-size: 9px;
  }
  .dock {
    padding: 8px 12px;
    gap: 5px;
  }
  .dock-btn {
    padding: 6px 10px;
    font-size: 10.5px;
  }
  .palette-dot {
    width: 18px;
    height: 18px;
  }
  .letter-body {
    font-size: 18px;
  }
  .toast-message {
    white-space: normal;
    width: 90%;
    font-size: 12.5px;
  }
}

