/* ============================================================
   Fun Zone — Shared design system
   Mobile-first. Breakpoints: 500px, 768px.
   ============================================================ */

:root {
  --pink-hot: #F43F8A;
  --pink-soft: #FBCFE8;
  --purple: #A855F7;
  --purple-deep: #7E22CE;
  --lavender: #E9D5FF;
  --mint: #6EE7B7;
  --yellow: #FDE047;
  --coral: #FB923C;
  --sky: #38BDF8;
  --rose-bg: #FFF1F5;

  --ink: #3B1F47;
  --ink-soft: #6B4A78;

  --radius-card: 22px;
  --radius-btn: 16px;
  --shadow-card: 0 10px 24px rgba(168, 85, 247, 0.18), 0 2px 6px rgba(244, 63, 138, 0.10);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background: var(--rose-bg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 {
  font-family: 'Baloo 2', 'Nunito', cursive;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}

button {
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a { color: inherit; text-decoration: none; }

/* ---------- Background blobs ---------- */
.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.bg-blobs::before,
.bg-blobs::after,
.bg-blobs > .blob {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
}
.bg-blobs::before {
  width: 320px; height: 320px;
  top: -80px; left: -80px;
  background: radial-gradient(circle, var(--pink-soft), transparent 70%);
}
.bg-blobs::after {
  width: 360px; height: 360px;
  bottom: -120px; right: -100px;
  background: radial-gradient(circle, var(--lavender), transparent 70%);
}
.bg-blobs > .blob {
  width: 260px; height: 260px;
  top: 40%; left: 60%;
  background: radial-gradient(circle, var(--mint), transparent 70%);
  opacity: 0.35;
}

/* ---------- Layout ---------- */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 18px 40px;
}

/* ---------- Top bar (game pages) ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 18px;
}
.topbar .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  background: white;
  border: 2px solid var(--lavender);
  border-radius: var(--radius-btn);
  color: var(--purple-deep);
  font-size: 16px;
  transition: transform 0.18s var(--bounce);
}
.topbar .back:active { transform: scale(0.94); }
.topbar .title {
  font-size: 22px;
  color: var(--purple-deep);
  flex: 1;
  text-align: center;
  padding-right: 80px; /* balance the back button */
}

.music-trigger,
.info-btn,
.sound-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: white;
  border: 2px solid var(--lavender);
  border-radius: var(--radius-btn);
  color: var(--purple-deep);
  font-size: 21px;
  transition: transform 0.18s var(--bounce);
}
.music-trigger:active,
.info-btn:active,
.sound-btn:active { transform: scale(0.92); }
.topbar:has(.music-trigger) .title,
.topbar:has(.info-btn) .title { padding-right: 0; }

.music-picker-backdrop,
.fz-info-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(59, 31, 71, 0.5);
  backdrop-filter: blur(5px);
}
.music-picker,
.fz-info-panel {
  width: min(100%, 430px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  padding: 20px;
  border: 2px solid var(--lavender);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: 0 18px 50px rgba(59, 31, 71, 0.3);
}
.music-picker-head,
.fz-info-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.music-picker-head h2,
.fz-info-head h2 { color: var(--purple-deep); font-size: 25px; }
.music-picker-head p { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }
.music-picker-close,
.fz-info-close {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--rose-bg);
  color: var(--purple-deep);
  font-size: 27px;
  line-height: 1;
}
.fz-info-body { color: var(--ink-soft); font-size: 15px; line-height: 1.6; }
.fz-info-body b { color: var(--purple-deep); }
.fz-info-body p { margin: 0 0 10px; }
.fz-info-body ul { margin: 0; padding-left: 20px; }
.fz-info-body li { margin-bottom: 7px; }

