:root {
  /* Colors */
  --color-bg:         #f5f0e8;
  --color-primary:    #6B1A1A;
  --color-accent:     #2d0a4e;
  --color-star:       #f0d060;
  --color-white:      #ffffff;
  --color-shadow:     rgba(0, 0, 0, 0.15);

  /* Typography */
  --font-handwrite:   'Caveat', cursive;
  --font-marker:      'Permanent Marker', cursive;
  --font-body:        'Nunito', sans-serif;

  /* Font Sizes */
  --text-xl:    3.2rem;
  --text-lg:    2.2rem;
  --text-md:    1.3rem;
  --text-sm:    1rem;
  --text-xs:    0.85rem;

  /* Spacing */
  --space-xs:   8px;
  --space-sm:   16px;
  --space-md:   32px;
  --space-lg:   64px;

  /* Borders — wobbly for hand-drawn feel */
  --radius-btn: 12px 4px 10px 5px / 5px 10px 4px 12px;
  --radius-card: 8px 14px 6px 12px / 12px 6px 14px 8px;
  --radius-polaroid: 3px;

  /* Shadows */
  --shadow-card:     4px 4px 12px var(--color-shadow);
  --shadow-polaroid: 3px 3px 10px rgba(0, 0, 0, 0.25), -1px -1px 5px rgba(0, 0, 0, 0.1);

  /* Animation */
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth:  cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast:   200ms;
  --duration-med:    400ms;
  --duration-slow:   800ms;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background-color: #f5f0e8;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
  color: var(--color-primary);
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url('assets/textures/paperbg.avif');
  background-repeat: repeat;
  background-size: 600px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

@supports not (background-image: url('x.avif')) {
  body::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  }
}

/* ── Loading screen ────────────────────────────────────────── */

#loading-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: #f5f0e8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s ease;
}

#loading-screen::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url('assets/textures/paperbg.avif');
  background-repeat: repeat;
  background-size: 600px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading-gif {
  width: 120px;
  height: 120px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

#loading-text {
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: #6B1A1A;
  margin-top: 16px;
  animation: pulse 1.5s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Stars layer — always visible behind everything */
#tsparticles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ── Sections ──────────────────────────────────────────────── */

.section {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  opacity: 0;
  padding: var(--space-md) var(--space-md) 100px;
  z-index: 1;
  overflow-y: auto;
}

.section.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  opacity: 1;
  gap: var(--space-sm);
}

/* ── Titles ────────────────────────────────────────────────── */

.title {
  font-family: var(--font-handwrite);
  font-size: var(--text-xl);
  font-weight: 700;
  margin: var(--space-sm) 0 var(--space-xs);
  text-align: center;
  line-height: 1.2;
}

.subtitle {
  font-family: var(--font-body);
  font-size: var(--text-md);
  margin: 0 0 var(--space-md);
  text-align: center;
  opacity: 0.85;
}

/* ── Buttons ───────────────────────────────────────────────── */

.btn-group {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-handwrite);
  font-size: 1.25rem;
  padding: 14px 36px;
  border-radius: var(--radius-btn);
  border: 2px solid var(--color-primary);
  cursor: pointer;
  transition:
    transform var(--duration-fast) var(--ease-bounce),
    background var(--duration-fast),
    box-shadow var(--duration-fast);
  letter-spacing: 0.05em;
  background: transparent;
  color: var(--color-primary);
}

.btn:hover {
  transform: scale(1.05) rotate(-1deg);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
}

.btn-return {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 40px;
  font-family: var(--font-handwrite);
  font-size: 1.1rem;
  background: rgba(107, 26, 26, 0.06);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-btn);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.2s ease, letter-spacing 0.2s ease;
  z-index: 10;
}

.btn-return:hover {
  background: rgba(107, 26, 26, 0.15);
  letter-spacing: 0.08em;
  transform: translateX(-50%);
}

.btn-return:active {
  transform: translateX(-50%);
}

.btn-retry-style {
  font-family: var(--font-handwrite);
  font-size: 1.4rem;
  padding: 16px 48px;
  background: var(--color-primary);
  color: var(--color-white);
  border: 2px solid var(--color-primary);
  border-radius: 12px 4px 10px 5px / 5px 10px 4px 12px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s ease, transform 0.2s ease;
  margin-top: 8px;
}

