/* Reset & Base Variables */
:root {
  --primary-glow: #ff4d6d;
  --petal-color1: #ff2a6d;
  --petal-color2: #ff758c;
  --bg-gradient: radial-gradient(circle at 50% 30%, #1a0b2e 0%, #0d0417 60%, #05020a 100%);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --font-cursive: 'Dancing Script', 'Sacramento', cursive;
  --font-romance: 'Great Vibes', cursive;
  --font-sans: 'Poppins', sans-serif;
  --text-main: #fff;
  --text-muted: #e0d0eb;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-main);
  position: relative;
}

/* Canvases */
canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#bgCanvas { z-index: 1; }
#flowerCanvas { z-index: 2; cursor: crosshair; }
#petalsCanvas { z-index: 3; pointer-events: none; }

/* Main Container UI */
.main-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px;
  pointer-events: none;
}

.header, .toolbar, .tap-hint, .footer-quotes, .color-palette-popover, .modal-overlay {
  pointer-events: auto;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
}

/* Top Wrapper & Header */
.top-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 680px;
  z-index: 20;
  pointer-events: auto;
}

.header {
  text-align: center;
  margin-top: 4px;
  max-width: 650px;
  animation: fadeInDown 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  background: rgba(255, 77, 109, 0.2);
  border: 1px solid rgba(255, 77, 109, 0.4);
  border-radius: 50px;
  color: #ff9ebb;
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(255, 77, 109, 0.5);
  box-shadow: 0 0 15px rgba(255, 77, 109, 0.2);
}

.title {
  font-family: var(--font-cursive);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 117, 140, 0.8), 0 0 25px rgba(255, 42, 109, 0.6);
  letter-spacing: 1px;
}

.subtitle {
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
  padding: 0 10px;
}

/* Action Toolbar (Relative flow under header, no overlap) */
.toolbar {
  display: flex;
  gap: 10px;
  padding: 8px 14px;
  position: relative;
  margin-top: 14px;
  z-index: 20;
  animation: fadeIn 1.4s ease forwards;
  max-width: 95vw;
  overflow-x: auto;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  color: #fff;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.tool-btn i, .tool-btn svg {
  width: 16px;
  height: 16px;
  stroke: #ff9ebb;
  transition: transform 0.25s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  border-color: rgba(255, 117, 140, 0.6);
  box-shadow: 0 4px 15px rgba(255, 77, 109, 0.35);
}

.tool-btn:active {
  transform: translateY(1px);
}

.tool-btn.active {
  background: linear-gradient(135deg, rgba(255, 42, 109, 0.4), rgba(255, 117, 140, 0.4));
  border-color: #ff4d6d;
}

.tool-btn.active i, .tool-btn.active svg {
  stroke: #fff;
  animation: pulse 1.2s infinite;
}

/* Tap Hint (Fades out after initial prompt) */
.tap-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #ffc4d6;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 18px;
  border-radius: 30px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  margin-bottom: 10px;
  animation: pulse 2.5s infinite;
  transition: opacity 0.8s ease, transform 0.8s ease, visibility 0.8s;
  pointer-events: none;
}

.tap-hint.fade-out {
  opacity: 0 !important;
  transform: translateY(15px) !important;
  visibility: hidden !important;
}

.tap-hint svg {
  width: 16px;
  height: 16px;
}

/* Footer Quotes */
.footer-quotes {
  width: 100%;
  max-width: 600px;
  margin-bottom: 8px;
}

.quote-card {
  padding: 12px 18px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quote-text {
  font-size: 0.9rem;
  font-style: italic;
  color: #f7ebff;
  line-height: 1.5;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.quote-btn {
  background: rgba(255, 77, 109, 0.2);
  border: 1px solid rgba(255, 77, 109, 0.4);
  color: #ffccd5;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quote-btn svg {
  width: 12px;
  height: 12px;
  fill: #ff4d6d;
  stroke: none;
}

.quote-btn:hover {
  background: rgba(255, 77, 109, 0.4);
  color: #fff;
  transform: scale(1.05);
}

/* Color Palette Popover */
.color-palette-popover {
  position: relative;
  margin-top: 10px;
  padding: 10px 18px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 30;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease;
}

.color-palette-popover.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.palette-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.color-options {
  display: flex;
  gap: 12px;
}

.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s;
  box-shadow: 0 0 10px var(--c1);
}

.color-dot:hover {
  transform: scale(1.2);
}

.color-dot.active {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 15px var(--c1);
}

/* Love Letter Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 2, 10, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.modal-overlay.open {
  display: flex;
  opacity: 1;
}

.glass-panel-modal {
  background: rgba(28, 14, 42, 0.88);
  border: 1px solid rgba(255, 117, 140, 0.35);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 42, 109, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
}

.letter-card {
  width: 100%;
  max-width: 520px;
  padding: 30px 26px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 18px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
}

.modal-close:hover {
  color: #ff4d6d;
  transform: rotate(90deg);
}

.envelope-header {
  text-align: center;
  margin-bottom: 20px;
}

.wax-seal {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  background: radial-gradient(circle at 35% 35%, #ff4d6d, #b5179e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(255, 42, 109, 0.5);
  animation: pulse 2s infinite;
}

.wax-seal svg {
  width: 24px;
  height: 24px;
  fill: #fff;
  stroke: none;
}

.recipient-tag {
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: #ff9ebb;
  font-weight: 600;
  text-transform: uppercase;
}

.letter-greeting {
  font-family: var(--font-cursive);
  font-size: 2rem;
  color: #fff;
  margin-bottom: 14px;
}

.letter-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #f0e6f6;
  white-space: pre-line;
  min-height: 120px;
  border-left: 2px solid rgba(255, 77, 109, 0.4);
  padding-left: 14px;
  margin-bottom: 20px;
}

.letter-sign {
  text-align: right;
  margin-top: 15px;
}

.letter-sign p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.letter-sign .signature {
  font-family: var(--font-romance);
  font-size: 2rem;
  color: #ff758c;
  display: block;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
  justify-content: flex-end;
}

.action-btn {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.action-btn.whatsapp-share {
  background: linear-gradient(135deg, #25d366, #128c7e);
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.35);
}

.action-btn.whatsapp-share:hover {
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.55);
}

.action-btn.primary {
  background: linear-gradient(135deg, #ff4d6d, #b5179e);
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(255, 77, 109, 0.4);
}

.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-25px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes modalPop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .title { font-size: 2.1rem; }
  .subtitle { font-size: 0.82rem; }
  .toolbar {
    margin-top: 10px;
    gap: 6px;
    padding: 6px 10px;
  }
  .tool-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  .tool-btn span {
    font-size: 0.75rem;
  }
  .color-palette-popover {
    margin-top: 8px;
    padding: 8px 12px;
  }
  .letter-card {
    padding: 22px 18px;
  }
  .letter-greeting {
    font-size: 1.6rem;
  }
  .letter-content {
    font-size: 0.88rem;
    line-height: 1.6;
  }
  .modal-actions {
    flex-direction: column;
  }
  .action-btn {
    width: 100%;
    justify-content: center;
  }
}

