/* ============================================================
   components.css — Shared UI Components
   ============================================================
   PURPOSE : Styles for all reusable UI pieces:
             nav bars, cards, buttons, play screen,
             end screen, toasts, confetti, etc.
             Layout variables come from main.css.
   EDIT     : Add new component styles here. Do NOT put layout
              or breakpoint rules here — those belong in main.css.
   ============================================================ */


/* ============================================================
   TOP NAVBAR (Tablet + Desktop)
   ============================================================ */
.top-nav {
  background: linear-gradient(135deg, #1a1a3e 0%, #0f0c29 100%);
  border-bottom: 2px solid rgba(168,85,247,0.3);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  position: sticky;              /* stays visible while body scrolls */
  top: 0;
  z-index: 500;
}
.top-nav::-webkit-scrollbar { height: 2px; }

/* ============================================================
   CHILD-FRIENDLY OVERRIDES (body.show-app scope only)
   Everything below applies ONLY on the games view.
   Login and admin keep the dark professional look.
   ============================================================ */

/* Nav bar */
body.show-app .top-nav {
  background: linear-gradient(135deg, #FEF3C7 0%, #DBEAFE 100%);
  border-bottom: 3px solid #FBBF24;
  box-shadow: 0 2px 12px rgba(251,191,36,0.15);
}
body.show-app .logo {
  color: #D97706;
  text-shadow: 2px 2px 0 rgba(251,191,36,0.4);
}
body.show-app .nav-divider { background: rgba(0,0,0,0.08); }

body.show-app .nav-btn {
  border: 2.5px solid #0EA5E9;                    /* strong sky blue */
  background: white;                              /* solid, not translucent */
  color: #0F172A;                                 /* near-black for max contrast */
  border-radius: 14px;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 14px;
  box-shadow: 0 2px 0 rgba(14,165,233,0.25);      /* soft sky-blue drop shadow */
}
body.show-app .nav-btn:hover {
  background: linear-gradient(135deg, #FEF3C7, white);
  border-color: #F59E0B;
  color: #78350F;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(245,158,11,0.35);
}
body.show-app .nav-btn.active {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  border-color: #B45309;
  color: white;
  box-shadow: 0 4px 12px rgba(245,158,11,0.5);
  text-shadow: 0 1px 0 rgba(0,0,0,0.15);
}

/* Search input in nav */
body.show-app .search-wrap input {
  border: 2.5px solid rgba(30,41,59,0.15);
  background: white;
  color: #1E293B;
  border-radius: 14px;
}
body.show-app .search-wrap input:focus {
  border-color: #38BDF8;
  background: white;
  box-shadow: 0 3px 10px rgba(56,189,248,0.2);
}
body.show-app .search-wrap input::placeholder { color: #94A3B8; }

/* Mobile bottom nav */
body.show-app .bottom-nav {
  background: linear-gradient(0deg, #FEF3C7, #DBEAFE);
  border-top: 3px solid #FBBF24;
  box-shadow: 0 -2px 12px rgba(251,191,36,0.15);
}

/* ─── Grade selector cards (Kindergarten / G1-G2 / etc) ─── */
body.show-app .grade-card {
  background: white;
  border: 3px solid #E0E7FF;
  border-radius: 24px;
  padding: 26px 18px;
  box-shadow: 0 4px 0 rgba(30,41,59,0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
body.show-app .grade-card:hover {
  transform: translateY(-6px) rotate(-1deg);
  border-color: #FBBF24;
  box-shadow: 0 10px 24px rgba(251,191,36,0.3);
}
body.show-app .grade-card:active { transform: translateY(-2px) scale(0.97); }
body.show-app .grade-emoji { font-size: 48px; margin-bottom: 10px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
body.show-app .grade-name  {
  color: #1E293B;
  font-size: 19px;
  font-family: 'Fredoka One', cursive;
}
body.show-app .grade-sub   { color: #64748B; font-size: 13px; font-weight: 600; }
body.show-app .grade-count {
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
  color: white;
  font-weight: 800;
  padding: 3px 12px;
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(245,158,11,0.35);
}

/* ─── Game cards (individual games) ─── */
body.show-app .game-card {
  background: white;
  border: 3px solid #E0E7FF;
  border-radius: 20px;
  padding: 20px 18px;
  box-shadow: 0 4px 0 rgba(30,41,59,0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
body.show-app .game-card:hover {
  transform: translateY(-4px);
  border-color: #38BDF8;
  box-shadow: 0 8px 20px rgba(56,189,248,0.28);
}
body.show-app .game-card:active { transform: translateY(-1px) scale(0.98); }
body.show-app .game-emoji         { font-size: 38px; }
body.show-app .game-info-text h3  { color: #1E293B; font-size: 15px; font-weight: 800; }
body.show-app .game-info-text p   { color: #64748B; font-weight: 600; }
body.show-app .tag {
  background: #FEF3C7;
  color: #92400E;
  border: 1.5px solid #FBBF24;
  font-weight: 800;
}

/* ─── Grade filter tabs ─── */
body.show-app .grade-tab {
  border: 2.5px solid #E0E7FF;
  background: white;
  color: #64748B;
  border-radius: 20px;
  font-size: 12px;
  padding: 8px 16px;
}
body.show-app .grade-tab:hover {
  background: #EFF6FF;
  color: #0F172A;
  border-color: #38BDF8;
}
body.show-app .grade-tab.active {
  background: linear-gradient(135deg, #38BDF8, #0EA5E9);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(56,189,248,0.4);
}

/* ─── Back button ─── */
body.show-app .back-btn {
  background: white;
  border: 2.5px solid #E0E7FF;
  color: #334155;
  border-radius: 14px;
  font-size: 14px;
}
body.show-app .back-btn:hover {
  background: #FEF3C7;
  border-color: #FBBF24;
  color: #92400E;
}

/* ─── Difficulty filter tabs (top of games list) ─── */
body.show-app .diff-tab {
  background: white;
  border-width: 2.5px;
}

/* ─── Play buttons on each card (Easy/Medium/Hard) ─── */
body.show-app .play-btn {
  background: white;
  border-width: 2.5px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  min-height: 40px;
}
body.show-app .games-header h2 { color: #1E293B; }

/* ─── Game play area ─── */
body.show-app .question-card {
  background: white;
  border: 4px solid #FEF3C7;
  border-radius: 24px;
  box-shadow: 0 6px 0 rgba(30,41,59,0.05), 0 2px 10px rgba(0,0,0,0.05);
  padding: 20px 22px;
}
body.show-app .question-text {
  color: #1E293B;
  text-shadow: 1px 1px 0 rgba(251,191,36,0.15);
}
body.show-app .question-sub  { color: #64748B; font-weight: 700; }
body.show-app .game-title-small { color: #D97706; }
body.show-app .progress-text    { color: #64748B; }
body.show-app .progress-track   { background: #E0E7FF; }
body.show-app .progress-fill    { background: linear-gradient(90deg, #FBBF24, #F59E0B); }

/* Score cards */
body.show-app .score-card {
  border-radius: 18px;
  border-width: 3px;
  box-shadow: 0 4px 0 rgba(30,41,59,0.06);
}
body.show-app .score-card.red  {
  background: linear-gradient(135deg, #FEE2E2, #FECACA);
  border-color: #F87171;
}
body.show-app .score-card.blue {
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
  border-color: #60A5FA;
}
body.show-app .score-card.red  .score-num { color: #DC2626; text-shadow: 2px 2px 0 rgba(255,255,255,0.6); }
body.show-app .score-card.blue .score-num { color: #2563EB; text-shadow: 2px 2px 0 rgba(255,255,255,0.6); }
body.show-app .score-card.red.active-turn  { box-shadow: 0 0 20px rgba(248,113,113,0.55), 0 4px 0 rgba(30,41,59,0.06); }
body.show-app .score-card.blue.active-turn { box-shadow: 0 0 20px rgba(96,165,250,0.55), 0 4px 0 rgba(30,41,59,0.06); }

/* Answer option buttons — the biggest visual change for kids */
body.show-app .opt-btn {
  border-radius: 18px;
  background: white;
  border-width: 4px;
  box-shadow: 0 4px 0 rgba(30,41,59,0.08);
  font-weight: 800;
  min-height: 56px;
  padding: 10px 8px;
}
body.show-app .team-panel.red  .opt-btn { border-color: #F87171; color: #DC2626; }
body.show-app .team-panel.blue .opt-btn { border-color: #60A5FA; color: #2563EB; }
body.show-app .team-panel.red  .opt-btn:hover:not(:disabled):not(.locked) {
  background: #FEF2F2;
  border-color: #DC2626;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 0 rgba(220,38,38,0.15);
}
body.show-app .team-panel.blue .opt-btn:hover:not(:disabled):not(.locked) {
  background: #EFF6FF;
  border-color: #2563EB;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 0 rgba(37,99,235,0.15);
}
body.show-app .opt-btn.correct {
  background: linear-gradient(135deg, #A7F3D0, #6EE7B7) !important;
  border-color: #10B981 !important;
  color: #047857 !important;
  box-shadow: 0 6px 0 rgba(16,185,129,0.25) !important;
}
body.show-app .opt-btn.wrong {
  background: linear-gradient(135deg, #FECACA, #FCA5A5) !important;
  border-color: #EF4444 !important;
  color: #B91C1C !important;
  box-shadow: 0 6px 0 rgba(239,68,68,0.25) !important;
}

/* ─── Game controls (Sound / Prev / Next / Skip / Games / Home) ─── */
body.show-app .ctrl-btn {
  background: white;
  border: 2.5px solid #38BDF8;
  color: #1E3A8A;
  border-radius: 14px;
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(56,189,248,0.25);
  padding: 10px 18px;
  min-height: 42px;
}
body.show-app .ctrl-btn:hover {
  background: linear-gradient(135deg, #38BDF8, #0EA5E9);
  border-color: #0EA5E9;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(56,189,248,0.4);
}
body.show-app .ctrl-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 0 rgba(56,189,248,0.25);
}

.logo {
  font-family: 'Fredoka One', cursive;
  font-size: 20px;
  color: var(--gold);
  white-space: nowrap;
  margin-right: 8px;
  text-shadow: 0 0 18px rgba(255,215,0,0.5);
  flex-shrink: 0;
}

.nav-divider { width: 1px; height: 26px; background: rgba(255,255,255,0.1); flex-shrink: 0; }

.nav-btn {
  padding: 7px 13px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 9px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.7);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s;
  flex-shrink: 0;
}
.nav-btn:hover        { background: rgba(168,85,247,0.2); border-color: var(--purple); color: white; }
.nav-btn.active       { background: linear-gradient(135deg,#a855f7,#7c3aed); border-color: transparent; color: white; box-shadow: 0 3px 12px rgba(168,85,247,0.45); }

.search-wrap { margin-left: auto; position: relative; flex-shrink: 0; }
.search-wrap input {
  padding: 7px 10px 7px 32px;
  border-radius: 9px;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.07);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  width: 160px;
  transition: all 0.2s;
}
.search-wrap input:focus       { outline: none; border-color: var(--purple); width: 200px; background: rgba(168,85,247,0.1); }
.search-wrap input::placeholder { color: rgba(255,255,255,0.4); }
.search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; }


/* ============================================================
   MOBILE BOTTOM NAV (phones ≤600px)
   ============================================================ */
.bottom-nav {
  display: none;   /* shown via media query in main.css */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--bottom-nav-h);
  background: linear-gradient(0deg, #0f0c29, #1a1a3e);
  border-top: 2px solid rgba(168,85,247,0.3);
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: auto;
  overflow-y: hidden;
  align-items: center;
  gap: 2px;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.bnav-btn {
  flex: 1;
  min-width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.18s;
  border-radius: 10px;
}
.bnav-btn .bnav-icon  { font-size: 20px; line-height: 1; }
.bnav-btn .bnav-label { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px; }
.bnav-btn.active      { color: var(--purple); background: rgba(168,85,247,0.12); }
.bnav-btn:active      { transform: scale(0.92); }


/* ============================================================
   HOME SCREEN
   ============================================================ */
.home-wrap {
  padding: 32px 20px 24px;
  max-width: 1000px;
  margin: 0 auto;
}
.home-hero           { text-align: center; margin-bottom: 36px; }
.home-hero h1 {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(28px, 6vw, 54px);
  background: linear-gradient(135deg, #FFD700, #ff6b9d, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  line-height: 1.1;
}
.home-hero p { color: var(--text-muted); font-size: clamp(14px, 2vw, 17px); }

/* Category Cards Grid */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.grade-card {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s;
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.grade-card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, var(--c1), var(--c2)); opacity: 0; transition: opacity 0.22s; }
.grade-card:hover::before  { opacity: 0.14; }
.grade-card:hover          { transform: translateY(-4px) scale(1.02); border-color: rgba(255,255,255,0.22); box-shadow: 0 10px 28px rgba(0,0,0,0.4); }
.grade-card:active         { transform: scale(0.96); }
.grade-emoji  { font-size: 40px; margin-bottom: 8px; display: block; }
.grade-name   { font-family: 'Fredoka One', cursive; font-size: 17px; color: white; }
.grade-sub    { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.grade-count  { display: inline-block; margin-top: 8px; background: rgba(255,255,255,0.1); border-radius: 20px; padding: 2px 9px; font-size: 11px; font-weight: 700; }


/* ============================================================
   GAMES LIST SCREEN
   ============================================================ */
.games-wrap    { padding: 20px 16px 24px; max-width: 1100px; margin: 0 auto; }
.games-header  { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.games-header h2 { font-family: 'Fredoka One', cursive; font-size: clamp(20px,4vw,26px); flex: 1; min-width: 0; }

.diff-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.diff-tab {
  padding: 7px 14px;
  border-radius: 30px;
  border: 2px solid;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
  background: transparent;
}
.diff-tab.easy   { border-color: var(--easy);   color: var(--easy); }
.diff-tab.medium { border-color: var(--medium); color: var(--medium); }
.diff-tab.hard   { border-color: var(--hard);   color: var(--hard); }
.diff-tab.easy.active,   .diff-tab.easy:hover   { background: var(--easy);   color: white; }
.diff-tab.medium.active, .diff-tab.medium:hover { background: var(--medium); color: white; }
.diff-tab.hard.active,   .diff-tab.hard:hover   { background: var(--hard);   color: white; }

/* Filter Row & Grade Tabs */
.filter-row { margin-bottom: 12px; }

.grade-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  overflow-x: auto;
  padding-bottom: 4px;
}
.grade-tabs::-webkit-scrollbar { height: 2px; }

.grade-tab {
  padding: 7px 14px;
  border-radius: 30px;
  border: 2px solid rgba(168,85,247,0.3);
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.grade-tab:hover  { background: rgba(168,85,247,0.15); color: white; border-color: var(--purple); }
.grade-tab.active { background: linear-gradient(135deg,#a855f7,#7c3aed); border-color: transparent; color: white; box-shadow: 0 3px 12px rgba(168,85,247,0.35); }

.back-btn {
  padding: 7px 14px;
  border-radius: 9px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.1); }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.game-card {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.22s;
  position: relative;
  overflow: hidden;
}
.game-card:hover  { transform: translateY(-3px); border-color: rgba(168,85,247,0.5); box-shadow: 0 7px 22px rgba(168,85,247,0.2); }
.game-card:active { transform: scale(0.97); }

.game-card-top      { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.game-emoji         { font-size: 32px; flex-shrink: 0; }
.game-info-text h3  { font-size: 14px; font-weight: 800; line-height: 1.2; }
.game-info-text p   { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.game-tags          { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tag { padding: 2px 7px; border-radius: 20px; font-size: 10px; font-weight: 700; background: rgba(168,85,247,0.15); color: var(--purple); border: 1px solid rgba(168,85,247,0.3); }
.game-play-btns { display: flex; gap: 5px; }
.play-btn {
  flex: 1;
  padding: 8px 4px;
  border: 2px solid;
  border-radius: 9px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.18s;
  background: transparent;
  min-height: 36px;
}
.play-btn.easy   { border-color: var(--easy);   color: var(--easy); }
.play-btn.medium { border-color: var(--medium); color: var(--medium); }
.play-btn.hard   { border-color: var(--hard);   color: var(--hard); }
.play-btn.easy:hover   { background: var(--easy);   color: white; }
.play-btn.medium:hover { background: var(--medium); color: white; }
.play-btn.hard:hover   { background: var(--hard);   color: white; }


/* ============================================================
   GAME PLAY SCREEN
   ============================================================ */
.play-wrap {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 8px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Score Bar */
.score-bar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; flex-shrink: 0; }
.score-card {
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: box-shadow 0.3s;
}
.score-card.red  { background: linear-gradient(135deg,rgba(255,71,87,0.22),rgba(192,57,43,0.12));  border: 2px solid rgba(255,71,87,0.35); }
.score-card.blue { background: linear-gradient(135deg,rgba(30,144,255,0.22),rgba(0,102,204,0.12)); border: 2px solid rgba(30,144,255,0.35); }
.score-card.red.active-turn  { border-color: var(--red);  box-shadow: 0 0 18px rgba(255,71,87,0.4); }
.score-card.blue.active-turn { border-color: var(--blue); box-shadow: 0 0 18px rgba(30,144,255,0.4); }
.score-team { font-family: 'Fredoka One', cursive; font-size: clamp(14px,2vw,18px); }
.score-num  { font-family: 'Fredoka One', cursive; font-size: clamp(28px,5vw,44px); line-height: 1; }
.score-card.red  .score-num { color: var(--red-light); }
.score-card.blue .score-num { color: var(--blue-light); }

.score-turn-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 20px; background: rgba(255,255,255,0.15); color: white; animation: pulse-badge 1s ease infinite; }
@keyframes pulse-badge { 0%,100%{opacity:1} 50%{opacity:0.45} }

.progress-center  { text-align: center; flex-shrink: 0; }
.progress-track   { width: 80px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin: 0 auto 4px; }
.progress-fill    { height: 100%; background: linear-gradient(90deg,var(--purple),#7c3aed); border-radius: 3px; transition: width 0.4s ease; }
.progress-text    { font-size: 11px; color: var(--text-muted); font-weight: 700; }
.game-title-small { font-family: 'Fredoka One', cursive; font-size: 12px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }

/* Question Card */
.question-card { background: var(--card); border: 2px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 14px 18px; text-align: center; flex-shrink: 0; }
.question-img  { max-width: 40%; max-height: 120px; border-radius: 10px; margin: 0 auto 8px; display: block; }
.question-text { font-family: 'Fredoka One', cursive; font-size: clamp(18px,3.5vw,36px); color: white; line-height: 1.3; white-space: pre-line; }
.question-sub  { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Puzzle Grid Table */
.puzzle-grid {
  margin: 10px auto;
  border-collapse: collapse;
  background: rgba(15, 12, 41, 0.6);
  border-radius: 10px;
  overflow: hidden;
}
.puzzle-grid td {
  width: clamp(28px, 6vw, 48px);
  height: clamp(28px, 6vw, 48px);
  text-align: center;
  vertical-align: middle;
  font-size: clamp(16px, 3.5vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px;
}
.puzzle-grid td.blank-cell {
  background: rgba(255, 200, 50, 0.15);
  animation: pulse-blank 1.2s ease-in-out infinite;
}
.puzzle-grid td.wall-cell {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(0, 0, 0, 0.5);
  font-size: clamp(10px, 2vw, 16px);
}
.puzzle-grid td.divider-cell {
  background: transparent;
  border: none;
  font-size: clamp(14px, 2.5vw, 22px);
  color: rgba(255, 255, 255, 0.4);
  width: clamp(14px, 2vw, 22px);
  padding: 0;
}
@keyframes pulse-blank {
  0%, 100% { background: rgba(255, 200, 50, 0.15); }
  50%      { background: rgba(255, 200, 50, 0.3); }
}

/* Turn Indicator */
.turn-indicator {
  text-align: center;
  font-size: clamp(12px,1.8vw,15px);
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 9px;
  flex-shrink: 0;
  transition: all 0.3s;
}
.turn-indicator.red  { background: rgba(255,71,87,0.13); color: var(--red-light);  border: 1px solid rgba(255,71,87,0.28); }
.turn-indicator.blue { background: rgba(30,144,255,0.13); color: var(--blue-light); border: 1px solid rgba(30,144,255,0.28); }
.turn-indicator.both { background: rgba(168,85,247,0.13); color: var(--purple);    border: 1px solid rgba(168,85,247,0.28); }

/* Answer Area */
.answer-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
}
.team-panel {
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.team-panel.red  { background: rgba(255,71,87,0.06);  border: 2px solid rgba(255,71,87,0.18); }
.team-panel.blue { background: rgba(30,144,255,0.06); border: 2px solid rgba(30,144,255,0.18); }
.team-panel.red.active-turn  { border-color: rgba(255,71,87,0.5); }
.team-panel.blue.active-turn { border-color: rgba(30,144,255,0.5); }

.team-panel-header { font-family: 'Fredoka One', cursive; font-size: clamp(14px,2.5vw,18px); text-align: center; padding: 5px; border-radius: 7px; flex-shrink: 0; }
.team-panel.red  .team-panel-header { color: var(--red-light); }
.team-panel.blue .team-panel-header { color: var(--blue-light); }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex: 1; min-height: 0; }
.opt-btn {
  border-radius: 10px;
  border: 3px solid;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(14px,2.2vw,24px);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 4px;
  min-height: 44px;
  width: 100%;
  height: 100%;
  word-break: break-word;
  overflow: hidden;
  line-height: 1.2;
}
.team-panel.red  .opt-btn { border-color: rgba(255,71,87,0.35);  color: var(--red-light); }
.team-panel.blue .opt-btn { border-color: rgba(30,144,255,0.35); color: var(--blue-light); }

.opt-btn:hover:not(:disabled):not(.locked) { transform: scale(1.05); }
.team-panel.red  .opt-btn:hover:not(:disabled):not(.locked) { background: rgba(255,71,87,0.18);  border-color: var(--red); }
.team-panel.blue .opt-btn:hover:not(:disabled):not(.locked) { background: rgba(30,144,255,0.18); border-color: var(--blue); }
.opt-btn:active:not(:disabled):not(.locked) { transform: scale(0.93) !important; }
.opt-btn:disabled, .opt-btn.locked { opacity: 0.38; cursor: not-allowed; transform: none !important; }

.opt-btn.correct { border-color: var(--green)  !important; background: rgba(46,204,113,0.22) !important; color: var(--green)  !important; animation: correctPop 0.45s ease; }
.opt-btn.wrong   { border-color: var(--hard)   !important; background: rgba(231,76,60,0.22)  !important; color: var(--hard)   !important; animation: wrongShake 0.38s ease; }
@keyframes correctPop  { 0%{transform:scale(1)} 45%{transform:scale(1.12)} 100%{transform:scale(1)} }
@keyframes wrongShake  { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

/* Feedback Bar */
.feedback-bar { text-align: center; font-family: 'Fredoka One', cursive; font-size: clamp(16px,2.5vw,24px); min-height: 32px; flex-shrink: 0; transition: all 0.3s; }

/* Game Controls */
.game-controls { display: flex; gap: 6px; justify-content: center; flex-shrink: 0; flex-wrap: wrap; }
.ctrl-btn {
  padding: 8px 16px;
  border-radius: 9px;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
  min-height: 38px;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.1); }


/* ============================================================
   DRAWING PLAY SCREEN
   ============================================================ */
.draw-wrap {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--nav-h));
  padding: 10px 12px;
  gap: 8px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

.draw-instruction-card {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px 16px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.draw-team-label {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(13px, 2vw, 17px);
  white-space: nowrap;
}
.draw-team-label.red  { color: var(--red-light); }
.draw-team-label.blue { color: var(--blue-light); }

.draw-instruction-text {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(16px, 3vw, 24px);
  color: white;
  flex: 1;
  line-height: 1.3;
}

/* Target shape preview — shows the player WHAT to draw */
.draw-shape-preview {
  background: rgba(168, 85, 247, 0.07);
  border: 2px dashed rgba(168, 85, 247, 0.5);
  border-radius: 10px;
  width: clamp(80px, 14vw, 140px);
  height: clamp(80px, 14vw, 140px);
  flex-shrink: 0;
  display: block;
}
@media (max-width: 600px) {
  .draw-shape-preview { width: 80px; height: 80px; }
}

.draw-timer {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(16px, 3vw, 22px);
  color: var(--gold);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}
.draw-timer.warning { color: var(--hard); animation: pulse-badge 0.5s ease infinite; }

/* Two drawing boards side by side */
.draw-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 500px) {
  .draw-area { grid-template-columns: 1fr; }
}
.draw-panel {
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  min-height: 0;
}
.draw-panel.red  { background: rgba(255,0,0,0.08); border: 2px solid rgba(255,80,80,0.3); }
.draw-panel.blue { background: rgba(0,100,255,0.08); border: 2px solid rgba(80,130,255,0.3); }

.draw-panel-header {
  text-align: center;
  font-family: 'Fredoka One', cursive;
  font-weight: 800;
  font-size: clamp(11px, 1.8vw, 15px);
  color: white;
  flex-shrink: 0;
  padding: 2px 0;
}

.draw-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.draw-canvas {
  background: rgba(15, 12, 41, 0.9);
  border-radius: 10px;
  cursor: crosshair;
  width: 95%;
  aspect-ratio: 1;
}
.draw-canvas.red  { border: 3px solid rgba(255,71,87,0.4);  box-shadow: 0 0 15px rgba(255,71,87,0.1); }
.draw-canvas.blue { border: 3px solid rgba(30,144,255,0.4); box-shadow: 0 0 15px rgba(30,144,255,0.1); }
.draw-canvas.submitted { opacity: 0.6; cursor: default; }

.draw-controls {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-shrink: 0;
  padding: 2px 0;
}
.draw-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 2px solid;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(11px, 1.4vw, 13px);
  cursor: pointer;
  transition: all 0.18s;
  background: transparent;
  min-height: 28px;
}
.draw-btn.clear  { border-color: rgba(255,255,255,0.2); color: white; }
.draw-btn.undo   { border-color: rgba(255,255,255,0.2); color: white; }
.draw-btn.submit { border-color: var(--green); color: var(--green); }
.draw-btn.clear:hover  { background: rgba(255,255,255,0.1); }
.draw-btn.undo:hover   { background: rgba(255,255,255,0.1); }
.draw-btn.submit:hover { background: var(--green); color: white; }
.draw-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.draw-panel-score {
  text-align: center;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(12px, 1.8vw, 16px);
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
  display: none;
}
.draw-panel-score.visible { display: block; }
.draw-panel-score.red  { background: rgba(255,71,87,0.15); color: var(--red-light); }
.draw-panel-score.blue { background: rgba(30,144,255,0.15); color: var(--blue-light); }

.draw-feedback {
  text-align: center;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(14px, 2.2vw, 20px);
  padding: 8px 16px;
  border-radius: 10px;
  flex-shrink: 0;
}
.draw-feedback.red  { background: rgba(255,71,87,0.15);  color: var(--red-light);  border: 1px solid rgba(255,71,87,0.3); }
.draw-feedback.blue { background: rgba(30,144,255,0.15); color: var(--blue-light); border: 1px solid rgba(30,144,255,0.3); }
.draw-feedback.tie  { background: rgba(255,215,0,0.15);  color: var(--gold);       border: 1px solid rgba(255,215,0,0.3); }


/* ============================================================
   END SCREEN
   ============================================================ */
.end-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  min-height: calc(100dvh - var(--nav-h));
  gap: 16px;
}
.end-trophy    { font-size: 70px; animation: trophyBounce 0.9s ease infinite; }
@keyframes trophyBounce { 0%,100%{transform:translateY(0) rotate(-5deg)} 50%{transform:translateY(-14px) rotate(5deg)} }
.end-winner    { font-family: 'Fredoka One', cursive; font-size: clamp(24px,5vw,46px); }
.end-winner.red  { color: var(--red-light); }
.end-winner.blue { color: var(--blue-light); }
.end-winner.tie  { color: var(--gold); }

.end-scores       { display: flex; gap: 28px; justify-content: center; align-items: center; flex-wrap: wrap; }
.end-score-card   { text-align: center; padding: 16px 26px; border-radius: var(--radius); }
.end-score-card.red  { background: rgba(255,71,87,0.14);  border: 2px solid rgba(255,71,87,0.3); }
.end-score-card.blue { background: rgba(30,144,255,0.14); border: 2px solid rgba(30,144,255,0.3); }
.end-score-num   { font-family: 'Fredoka One', cursive; font-size: clamp(40px,8vw,56px); }
.end-score-card.red  .end-score-num { color: var(--red-light); }
.end-score-card.blue .end-score-num { color: var(--blue-light); }
.end-score-label { font-size: 14px; font-weight: 700; color: var(--text-muted); }

.end-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.end-btn {
  padding: 12px 24px;
  border-radius: 11px;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 46px;
}
.end-btn.play-again { background: linear-gradient(135deg,var(--purple),#7c3aed); color: white; box-shadow: 0 4px 14px rgba(168,85,247,0.4); }
.end-btn.play-again:hover { transform: scale(1.05); }
.end-btn.secondary { background: rgba(255,255,255,0.07); color: white; border: 2px solid rgba(255,255,255,0.15); }
.end-btn.secondary:hover { background: rgba(255,255,255,0.12); }


/* ============================================================
   CONFETTI
   ============================================================ */
.confetti-piece {
  position: fixed;
  top: -20px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  z-index: 1000;
  pointer-events: none;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}


/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card2);
  border: 2px solid rgba(255,255,255,0.15);
  color: white;
  padding: 10px 20px;
  border-radius: 11px;
  font-weight: 700;
  font-size: 14px;
  z-index: 999;
  white-space: nowrap;
  animation: toastIn 0.25s ease, toastOut 0.25s ease 1.75s forwards;
  pointer-events: none;
}
@keyframes toastIn  { from{opacity:0;transform:translateX(-50%) translateY(8px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }
@keyframes toastOut { from{opacity:1} to{opacity:0} }


/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { grid-column: 1/-1; text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state span { font-size: 54px; display: block; margin-bottom: 14px; }


/* ============================================================
   MODE SELECTION MODAL
   ============================================================ */
.mode-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.mode-modal {
  background: var(--card-bg, #1a1a2e);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 30px 24px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.mode-modal-title {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(18px, 3vw, 22px);
  color: #fff;
  margin-bottom: 20px;
}

.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  margin-bottom: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.mode-btn.solo {
  border-color: rgba(168, 85, 247, 0.5);
  background: rgba(168, 85, 247, 0.15);
}

.mode-btn.solo:hover {
  background: rgba(168, 85, 247, 0.3);
}

.mode-btn.teams {
  border-color: rgba(30, 144, 255, 0.5);
  background: rgba(30, 144, 255, 0.15);
}

.mode-btn.teams:hover {
  background: rgba(30, 144, 255, 0.3);
}

.mode-icon {
  font-size: 28px;
}

.mode-label {
  font-size: 18px;
}

/* ============================================================
   SINGLE-PLAYER MODE — hide blue panel, expand red
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   SINGLE PLAYER MODE — cohesive solo layout (not "2-player with
   one side hidden"). Blue panels removed completely; red panel
   re-themed as a neutral player panel; score card relabeled.
───────────────────────────────────────────────────────────── */

/* Hide all blue elements completely */
.single-player .team-panel.blue,
.single-player .draw-panel.blue,
.single-player .score-card.blue {
  display: none !important;
}

/* Score bar — flex-center so score & progress sit close together,
   no big empty gap between them */
.single-player .score-bar {
  display: flex !important;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.single-player .progress-center { min-width: 160px; }
.single-player .progress-track  { width: 160px !important; }

/* Re-theme red score card as a neutral player score (gold accent).
   NOTE: do NOT use `margin: 0 auto` here — on a flex child, auto
   margins consume all free space and push siblings to the edges.
   The parent flex `justify-content: center` handles centering. */
.single-player .score-card.red {
  background: linear-gradient(135deg, rgba(255,215,0,0.18), rgba(168,85,247,0.12));
  border: 2px solid rgba(255,215,0,0.45);
  flex: 0 0 auto;
  width: clamp(220px, 35vw, 320px);
  margin: 0;
}
.single-player .score-card.red .score-num { color: var(--gold); }
/* Replace "🔴 RED" label with "⭐ YOUR SCORE" */
.single-player .score-card.red .score-team { font-size: 0; line-height: 0; }
.single-player .score-card.red .score-team::before {
  content: '⭐ YOUR SCORE';
  font-family: 'Fredoka One', cursive;
  font-size: clamp(11px, 1.6vw, 15px);
  color: var(--gold);
  letter-spacing: 0.5px;
}
.single-player .score-card.red .score-turn-badge { display: none; }

/* MCQ answer area: single centered column */
.single-player .answer-area { grid-template-columns: 1fr; max-width: 600px; margin: 0 auto; width: 100%; }
.single-player .team-panel.red {
  background: linear-gradient(135deg, rgba(168,85,247,0.10), rgba(124,58,237,0.05));
  border: 2px solid rgba(168,85,247,0.30);
}
.single-player .team-panel-header { display: none; }
.single-player .options-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 500px) {
  .single-player .options-grid { grid-template-columns: 1fr; }
}

/* Drawing / Maze games: single canvas centered */
.single-player .draw-area { grid-template-columns: 1fr; max-width: 540px; margin: 0 auto; width: 100%; }
.single-player .draw-panel.red {
  background: linear-gradient(135deg, rgba(168,85,247,0.10), rgba(124,58,237,0.05));
  border: 2px solid rgba(168,85,247,0.30);
}
.single-player .draw-panel-header { display: none; }

/* Hide turn indicator (it's about racing teams) */
.single-player .turn-indicator { display: none; }


/* ============================================================
   MOBILE OVERRIDE — bottom nav must display on small screens
   (must be at the end to override the base display:none above)
   ============================================================ */
@media (max-width: 600px) {
  .bottom-nav { display: flex; }
}


/* ============================================================
   PUZZLE / TEAM GAME GRID — responsive overflow fix
   ============================================================ */

/* Wrap the puzzle-grid table in a scrollable container
   so wide grids (6-7 col word search) don't overflow on small phones */
#puzzleGrid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Very small phones — shrink cells so the grid doesn't force overflow */
@media (max-width: 374px) {
  .puzzle-grid td {
    width:  clamp(20px, 8vw, 30px);
    height: clamp(20px, 8vw, 30px);
    font-size: clamp(10px, 3vw, 16px);
    padding: 1px;
  }
}

/* iPad landscape — more breathing room */
@media (min-width: 768px) and (max-width: 1024px) {
  .puzzle-grid td {
    width:  clamp(36px, 5vw, 52px);
    height: clamp(36px, 5vw, 52px);
    font-size: clamp(20px, 2.8vw, 32px);
  }
  .question-card  { padding: 14px 20px; }
  .options-grid   { gap: 10px; }
}

/* Large desktop — bigger puzzle cells */
@media (min-width: 1600px) {
  .puzzle-grid td {
    width:  clamp(48px, 4vw, 64px);
    height: clamp(48px, 4vw, 64px);
    font-size: clamp(24px, 2.2vw, 36px);
  }
  .question-card  { padding: 20px 28px; }
  .opt-btn        { min-height: 60px; font-size: clamp(18px, 1.6vw, 26px); }
}

/* 4K / Smart TV */
@media (min-width: 2400px) {
  .puzzle-grid td {
    width: 80px; height: 80px; font-size: 32px;
  }
  .opt-btn   { min-height: 80px; font-size: 28px; }
  .game-card { border-radius: 20px; }
  .play-btn  { font-size: 16px; padding: 10px 16px; }
}

/* ── Touch maze canvas — fail flash + nice background ── */
.draw-canvas {
  background: #0f0c29;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
@keyframes maze-fail-flash {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.draw-canvas.failed {
  animation: maze-fail-flash 0.5s ease-out;
}

/* ── Activity filter tab scrollable on small screens ── */
#activityTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 500px) {
  #activityTabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  #activityTabs .grade-tab {
    flex-shrink: 0;
    font-size: 11px;
    padding: 5px 9px;
  }
}


/* ============================================================
   AUTH SCREENS — login + expired
   ============================================================
   The .auth-screen elements are hidden by default. body classes
   `show-login` / `show-expired` / `show-app` toggle visibility
   so we can swap between them without flicker.
   ============================================================ */

/* Default state: app + auth all hidden (waiting for auth check) */
body .app,
body .auth-screen { display: none; }

/* App visible after successful auth.
   MUST be `flex` (not `block`) so .content's flex:1 + overflow-y:auto
   actually constrains height and triggers scroll. Using `block` here
   was the root cause of scroll failing on iPad/phone. */
body.show-app .app { display: flex; }

/* Login screen visible */
body.show-login .auth-screen#authLogin {
  display: flex;
}

/* Expired screen visible */
body.show-expired .auth-screen#authExpired {
  display: flex;
}

/* Hide logout button if not logged in (no .show-app class) */
body:not(.show-app) #logoutBtn { display: none; }

/* Auth screen layout — must scroll properly when content > viewport */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1a3e 50%, #0f0c29 100%);
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* smooth momentum scroll on iOS */
  overscroll-behavior: contain;
  touch-action: pan-y;                 /* explicitly allow vertical touch scroll */
}

/* The card is centered when there's room, scrollable when not.
   `margin: auto` on a flex item does both — the classic fix for the
   "flex + align-items: center + overflow-y: auto" clipping bug. */
.auth-card {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(168, 85, 247, 0.3);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  margin: auto;
}

.auth-logo {
  font-family: 'Fredoka One', cursive;
  font-size: 36px;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.auth-title {
  font-family: 'Fredoka One', cursive;
  font-size: 24px;
  color: white;
  margin: 8px 0 4px;
}

.auth-subtitle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  margin: 0 0 24px;
}

.auth-icon {
  font-size: 56px;
  margin-bottom: 12px;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-form input {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
  box-sizing: border-box;
}
.auth-form input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}
.auth-form input:focus {
  outline: none;
  border-color: rgba(168, 85, 247, 0.7);
  background: rgba(255, 255, 255, 0.10);
}

.auth-error {
  background: rgba(255, 71, 87, 0.15);
  border: 1px solid rgba(255, 71, 87, 0.4);
  color: #FFB3B3;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
}

.auth-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  padding: 14px 20px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #A855F7, #7C3AED);
  color: white;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.auth-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(168, 85, 247, 0.4);
}
.auth-btn:active:not(:disabled) {
  transform: translateY(0);
}
.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 16px;
}
.auth-btn.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.auth-links {
  margin: 8px 0 16px;
  font-size: 13px;
}
.auth-links a {
  color: rgba(168, 85, 247, 0.9);
  text-decoration: none;
  transition: color 0.2s;
}
.auth-links a:hover {
  color: #C4B5FD;
  text-decoration: underline;
}

.auth-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.6;
}
.auth-footer a {
  color: rgba(168, 85, 247, 0.85);
  text-decoration: none;
}
.auth-footer a:hover { text-decoration: underline; }

.auth-message {
  color: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  line-height: 1.6;
  margin: 12px 0;
}

.auth-school {
  color: rgba(168, 85, 247, 0.9);
  font-weight: 700;
  margin: 8px 0 16px;
  font-size: 14px;
}
.auth-school:empty { display: none; }

.auth-contact {
  background: rgba(168, 85, 247, 0.10);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}
.auth-contact a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
}
.auth-contact a:hover { text-decoration: underline; }


/* ── Logout button in top nav ────────────────────────────── */
.nav-logout {
  background: rgba(255, 71, 87, 0.12) !important;
  border-color: rgba(255, 71, 87, 0.35) !important;
  color: rgba(255, 200, 200, 0.95) !important;
}
.nav-logout:hover {
  background: rgba(255, 71, 87, 0.22) !important;
  border-color: rgba(255, 71, 87, 0.6) !important;
}

/* ── Help button in top nav (WhatsApp green) ─────────────── */
.nav-help {
  background: linear-gradient(135deg, #25D366, #128C7E) !important;
  border-color: rgba(37, 211, 102, 0.7) !important;
  color: white !important;
}
.nav-help:hover {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
  border-color: #128C7E !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4) !important;
}
/* Kid theme adjustment: white pill with green accent (fits the light nav) */
body.show-app .nav-help {
  background: linear-gradient(135deg, #25D366, #128C7E) !important;
  border-color: transparent !important;
  color: white !important;
  box-shadow: 0 3px 8px rgba(37, 211, 102, 0.35) !important;
}
body.show-app .nav-help:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(37, 211, 102, 0.5) !important;
}


/* ── App footer (home screen contact info) ───────────────── */
.app-footer {
  text-align: center;
  padding: 18px 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.app-footer a {
  color: rgba(168, 85, 247, 0.85);
  text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }
.app-footer .dot { color: rgba(255, 255, 255, 0.25); }


/* ── Responsive: smaller auth card on tiny phones ────────── */
@media (max-width: 380px) {
  .auth-card { padding: 24px 18px; }
  .auth-logo { font-size: 30px; }
  .auth-title { font-size: 20px; }
}


/* ============================================================
   ADMIN DASHBOARD
   ============================================================ */
.admin-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #0f0c29;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0;
}
body.show-admin .admin-screen { display: flex; }
body.show-admin .app          { display: none; }
body.show-admin .auth-screen  { display: none; }
body.show-admin #logoutBtn    { display: none; }

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 2px solid rgba(168,85,247,0.25);
  background: linear-gradient(135deg, rgba(168,85,247,0.12), rgba(124,58,237,0.06));
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.admin-logo {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--gold);
}
.admin-subtitle {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: white;
}
.admin-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-info {
  margin: 16px 24px;
  padding: 12px 16px;
  background: rgba(255, 215, 0, 0.10);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  line-height: 1.5;
}

.admin-table-wrap {
  margin: 0 24px 24px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  background: rgba(168, 85, 247, 0.15);
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.admin-table td {
  padding: 14px;
  color: white;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.admin-table tr:hover td {
  background: rgba(168, 85, 247, 0.05);
}
.admin-school-name {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
}
.admin-email {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}
.admin-date {
  font-family: monospace;
  color: rgba(255, 255, 255, 0.85);
}
.admin-lastlogin {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}
.admin-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.admin-loading,
.admin-empty,
.admin-error {
  text-align: center;
  padding: 32px !important;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}
.admin-error { color: #FF6B6B; }

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.status-badge.active   { background: rgba(46, 204, 113, 0.18); color: #6FE5A1; }
.status-badge.expired  { background: rgba(255, 165, 0, 0.18);  color: #FFD180; }
.status-badge.banned   { background: rgba(255, 71, 87, 0.18);  color: #FFB3B3; }
.status-badge.none     { background: rgba(160, 160, 160, 0.18);color: #ccc; }

/* Admin buttons */
.admin-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #A855F7, #7C3AED);
  color: white;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
}
.admin-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
}
.admin-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-btn.small    { padding: 6px 10px; font-size: 12px; }
.admin-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.admin-btn.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}
.admin-btn.success {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}
.admin-btn.warn {
  background: linear-gradient(135deg, #f39c12, #e67e22);
}
.admin-btn.danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

/* Admin nav button (in main app top nav) — only shown to admins */
.nav-admin {
  background: linear-gradient(135deg, #A855F7, #7C3AED) !important;
  border-color: rgba(168, 85, 247, 0.7) !important;
  color: white !important;
}
.nav-admin:hover {
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.5) !important;
}

/* Stats panel */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin: 18px 24px 0;
}
.admin-stat {
  background: white;
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
  border-top: 4px solid #6b7280;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.admin-stat.success { border-top-color: #10b981; }
.admin-stat.warn    { border-top-color: #f59e0b; }
.admin-stat.danger  { border-top-color: #ef4444; }
.admin-stat.muted   { border-top-color: #9ca3af; }
.admin-stat-num {
  font-size: 32px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1;
}
.admin-stat-label {
  margin-top: 8px;
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}
@media (max-width: 900px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .admin-stats { grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 16px 0; }
  .admin-stat { padding: 12px 10px; }
  .admin-stat-num { font-size: 24px; }
  .admin-stat-label { font-size: 12px; }
}

/* Edit modal */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.admin-modal {
  background: #1a1a3e;
  border: 2px solid rgba(168, 85, 247, 0.4);
  border-radius: 14px;
  padding: 24px 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.admin-modal h2 {
  font-family: 'Fredoka One', cursive;
  color: white;
  margin: 0 0 16px;
  font-size: 22px;
}
.admin-modal label {
  display: block;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
.admin-modal label .muted {
  color: rgba(255, 255, 255, 0.45);
  font-weight: 400;
  font-size: 12px;
}
.admin-modal input,
.admin-modal textarea {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  width: 100%;
  margin-top: 6px;
  box-sizing: border-box;
}
.admin-modal input:focus,
.admin-modal textarea:focus {
  outline: none;
  border-color: rgba(168, 85, 247, 0.7);
  background: rgba(255, 255, 255, 0.10);
}
.admin-modal input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}
.admin-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.admin-modal-hint {
  margin: -6px 0 14px;
  padding: 8px 12px;
  background: #fff8e1;
  border-left: 3px solid #ffb300;
  border-radius: 4px;
  color: #5d4037;
  font-size: 13px;
}
.admin-modal-hint code {
  background: rgba(0,0,0,0.07);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}
.admin-modal-error {
  margin-top: 10px;
  padding: 10px 12px;
  background: #ffebee;
  border-left: 3px solid #d32f2f;
  border-radius: 4px;
  color: #b71c1c;
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 600px) {
  .admin-header  { padding: 12px 16px; }
  .admin-info, .admin-table-wrap { margin: 12px 16px; }
  .admin-subtitle { font-size: 14px; }
  .admin-table th, .admin-table td { padding: 10px 8px; font-size: 13px; }
  .admin-actions { flex-direction: column; }
}


/* ============================================================
   SUPPORT BUTTON + POPUP
   Floating bottom-right pill that opens a contact popup.
   Hidden on the admin screen (admin is support).
============================================================ */

.support-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  display: none;                       /* gated by body class below */
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #25D366, #128C7E);   /* WhatsApp greens */
  color: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(18, 140, 126, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.support-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(18, 140, 126, 0.55);
}
.support-fab:active { transform: translateY(0); }
.support-fab-icon { font-size: 20px; line-height: 1; }
.support-fab-text { letter-spacing: 0.3px; }

/* Floating FAB is retired — Help lives in the top nav now.
   Keeping the popup itself; just never showing the FAB. */
.support-fab { display: none !important; }

/* Popup overlay (click outside to close) */
.support-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9100;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  animation: supportFade 0.18s ease;
}
@keyframes supportFade {
  from { background: rgba(0,0,0,0); }
  to   { background: rgba(0,0,0,0.55); }
}

.support-popup-card {
  background: white;
  border-radius: 18px;
  width: 100%;
  max-width: 360px;
  padding: 22px;
  margin-bottom: 70px;                 /* clears the FAB */
  margin-right: 4px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: supportSlide 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
@keyframes supportSlide {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.support-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s ease, color 0.15s ease;
}
.support-close:hover { background: #f1f5f9; color: #475569; }

.support-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  color: #1f2937;
}
.support-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: #6b7280;
}

.support-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #1f2937;
  background: #f8fafc;
  border: 1.5px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  margin-bottom: 10px;
}
.support-option:last-child { margin-bottom: 0; }
.support-option:hover {
  background: white;
  transform: translateX(2px);
}
.support-option.whatsapp:hover { border-color: #25D366; }
.support-option.email:hover    { border-color: #6366F1; }

.support-option-icon {
  font-size: 26px;
  line-height: 1;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}
.support-option.whatsapp .support-option-icon { background: #DCFCE7; }
.support-option.email    .support-option-icon { background: #E0E7FF; }

.support-option-text { flex: 1; }
.support-option-title {
  font-weight: 700;
  font-size: 15px;
  color: #1f2937;
  margin-bottom: 2px;
}
.support-option-sub {
  font-size: 13px;
  color: #6b7280;
}
.support-option-arrow {
  font-size: 24px;
  color: #cbd5e1;
  font-weight: 300;
}

@media (max-width: 480px) {
  .support-fab {
    right: 14px;
    bottom: 14px;
    padding: 11px 16px;
    font-size: 14px;
  }
  .support-fab-text { display: none; }   /* icon-only on tiny screens to save space */
  .support-fab { padding: 12px; width: 48px; height: 48px; justify-content: center; }
  .support-popup { padding: 16px; align-items: flex-end; }
  .support-popup-card { margin-bottom: 64px; }
}
