/* ==========================================================================
   KIDSGURU - HTML5 NUMBER TRACING GAME (1 - 100)
   Style Sheet (style.css)
   ========================================================================== */

:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --accent-pink: #ec4899;
  --accent-yellow: #f59e0b;
  --accent-green: #10b981;
  --accent-blue: #06b6d4;
  --bg-gradient: linear-gradient(135deg, #e0e7ff 0%, #fbcfe8 50%, #fed7aa 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --font-heading: 'Fredoka', cursive, sans-serif;
  --font-body: 'Poppins', sans-serif;
  --shadow-soft: 0 10px 25px rgba(99, 102, 241, 0.15);
  --shadow-3d: 0 6px 0 rgba(0, 0, 0, 0.15);
  --border-radius-lg: 24px;
  --border-radius-md: 16px;
  --border-radius-sm: 10px;
}

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

body, html {
  width: 100%;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: #1e1b4b;
}

/* Screen Wrapper */
.game-app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  overflow: visible;
  padding-bottom: 24px;
}

/* Animated Floating Background Elements */
.bg-bubbles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  opacity: 0.25;
  animation: floatUp 12s infinite linear;
}

@keyframes floatUp {
  0% { transform: translateY(105vh) scale(0.8) rotate(0deg); }
  100% { transform: translateY(-15vh) scale(1.2) rotate(360deg); }
}

/* Header Bar */
.game-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Back Button */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #fff;
  border: 2px solid #7dd3fc;
  border-radius: 50px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #0369a1, 0 6px 10px rgba(0,0,0,0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-back:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0369a1;
}

/* Icon Buttons */
.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #cbd5e1, 0 4px 8px rgba(0,0,0,0.08);
  transition: all 0.15s ease;
}

.btn-icon:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.btn-icon.muted {
  filter: grayscale(0.8);
  opacity: 0.7;
}

/* Difficulty Selector Pills */
.difficulty-selector {
  display: flex;
  background: #e0e7ff;
  padding: 3px;
  border-radius: 50px;
  border: 2px solid #c7d2fe;
}

.diff-btn {
  padding: 5px 12px;
  border-radius: 50px;
  border: none;
  background: transparent;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: #4338ca;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diff-btn.active {
  background: #4f46e5;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

/* Status Bar */
.status-bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.6);
  margin: 8px 16px 0 16px;
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
}

.stat-badge {
  background: #ffffff;
  padding: 4px 12px;
  border-radius: 50px;
  border: 2px solid #f3f4f6;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 4px;
}

.progress-text {
  color: #4f46e5;
}

/* Main Playing Arena */
.main-arena {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  z-index: 2;
}

.canvas-card {
  position: relative;
  width: 100%;
  max-width: min(500px, 50vh);
  aspect-ratio: 1 / 1;
  background: #ffffff;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-soft), inset 0 0 0 4px rgba(99, 102, 241, 0.15);
  border: 4px solid #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

canvas#tracingCanvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  display: block;
}

/* Toast Message / Floating Feedback */
.feedback-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  pointer-events: none;
  background: rgba(30, 27, 75, 0.9);
  color: #ffffff;
  padding: 8px 20px;
  border-radius: 50px;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}

.feedback-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.feedback-banner.error {
  background: #ef4444;
}

.feedback-banner.success {
  background: #10b981;
}

/* Controls Navigation Bar */
.controls-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px 24px 16px;
  width: 100%;
}

.btn-action {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  min-height: 48px;
}

.btn-nav {
  background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
  border: 2.5px solid #a5b4fc;
  box-shadow: 0 4px 0 #3730a3, 0 6px 12px rgba(79, 70, 229, 0.3);
}

.btn-hear {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
  border: 2.5px solid #fde68a;
  box-shadow: 0 4px 0 #b45309, 0 6px 12px rgba(217, 119, 6, 0.3);
}

.btn-retry {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
  border: 2.5px solid #fca5a5;
  box-shadow: 0 4px 0 #991b1b, 0 6px 12px rgba(220, 38, 38, 0.3);
  padding: 10px 14px;
}

.btn-jump {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  border: 2.5px solid #6ee7b7;
  box-shadow: 0 4px 0 #047857, 0 6px 12px rgba(5, 150, 105, 0.3);
}

.btn-action:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  border: 4px solid #e0e7ff;
  text-align: center;
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-height: 88vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 26px;
  color: #1e1b4b;
  margin-bottom: 12px;
}

/* Success Modal Details */
.stars-reward-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 40px;
  margin: 16px 0;
}

.star-pop {
  animation: starPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes starPop {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  70% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.accuracy-badge {
  display: inline-block;
  background: #ecfdf5;
  color: #047857;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 50px;
  border: 2px solid #a7f3d0;
  margin: 8px 0;
}

.modal-btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.btn-primary {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 2.5px solid #6ee7b7;
  padding: 12px 24px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 0 #047857, 0 6px 12px rgba(5, 150, 105, 0.3);
  transition: transform 0.1s ease;
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #047857;
}

/* Number Picker Grid Modal */
.number-grid-container {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 6px;
  margin: 12px 0;
}

.num-grid-item {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 2px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.num-grid-item.completed {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  color: #166534 !important;
}

.num-grid-item.current {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transform: scale(1.1);
  z-index: 2;
}

.num-grid-item:hover {
  transform: scale(1.05);
}

/* Parent Stats Modal Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.stat-box {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  padding: 12px;
  text-align: center;
}

.stat-box-val {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: #4f46e5;
}

.stat-box-lbl {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

/* Badges Showcase */
.badges-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px;
}

.badge-item {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-heading);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.4;
  filter: grayscale(1);
}

.badge-item.unlocked {
  opacity: 1;
  filter: none;
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

/* Confetti Canvas Overlay */
canvas#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 200;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 480px) {
  .game-header {
    padding: 8px 10px;
  }

  .btn-back span {
    display: none;
  }

  .difficulty-selector {
    padding: 2px;
  }

  .diff-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  .stat-item {
    font-size: 14px;
  }

  .controls-bar {
    gap: 8px;
    padding: 8px 10px 12px 10px;
  }

  .btn-action {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 44px;
  }

  .number-grid-container {
    grid-template-columns: repeat(4, 1fr);
  }
}