.music-volume {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 2px dashed var(--lavender);
}
.music-volume label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.music-volume label span { color: var(--purple-deep); }
.music-volume input[type="range"] {
  width: 100%;
  height: 32px;
  accent-color: var(--pink-hot);
  cursor: pointer;
}
.music-theme-group + .music-theme-group { margin-top: 16px; }
.music-theme-group h3 {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.music-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.music-theme {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 2px solid var(--lavender);
  border-radius: 12px;
  background: white;
  color: var(--purple-deep);
  text-align: left;
  transition: transform 0.18s var(--bounce), background 0.18s ease, color 0.18s ease;
}
.music-theme span { flex: 0 0 26px; font-size: 23px; text-align: center; }
.music-theme b { font-size: 14px; }
.music-theme:active { transform: scale(0.96); }
.music-theme.selected {
  border-color: transparent;
  background: linear-gradient(135deg, var(--pink-hot), var(--purple));
  color: white;
}
.music-mute {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border-radius: 12px;
  background: var(--rose-bg);
  color: var(--purple-deep);
  font-size: 14px;
}
@media (max-width: 380px) {
  .music-theme-grid { grid-template-columns: 1fr; }
}

/* ---------- Landing header ---------- */
.hero {
  text-align: center;
  padding: 18px 8px 22px;
}
.hero h1 {
  font-size: 44px;
  background: linear-gradient(135deg, var(--pink-hot), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
}

/* ---------- Game grid ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 8px 0;
}
@media (min-width: 500px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
@media (min-width: 768px) {
  .game-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 10px 16px;
  min-height: 140px;
  border-radius: var(--radius-card);
  background: linear-gradient(160deg, var(--pink-soft), var(--lavender));
  box-shadow: var(--shadow-card);
  color: var(--purple-deep);
  border: 2px solid rgba(255, 255, 255, 0.7);
  transition: transform 0.2s var(--bounce);
  opacity: 0;
  transform: scale(0.6);
  animation: cardPop 0.55s var(--bounce) forwards;
}
.game-card:active { transform: scale(0.95); }

.game-card .icon {
  font-size: 46px;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(126, 34, 206, 0.25));
}
.game-card .label {
  font-family: 'Baloo 2', cursive;
  font-weight: 700;
  font-size: 17px;
  text-align: center;
}

/* Per-card gradients */
.game-card.tic-tac-toe { background: linear-gradient(160deg, #FBCFE8, #A855F7); color: white; }
.game-card.snake       { background: linear-gradient(160deg, #6EE7B7, #38BDF8); color: white; }
.game-card.math        { background: linear-gradient(160deg, #FDE047, #FB923C); color: var(--ink); }
.game-card.hangman     { background: linear-gradient(160deg, #A855F7, #38BDF8); color: white; }
.game-card.wordle      { background: linear-gradient(160deg, #FB923C, #F43F8A); color: white; }
.game-card.tetris      { background: linear-gradient(160deg, #38BDF8, #A855F7); color: white; }
.game-card.number-stars{ background: linear-gradient(160deg, #FDE047, #FB923C); color: white; }
.game-card.snakes      { background: linear-gradient(160deg, #A855F7, #6EE7B7); color: white; }
.game-card.chowka      { background: linear-gradient(160deg, #FBBF24, #F43F8A); color: white; }
.game-card.spelling    { background: linear-gradient(160deg, #FDE047, #F43F8A); color: white; }

/* Locked / coming soon */
.game-card.locked {
  background: linear-gradient(160deg, #E5E7EB, #D1D5DB);
  color: #6B7280;
  cursor: default;
  pointer-events: none;
  filter: saturate(0.6);
}
.game-card.locked .soon {
  position: absolute;
  top: 10px; right: 10px;
  background: white;
  color: var(--purple-deep);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Staggered entrance */
@keyframes cardPop {
  0%   { opacity: 0; transform: scale(0.6) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.12s; }
.game-card:nth-child(3) { animation-delay: 0.19s; }
.game-card:nth-child(4) { animation-delay: 0.26s; }
.game-card:nth-child(5) { animation-delay: 0.33s; }
.game-card:nth-child(6) { animation-delay: 0.40s; }
.game-card:nth-child(7) { animation-delay: 0.47s; }
.game-card:nth-child(8) { animation-delay: 0.54s; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 14px 26px;
  border-radius: var(--radius-btn);
  font-size: 17px;
  font-weight: 800;
  transition: transform 0.18s var(--bounce), box-shadow 0.18s ease;
}
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--pink-hot), var(--purple));
  color: white;
  box-shadow: 0 8px 18px rgba(168, 85, 247, 0.35);
}
.btn-secondary {
  background: white;
  color: var(--purple-deep);
  border: 2px solid var(--lavender);
}

/* Choice chips (mode / difficulty) */
.choice-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.chip {
  flex: 1 1 100px;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--radius-btn);
  background: white;
  border: 2px solid var(--lavender);
  color: var(--purple-deep);
  font-size: 16px;
  font-weight: 800;
  transition: transform 0.18s var(--bounce), background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.chip:active { transform: scale(0.95); }
.chip.selected {
  background: linear-gradient(135deg, var(--pink-hot), var(--purple));
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(168, 85, 247, 0.35);
}

/* ---------- Setup / Result panels ---------- */
.panel {
  background: white;
  border-radius: var(--radius-card);
  padding: 22px 18px;
  box-shadow: var(--shadow-card);
  border: 2px solid rgba(233, 213, 255, 0.6);
}
.panel h2 {
  font-size: 24px;
  color: var(--purple-deep);
  text-align: center;
  margin-bottom: 6px;
}
.panel .subtle {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 18px;
}
.panel .field {
  margin-bottom: 18px;
}
.panel .field-label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 10px;
}

.hidden { display: none !important; }

/* ---------- Pass-the-phone overlay ---------- */
.pass-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, rgba(244, 63, 138, 0.95), rgba(168, 85, 247, 0.95));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: white;
  text-align: center;
  padding: 24px;
  z-index: 100;
  animation: fadeIn 0.25s ease;
}
.pass-overlay .pass-emoji {
  font-size: 96px;
  animation: bob 1.2s ease-in-out infinite;
}
.pass-overlay h2 {
  font-size: 32px;
  color: white;
}
.pass-overlay p {
  font-size: 16px;
  opacity: 0.9;
  margin: 0;
}
.pass-overlay .tap-hint {
  margin-top: 12px;
  font-size: 14px;
  opacity: 0.8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-10px);} }
@keyframes pulse { 0%,100%{ opacity: 0.8;} 50%{ opacity: 0.4;} }

/* ---------- Confetti ---------- */
.confetti-piece {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 200;
  will-change: transform, opacity;
}
/* ---- Modal (result dialog) ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 31, 71, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 150;
  animation: fadeIn 0.22s ease;
}
.modal-backdrop.hidden { display: none !important; }
.modal-panel {
  width: 100%;
  max-width: 360px;
  margin: 0;
  animation: modalPop 0.4s var(--bounce);
}
@keyframes modalPop {
  0%   { opacity: 0; transform: scale(0.7) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-panel h2 {
  font-size: 30px;
  background: linear-gradient(135deg, var(--pink-hot), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  margin-bottom: 4px;
}
.modal-panel .result-emoji {
  font-size: 64px;
  text-align: center;
  display: block;
  margin: 8px 0 12px;
}