/* =========================================
   WONDER WORKSHOP — Workshop Theme
   Kid-friendly, warm, wood-tool aesthetic
   ========================================= */

/* ===== CSS ROOT VARIABLES ===== */
:root {
  --orange: #FF8C00;
  --orange-dark: #E07B00;
  --gold: #FFD700;
  --gold-dark: #DAA520;
  --blue: #4A90D9;
  --blue-dark: #357ABD;
  --green: #4CAF50;
  --purple: #9C27B0;
  --red: #F44336;
  --pink: #FF69B4;
  --teal: #4ECDC4;
  --dark: #2D2D2D;
  --dark-soft: #5D4037;
  --light: #FFF8E1;
  --beige: #FFF8E1;
  --beige-dark: #F5E6CC;
  --grey: #888;
  --wood-light: #F5DEB3;
  --wood: #DEB887;
  --wood-dark: #A0522D;
  --bg: #FFF8E1;
  --shadow: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ===== FONTS & BASE ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Comic Sans MS', cursive, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255,140,0,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(74,144,217,0.03) 0%, transparent 50%);
  color: var(--dark);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, var(--beige) 0%, #FFF8E1 100%);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 20px;
  animation: slideUp 0.4s ease-out;
}
.screen.active { display: block; }
.screen-center {
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ===== WORKSHOP ANIMATIONS ===== */
@keyframes gearSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes gearSpinReverse {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(-360deg); }
}
@keyframes slideInRight {
  0% { transform: translateX(40px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.08); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes flipInY {
  0% { transform: perspective(400px) rotateY(90deg); opacity: 0; }
  40% { transform: perspective(400px) rotateY(-10deg); }
  70% { transform: perspective(400px) rotateY(10deg); }
  100% { transform: perspective(400px) rotateY(0deg); opacity: 1; }
}
@keyframes rainbowGlow {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 5px rgba(255,215,0,0.3); }
  50% { box-shadow: 0 0 20px rgba(255,215,0,0.6); }
}
@keyframes sawBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-5px) rotate(-5deg); }
  75% { transform: translateY(-3px) rotate(5deg); }
}
@keyframes hammerStrike {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  15% { transform: translateY(-10px) rotate(-10deg); }
  30% { transform: translateY(0) rotate(0deg); }
  45% { transform: translateY(-8px) rotate(10deg); }
  60% { transform: translateY(0) rotate(0deg); }
}
@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
  50% { opacity: 1; transform: scale(1) rotate(180deg); }
}
@keyframes woodGrain {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background:
    linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(255,140,0,0.3);
  border-bottom: 3px solid var(--gold);
}

.topbar h2 {
  flex: 1;
  font-size: 18px;
  font-weight: 800;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .sparks-badge {
  background: rgba(255,255,255,0.2);
  color: var(--gold);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.3);
  white-space: nowrap;
}

.back-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); }
.back-btn:active { transform: scale(0.95); }

/* ===== GIZMO ===== */
.gizmo {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 16px;
  padding: 14px 16px;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
  border-radius: 16px;
  border: 2px solid var(--gold);
  box-shadow: 0 3px 10px rgba(255,215,0,0.2), inset 0 1px 0 rgba(255,255,255,0.8);
  position: relative;
}

.gizmo::before {
  content: '🔩';
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 14px;
  animation: gearSpin 4s linear infinite;
}
.gizmo::after {
  content: '🔩';
  position: absolute;
  bottom: -8px;
  right: -8px;
  font-size: 14px;
  animation: gearSpinReverse 3s linear infinite;
}

.gizmo-avatar {
  font-size: 40px;
  line-height: 1;
  flex-shrink: 0;
  animation: bounce 2s ease-in-out infinite;
}

.gizmo-msg {
  font-size: 14px;
  line-height: 1.5;
  color: var(--dark-soft);
  flex: 1;
}

