:root {
  --xmas-red: #dc2626;
  --xmas-red-dark: #991b1b;
  --xmas-green: #15803d;
  --xmas-green-light: #22c55e;
  --snow-white: #ffffff;
  --gold: #fbbf24;
  --gold-dark: #b45309;
  --sky: #38bdf8;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Fredoka', 'Quicksand', 'Nunito', 'Segoe UI', cursive, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
body {
  background: radial-gradient(circle at 50% 20%, #1e3a8a 0%, #0f172a 85%);
  color: #1e293b;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.85rem 0.75rem 2.5rem;
  overflow-x: hidden;
  position: relative;
}
.snow-layer {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.snowflake {
  position: absolute;
  top: -20px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.1rem;
  animation: fall linear infinite;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.9; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: 0.2; }
}

header {
  text-align: center;
  margin-bottom: 0.65rem;
  width: 100%;
  max-width: 500px;
  position: relative;
  z-index: 2;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 0.45rem;
}
.roblox-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  color: var(--xmas-red);
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 900;
  border-radius: 9999px;
  box-shadow: 0 4px 0px rgba(0,0,0,0.2);
  border: 2.5px solid #fecaca;
}
.wallet-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fef08a;
  color: #854d0e;
  padding: 0.35rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 900;
  border-radius: 9999px;
  border: 2.5px solid #ca8a04;
  box-shadow: 0 4px 0px #a16207;
}

