@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=JetBrains+Mono:wght@300;400;500;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg-deep: #030805;
  --accent-blue: #7094ff;
  --accent-cyan: #4bf2df;
  --accent-violet: #b18cfe;
  --accent-gold: #f6d365;
  --text-main: #f0f7f2;
  --text-muted: #8fa696;
  --font-serif: 'Playfair Display', 'Cinzel', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
}

/* Background Canvas */
#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  overflow: hidden;
  background: radial-gradient(circle at center, #05160b 0%, #020a05 60%, #010402 100%);
}

#ascii-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 1.8s cubic-bezier(0.16, 1, 0.3, 1);
}

#ascii-canvas.visible {
  opacity: 1;
}

.vignette-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(1, 4, 2, 0.82) 100%);
}

/* Particle Canvas for Confetti & Sparkles */
#fx-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ========================================================
   INTRO SCREEN (Tampilan Awal Sebelum Hadiah Dibuka)
======================================================== */
.intro-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(6, 26, 14, 0.95) 0%, rgba(2, 8, 4, 0.98) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1), transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 24px;
}

.intro-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.08);
}

.intro-card {
  max-width: 480px;
  width: 100%;
  background: rgba(10, 24, 16, 0.75);
  border: 1px solid rgba(112, 148, 255, 0.25);
  border-radius: 28px;
  padding: 42px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 50px rgba(112, 148, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: floatCard 4s ease-in-out infinite;
}

@keyframes floatCard {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.intro-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(75, 242, 223, 0.12);
  border: 1px solid rgba(75, 242, 223, 0.3);
  padding: 6px 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.intro-flower-icon {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 0 16px rgba(112, 148, 255, 0.6));
  animation: pulseFlower 2.5s infinite ease-in-out;
}

@keyframes pulseFlower {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.12) rotate(4deg); }
}

.intro-title {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffffff 20%, #b2cbfe 60%, #c4a1fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.25;
}

.intro-desc {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #c7dbce;
  max-width: 380px;
}

/* Tombol Buka Hadiah */
.btn-open-gift {
  margin-top: 8px;
  background: linear-gradient(135deg, #4d71e2 0%, #7094ff 50%, #9a6bf8 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  padding: 16px 36px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(77, 113, 226, 0.45), 0 0 25px rgba(177, 140, 254, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.btn-open-gift:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 40px rgba(77, 113, 226, 0.65), 0 0 35px rgba(75, 242, 223, 0.5);
  border-color: rgba(255, 255, 255, 0.7);
}

.btn-open-gift:active {
  transform: translateY(0) scale(0.98);
}

.btn-open-gift::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: rotate(30deg);
  animation: shineSweep 3s infinite;
}

@keyframes shineSweep {
  0% { transform: translateX(-100%) rotate(30deg); }
  25%, 100% { transform: translateX(100%) rotate(30deg); }
}

/* ========================================================
   TOP MINIMAL HEADER (Hanya Menampilkan Info Nicchi & Sound)
======================================================== */
.top-header {
  position: fixed;
  top: 24px;
  left: 32px;
  right: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-15px);
  transition: all 1s cubic-bezier(0.16, 1, 0.3, 1) 0.5s;
}