/* ===== PWA INSTALL BANNER ===== */
.pwa-install-banner {
  margin: 0 16px 12px;
  text-align: center;
}

.pwa-install-btn {
  background: linear-gradient(135deg, var(--orange) 0%, #FF6B00 100%);
  color: white;
  border: 2px solid var(--gold);
  padding: 12px 28px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(255,140,0,0.3);
  animation: pulse 2s ease-in-out infinite;
}
.pwa-install-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 20px rgba(255,140,0,0.4);
}
.pwa-install-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.pwa-install-sub {
  font-size: 12px;
  color: var(--grey);
  margin-top: 6px;
}

.pwa-installed-msg {
  margin: 8px 16px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  border: 2px solid var(--green);
  border-radius: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #2E7D32;
}

/* ===== DAILY BANNER ===== */
.daily-banner {
  margin: 10px 16px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--gold), #FFA000);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 3px 10px rgba(255,215,0,0.3);
  animation: pulse 3s ease-in-out infinite;
  font-weight: 700;
  color: var(--dark);
  font-size: 14px;
}
.daily-banner:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(255,215,0,0.4); }
.daily-banner:active { transform: translateY(0); }

.daily-banner-icon {
  font-size: 24px;
  animation: bounce 1.5s ease-in-out infinite;
}

/* ===== HOME ===== */
.home-subtitle {
  text-align: center;
  color: var(--dark-soft);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
}

.home-card {
  background:
    linear-gradient(180deg, #FFF8E1 0%, #F5E6CC 100%);
  border: 2px solid var(--wood);
  border-radius: 16px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.home-card::before {
  content: '🔩';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 12px;
  opacity: 0.5;
  animation: gearSpin 6s linear infinite;
}

.home-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--orange), var(--gold), var(--orange));
}

.home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: var(--orange);
}

.home-card:active { transform: translateY(-2px) scale(0.97); }

.home-card-icon {
  font-size: 36px;
  margin-bottom: 8px;
  display: block;
}

.home-card-label {
  font-size: 15px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 4px;
}

.home-card-desc {
  font-size: 12px;
  color: var(--grey);
  line-height: 1.3;
}

/* ===== CHAPTER LIST ===== */
.chapter-list {
  padding: 8px 16px;
}

.chapter-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
  border: 2px solid var(--wood);
  border-radius: 14px;
  border-left: 5px solid var(--blue);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chapter-card::before {
  content: '🔩';
  position: absolute;
  top: -8px;
  right: 8px;
  font-size: 11px;
  opacity: 0.4;
  animation: gearSpin 5s linear infinite;
}

.chapter-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border-color: var(--orange);
}

.chapter-card:active { transform: translateX(2px) scale(0.99); }

.chapter-card.locked { opacity: 0.7; cursor: not-allowed; }
.chapter-card.complete { border-color: var(--green) !important; }

.chapter-icon {
  font-size: 36px;
  flex-shrink: 0;
}

.chapter-info { flex: 1; }

.chapter-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 4px;
}

.chapter-progress {
  font-size: 12px;
  color: var(--grey);
  margin-bottom: 6px;
}

.chapter-bar {
  height: 8px;
  background: var(--beige-dark);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--wood);
}

.chapter-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--blue);
  position: relative;
}

.chapter-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.chapter-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  margin-top: 4px;
}

.chapter-status {
  font-size: 24px;
  flex-shrink: 0;
}

/* ===== CHALLENGE LIST ===== */
.challenge-list {
  padding: 8px 16px;
}

.challenge-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
  border: 2px solid var(--wood);
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.challenge-card::before {
  content: '⚙️';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
  opacity: 0.4;
  animation: gearSpin 4s linear infinite;
}

.challenge-card:hover {
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: var(--orange);
}

.challenge-card.completed {
  opacity: 0.75;
  border-color: var(--green);
}

.challenge-card.completed::before {
  content: '✅';
  opacity: 1;
  animation: none;
}

