/* ============================================
   Shared styles — English Learning Games
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700;800;900&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-main: 'Fredoka One', 'Comic Sans MS', cursive, sans-serif;
  --font-body: 'Nunito', 'Arial Rounded MT Bold', sans-serif;
  --radius-card: 24px;
  --radius-btn: 50px;
  --shadow-card: 0 8px 28px rgba(0,0,0,0.22);
  --shadow-hover: 0 16px 44px rgba(0,0,0,0.30);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  min-height: 100vh;
  color: white;
  overflow-x: hidden;
  user-select: none;
}

/* ——— Backgrounds per page ——— */
body.bg-home     { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
body.bg-memory   { background: linear-gradient(135deg, #4776e6 0%, #8e54e9 100%); }
body.bg-quiz     { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
body.bg-bubbles  { background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%); }
body.bg-whack    { background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%); }
body.bg-wordlist { background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); }
body.bg-colors   { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
body.bg-numbers  { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
body.bg-cups     { background: linear-gradient(135deg, #c0392b 0%, #8e44ad 100%); }
body.bg-letters  { background: linear-gradient(135deg, #00b09b 0%, #96c93d 100%); }
body.bg-shadow   { background: linear-gradient(135deg, #0f2027 0%, #2c5364 100%); }
body.bg-read     { background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%); }
body.bg-journey  { background: linear-gradient(135deg, #1a0533 0%, #0d1b4b 100%); }
body.bg-feed     { background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%); }

/* ——— HOME PAGE ——— */
.home-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}

.home-title {
  font-size: clamp(2.5rem, 7vw, 5rem);
  text-shadow: 3px 4px 0 rgba(0,0,0,0.18);
  margin-bottom: 0.4rem;
  animation: float 3s ease-in-out infinite;
}

.home-subtitle {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  opacity: 0.88;
  margin-bottom: 3rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.8rem;
  max-width: 900px;
  width: 100%;
}

.game-card {
  background: white;
  border-radius: var(--radius-card);
  padding: 2.2rem 1.8rem;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s;
  display: block;
}

.game-card:hover {
  transform: translateY(-10px) scale(1.04);
  box-shadow: var(--shadow-hover);
}

.game-card .gc-icon {
  font-size: 5rem;
  display: block;
  margin-bottom: 0.8rem;
  line-height: 1;
}

.game-card h2 {
  font-size: 1.7rem;
  color: #2d2d2d;
  margin-bottom: 0.5rem;
}

.game-card p {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  color: #666;
  line-height: 1.4;
}

/* Card accent bars */
.game-card.card-memory    { border-top: 6px solid #8e54e9; }
.game-card.card-quiz      { border-top: 6px solid #11998e; }
.game-card.card-bubble    { border-top: 6px solid #f7971e; }
.game-card.card-whack     { border-top: 6px solid #56ab2f; }
.game-card.card-wordlist  { border-top: 6px solid #2a5298; }
.game-card.card-colors    { border-top: 6px solid #ff6b6b; }
.game-card.card-cups      { border-top: 6px solid #e74c3c; }
.game-card.card-read      { border-top: 6px solid #9b59b6; }

/* Age badge on game cards */
.age-badge {
  display: inline-block;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 0.7rem;
  padding: 0.18rem 0.6rem;
  border-radius: 50px;
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

/* ——— GAME PAGES shared layout ——— */
.game-page {
  height: 100vh;
  min-height: unset;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0.5rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.2rem 0.25rem;
  flex-shrink: 0;
  gap: 0.4rem;
  position: relative;
}

/* Right cluster: category filter + score + new-game button */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

/* Category button compact size inside header */
.header-right .cf-btn {
  font-size: clamp(0.62rem, 1.5vw, 0.76rem);
  padding: 0.17rem 0.5rem;
}

/* Small circular New Game button */
.new-game-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.4s;
}
.new-game-btn:hover  { background: rgba(255,255,255,0.32); }
.new-game-btn:active { transform: rotate(360deg); }

.back-btn {
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.4);
  color: white;
  font-family: var(--font-main);
  font-size: clamp(0.78rem, 2vw, 0.95rem);
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.back-btn:hover { background: rgba(255,255,255,0.38); }

.game-title {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}

.score-display {
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.4);
  padding: 0.22rem 0.75rem;
  border-radius: var(--radius-btn);
  font-size: clamp(0.8rem, 2vw, 1rem);
  min-width: 60px;
  text-align: center;
  white-space: nowrap;
}

/* ——— BUTTONS ——— */
.btn {
  font-family: var(--font-main);
  font-size: 1.15rem;
  padding: 0.75rem 2rem;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.18s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn:active { transform: scale(0.94) !important; }

.btn-primary {
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: white;
}

.btn-primary:hover { transform: translateY(-3px) scale(1.03); }

.btn-secondary {
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.5);
  color: white;
}

.btn-secondary:hover { background: rgba(255,255,255,0.38); }

.btn-green {
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  color: #1a4a2e;
}

/* ——— VICTORY SCREEN ——— */
.victory-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,215,0,0.96), rgba(255,120,0,0.96));
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  text-align: center;
  padding: 2rem;
}

.victory-screen.show { display: flex; }

.victory-trophy {
  font-size: 6rem;
  animation: bounce 1s ease-in-out infinite;
  margin-bottom: 0.5rem;
}

.victory-screen h1 {
  font-size: clamp(3rem, 8vw, 5rem);
  text-shadow: 3px 4px 0 rgba(0,0,0,0.18);
  margin-bottom: 0.5rem;
}

.victory-screen p {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin-bottom: 2rem;
  opacity: 0.92;
}

.victory-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Confetti stars floating behind victory */
.confetti-star {
  position: fixed;
  font-size: 2rem;
  pointer-events: none;
  animation: confettiFall linear forwards;
  z-index: 999;
}

@keyframes confettiFall {
  from { transform: translateY(-60px) rotate(0deg); opacity: 1; }
  to   { transform: translateY(110vh)  rotate(720deg); opacity: 0.3; }
}

/* ——— PROGRESS BAR ——— */
.progress-bar-wrap {
  width: 100%;
  max-width: 500px;
  background: rgba(255,255,255,0.25);
  border-radius: 50px;
  height: 18px;
  overflow: hidden;
  margin: 0 auto;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #fff 0%, rgba(255,255,255,0.7) 100%);
  border-radius: 50px;
  transition: width 0.4s ease;
}

/* ——— ANIMATIONS ——— */
@keyframes float {
  0%, 100% { transform: translateY(0);    }
  50%       { transform: translateY(-12px); }
}

@keyframes bounce {
  0%, 100% { transform: scale(1);    }
  50%       { transform: scale(1.15); }
}

@keyframes pop {
  0%   { transform: scale(1);   }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1);   }
}

@keyframes shake {
  0%, 100% { transform: translateX(0);   }
  20%       { transform: translateX(-12px); }
  40%       { transform: translateX(12px);  }
  60%       { transform: translateX(-8px);  }
  80%       { transform: translateX(8px);   }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1);   }
}

@keyframes spinPop {
  0%   { transform: scale(1)   rotate(0deg);   }
  50%  { transform: scale(1.4) rotate(180deg); }
  100% { transform: scale(0)   rotate(360deg); opacity: 0; }
}

.anim-pop     { animation: pop 0.4s ease; }
.anim-shake   { animation: shake 0.5s ease; }
.anim-zoomIn  { animation: zoomIn 0.4s cubic-bezier(.34,1.56,.64,1); }
.anim-fadeUp  { animation: fadeInUp 0.4s ease; }

/* ——— CATEGORY FILTER DROPDOWN ——— */
.cat-filter-row {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 0 0.8rem 0.4rem;
}

/* Trigger button */
.cf-btn {
  font-family: var(--font-main);
  font-size: clamp(0.8rem, 2.2vw, 0.95rem);
  padding: 0.35rem 1rem;
  border-radius: 50px;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.14);
  color: white;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.cf-btn:hover  { background: rgba(255,255,255,0.26); }
.cf-btn:active { transform: scale(0.95); }

/* Floating dropdown panel */
.cf-panel {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  max-width: 260px;
  background: rgba(20, 50, 110, 0.97);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 16px;
  padding: 0.5rem 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  display: none;
  max-height: 70vh;
  overflow-y: auto;
}
.cf-panel.open { display: block; }

/* Each checkbox row */
.cf-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.88rem;
  color: white;
}
.cf-row:hover { background: rgba(255,255,255,0.12); }

.cf-row input[type=checkbox] {
  width: 17px;
  height: 17px;
  accent-color: #38ef7d;
  cursor: pointer;
  flex-shrink: 0;
}

/* "All categories" row */
.cf-all {
  font-size: 0.92rem;
  font-family: var(--font-main);
}

/* Category label (takes remaining space) */
.cf-label { flex: 1; }

/* Word count badge */
.cf-count {
  font-size: 0.75rem;
  background: rgba(255,255,255,0.15);
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  white-space: nowrap;
}

/* Divider between All and individual cats */
.cf-divider {
  height: 1px;
  background: rgba(255,255,255,0.2);
  margin: 0.3rem 0.6rem;
}

/* ——— BADGE TOAST ——— */
.badge-toast {
  position: fixed;
  top: -90px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: white;
  border-radius: 20px;
  padding: 0.55rem 1.4rem 0.55rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  z-index: 10000;
  box-shadow: 0 6px 28px rgba(0,0,0,0.35);
  transition: top 0.45s cubic-bezier(.34,1.56,.64,1);
  font-family: var(--font-main);
  white-space: nowrap;
  pointer-events: none;
}
.badge-toast.show  { top: 0.8rem; }
.bt-emoji          { font-size: 2.2rem; line-height: 1; }
.bt-label          { font-family: var(--font-body); font-weight: 900; font-size: 0.68rem; opacity: 0.9; }
.bt-name           { font-size: 1rem; }

/* ——— BADGE SHELF (home page) ——— */
.badge-shelf {
  margin-top: 1.8rem;
  text-align: center;
}
.badge-shelf-title {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 0.88rem;
  opacity: 0.75;
  margin-bottom: 0.55rem;
}
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
}
.badge-chip {
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 50px;
  padding: 0.3rem 0.8rem 0.3rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-main);
  font-size: 0.82rem;
  color: white;
}
.badge-chip .bc-emoji { font-size: 1.2rem; line-height: 1; }

/* ——— TWEMOJI ——— */
img.emoji {
  display: inline-block;
  vertical-align: -0.15em;
  width: 1em;
  height: 1em;
}

/* ——— UTILITY ——— */
.center { text-align: center; }
.mt1    { margin-top: 1rem; }
.mt2    { margin-top: 2rem; }