.btn-retry-style:hover {
  background: #8B1A1A;
  transform: scale(1.05) rotate(-1deg);
}

/* ── Sticker (onboarding GIF) ──────────────────────────────── */

.sticker-wrapper {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.sticker-wrapper img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* ── Dashboard grid ────────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 200px 200px;
  grid-template-rows: 200px 200px;
  gap: 20px;
  justify-content: center;
  margin-top: var(--space-md);
}

.dash-card {
  width: 200px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2.5px solid var(--color-primary);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition:
    transform var(--duration-fast) var(--ease-bounce),
    background var(--duration-fast),
    box-shadow var(--duration-fast);
  font-family: var(--font-handwrite);
  font-size: 1.15rem;
  color: var(--color-primary);
}

.dash-card:last-child {
  grid-column: auto;
  justify-self: auto;
}

.dash-card:hover {
  transform: translateY(-6px) rotate(-1deg);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-card);
}

.dash-card svg {
  width: 52px;
  height: 52px;
  stroke: var(--color-primary);
  fill: none;
  stroke-width: 2.2;
}

/* ── Photos section subtitle ──────────────────────────────── */

.photos-subtitle {
  font-family: var(--font-handwrite);
  font-size: 1.15rem;
  color: var(--color-primary);
  text-align: center;
  max-width: 480px;
  line-height: 1.7;
  margin: 0 auto 4px;
  background: rgba(107, 26, 26, 0.06);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 8px 8px 0;
  padding: 10px 20px 10px 16px;
}

/* ── Polaroid gallery ──────────────────────────────────────── */

.polaroid-container {
  display: flex;
  justify-content: center;
  gap: 32px;
  width: 100%;
  min-width: 700px;
  max-width: 900px;
  margin-top: var(--space-md);
  flex-wrap: wrap;
  position: relative;
}

.polaroid-container::before {
  content: '';
  position: absolute;
  inset: -30px;
  background: radial-gradient(ellipse at center,
    rgba(245, 240, 232, 0) 40%,
    rgba(245, 240, 232, 0.85) 100%);
  pointer-events: none;
  z-index: 10;
}

.polaroid {
  background: var(--color-white);
  padding: 14px 14px 52px 14px;
  box-shadow: var(--shadow-polaroid);
  border-radius: var(--radius-polaroid);
  cursor: grab;
  filter: drop-shadow(0 4px 24px rgba(107, 26, 26, 0.18));
  transition: filter 0.3s ease, transform 0.3s ease;
  flex-shrink: 0;
  position: relative;
  z-index: 11;
}

.polaroid:hover {
  filter: drop-shadow(0 8px 32px rgba(107, 26, 26, 0.32));
  box-shadow: 6px 6px 20px rgba(0, 0, 0, 0.3);
  z-index: 12;
  transform: translateY(-4px) !important;
}

.polaroid img {
  width: 170px;
  height: 170px;
  object-fit: cover;
  display: block;
}

.polaroid img,
.polaroid .polaroid-placeholder {
  filter: blur(4px);
}