.challenge-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.challenge-num.easy { background: var(--green); }
.challenge-num.medium { background: var(--orange); }
.challenge-num.hard { background: var(--red); }

.challenge-title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
}

.challenge-sparks {
  font-size: 12px;
  color: var(--gold-dark);
  font-weight: 700;
  flex-shrink: 0;
}

.challenge-desc {
  display: none;
  font-size: 11px;
  color: var(--grey);
  width: 100%;
  margin-top: 4px;
}

.challenge-card.completed .challenge-num {
  background: var(--green) !important;
}

/* ===== CHALLENGE PLAY ===== */
.challenge-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  min-height: calc(100vh - 100px);
}

.challenge-question {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
  color: var(--dark-soft);
  line-height: 1.4;
}

.challenge-instruction {
  font-size: 14px;
  color: var(--grey);
  text-align: center;
  margin-bottom: 20px;
}

/* ===== ANSWER OPTIONS ===== */
.answers {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.answer-btn {
  padding: 14px 18px;
  border: 3px solid var(--wood);
  border-radius: 14px;
  background:
    linear-gradient(180deg, #FFF8E1 0%, #F5E6CC 100%);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-family: inherit;
  color: var(--dark);
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.answer-btn::before {
  content: '🔧';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
  opacity: 0.3;
}

.answer-btn:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74,144,217,0.15);
}

.answer-btn:active { transform: translateY(-1px) scale(0.98); }

.answer-btn.selected { border-color: var(--blue); background: linear-gradient(135deg, #E3F2FD, #BBDEFB); }
.answer-btn.correct { border-color: var(--green); background: linear-gradient(135deg, #E8F5E9, #C8E6C9); }
.answer-btn.incorrect { border-color: var(--red); background: linear-gradient(135deg, #FFEBEE, #FFCDD2); }
.answer-btn:disabled { cursor: not-allowed; opacity: 0.7; }

/* ===== QUIZ BUTTONS ===== */
.quiz-btn {
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  margin-top: 16px;
  animation: bounce 2s ease-in-out infinite;
}

.quiz-btn:hover { transform: translateY(-3px) scale(1.02); }
.quiz-btn:active { transform: translateY(-1px) scale(0.97); animation: none; }

.quiz-btn-primary {
  background: linear-gradient(135deg, var(--orange) 0%, #FF6B00 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(255,140,0,0.3);
}

.quiz-btn-success {
  background: linear-gradient(135deg, var(--green) 0%, #388E3C 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(76,175,80,0.3);
}

/* ===== MATCHING GAME ===== */
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.match-item {
  padding: 14px;
  border: 3px solid var(--wood);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #FFF8E1 0%, #F5E6CC 100%);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  color: var(--dark);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.match-item:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
}
.match-item.selected { border-color: var(--blue); background: linear-gradient(135deg, #E3F2FD, #BBDEFB); }
.match-item.matched { border-color: var(--green); background: linear-gradient(135deg, #E8F5E9, #C8E6C9); cursor: default; }
.match-item.wrong { border-color: var(--red); background: linear-gradient(135deg, #FFEBEE, #FFCDD2); }

/* ===== SORTING GAME ===== */
.sort-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 400px;
}

.sort-item {
  padding: 12px 16px;
  border: 3px solid var(--wood);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #FFF8E1 0%, #F5E6CC 100%);
  cursor: grab;
  transition: var(--transition);
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.sort-item:hover {
  border-color: var(--blue);
  transform: translateX(4px);
}

.sort-item.placed {
  border-color: var(--green);
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
}

.sort-zones {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  justify-content: center;
}

.sort-zone {
  flex: 1;
  padding: 16px 12px;
  border: 3px dashed var(--wood);
  border-radius: 12px;
  text-align: center;
  min-height: 80px;
  font-weight: 700;
  font-size: 13px;
  color: var(--grey);
  transition: var(--transition);
}

.sort-zone.dragover { border-color: var(--blue); background: rgba(74,144,217,0.05); }

/* ===== TAP GAME ===== */
.tap-game-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 4px solid var(--orange);
  background: linear-gradient(135deg, var(--orange), #FF6B00);
  color: white;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 8px 32px rgba(255,140,0,0.3);
  font-family: inherit;
}

.tap-game-btn:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(255,140,0,0.4); }
.tap-game-btn:active { transform: scale(0.95); }

.tap-count {
  font-size: 72px;
  font-weight: 900;
  color: var(--orange);
  margin: 16px 0;
  text-shadow: 2px 2px 0 var(--gold);
}

/* ===== INVENTIONS ===== */
.inv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 16px;
}

.inv-card {
  background:
    linear-gradient(180deg, #FFF8E1 0%, #F0E0C0 100%);
  border: 2px solid var(--wood);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.inv-card::before {
  content: '🔩';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
  opacity: 0.4;
  animation: gearSpin 5s linear infinite;
}

.inv-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  border-color: var(--orange);
}

.inv-card.owned {
  border-color: var(--gold);
  background: linear-gradient(180deg, #FFF8E1 0%, #FFF3CD 100%);
}

.inv-card-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 6px;
}

.inv-card-name {
  font-size: 13px;
  font-weight: 800;
}

.inv-card-cost {
  font-size: 12px;
  color: var(--gold-dark);
  font-weight: 700;
}

.inv-card-cat {
  font-size: 10px;
  color: var(--grey);
  margin-top: 2px;
}

/* ===== INVENTIONS SHOWCASE SECTIONS ===== */
.inv-section {
  margin-bottom: 20px;
}

.inv-section-title {
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 800;
  color: var(--dark-soft);
  background: linear-gradient(90deg, var(--wood-light), transparent);
  border-left: 4px solid var(--orange);
  margin-bottom: 8px;
}

/* ===== NOTEBOOK ===== */
.notebook-list {
  padding: 8px 16px;
}

.notebook-card {
  padding: 14px 16px;
  margin-bottom: 8px;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #F5E6CC 100%);
  border: 2px solid var(--wood);
  border-radius: 12px;
  transition: var(--transition);
}

.notebook-card.journal-unlocked {
  border-color: var(--gold);
  background: linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
}

.notebook-card.journal-locked { opacity: 0.6; }

.notebook-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 4px;
}

.notebook-desc {
  font-size: 12px;
  color: var(--grey);
}

.notebook-status {
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--gold-dark);
}

.notebook-rank {
  padding: 12px 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #FFF8E1, #FFF3CD);
  border: 2px solid var(--gold);
  border-radius: 14px;
  text-align: center;
  position: relative;
}

.notebook-rank::after {
  content: '⭐';
  position: absolute;
  top: -10px;
  right: -10px;
  font-size: 20px;
  animation: sparkle 2s ease-in-out infinite;
}

.notebook-rank-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 4px;
}

.notebook-rank-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--dark-soft);
}

.notebook-rank-sparks {
  font-size: 14px;
  color: var(--grey);
}

/* ===== PARENT DASHBOARD ===== */
.parent-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 16px;
}

.parent-stat {
  padding: 16px;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #F5E6CC 100%);
  border: 2px solid var(--wood);
  border-radius: 12px;
  text-align: center;
}

.parent-stat:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
}

.parent-stat-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--orange);
}

.parent-stat-label {
  font-size: 12px;
  color: var(--grey);
  font-weight: 600;
}

/* ===== UNLOCK SECTION ===== */
.unlock-section {
  padding: 40px 20px;
  text-align: center;
}

.unlock-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounce 2s ease-in-out infinite;
}

.unlock-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--dark-soft);
  margin-bottom: 8px;
}

.unlock-desc {
  font-size: 14px;
  color: var(--grey);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ===== PRICING ===== */
.pricing-page {
  padding: 20px 16px;
}

.pricing-page-card {
  padding: 24px 20px;
  margin-bottom: 12px;
  border: 2px solid var(--wood);
  border-radius: 16px;
  background:
    linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.pricing-page-card.featured {
  border-color: var(--gold);
  background: linear-gradient(135deg, #FFF8E1, #FFE082);
  box-shadow: 0 0 30px rgba(255,215,0,0.2);
  position: relative;
}

.pricing-page-card.featured::after {
  content: '⭐ BEST VALUE';
  position: absolute;
  top: -10px;
  right: 16px;
  background: var(--orange);
  color: white;
  padding: 2px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
}

.pricing-page-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.pricing-page-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--dark-soft);
}

.pricing-page-price {
  font-size: 36px;
  font-weight: 900;
  color: var(--orange);
  margin: 8px 0;
}

.pricing-page-price small {
  font-size: 16px;
  font-weight: 400;
  color: var(--grey);
}

.pricing-page-desc {
  font-size: 13px;
  color: var(--grey);
  margin-bottom: 12px;
}

.pricing-page-btn {
  padding: 12px 32px;
  border: none;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  background: linear-gradient(135deg, var(--orange) 0%, #FF6B00 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(255,140,0,0.3);
}

.pricing-page-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,140,0,0.4); }
.pricing-page-btn:active { transform: translateY(0); }

/* ===== AUTH ===== */
.auth-form {
  padding: 20px 16px;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  border: 3px solid var(--wood);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 12px;
  background: white;
  transition: var(--transition);
  outline: none;
}

.auth-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,140,0,0.1);
}

