/* ==========================================================================
   FOR SARAH ❤️ — Stylesheet
   -------------------------------------------------------------------------
   Design tokens
   Color:
     --cream        #FDF6EE   base background
     --blush        #F6D9DD   soft pink surfaces
     --blush-deep   #ECB8C1   pink accents / hover
     --rose         #B0546B   primary accent, buttons, links
     --rose-deep    #7A3348   headings, deep text accents
     --gold         #C9A15E   dividers, sparkle, seal
     --gold-soft    #E8D6B0   subtle gold surfaces
     --ink          #4A2138   body text
   Type:
     Display  — "Playfair Display" (headlines, the wordmark)
     Script   — "Cormorant Garamond" italic (romantic accents, quotes)
     Body     — "Nunito" (everything else — soft, warm, readable)
   Signature element:
     The "wax seal" — a small circular seal (♥ pressed in gold) that marks
     completed games, chapter openings, and the homepage title, echoing a
     handwritten love letter sealed with wax.
   ========================================================================== */

:root {
  --cream: #FDF6EE;
  --cream-deep: #F7ECDD;
  --blush: #F6D9DD;
  --blush-deep: #ECB8C1;
  --rose: #B0546B;
  --rose-deep: #7A3348;
  --gold: #C9A15E;
  --gold-soft: #E8D6B0;
  --ink: #4A2138;
  --ink-soft: #8C6A78;
  --white: #FFFFFF;

  --font-display: 'Playfair Display', serif;
  --font-script: 'Cormorant Garamond', serif;
  --font-body: 'Nunito', sans-serif;

  --shadow-soft: 0 10px 40px rgba(122, 51, 72, 0.12);
  --shadow-deep: 0 20px 60px rgba(122, 51, 72, 0.18);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

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

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, var(--blush) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, var(--gold-soft) 0%, transparent 50%),
    linear-gradient(160deg, var(--cream) 0%, var(--cream-deep) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--rose-deep);
  margin: 0 0 0.4em;
  letter-spacing: 0.01em;
}

p { line-height: 1.7; }

.eyebrow {
  font-family: var(--font-script);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--rose);
  letter-spacing: 0.02em;
}

button { font-family: var(--font-body); cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--rose);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------------- */
/* Ambient layer — floating hearts + sparkles                             */
/* ---------------------------------------------------------------------- */

#ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floating-heart {
  position: absolute;
  bottom: -10%;
  color: var(--blush-deep);
  opacity: 0.55;
  animation: floatUp linear infinite;
  will-change: transform;
}

.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: sparkle 3.2s ease-in-out infinite;
}

@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-115vh) translateX(var(--drift, 20px)) rotate(20deg); opacity: 0; }
}

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.4); }
  50%      { opacity: 0.9; transform: scale(1.1); }
}

/* ---------------------------------------------------------------------- */
/* Layout shell                                                           */
/* ---------------------------------------------------------------------- */

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(20px, 5vw, 60px) clamp(16px, 5vw, 40px) 80px;
}

