:root{
  --bg:#f8fafc;
  --card:#ffffff;
  --text:#0b1220;
  --muted:#6b7280;
  --accent:#10b981;
  --accent-700:#059669;
  --danger:#ef4444;
  --warning:#f59e0b;
  --border:#e5e7eb;
  --beginner:#3b82f6;   /* blue */
  --intermediate:#ec4899; /* pink */
  --advanced:#10b981;   /* green */
}
*{box-sizing:border-box}
html,body{height:100%;background:#f8fafc !important}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  background: #f8fafc !important;
  color:var(--text);
  -webkit-tap-highlight-color:transparent;
}
#app{display:flex;flex-direction:column;min-height:100%;background:#f8fafc !important}
.app-header,.app-footer{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#e2e8f0;border-bottom:1px solid var(--border)}
.app-footer{border-top:none;border-bottom:none;background:transparent;padding:0;position:relative}
.footer-content{position:absolute;bottom:20px;right:20px;z-index:1000}
.footer-text{font-size:12px;color:#6b7280;font-weight:800;text-align:right;background:#ffffff;padding:8px 12px;border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,0.1);border:1px solid #e5e7eb;white-space:nowrap;line-height:1.2}
.brand{font-weight:800;letter-spacing:.3px;color:#0b1220}
.controls{display:flex;gap:12px;flex-wrap:wrap}
.segmented{display:flex;background:#f3f4f6;border:1px solid var(--border);border-radius:999px;overflow:hidden;box-shadow:0 1px 2px #0000000d}
.segmented-btn{appearance:none;border:none;background:transparent;color:var(--muted);padding:10px 14px;cursor:pointer;font-weight:600}
.segmented-btn.active{background:#ffffff;color:var(--text);box-shadow:0 1px 2px #00000010}
.board{flex:1;display:flex;align-items:center;justify-content:center;padding:0 16px}
.question-card{width:min(1100px,100%);background:var(--card);border:2px solid var(--border);border-radius:20px;padding:18px;box-shadow:0 10px 20px #00000010}
.meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 600; margin: 0; position: relative; z-index: 1; }

#counter {
    display: block;
    text-align: left;
    margin-left: 20px; /* Adjust value as needed */
    font-weight: 600;
}

.question{font-size:28px;line-height:1.2;margin:16px 0 12px;padding:0 20px}
.options{display:grid;gap:10px;grid-template-columns:1fr;}
.option{border:1px solid var(--border);background:#ffffff;color:var(--text);border-radius:14px;padding:14px;display:flex;gap:10px;align-items:flex-start;justify-content:flex-start;text-align:left;cursor:pointer;touch-action:manipulation}
.options,.option span{ text-align:left }
.option:hover{border-color:#cbd5e1}
.option.correct{border-color:var(--accent);background:#ecfdf5}
.option.wrong{border-color:var(--danger);background:#fee2e2}
.badge{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:999px;background:#f3f4f6;color:var(--muted);font-weight:800}
.actions{display:flex;justify-content:flex-end;margin-top:12px}
.primary{background:var(--accent-700);border:none;color:#ffffff;font-weight:800;padding:12px 16px;border-radius:12px;cursor:pointer;box-shadow:0 6px 12px #05966933;transition:transform .12s ease, box-shadow .12s ease}
.primary:hover{transform:translateY(-1px);box-shadow:0 8px 16px #05966944}
.ghost{background:transparent;border:1px solid var(--border);color:var(--text);padding:10px 12px;border-radius:12px;cursor:pointer}
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  max-width: 350px;
  animation: slideIn 0.3s ease-out;
}

.toast[hidden] {
  display: none !important;
}

.celebrate {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10001;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px 40px;
  border-radius: 20px;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 20px 40px rgba(102, 126, 234, 0.4);
  animation: celebrateAnimation 1.1s ease-out;
  max-width: 90vw;
  word-wrap: break-word;
}

.celebrate.show {
  display: block !important;
}

@keyframes celebrateAnimation {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (min-width:700px){
  .question{font-size:34px}
  .options{grid-template-columns:1fr 1fr}
}

/* Landing */
.landing{width:min(1100px,100%);}
.landing-title{font-size:36px;margin:0 0 16px}
.levels{display:grid;grid-template-columns:1fr;gap:14px}
.level-card{display:flex;flex-direction:column;align-items:flex-start;gap:6px;border:2px solid transparent;border-radius:18px;padding:18px;cursor:pointer;box-shadow:0 6px 14px #00000014;transition:transform .15s ease, outline-color .15s ease}
.level-card[data-start="beginner"]{background:var(--beginner);color:#ffffff}
.level-card[data-start="intermediate"]{background:var(--intermediate);color:#ffffff}
.level-card[data-start="advanced"]{background:var(--advanced);color:#ffffff}
.level-card:focus,.level-card:hover{outline:none;transform:translateY(-2px);filter:brightness(0.95)}
.level-card.selected{outline:4px solid #ffffff; outline-offset:2px; filter:brightness(1)}
.level-title{font-size:22px;font-weight:800}
.level-sub{color:#ffffffcc;font-weight:600}

@media (min-width:800px){
  .levels{grid-template-columns:repeat(3,1fr)}
}

/* Welcome Page Styles */
#welcome {
  width: min(1200px, 100%);
  padding: 20px;
}

.welcome-content {
  display: flex;
  align-items: center;
  gap: 80px;
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-left {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.character-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.character-image {
  width: 600px;
  height: 600px;
  object-fit: contain;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.character-image:hover {
  transform: scale(1.05);
}

.welcome-right {
  flex: 1;
  text-align: left;
}

.welcome-title {
  font-size: 48px;
  font-weight: 800;
  color: #0b1220;
  margin: 0 0 16px 0;
  line-height: 1.1;
}

.welcome-sub {
  font-size: 18px;
  color: #6b7280;
  margin: 0 0 32px 0;
  line-height: 1.5;
}

#begin-btn {
  background: #ff6b9d;
  border: none;
  color: #ffffff;
  font-weight: 600;
  font-size: 16px;
  padding: 12px 24px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 32px;
}

#begin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(255, 107, 157, 0.5);
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Feature Card */
.feature-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  width: 160px;
  min-height: 120px;
  text-align: left;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* Icon with background badge */
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-bottom: 12px;
  font-size: 18px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

/* Title */
.feature-title {
  font-size: 14px;
  font-weight: 700;
  color: #0b1220;
  margin: 0 0 6px 0;
  line-height: 1.2;
}

/* Description */
.feature-desc {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
  line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 768px) {
  .welcome-content {
    flex-direction: column;
    gap: 40px;
    text-align: center;
  }
  
  .welcome-right {
    text-align: center;
  }
  
  .welcome-title {
    font-size: 36px;
  }
  
  .character-image {
    width: 450px;
    height: 450px;
  }
  
  .welcome-features {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .feature-box {
    padding: 15px;
    width: 100%;
  }
  
  .feature-icon {
    font-size: 28px;
    margin-bottom: 10px;
  }
  
  .feature-title {
    font-size: 14px;
  }
  
  .feature-desc {
    font-size: 11px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .welcome-features {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }
}

/* Avatars */
.avatars{display:grid;grid-template-columns:repeat(2,1fr);gap:18px;justify-items:center}
.avatar-card{display:flex;flex-direction:column;align-items:center;gap:10px;border:2px solid transparent;border-radius:18px;padding:18px;background:var(--card);cursor:pointer;box-shadow:0 6px 14px #00000014;transition:transform .15s ease}
.avatar-card:hover,.avatar-card:focus{transform:translateY(-2px)}
.avatar-card.selected{outline:4px solid var(--accent);outline-offset:2px}
.avatar-img{width:140px;height:140px;border-radius:999px;object-fit:cover;border:4px solid var(--border);background:#f3f4f6}
.avatar-name{font-weight:800;color:var(--text)}

@media (min-width:800px){
  .avatars{grid-template-columns:repeat(4,1fr)}
}

.avatar-actions{display:flex;justify-content:center;margin-top:16px}

/* Center align avatar title and grid only on avatar page */
#avatar-select .landing-title{text-align:center}
#avatar-select .avatars{grid-template-columns:repeat(2,max-content);justify-content:center;gap:28px}

/* Subject level colors (reuse level-card styles) */
.level-card[data-subject="physics"]{background:#60a5fa;color:#ffffff}
.level-card[data-subject="chemistry"]{background:#f97316;color:#ffffff}
.level-card[data-subject="biology"]{background:#22c55e;color:#ffffff}

/* Grade buttons: color according to chosen difficulty (data-diff on grade buttons) */
.level-card[data-diff="beginner"]{
  background: var(--beginner);
  color: #ffffff;
  border-color: transparent;
}
.level-card[data-diff="intermediate"]{
  background: var(--intermediate);
  color: #ffffff;
  border-color: transparent;
}
.level-card[data-diff="advanced"]{
  background: var(--advanced);
  color: #ffffff;
  border-color: transparent;
}

/* Keep the same hover/selected behavior */
.level-card[data-diff] :where(.level-title, .level-sub) { color: inherit; }
.level-card[data-diff]:hover,
.level-card[data-diff]:focus {
  filter: brightness(0.95);
  transform: translateY(-2px);
}
.level-card[data-diff].selected { outline: 4px solid #ffffff; outline-offset: 2px; filter: brightness(1); }

/* Quiz UI */
.quiz-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;gap:5px}
.progress-container{flex:1;display:flex;align-items:center;gap:12px}
.progress-bar{flex:1;height:8px;background:#e5e7eb;border-radius:4px;overflow:hidden}
.progress-fill{height:100%;background:var(--accent);border-radius:4px;transition:width 0.3s ease;width:0%}
.progress-text{font-weight:10;color:var(--bg);min-width:1px;text-align:right;font-size:1px}
.timer-container{display:flex;flex-direction:column;align-items:center;gap:8px}
.timer-circle{width:64px;height:64px;border-radius:50%;background:var(--accent);display:flex;align-items:center;justify-content:center;position:relative;box-shadow:0 0 0 4px #ffffff, 0 0 0 8px var(--accent);}
.timer-text{color:#ffffff;font-weight:800;font-size:20px}
.timer-circle.warning{background:var(--warning)}
.timer-circle.danger{background:var(--danger)}
.streak-display{text-align:center}
.streak-display #streak{font-size:12px;font-weight:600;color:var(--muted)}

/* Confetti / Sparkles */
#confetti-root{position:fixed;left:0;top:0;width:100vw;height:100vh;pointer-events:none;z-index:9999;overflow:visible}
.confetti-burst{position:fixed;left:0;top:0;width:100vw;height:100vh;pointer-events:none;z-index:9999;overflow:visible}
.sparkle{position:absolute;width:8px;height:8px;border-radius:2px;opacity:.95;animation:burst 1100ms ease-out forwards}
.sparkle:nth-child(4n){border-radius:50%}
.sparkle:nth-child(3n){width:6px;height:6px}
@keyframes burst{
  0%{transform:translate(0,0) scale(1) rotate(0deg);opacity:1}
  100%{transform:translate(var(--tx), var(--ty)) scale(0.9) rotate(720deg);opacity:0}
}

/* Centered celebration message */
.celebrate-message{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%) scale(0.85);
  background:linear-gradient(180deg,#ffffff 0%, #fff7ed 100%);
  border:2px solid #fbbf24;
  padding:20px 26px;border-radius:16px;
  box-shadow:0 30px 80px #00000055, 0 0 0 4px #ffffff;
  font-weight:900;font-size:24px;color:#0b1220;z-index:10001;opacity:0;
  transition:transform .2s ease, opacity .2s ease;
  backdrop-filter:saturate(140%) blur(2px);
  text-shadow:0 2px 0 #ffffff;
}
.celebrate-message.show{opacity:1;transform:translate(-50%,-50%) scale(1)}

/* Screen-dimming overlay to highlight popup */
.celebrate-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.35);backdrop-filter:blur(1px);z-index:10000}

/* Celebrate message styles */
.celebrate{
  position:fixed;
  top:50%;left:50%;
  transform:translate(-50%,-50%);
  background:var(--accent);
  color:white;
  padding:20px 30px;
  border-radius:20px;
  font-weight:800;
  font-size:24px;
  z-index:10001;
  pointer-events:none;
  opacity:0;
  transition:opacity 0.3s ease;
  box-shadow:0 10px 30px rgba(0,0,0,0.3);
}
.celebrate.show{
  opacity:1;
}

/* make sparkles extra vibrant */
.sparkle{box-shadow:0 0 0 2px #ffffff22, 0 0 10px #ffffff55;mix-blend-mode:screen;will-change:transform,opacity}

/* Video Container Styles for Quiz Results */
.result-video-container {
  max-width: 600px;
  margin: 20px auto;
  padding: 0 20px;
}

.video-placeholder {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border: 2px dashed #cbd5e0;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  transition: all 0.3s ease;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.video-placeholder:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

/* Actual video styling when you add it */
.result-video-container iframe,
.result-video-container video {
  width: 100%;
  max-width: 560px;
  height: 315px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border: none;
}

/* GIF animation styling */
.completion-gif {
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border: none;
  display: block;
  margin: 0 auto;
}

/* Small GIF animation styling - for top of page */
.completion-gif-small {
  max-width: 200px;
  width: 200px;
  height: auto;
  border-radius: 0;
  box-shadow: none;
  border: none;
  display: inline-block;
  margin: 0;
  padding: 0;
  vertical-align: top;
}

/* Responsive video container */
@media (max-width: 768px) {
  .result-video-container {
    padding: 0 10px;
  }
  
  .result-video-container iframe,
  .result-video-container video {
    height: 200px;
  }
  
  .video-placeholder {
    min-height: 150px;
    padding: 30px 15px;
  }
}

/* Grade and Subject Display */
.grade-subject-display {
  display: flex;
  gap: 40px;
  margin-bottom: 4px;
  padding: 0 20px;
}

.grade-label, .subject-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.label-text {
  font-size: 16px;
  font-weight: 600;
  color: #2e7d32;
  position: relative;
}


.label-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-transform: capitalize;
}

/* --- Star glow & animation --- */
.star-container { 
  display: flex; 
  gap: 6px; 
  justify-content: center; 
  margin: 10px 0; 
  align-items: center; 
}

.star-container svg {
  width: 36px; 
  height: 36px;
  display: block;
  will-change: transform, filter;
  transition: transform 220ms ease, filter 220ms ease, opacity 220ms ease;
}

/* filled stars pulse with a golden glow */
.star-full svg,
.star-half svg {
  filter: drop-shadow(0 0 6px rgba(255,215,0,0.85));
  animation: starGlow 1.8s ease-in-out infinite;
}

/* half stars get a slightly milder glow */
.star-half svg {
  filter: drop-shadow(0 0 5px rgba(255,215,0,0.75));
  opacity: 0.98;
}

/* empty stars are muted */
.star-empty svg {
  filter: none;
  opacity: 0.45;
  transform: scale(0.98);
}

/* hover (if you want interactivity when hovering the score area) */
.star-container:hover .star-full svg,
.star-container:hover .star-half svg {
  transform: scale(1.06);
  filter: drop-shadow(0 0 12px rgba(255,215,0,0.95));
}

/* subtle pulsing glow keyframes */
@keyframes starGlow {
  0% {
    filter: drop-shadow(0 0 3px rgba(255,215,0,0.6));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(255,215,0,0.95));
    transform: scale(1.09);
  }
  100% {
    filter: drop-shadow(0 0 3px rgba(255,215,0,0.6));
    transform: scale(1);
  }
}

/* make sure SVG star shapes use crisp edges on different displays */
.star-container svg path { shape-rendering: geometricPrecision; }


.star {
  font-size: 28px;
  color: #d1d5db;
  transition: color 0.3s ease;
}

.star.filled {
  color: #fbbf24;
}

.star:not(.filled) {
  color: #d1d5db !important;
}

.performance-message {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin: 12px 0;
}

/* Results page button styling */
.secondary {
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-size: 14px;
}

.secondary:hover {
  background: #4a5568;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.secondary:active {
  transform: translateY(0);
}