.auth-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--orange) 0%, #FF6B00 100%);
  color: white;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(255,140,0,0.3);
}
.auth-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,140,0,0.4); }
.auth-btn:active { transform: translateY(0); }

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--grey);
}
.auth-switch a {
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* ===== PARENT SECTION ===== */
.parent-code {
  text-align: center;
  padding: 20px 16px;
}
.parent-code-display {
  font-size: 32px;
  font-weight: 900;
  color: var(--orange);
  letter-spacing: 8px;
  padding: 16px;
  background: white;
  border: 3px dashed var(--wood);
  border-radius: 12px;
  display: inline-block;
  margin: 12px 0;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}
.modal-box {
  position: relative;
  background: white;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  animation: slideUp 0.3s ease-out;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  border: 2px solid var(--orange);
}
.modal-box::before {
  content: '🔩';
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 14px;
  animation: gearSpin 4s linear infinite;
}
.modal-icon { font-size: 48px; margin-bottom: 8px; }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; color: var(--dark-soft); }
.modal-text { font-size: 14px; color: #555; line-height: 1.5; margin-bottom: 16px; }

/* ===== CONFETTI ===== */
.confetti {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  z-index: 2000;
  pointer-events: none;
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-size: 18px;
  color: #888;
  flex-direction: column;
  gap: 12px;
}
.loading-dot {
  font-size: 48px;
  animation: dotPulse 1s infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 1; }
}

