:root {
  --bg-1: #1a0b2e;
  --bg-2: #2d1b4e;
  --bg-3: #3d1a4a;
  --pink: #ff7eb3;
  --pink-soft: #ffb3d1;
  --gold: #ffd86b;
  --rose: #ff5e8a;
  --text: #fdeef5;
  --muted: #c8b6d6;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Poppins", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, var(--bg-3), transparent 60%),
              radial-gradient(circle at 80% 80%, var(--bg-2), transparent 55%),
              linear-gradient(160deg, var(--bg-1), #120821);
  overflow-x: hidden;
}

body { min-height: 100vh; }

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.8s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- INTRO ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: radial-gradient(circle at 50% 40%, #2a1248, #0c0518 80%);
  flex-direction: column;
}
#intro-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.intro-text {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: introTextIn 1.6s ease 0.6s both;
}
.intro-title {
  font-family: "Dancing Script", cursive;
  font-size: clamp(4rem, 16vw, 9rem);
  font-weight: 700;
  background: linear-gradient(90deg, var(--pink-soft), var(--gold), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(255, 126, 179, 0.35);
  line-height: 1;
}
.intro-sub {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  color: var(--muted);
  margin-top: 8px;
  letter-spacing: 1px;
}
@keyframes introTextIn {
  from { opacity: 0; transform: scale(0.85); filter: blur(8px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}
.intro.fade-out { animation: fadeOut 1s ease forwards; }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }

/* ---------- WELCOME ---------- */
.welcome-card, .letter-paper, .game-stage {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.welcome-card {
  max-width: 540px;
  text-align: center;
  padding: 48px 36px;
}
.welcome-emoji { font-size: 2.4rem; margin-bottom: 10px; letter-spacing: 4px; }
.welcome-card h2 {
  font-family: "Dancing Script", cursive;
  font-size: 3rem;
  margin-bottom: 16px;
  color: var(--pink-soft);
}
.welcome-card p { color: var(--text); line-height: 1.7; margin-bottom: 10px; font-weight: 300; }
.muted { color: var(--muted) !important; font-style: italic; }

/* ---------- BUTTONS ---------- */
.btn {
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.25s ease, background 0.25s ease;
  margin-top: 20px;
}
.btn.primary {
  background: linear-gradient(135deg, var(--rose), var(--pink));
  color: #fff;
  box-shadow: 0 10px 30px rgba(255, 94, 138, 0.4);
}
.btn.primary:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 14px 40px rgba(255, 94, 138, 0.55); }
.btn.ghost {
  background: transparent;
  color: var(--pink-soft);
  border: 1.5px solid var(--glass-border);
}
.btn.ghost:hover { background: var(--glass); transform: translateY(-2px); }
.btn:active { transform: scale(0.97); }
.btn.small { padding: 9px 18px; font-size: 0.85rem; margin-top: 0; }

/* ---------- GAMES ---------- */
.games { flex-direction: column; align-items: center; gap: 18px; padding-top: 30px; }
.game-header { width: 100%; max-width: 720px; }
.progress-info { display: flex; flex-direction: column; gap: 8px; }
#game-counter { font-size: 0.9rem; color: var(--muted); letter-spacing: 1px; }
.progress-bar { width: 100%; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--pink), var(--rose));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.game-stage {
  width: 100%;
  max-width: 720px;
  padding: 28px 26px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.game-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--pink-soft);
  margin-bottom: 6px;
}
.game-instructions { color: var(--muted); font-weight: 300; margin-bottom: 18px; max-width: 520px; }
.game-area {
  position: relative;
  width: 100%;
  min-height: 340px;
  border-radius: 18px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
}
.game-footer {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 50px;
}
.game-status { color: var(--gold); font-weight: 500; }
.game-status.win { animation: pop 0.5s ease; }
@keyframes pop { 0%{transform:scale(0.6);opacity:0} 60%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }

/* ---------- LETTER ---------- */
.letter { padding: 40px 20px; }
.letter-paper {
  max-width: 620px;
  padding: 48px 44px;
  background: linear-gradient(160deg, rgba(255,245,250,0.97), rgba(255,236,244,0.95));
  color: #4a2740;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.letter-heading {
  font-family: "Dancing Script", cursive;
  font-size: 2.6rem;
  color: var(--rose);
  text-align: center;
  margin-bottom: 24px;
}
.letter-body {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.3rem;
  line-height: 1.9;
  white-space: pre-wrap;
  min-height: 200px;
}
.letter-body .cursor { animation: blink 0.9s steps(1) infinite; color: var(--rose); }
@keyframes blink { 50% { opacity: 0; } }
.letter-choice { margin-top: 28px; text-align: center; }
.letter-question { font-family: "Cormorant Garamond", serif; font-size: 1.5rem; font-weight: 600; color: var(--rose); margin-bottom: 8px; }
.choice-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.choice-buttons .btn.ghost { color: var(--rose); border-color: rgba(255,94,138,0.4); }
.choice-buttons .btn.ghost:hover { background: rgba(255,94,138,0.08); }
.letter-final {
  margin-top: 26px;
  text-align: center;
  font-family: "Dancing Script", cursive;
  font-size: 1.8rem;
  color: var(--rose);
  animation: fadeIn 0.8s ease both;
}

/* ---------- GAME ELEMENTS (shared) ---------- */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, background 0.2s ease;
  font-size: 1.8rem;
}
.tile:hover { transform: scale(1.06); background: rgba(255,255,255,0.16); }
.tile.matched { background: rgba(255,126,179,0.3); cursor: default; }
.tile.flipped { background: rgba(255,255,255,0.22); }
.tile.wrong { animation: shake 0.4s ease; }
@keyframes shake { 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

.floater {
  position: absolute;
  font-size: 2rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease;
}
.floater:hover { transform: scale(1.2); }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 10px; font-style: italic; }

.choice-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.choice-pill {
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.18s ease;
  font-size: 1rem;
}
.choice-pill:hover { background: rgba(255,126,179,0.25); transform: translateY(-2px); }
.choice-pill.correct { background: rgba(120,255,170,0.3); border-color: rgba(120,255,170,0.6); }
.choice-pill.incorrect { background: rgba(255,90,90,0.3); border-color: rgba(255,90,90,0.6); }

.big-emoji { font-size: 3rem; }

.word-display { font-family: "Cormorant Garamond", serif; font-size: 2.4rem; letter-spacing: 8px; color: var(--gold); }

.keyboard { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 480px; }
.key {
  width: 38px; height: 44px;
  border-radius: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-transform: uppercase; font-weight: 500;
  transition: all 0.15s ease;
}
.key:hover { background: rgba(255,255,255,0.18); }
.key.used { opacity: 0.3; cursor: default; pointer-events: none; }

@media (max-width: 560px) {
  .welcome-card, .letter-paper { padding: 34px 22px; }
  .game-stage { padding: 20px 16px; }
  .key { width: 32px; height: 40px; }
}