.top-header.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.nicchi-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(8, 20, 13, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid rgba(112, 148, 255, 0.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.nicchi-brand-text h1 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #fff;
}

.nicchi-brand-text p {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent-cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-discreet {
  background: rgba(8, 20, 13, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(112, 148, 255, 0.2);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  font-family: var(--font-sans);
}

.btn-discreet:hover {
  background: rgba(14, 34, 22, 0.85);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(75, 242, 223, 0.3);
}

.btn-discreet.active {
  background: rgba(75, 242, 223, 0.16);
  border-color: var(--accent-cyan);
  color: #fff;
}

/* ========================================================
   BOTTOM WATERMARK (Sangat Halus & Tenang)
======================================================== */
.bottom-caption {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.5s ease 1s;
  background: rgba(6, 16, 10, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.82rem;
  color: #a7c5b3;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.bottom-caption.visible {
  opacity: 1;
}

/* ========================================================
   BIRTHDAY LETTER MODAL
======================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(2, 6, 4, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  padding: 20px;
}

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

.modal-card {
  background: #09170f;
  border: 1px solid rgba(112, 148, 255, 0.3);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 45px rgba(112, 148, 255, 0.22);
  border-radius: 26px;
  max-width: 500px;
  width: 100%;
  padding: 36px 32px;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  text-align: left;
}

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

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.modal-header-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: #fff;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-cyan);
  margin-bottom: 20px;
}

.modal-body {
  font-size: 0.94rem;
  line-height: 1.75;
  color: #d1e2d7;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body p {
  letter-spacing: 0.015em;
}

.modal-signature {
  margin-top: 10px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent-blue);
  text-align: right;
}

/* Toast */
.toast-notice {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(12, 28, 18, 0.95);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 10px 24px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notice.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 640px) {
  .intro-card {
    padding: 32px 20px;
  }
  .intro-title {
    font-size: 1.65rem;
  }
  .top-header {
    top: 16px;
    left: 16px;
    right: 16px;
  }
  .nicchi-brand-text h1 {
    font-size: 0.88rem;
  }
  .nicchi-brand-text p {
    font-size: 0.62rem;
  }
  .btn-discreet {
    padding: 8px 14px;
    font-size: 0.76rem;
  }
  .bottom-caption {
    font-size: 0.74rem;
    padding: 6px 16px;
  }
}

/* ========================================================
   MOBILE / RESPONSIVE ENHANCEMENTS
======================================================== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

/* Tinggi dinamis mengikuti address bar browser mobile */
#canvas-container,
.intro-screen,
.modal-overlay {
  height: 100vh;
  height: 100dvh;
}

/* Hormati area notch / gesture bar */
.top-header {
  top: calc(24px + env(safe-area-inset-top, 0px));
  left: calc(32px + env(safe-area-inset-left, 0px));
  right: calc(32px + env(safe-area-inset-right, 0px));
}

.bottom-caption {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 64px);
  white-space: normal;
  text-align: center;
  line-height: 1.55;
}

.intro-screen {
  padding: calc(24px + env(safe-area-inset-top, 0px))
           calc(24px + env(safe-area-inset-right, 0px))
           calc(24px + env(safe-area-inset-bottom, 0px))
           calc(24px + env(safe-area-inset-left, 0px));
}

.modal-overlay {
  padding: calc(20px + env(safe-area-inset-top, 0px))
           calc(20px + env(safe-area-inset-right, 0px))
           calc(20px + env(safe-area-inset-bottom, 0px))
           calc(20px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
}

/* Konten modal & intro bisa discroll di layar pendek */
.intro-card,
.modal-card {
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Target sentuh nyaman di jari (>= 44px) */
.btn-open-gift {
  min-height: 52px;
  width: 100%;
  max-width: 320px;
  justify-content: center;
}

.btn-discreet {
  min-height: 44px;
}

.modal-close-btn {
  width: 40px;
  height: 40px;
}

/* Toast tidak overflow di layar sempit */
.toast-notice {
  max-width: calc(100vw - 40px);
  white-space: normal;
  text-align: center;
}

@media (max-width: 640px) {
  .top-header {
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .nicchi-brand {
    padding: 8px 14px;
    gap: 8px;
    max-width: 100%;
  }

  .nicchi-brand-text h1 {
    font-size: 0.92rem;
  }

  .nicchi-brand-text p {
    font-size: 0.58rem;
  }

  .top-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .btn-discreet {
    padding: 10px 14px;
    font-size: 0.78rem;
    min-height: 42px;
  }

  .bottom-caption {
    font-size: 0.72rem;
    padding: 8px 14px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 32px);
  }

  .modal-card {
    padding: 26px 20px;
    border-radius: 20px;
  }

  .intro-card {
    padding: 30px 20px;
  }
}

/* Landscape HP: hemat ruang vertikal */
@media (max-height: 520px) {
  .top-header {
    top: calc(8px + env(safe-area-inset-top, 0px));
  }

  .intro-card {
    padding: 20px 16px;
    gap: 10px;
  }

  .intro-flower-icon {
    font-size: 2.2rem;
  }

  .intro-title {
    font-size: 1.4rem;
  }

  .intro-desc {
    font-size: 0.82rem;
  }

  .bottom-caption {
    display: none;
  }
}