.screen {
  width: 100%;
  max-width: 780px;
  animation: fadeSlideIn 0.6s ease both;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen.leaving { animation: fadeSlideOut 0.35s ease both; }

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

/* ---------------------------------------------------------------------- */
/* Glassmorphism card primitive                                          */
/* ---------------------------------------------------------------------- */

.glass {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

/* ---------------------------------------------------------------------- */
/* Homepage                                                                */
/* ---------------------------------------------------------------------- */

.home-hero { text-align: center; padding: 10px 10px 6px; }

.wordmark-wrap { position: relative; display: inline-block; margin-bottom: 8px; }

.seal {
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.2rem;
  box-shadow: 0 6px 18px rgba(201, 161, 94, 0.5);
  animation: sealPress 900ms cubic-bezier(.2,1.4,.4,1) both;
}

@keyframes sealPress {
  0%   { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

.wordmark {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  margin-bottom: 6px;
}

.subtitle {
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 0 auto 34px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 30px;
}

.chapter-card {
  position: relative;
  width: 100%;
  appearance: none;
  font: inherit;
  padding: 26px 20px 22px;
  text-align: left;
  border: none;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ink);
}

.chapter-card:hover:not(.locked) {
  transform: translateY(-6px);
  box-shadow: var(--shadow-deep);
}

.chapter-card .chapter-num {
  font-family: var(--font-script);
  font-style: italic;
  color: var(--gold);
  font-size: 1.05rem;
}

.chapter-card h3 { font-size: 1.35rem; margin-bottom: 2px; }

.chapter-card .chapter-status {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chapter-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.chapter-card.completed .chapter-status { color: var(--rose); font-weight: 600; }

/* Progress panel */

.progress-panel {
  padding: 24px 26px;
  margin-bottom: 26px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.progress-stat { text-align: center; flex: 1; min-width: 90px; }
.progress-stat .num { font-family: var(--font-display); font-size: 1.5rem; color: var(--rose-deep); display: block; }
.progress-stat .label { font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(176, 84, 107, 0.12);
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blush-deep), var(--rose));
  border-radius: 20px;
  transition: width 0.6s cubic-bezier(.3,.9,.4,1);
}

.home-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  border: none;
  border-radius: 999px;
  padding: 13px 28px;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-rose {
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: var(--white);
  box-shadow: 0 8px 24px rgba(176, 84, 107, 0.35);
}
.btn-rose:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(176, 84, 107, 0.45); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: var(--rose-deep);
  box-shadow: 0 8px 24px rgba(201, 161, 94, 0.35);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(201, 161, 94, 0.45); }

.btn-ghost {
  background: transparent;
  color: var(--rose-deep);
  border: 1.5px solid var(--blush-deep);
}
.btn-ghost:hover { background: rgba(236, 184, 193, 0.25); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.icon-btn {
  border: none;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--rose-deep);
  font-size: 1.1rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease;
}
.icon-btn:hover { transform: scale(1.08); }

#music-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
}

/* ---------------------------------------------------------------------- */
/* Chapter intro screen                                                    */
/* ---------------------------------------------------------------------- */

.chapter-intro-card {
  padding: clamp(28px, 6vw, 46px);
  text-align: center;
  margin-bottom: 26px;
}

.chapter-intro-card .eyebrow { display: block; margin-bottom: 10px; }

.chapter-paragraph {
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  color: var(--ink);
  line-height: 1.85;
  margin: 18px 0 28px;
}

/* ---------------------------------------------------------------------- */
/* Game grid + game cards                                                  */
/* ---------------------------------------------------------------------- */

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.game-card {
  width: 100%;
  appearance: none;
  font: inherit;
  padding: 22px 20px;
  text-align: left;
  border: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.game-card .game-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blush);
  color: var(--rose-deep);
  font-family: var(--font-display);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.game-card.completed .game-num { background: var(--gold); color: var(--white); }

.game-card h4 { margin: 0; font-family: var(--font-display); font-size: 1.15rem; color: var(--rose-deep); }

.game-card p { font-size: 0.92rem; color: var(--ink-soft); margin: 0 0 6px; flex-grow: 1; }

.game-card .game-state {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.game-card.completed .game-state { color: var(--rose); }
.game-card.current .game-state { color: var(--gold); }
.game-card.locked .game-state { color: var(--ink-soft); }

.game-card.locked { opacity: 0.55; }

/* ---------------------------------------------------------------------- */
/* Individual game screen (placeholder game shell)                        */
/* ---------------------------------------------------------------------- */

.game-shell {
  padding: clamp(30px, 6vw, 50px);
  text-align: center;
}

.game-shell .game-num-badge {
  display: inline-flex;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blush-deep), var(--rose));
  color: var(--white);
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.game-shell .placeholder-note {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-top: 1px dashed var(--blush-deep);
  padding-top: 16px;
}

/* ---------------------------------------------------------------------- */
/* Navigation bar (used within chapter/game screens)                      */
/* ---------------------------------------------------------------------- */

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.nav-bar .nav-group { display: flex; gap: 8px; flex-wrap: wrap; }

.nav-link-btn {
  background: none;
  border: none;
  color: var(--rose);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
}
.nav-link-btn:hover { color: var(--rose-deep); }
.nav-link-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.bottom-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------- */
/* Completion screen                                                       */
/* ---------------------------------------------------------------------- */

.completion-screen { text-align: center; padding: 20px 10px; }

.completion-card { padding: clamp(34px, 7vw, 60px) clamp(24px, 6vw, 50px); position: relative; overflow: hidden; }

.completion-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle, rgba(236,184,193,0.55) 0%, transparent 60%);
  animation: glowPulse 4s ease-in-out infinite;
  z-index: -1;
}

@keyframes glowPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

.completion-heart { font-size: 3rem; animation: heartBeat 1.6s ease-in-out infinite; }

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.15); }
  40% { transform: scale(0.98); }
}

.completion-message {
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  margin: 18px 0 30px;
}

/* Confetti */

.confetti-piece {
  position: fixed;
  top: -10px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  z-index: 40;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.3; }
}

/* ---------------------------------------------------------------------- */
/* Modal                                                                   */
/* ---------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 33, 56, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeSlideIn 0.25s ease both;
}

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

.modal-card {
  max-width: 420px;
  width: 100%;
  padding: 32px 28px;
  text-align: center;
}

.modal-seal { font-size: 1.6rem; color: var(--gold); margin: 0 0 10px; }
.modal-body { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------------- */
/* Utility                                                                  */
/* ---------------------------------------------------------------------- */

.hidden { display: none !important; }
.text-center { text-align: center; }

/* ---------------------------------------------------------------------- */
/* Responsive tweaks                                                       */
/* ---------------------------------------------------------------------- */

@media (max-width: 520px) {
  .chapter-grid, .games-grid { grid-template-columns: 1fr; }
  .progress-row { gap: 6px; }
  .nav-bar { flex-direction: column; align-items: stretch; }
  .nav-bar .nav-group { justify-content: center; }
  .bottom-nav { flex-direction: column-reverse; }
  .bottom-nav .btn { width: 100%; justify-content: center; }
}
