/* MathQuest - Kid Friendly & Mobile Responsive Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Outfit:wght@400;600;800&display=swap');

:root {
  --primary-color: #6C5CE7;
  --primary-light: #A29BFE;
  --secondary-color: #FF7675;
  --accent-yellow: #FDCB6E;
  --accent-green: #55E6C1;
  --accent-blue: #74B9FF;
  --bg-gradient: linear-gradient(135deg, #a8c0ff 0%, #3f2b96 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
  --text-color: #2D3436;
  --text-muted: #636E72;
  --font-fun: 'Fredoka', cursive, sans-serif;
  --font-body: 'Outfit', sans-serif;
  --border-radius: 24px;
  --transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --card-bg: rgba(30, 41, 59, 0.92);
  --card-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  --text-color: #F8FAFC;
  --text-muted: #94A3B8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Background floating particles */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-shape {
  position: absolute;
  font-size: 2.5rem;
  opacity: 0.15;
  animation: floatAround 18s infinite ease-in-out alternate;
}

@keyframes floatAround {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-50px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

/* Navigation Bar */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 3px solid rgba(255, 255, 255, 0.3);
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] header.app-header {
  background: rgba(15, 23, 42, 0.85);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.logo-icon {
  font-size: 2.2rem;
  animation: bounce 2s infinite ease-in-out;
}

.logo-text h1 {
  font-family: var(--font-fun);
  font-size: 1.6rem;
  background: linear-gradient(45deg, #FF7675, #6C5CE7, #00CEC9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

.logo-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-badge {
  background: linear-gradient(135deg, #FDCB6E, #E17055);
  color: white;
  padding: 6px 14px;
  border-radius: 30px;
  font-family: var(--font-fun);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(225, 112, 85, 0.3);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(0, 0, 0, 0.1);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover, .icon-btn:active {
  transform: scale(1.1) rotate(5deg);
  background: white;
}

/* Main Container */
main.app-main {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 1000px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem 4rem 1rem;
}

/* View Containers */
.view {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Welcome Hero View */
.hero-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--card-shadow);
  border: 4px solid rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
}

.hero-mascot {
  font-size: 4.5rem;
  margin-bottom: 0.5rem;
  display: inline-block;
  animation: wiggle 3s infinite ease-in-out;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg) scale(1.05); }
  75% { transform: rotate(10deg) scale(1.05); }
}

.hero-title {
  font-family: var(--font-fun);
  font-size: 2.2rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.mode-card {
  background: linear-gradient(145deg, #ffffff, #f1f5f9);
  border: 3px solid #e2e8f0;
  border-radius: 20px;
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  position: relative;
}

[data-theme="dark"] .mode-card {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border-color: #334155;
}

.mode-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 12px 25px rgba(108, 92, 231, 0.25);
  border-color: var(--primary-color);
}

.mode-card .mode-icon {
  font-size: 3rem;
  margin-bottom: 0.8rem;
}

.mode-card h3 {
  font-family: var(--font-fun);
  font-size: 1.4rem;
  color: var(--text-color);
  margin-bottom: 0.4rem;
}

.mode-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Quiz Quest Layout */
.quest-container {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--card-shadow);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.progress-bar-bg {
  flex: 1;
  height: 16px;
  background: #E2E8F0;
  border-radius: 10px;
  margin: 0 1rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #55E6C1, #6C5CE7);
  width: 0%;
  transition: width 0.4s ease;
}

.section-tag {
  background: var(--primary-light);
  color: #2D3436;
  padding: 4px 12px;
  border-radius: 12px;
  font-family: var(--font-fun);
  font-size: 0.9rem;
  display: inline-block;
  margin-bottom: 1rem;
}

.question-box {
  background: rgba(108, 92, 231, 0.05);
  border: 2px dashed var(--primary-light);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.5;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn-option {
  background: white;
  border: 3px solid #CBD5E1;
  border-radius: 16px;
  padding: 1rem 1.2rem;
  font-family: var(--font-fun);
  font-size: 1.1rem;
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

[data-theme="dark"] .btn-option {
  background: #334155;
  border-color: #475569;
}

.btn-option:hover {
  transform: translateY(-3px);
  border-color: var(--primary-color);
  background: rgba(108, 92, 231, 0.1);
}

.btn-option.correct {
  background: #55E6C1 !important;
  border-color: #00B894 !important;
  color: #000 !important;
  animation: pulse 0.5s ease;
}

.btn-option.wrong {
  background: #FF7675 !important;
  border-color: #D63031 !important;
  color: white !important;
}

/* Ordering Rocket Game */
.ordering-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.rocket-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 80px;
  background: rgba(0, 0, 0, 0.05);
  border: 2px dashed #94A3B8;
  border-radius: 20px;
  width: 100%;
  padding: 12px;
}

.rocket-chip {
  background: linear-gradient(135deg, #74B9FF, #0984E3);
  color: white;
  font-family: var(--font-fun);
  font-size: 1.3rem;
  padding: 12px 20px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(9, 132, 227, 0.3);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rocket-chip:hover {
  transform: scale(1.1);
}

/* Comparison Balloon Game */
.comparison-arena {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin: 2rem 0;
}

.number-balloon {
  width: 110px;
  height: 130px;
  background: linear-gradient(135deg, #FF7675, #D63031);
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-fun);
  font-size: 2rem;
  box-shadow: 0 10px 20px rgba(214, 48, 49, 0.3);
  position: relative;
  animation: balloonFloat 3s infinite ease-in-out alternate;
}

@keyframes balloonFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-15px); }
}

.symbol-selector {
  display: flex;
  gap: 10px;
}

.btn-symbol {
  width: 55px;
  height: 55px;
  font-size: 1.8rem;
  border-radius: 16px;
  background: #FDCB6E;
  border: 3px solid #E17055;
  cursor: pointer;
  font-family: var(--font-fun);
  transition: var(--transition);
}

.btn-symbol:hover {
  transform: scale(1.2) rotate(5deg);
}

/* Interactive Carrying Column Addition */
.column-add-board {
  display: inline-block;
  background: #F8FAFC;
  border: 3px solid #CBD5E1;
  border-radius: 20px;
  padding: 1.5rem 2rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 1rem auto;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

[data-theme="dark"] .column-add-board {
  background: #0F172A;
  border-color: #334155;
}

.grid-table {
  display: grid;
  grid-template-columns: repeat(4, 50px);
  gap: 8px;
  text-align: center;
  align-items: center;
}

.digit-header {
  color: var(--primary-color);
  font-family: var(--font-fun);
  font-size: 1.2rem;
}

.carry-circle {
  width: 38px;
  height: 38px;
  border: 2px dashed #FF7675;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin: auto;
  background: #FFF5F5;
}

.digit-input {
  width: 45px;
  height: 45px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  border: 2px solid #94A3B8;
  border-radius: 10px;
  font-family: var(--font-fun);
}

/* Action Buttons */
.primary-btn {
  background: linear-gradient(135deg, #6C5CE7, #4834D4);
  color: white;
  border: none;
  padding: 0.9rem 2rem;
  font-family: var(--font-fun);
  font-size: 1.2rem;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.4);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.primary-btn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 12px 25px rgba(108, 92, 231, 0.6);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-color);
  border: 2px solid #CBD5E1;
  padding: 0.8rem 1.6rem;
  font-family: var(--font-fun);
  font-size: 1.1rem;
  border-radius: 30px;
  cursor: pointer;
  transition: var(--transition);
}

.secondary-btn:hover {
  background: #F1F5F9;
  transform: translateY(-2px);
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5deg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 30px;
  padding: 2.5rem 2rem;
  max-width: 450px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.modal-title {
  font-family: var(--font-fun);
  font-size: 1.8rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.modal-msg {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Bottom Mobile Navigation */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10deg);
  border-top: 2px solid rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  justify-content: space-around;
  z-index: 99;
}

[data-theme="dark"] .mobile-nav {
  background: rgba(15, 23, 42, 0.95);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
}

.nav-item.active {
  color: var(--primary-color);
}

.nav-item span.icon {
  font-size: 1.4rem;
}

/* Printable Paper Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  header.app-header, .mobile-nav, .bg-particles, .header-controls, .no-print {
    display: none !important;
  }
  main.app-main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .printable-paper {
    display: block !important;
    font-family: Arial, sans-serif;
    color: black;
    padding: 20px;
  }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  header.app-header {
    padding: 0.6rem 1rem;
  }
  .hero-title {
    font-size: 1.7rem;
  }
  .mode-grid {
    grid-template-columns: 1fr;
  }
  .mobile-nav {
    display: flex;
  }
  .comparison-arena {
    flex-direction: column;
    gap: 1.5rem;
  }
}