@keyframes confettiFall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ===== RESPONSIVE ===== */
@media (min-width: 481px) {
  #app { border-radius: 20px; margin-top: 20px; min-height: calc(100vh - 40px); }
}
@media (max-width: 360px) {
  .home-grid, .inv-grid { grid-template-columns: 1fr; }
  .topbar h2 { font-size: 15px; }
}
@media (min-width: 768px) {
  #app { max-width: 600px; }
  .home-grid { grid-template-columns: 1fr 1fr; }
  .inv-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ===== Streak Badge ===== */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* ===== Number Pad ===== */
.number-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 240px;
  margin: 12px auto;
}
.numpad-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--wood);
  background: white;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.numpad-btn:hover { border-color: var(--orange); background: #FFF8E1; }
.numpad-btn:active { transform: scale(0.9); background: var(--orange); color: white; }
.numpad-btn.del { font-size: 18px; }
.numpad-btn.submit { background: var(--green); color: white; border-color: var(--green); }
.numpad-btn.submit:hover { background: #388E3C; }
.numpad-display {
  font-size: 36px;
  font-weight: 800;
  color: var(--dark);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  letter-spacing: 4px;
}

/* ===== BUTTON SYSTEM v2 — Playful Workshop Style ===== */
.btn {
  display: inline-block;
  padding: 14px 24px;
  border: none;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(-1px) scale(0.98); }
.btn-block { width: 100%; display: block; }

.btn-primary { background: linear-gradient(135deg, #FF8C00 0%, #FF6B00 100%); color: white; box-shadow: 0 4px 16px rgba(255,140,0,0.3); }
.btn-success { background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%); color: white; box-shadow: 0 4px 16px rgba(76,175,80,0.3); }
.btn-orange { background: linear-gradient(135deg, #FF9800 0%, #E65100 100%); color: white; box-shadow: 0 4px 16px rgba(255,152,0,0.3); }
.btn-gold { background: linear-gradient(135deg, #FFD700 0%, #FFA000 100%); color: #5D4037; box-shadow: 0 4px 16px rgba(255,215,0,0.3); }
.btn-default { background: #f0f0f0; color: #666; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.btn-default:hover { background: #e0e0e0; color: #333; }

/* Game option buttons */
.mock-option {
  display: block;
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 10px;
  border: 2px solid #e0d5c0;
  border-radius: 14px;
  background: linear-gradient(135deg, #FFF8E1 0%, #FFF3CD 100%);
  font-size: 16px;
  font-weight: 600;
  color: #4A3728;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  font-family: inherit;
}
.mock-option:hover {
  border-color: #FF8C00;
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(255,140,0,0.15);
}
.mock-option:active { transform: scale(0.98); }
.mock-option.correct {
  background: linear-gradient(135deg, #C8E6C9 0%, #A5D6A7 100%);
  border-color: #4CAF50;
  color: #1B5E20;
  font-weight: 800;
}
.mock-option.wrong {
  background: linear-gradient(135deg, #FFCDD2 0%, #EF9A9A 100%);
  border-color: #F44336;
  color: #B71C1C;
}
.mock-option.selected {
  border-color: #4A90D9;
  background: linear-gradient(135deg, #BBDEFB 0%, #90CAF9 100%);
}
.mock-option.correct { animation: bounce 0.5s ease; }
.mock-option.wrong { animation: shake 0.4s ease; }

/* Auth box styling */
.auth-box {
  background: white;
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  animation: slideUp 0.4s ease-out;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: #f5f0e8;
  border-radius: 50px;
  padding: 4px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: #888;
  transition: all 0.25s ease;
}
.auth-tab.active {
  background: linear-gradient(135deg, #FF8C00 0%, #FF6B00 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255,140,0,0.3);
}
.auth-input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 2px solid #e8e0d5;
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  background: #FFFAF0;
  transition: all 0.25s ease;
  box-sizing: border-box;
}
.auth-input:focus {
  outline: none;
  border-color: #FF8C00;
  box-shadow: 0 0 0 3px rgba(255,140,0,0.15);
}

/* ===== GAME SCENE BACKGROUNDS ===== */
.scene-jungle { background: linear-gradient(180deg, #87CEEB 0%, #90EE90 40%, #228B22 100%); }
.scene-space { background: linear-gradient(180deg, #0B0B2B 0%, #1a1a4e 60%, #2d1b69 100%); }
.scene-sky { background: linear-gradient(180deg, #87CEEB 0%, #B0E0FF 60%, #FFE4B5 100%); }
.scene-body { background: linear-gradient(180deg, #FFE4E1 0%, #FFDAB9 100%); }
.scene-playground { background: linear-gradient(180deg, #87CEEB 0%, #90EE90 40%, #FFD700 100%); }
.scene-rainbow { background: linear-gradient(90deg, #FF0000, #FF7F00, #FFFF00, #00FF00, #0000FF, #4B0082, #8F00FF); min-height: 200px; border-radius: 20px; }
.scene-workshop { background: linear-gradient(135deg, #F5DEB3 0%, #DEB887 100%); }

.challenge-game-area {
  border-radius: 24px 24px 0 0;
  padding: 20px;
  min-height: 300px;
  position: relative;
  overflow: hidden;
}
.challenge-game-area .scene-title {
  font-size: 22px;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  text-align: center;
  margin-bottom: 16px;
}

/* ===== CHALLENGE TIMER BAR ===== */
.timer-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #FFC107, #F44336);
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* ===== MATCH CARD FLIP ===== */
.match-card-container {
  perspective: 600px;
  display: inline-block;
}
.match-card {
  width: 100%;
  height: 80px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  cursor: pointer;
  border-radius: 12px;
}
.match-card.flipped {
  transform: rotateY(180deg);
}
.match-card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  border: 3px solid #e0d5c0;
  box-sizing: border-box;
}
.match-card-front {
  background: linear-gradient(135deg, #FF8C00, #FF6B00);
  color: white;
  font-size: 14px;
}
.match-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #FFF8E1 0%, #FFF3CD 100%);
  color: #4A3728;
}
.match-card.matched {
  transform: rotateY(180deg);
  cursor: default;
}
.match-card.matched .match-card-back {
  border-color: #4CAF50;
  background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
}

/* ===== RAINBOW BUILD GAME ===== */
.rainbow-arc {
  position: relative;
  height: 140px;
  margin: 0 auto 16px;
  width: 260px;
}
.rainbow-band {
  position: absolute;
  border-radius: 50%;
  border: 8px solid transparent;
  transition: all 0.3s ease;
}
.rainbow-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 0 12px;
}
.rainbow-tile {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 3px solid rgba(255,255,255,0.5);
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.rainbow-tile:active { transform: scale(0.92); }
.rainbow-tile.used { opacity: 0.4; transform: scale(0.85); cursor: default; }

/* ===== BUILD GAME ===== */
.build-bench {
  background: linear-gradient(135deg, #DEB887, #C4A265);
  border-radius: 16px;
  padding: 20px 16px;
  min-height: 200px;
  position: relative;
  border: 3px solid #A0522D;
}
.build-part {
  display: inline-block;
  padding: 12px 18px;
  margin: 4px;
  background: #FFF8E1;
  border: 2px solid #A0522D;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: bounceIn 0.3s ease-out both;
}
.build-part:active { transform: scale(0.92); }
.build-part.used { opacity: 0.3; cursor: default; transform: scale(0.85); }
.build-slot {
  min-height: 60px;
  border: 2px dashed rgba(160,82,45,0.4);
  border-radius: 12px;
  margin-top: 12px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

/* ===== REVEAL/DRAWING GAME ===== */
.draw-canvas {
  border: 3px solid #e0d5c0;
  border-radius: 16px;
  background: white;
  touch-action: none;
  width: 100%;
  max-width: 320px;
  height: 240px;
  display: block;
  margin: 0 auto;
}

.color-picker {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s ease;
}
.color-swatch.active { border-color: #333; transform: scale(1.2); }

/* ===== RESPONSIVE GAME TWEAKS ===== */
@media (max-width: 360px) {
  .rainbow-tile { width: 44px; height: 44px; font-size: 16px; }
  .rainbow-arc { width: 200px; height: 110px; }
  .match-card { height: 64px; }
  .build-part { font-size: 14px; padding: 8px 12px; }
}

/* ===== Purchase Success ===== */
.purchase-success {
  text-align: center;
  padding: 40px 20px;
}
.purchase-success .checkmark {
  font-size: 80px;
  animation: bounce 1s ease-in-out 3;
}