.polaroid-placeholder {
  width: 170px;
  height: 170px;
  background: linear-gradient(135deg, #f5c6cb, #c6def5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border-radius: 2px;
}

.polaroid-placeholder.placeholder-2 {
  background: linear-gradient(135deg, #c6f5d5, #f5eac6);
}

.polaroid-placeholder.placeholder-3 {
  background: linear-gradient(135deg, #d5c6f5, #f5c6e8);
}

.polaroid-label {
  font-family: var(--font-handwrite);
  font-size: 1.1rem;
  color: #444;
  text-align: center;
  margin-top: 10px;
  display: block;
  letter-spacing: 0.02em;
}

.hint-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding: 10px 28px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px dashed var(--color-primary);
  border-radius: 12px 4px 10px 5px / 5px 10px 4px 12px;
  animation: pulse 2s ease-in-out infinite;
}

.hint-box p {
  font-family: var(--font-handwrite);
  font-size: 1.3rem;
  color: var(--color-primary);
  margin: 0;
  letter-spacing: 0.03em;
}

.hint-box span {
  font-size: 1.1rem;
}

#modal-img {
  filter: none;
}

/* ── SoundCloud / Song section ─────────────────────────────── */

.soundcloud-wrapper {
  width: 560px;
  max-width: 90vw;
  border: 3px solid var(--color-primary);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 6px 6px 0px var(--color-primary);
  margin: 24px 0;
}

.secret-msg {
  background: rgba(255, 255, 255, 0.8);
  border: 1.5px dashed var(--color-primary);
  border-radius: 4px 12px 4px 12px;
  padding: 8px 20px;
  font-family: var(--font-handwrite);
  font-size: 1rem;
  color: var(--color-accent);
  margin-top: 16px;
  position: relative;
}

.secret-msg::before {
  content: "\2728";
  margin-right: 6px;
}

/* ── Photo modal ──────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.modal-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #fffef9;
  border: 2.5px solid var(--color-primary);
  border-radius: 16px;
  padding: 40px;
  max-width: 820px;
  width: 92%;
  display: flex;
  gap: 40px;
  position: relative;
  box-shadow: 6px 6px 0px var(--color-primary);
  max-height: 90vh;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--color-primary);
  font-family: var(--font-handwrite);
}

.modal-left {
  flex: 0 0 48%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-polaroid {
  background: white;
  padding: 16px 16px 56px 16px;
  box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.2);
  transform: rotate(-2deg);
  width: 100%;
  box-sizing: border-box;
}

.modal-polaroid img {
  width: 100%;
  height: auto;
  min-height: 280px;
  max-height: 380px;
  object-fit: contain;
  background: #f0f0f0;
  display: block;
  border-radius: 2px;
}

.modal-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.modal-title {
  font-family: var(--font-handwrite);
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.modal-desc {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 2;
  color: #444;
  margin: 0;
  direction: rtl;
  text-align: right;
}

/* ── Letter / Message ──────────────────────────────────────── */

.letter-wrapper {
  max-width: 620px;
  width: 90%;
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-card);
  padding: 48px 40px;
  box-shadow: var(--shadow-card);
  max-height: 70vh;
  overflow-y: auto;
}

.letter-body p {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.9;
  color: #333;
  margin-bottom: 16px;
}

.signature {
  font-family: var(--font-marker);
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-top: 24px;
  text-align: right;
}

/* ── Gift section ─────────────────────────────────────────── */

.gift-sticker-wrapper {
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gift-sticker {
  width: 280px;
  height: 280px;
  object-fit: contain;
  max-width: 70vw;
  max-height: 40vh;
}

.gift-message {
  font-family: var(--font-handwrite);
  font-size: 1.4rem;
  color: var(--color-primary);
  background: rgba(255, 255, 255, 0.7);
  border: 2px dashed var(--color-primary);
  border-radius: 12px 4px 10px 5px / 5px 10px 4px 12px;
  padding: 16px 32px;
  max-width: 400px;
  text-align: center;
  margin: 8px auto;
}

.gift-message p {
  margin: 0;
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 600px) {
  :root {
    --text-xl: 2.4rem;
    --text-lg: 1.6rem;
  }

  .section {
    padding: var(--space-md) var(--space-sm);
  }

  .sticker-wrapper {
    width: 160px;
    height: 160px;
  }

  .dashboard-grid {
    grid-template-columns: 150px 150px;
    grid-template-rows: 150px 150px;
    gap: 14px;
  }

  .dash-card {
    width: 150px;
    height: 150px;
  }

  .polaroid-container {
    min-width: 0;
    width: 100%;
    gap: 16px;
  }

  .polaroid-placeholder,
  .polaroid img {
    width: 120px;
    height: 120px;
  }

  .youtube-wrapper iframe {
    height: 200px;
  }

  .letter-wrapper {
    padding: 24px 18px;
  }

  .modal-card {
    flex-direction: column;
    padding: 28px 20px;
    gap: 20px;
  }

  .modal-left {
    flex: none;
    display: flex;
    justify-content: center;
  }

  .modal-polaroid {
    max-width: 200px;
  }

  .modal-polaroid img {
    height: 140px;
  }
}