/* Times Table Selector Carousel */
.table-picker-wrap {
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #ffffff;
  border-radius: 18px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.picker-label {
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--xmas-red-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.table-pills-row {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0 4px;
}
.table-pills-row::-webkit-scrollbar { display: none; }
.table-select-btn {
  flex-shrink: 0;
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 0.35rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 900;
  color: #475569;
  cursor: pointer;
  transition: all 0.12s;
}
.table-select-btn.active {
  background: var(--xmas-red);
  color: #ffffff;
  border-color: #fca5a5;
  box-shadow: 0 3px 0px var(--xmas-red-dark);
  transform: translateY(-2px);
}

/* Voice Chooser Bar */
.voice-picker-wrap {
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #ffffff;
  border-radius: 18px;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.voice-pills-row {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0 4px;
}
.voice-pills-row::-webkit-scrollbar { display: none; }
.voice-select-btn {
  flex-shrink: 0;
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 900;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.12s;
}
.voice-select-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #7dd3fc;
  box-shadow: 0 3px 0px #0369a1;
  transform: translateY(-2px);
}

/* Avatar Showcase Card */
.avatar-showcase {
  background: rgba(255, 255, 255, 0.95);
  border: 3.5px solid #ffffff;
  border-radius: 20px;
  padding: 0.55rem 0.85rem;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}
.avatar-preview-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.avatar-figure {
  position: relative;
  width: 56px;
  height: 56px;
  background: #fdf2f8;
  border: 3px solid #f472b6;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 4px 0px #cbd5e1;
}
.makeup-layer {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 1.05rem;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
}
.avatar-info { text-align: left; }
.avatar-tag { font-size: 0.7rem; font-weight: 900; color: #64748b; letter-spacing: 0.5px; text-transform: uppercase; }
.avatar-name { font-size: 1rem; font-weight: 900; color: #0f172a; }
.avatar-makeup-title { font-size: 0.78rem; font-weight: 800; color: var(--xmas-red); }

h1 {
  font-size: 1.85rem;
  color: #ffffff;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  text-shadow: 0 4px 0px var(--xmas-red-dark), 0 6px 15px rgba(220, 38, 38, 0.5);
  margin-bottom: 0.15rem;
}
p.sub {
  color: #fecaca;
  font-size: 0.88rem;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.nav-tabs {
  display: flex;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  padding: 0.35rem;
  border-radius: 20px;
  margin-bottom: 0.85rem;
  border: 3px solid #ffffff;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 500px;
  position: relative;
  z-index: 2;
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: #64748b;
  padding: 0.6rem 0.25rem;
  border-radius: 14px;
  font-weight: 900;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.12s;
}
.tab-btn.active {
  background: var(--xmas-red);
  color: #ffffff;
  box-shadow: 0 4px 0px var(--xmas-red-dark);
  transform: translateY(-2px);
}

.container { width: 100%; max-width: 500px; position: relative; z-index: 2; }
.view { display: none; }
.view.active { display: block; }

/* Skip strip */
.skip-strip {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.85rem;
  scrollbar-width: none;
}
.skip-strip::-webkit-scrollbar { display: none; }
.skip-pill {
  background: #ffffff;
  border: 3px solid #fde047;
  border-radius: 16px;
  padding: 0.45rem 0.85rem;
  font-weight: 900;
  color: #d97706;
  font-size: 1.05rem;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 4px 0px #f59e0b;
  transition: transform 0.1s;
}
.skip-pill:active { transform: translateY(2px); box-shadow: 0 2px 0px #f59e0b; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 0.65rem; }
.fact-card {
  background: #ffffff;
  border: 3.5px solid #e0f2fe;
  border-radius: 20px;
  padding: 0.75rem 0.4rem;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 0px #bae6fd;
  transition: all 0.12s;
}
.fact-card:hover { transform: translateY(-3px); border-color: #38bdf8; }
.fact-card:active { transform: translateY(3px); box-shadow: 0 2px 0px #bae6fd; }
.fact-card .eq { font-size: 0.92rem; color: #64748b; font-weight: 900; margin-bottom: 0.15rem; }
.fact-card .ans { font-size: 1.65rem; font-weight: 900; color: var(--xmas-red); }
.fact-card .voice-icon { font-size: 0.8rem; margin-top: 3px; }

/* Flashcard */
.flashcard-wrap {
  perspective: 1000px;
  height: 275px;
  margin-bottom: 1.1rem;
  cursor: pointer;
}
.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 26px;
}
.flashcard.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 5px solid var(--xmas-red);
  border-radius: 26px;
  padding: 1.25rem;
  box-shadow: 0 10px 0px var(--xmas-red-dark);
}
.card-back { transform: rotateY(180deg); border-color: var(--xmas-green); box-shadow: 0 10px 0px #14532d; background: #f0fdf4; }
.card-badge {
  background: #fee2e2;
  color: var(--xmas-red-dark);
  padding: 0.35rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
}
.card-main { font-size: 3.2rem; font-weight: 900; color: #0f172a; }
.card-back .card-main { color: var(--xmas-green); }
.card-hint {
  font-size: 0.95rem;
  font-weight: 800;
  color: #64748b;
  margin-top: 0.4rem;
}
.card-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  max-width: 290px;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.rp-badge {
  background: #fef08a;
  border: 2px solid #eab308;
  color: #854d0e;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: 0 2px 0px #ca8a04;
}

.controls { display: flex; gap: 0.65rem; justify-content: center; }
.btn {
  background: #ffffff;
  color: #0f172a;
  border: 3px solid #cbd5e1;
  padding: 0.75rem 1.35rem;
  border-radius: 18px;
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 5px 0px #94a3b8;
  transition: all 0.1s;
}
.btn:hover { border-color: #38bdf8; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0px #94a3b8; }
.btn.primary {
  background: var(--xmas-red);
  color: #ffffff;
  border-color: #fca5a5;
  box-shadow: 0 5px 0px var(--xmas-red-dark);
}

/* Quiz Card */
.quiz-card {
  background: #ffffff;
  border: 5px solid #ffffff;
  border-radius: 26px;
  padding: 1.35rem;
  text-align: center;
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.25);
  position: relative;
}
.score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}
.stat-pill {
  background: #f1f5f9;
  padding: 0.4rem 0.85rem;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  color: #0f172a;
  font-size: 0.92rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.try-badge {
  display: none;
  background: #fef08a;
  color: #854d0e;
  padding: 0.35rem 0.9rem;
  border-radius: 12px;
  border: 2px solid #eab308;
  font-size: 0.88rem;
  font-weight: 900;
  margin-bottom: 0.6rem;
  box-shadow: 0 3px 0px #ca8a04;
}
.try-badge.active { display: inline-block; animation: popBounce 0.3s ease; }
@keyframes popBounce { 0% { transform: scale(0.9); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.timer-bar {
  height: 12px;
  width: 100%;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 1rem;
  border: 2px solid #cbd5e1;
}
.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--xmas-green-light), var(--xmas-red));
  width: 100%;
  transition: width 0.1s linear;
}
.question-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.2rem 0 1rem;
}
.question {
  font-size: 3.1rem;
  font-weight: 900;
  color: #0f172a;
}
.btn-speaker {
  background: #fee2e2;
  border: 2px solid var(--xmas-red);
  font-size: 1.4rem;
  padding: 0.4rem 0.6rem;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0px var(--xmas-red-dark);
}
.btn-speaker:active { transform: translateY(2px); box-shadow: 0 1px 0px var(--xmas-red-dark); }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.option-btn {
  background: #f8fafc;
  border: 3.5px solid #e2e8f0;
  color: #0f172a;
  padding: 1rem;
  font-size: 1.85rem;
  font-weight: 900;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 6px 0px #cbd5e1;
  transition: all 0.1s;
}
.option-btn:active { transform: translateY(3px); box-shadow: 0 2px 0px #cbd5e1; }
.option-btn.correct { background: var(--xmas-green); border-color: #86efac; color: #ffffff; box-shadow: 0 6px 0px #14532d; }
.option-btn.wrong { background: var(--xmas-red); border-color: #fca5a5; color: #ffffff; box-shadow: 0 6px 0px var(--xmas-red-dark); }

/* Learning Overlay */
.learning-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  padding: 1.25rem 1rem;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  animation: popModal 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.learning-overlay.active { display: flex; }
@keyframes popModal { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.help-badge {
  background: #fee2e2;
  border: 2px solid var(--xmas-red);
  color: var(--xmas-red-dark);
  padding: 0.35rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: 0 3px 0px var(--xmas-red-dark);
}
.learn-equation {
  font-size: 2.9rem;
  font-weight: 900;
  color: var(--xmas-red);
  margin: 0.2rem 0;
}
.learn-visual-box {
  background: #f0fdf4;
  border: 3px dashed #86efac;
  border-radius: 16px;
  padding: 0.75rem 0.5rem;
  width: 100%;
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: center;
}
.learn-group-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 900;
  color: #1e293b;
}
.learn-group-row .bucks {
  display: flex;
  gap: 4px;
}
.learn-group-row .bucks span {
  background: #fef08a;
  border: 1.5px solid #ca8a04;
  color: #854d0e;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.82rem;
}
.learn-note {
  font-size: 0.92rem;
  font-weight: 800;
  color: #475569;
  line-height: 1.35;
}
.btn-got-it {
  background: var(--xmas-green);
  color: #ffffff;
  border: 3px solid #86efac;
  padding: 0.9rem 1.8rem;
  border-radius: 18px;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0px #14532d;
  margin-top: 0.5rem;
  width: 90%;
  letter-spacing: 0.5px;
}
.btn-got-it:active { transform: translateY(3px); box-shadow: 0 2px 0px #14532d; }

/* Christmas RP Mall */
.shop-header {
  background: #ffffff;
  border: 3.5px solid #fecaca;
  border-radius: 20px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 6px 0px #f87171;
  text-align: center;
}
.sub-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.sub-tab-btn {
  flex: 1;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  padding: 0.5rem;
  border-radius: 14px;
  font-weight: 900;
  font-size: 0.82rem;
  cursor: pointer;
  color: #64748b;
  box-shadow: 0 3px 0px #94a3b8;
}
.sub-tab-btn.active {
  background: var(--xmas-red);
  color: #ffffff;
  border-color: #f87171;
  box-shadow: 0 3px 0px var(--xmas-red-dark);
}

.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.shop-card {
  background: #ffffff;
  border: 3.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 0.85rem 0.5rem;
  text-align: center;
  box-shadow: 0 6px 0px #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.shop-icon { font-size: 2.2rem; margin-bottom: 0.25rem; }
.shop-title { font-size: 0.92rem; font-weight: 900; color: #0f172a; margin-bottom: 0.15rem; }
.shop-desc { font-size: 0.72rem; color: #64748b; font-weight: 800; margin-bottom: 0.35rem; }
.shop-price { font-size: 0.88rem; font-weight: 900; color: #d97706; margin-bottom: 0.5rem; }

.shop-btn {
  width: 100%;
  background: var(--xmas-red);
  color: #ffffff;
  border: 2px solid #fca5a5;
  border-radius: 12px;
  padding: 0.5rem;
  font-weight: 900;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 3px 0px var(--xmas-red-dark);
}
.shop-btn:active { transform: translateY(2px); box-shadow: 0 1px 0px var(--xmas-red-dark); }
.shop-btn.equipped {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
  box-shadow: none;
  cursor: default;
}
.shop-btn.owned-equip {
  background: #38bdf8;
  border-color: #bae6fd;
  box-shadow: 0 3px 0px #0284c7;
}

.roblox-tip {
  margin-top: 1rem;
  background: #ffffff;
  border: 3px solid #fecaca;
  border-radius: 18px;
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #475569;
  box-shadow: 0 6px 0px #fca5a5;
}

[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 3px; }
.nav-tabs :focus-visible, .controls :focus-visible { outline-color: #1e3a8a; }
.flashcard-wrap:focus-visible { outline-color: #fef08a; }
.game-settings { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.9rem; }
.game-settings label { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2rem; }
.game-notice { background: #fef3c7; color: #78350f; border-radius: 0.5rem; padding: 0.5rem; margin-bottom: 0.5rem; }
.shop-status:not(:empty) { background: white; padding: 0.65rem; border-radius: 0.5rem; margin-bottom: 0.65rem; }
.avatar-figure { flex-shrink: 0; font-weight: 800; color: #9d174d; }
.flashcard-wrap { display: block; width: 100%; padding: 0; border: 0; border-radius: 26px; background: transparent; }
.flashcard { display: block; }
.card-face { inset: 0; }
.fact-card { color: inherit; }
.skip-pill { color: #92400e; }
.score-bar, .controls { flex-wrap: wrap; gap: 0.45rem; }
.question-row { flex-wrap: wrap; }
.question { font-size: clamp(1.65rem, 8vw, 3.1rem); }
.btn-speaker { font-size: 0.9rem; }
.learning-overlay { position: static; gap: 0.85rem; padding: 0; }
.learn-equation { font-size: clamp(1.6rem, 8vw, 2.9rem); }
.learn-visual-box { align-items: stretch; }
.learn-group-row { flex-wrap: wrap; justify-content: center; }
@media (max-width: 360px) {
  .quiz-card { padding: 0.75rem; }
  .option-btn { padding: 0.65rem; }
  .btn { padding-inline: 0.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .snow-layer { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.fact-card span { display: block; }
.quiz-result { grid-column: 1 / -1; }
.shop-actions { width: 100%; }
#dress-up-btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; border-radius: 12px; }
#active-table-badge { color: var(--xmas-green); font-size: 0.82rem; }
#active-voice-badge { color: #075985; font-size: 0.82rem; }
.shop-header h2 { font-size: 1.3rem; color: var(--xmas-red); margin-bottom: 0.2rem; }
.shop-header p { font-size: 0.85rem; color: #475569; font-weight: 800; }
