:root {
  --bg-deep: #0f172a;
  --bg-gradient: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f172a 100%);
  --primary: #8b5cf6;
  --primary-glow: #a78bfa;
  --accent: #06b6d4;
  --accent-glow: #67e8f9;
  --success: #10b981;
  --error: #f43f5e;
  --text-light: #f8fafc;
  --text-dim: #94a3b8;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-high: rgba(255, 255, 255, 0.15);
  --glass-border: rgba(255, 255, 255, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Fredoka', sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text-light);
  background-color: var(--bg-deep);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  overflow-x: hidden;
}

/* Background Animation */
.cosmos-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.star-field {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(1px 1px at 10% 10%, #fff, transparent),
    radial-gradient(1px 1px at 20% 20%, #fff, transparent),
    radial-gradient(2px 2px at 30% 30%, #fff, transparent),
    radial-gradient(1px 1px at 40% 40%, #fff, transparent),
    radial-gradient(1px 1px at 50% 50%, #fff, transparent),
    radial-gradient(2px 2px at 60% 60%, #fff, transparent),
    radial-gradient(1px 1px at 70% 70%, #fff, transparent),
    radial-gradient(1px 1px at 80% 80%, #fff, transparent),
    radial-gradient(2px 2px at 90% 90%, #fff, transparent);
  background-size: 550px 550px;
  opacity: 0.6;
  animation: starMove 100s linear infinite;
}

.planet {
  position: absolute;
  border-radius: 50%;
  opacity: 0.8;
}

.planet-1 {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #ff7e5f, #feb47b);
  top: 10%;
  right: -40px;
  box-shadow: 0 0 40px rgba(255, 126, 95, 0.4);
  animation: float 20s ease-in-out infinite;
}

.planet-2 {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  bottom: 15%;
  left: -20px;
  box-shadow: 0 0 30px rgba(79, 172, 254, 0.4);
  animation: float 25s ease-in-out infinite reverse;
}

.nebula {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.15), transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.1), transparent 50%);
  filter: blur(40px);
}

@keyframes starMove {
  from { background-position: 0 0; }
  to { background-position: 550px 550px; }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

/* Layout & Glass Panel */
.app-container {
  width: min(600px, 100%);
  position: relative;
  z-index: 1;
}

.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 2rem;
  color: var(--text-light);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Landing Page Styles */
.hero-section {
  text-align: center;
  margin-bottom: 2.5rem;
}

.badge-pill {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-glow);
  margin-bottom: 1rem;
  letter-spacing: 0.5px;
}

.main-title {
  font-family: var(--font-heading);
  font-size: 3rem;
  line-height: 1.1;
  margin: 0 0 1rem;
  font-weight: 800;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.highlight {
  background: linear-gradient(135deg, var(--accent), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

/* Section Labels */
.section-label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 0 0 1rem;
  font-weight: 700;
}

/* Difficulty Selector */
.difficulty-selector {
  margin-bottom: 2rem;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.diff-card {
  position: relative;
  cursor: pointer;
}

.diff-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.diff-content {
  background: var(--glass);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 1rem 0.5rem;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.diff-card .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
  transition: transform 0.2s ease;
}

.diff-card .name {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.diff-card .desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Active State */
.diff-card input:checked + .diff-content {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  transform: translateY(-4px);
}

.diff-card input:checked + .diff-content .icon {
  transform: scale(1.2);
}

/* Primary Button */
.btn-primary {
  width: 100%;
  padding: 1.2rem;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary:active {
  transform: scale(0.98);
}

.shimmer-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: skewX(-20deg);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}

/* Leaderboard Mini */
.leaderboard-mini {
  margin-top: 2rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.lb-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--accent-glow);
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.5rem;
}

.lb-list {
  padding: 0;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem;
  background: var(--glass);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.leaderboard-item span:first-child {
  font-weight: 600;
  color: white;
}

.leaderboard-time {
  color: var(--accent);
  font-family: var(--font-heading);
  font-weight: 700;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1rem;
  margin: 0;
}

/* GAME PAGE STYLES */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-icon-text {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-text:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  border-color: var(--text-light);
  color: var(--text-light);
}

.game-info .mini-title {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.badges {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-glow);
  border-radius: 4px;
  font-weight: 700;
}

.level-badge {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary-glow);
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.stat-item {
    background: rgba(0,0,0,0.2);
    flex: 1;
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.stat-item .value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: white;
}

/* Question Area */
.game-display {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.question-container {
  text-align: center;
}

.question-box {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.1);
}

#questionText {
  font-size: 3.5rem;
  margin: 0;
  font-family: var(--font-heading);
  background: linear-gradient(135deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.2));
}

.status-msg {
    min-height: 1.5rem;
    color: var(--text-dim);
    font-size: 1rem;
    margin: 0;
}

.status-msg.ok { color: var(--success); font-weight: 700; }
.status-msg.err { color: var(--error); font-weight: 700; }

/* Timer & Progress */
.timer-container {
    background: rgba(0,0,0,0.2);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
}

.timer-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-light);
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    width: 0%; /* JS will control this */
    transition: width 0.3s ease, background 0.3s ease;
}

.progress-fill.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.progress-fill.danger { background: linear-gradient(90deg, #f87171, #ef4444); }

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.option-btn {
    border: none;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 1.2rem 0;
    font-size: 1.8rem;
    font-family: var(--font-heading);
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.option-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 6px 0 rgba(0,0,0,0.2), 0 0 20px rgba(139, 92, 246, 0.4);
}

.option-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 0 0 rgba(0,0,0,0.2);
}

.option-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal-content {
    width: min(400px, 100%);
    text-align: center;
    border: 2px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    background: radial-gradient(circle at top, #2e1065, #0f172a);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 1s infinite;
}

.result-text {
    font-size: 1.2rem;
    color: var(--accent-glow);
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.custom-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.3);
    color: white;
    font-size: 1rem;
    font-family: var(--font-body);
}

.custom-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

.full-width {
    width: 100%;
}

.error-msg {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 0.4rem;
    min-height: 1.2em;
}

#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .glass-panel {
        padding: 1.5rem;
    }
    
    .difficulty-grid {
        gap: 0.5rem;
    }
    
    .diff-content {
        padding: 0.8rem 0.2rem;
    }
    
    .diff-card .icon {
        font-size: 1.5rem;
    }
    
    .main-title {
        font-size: 2.2rem;
    }
    
    .stats-bar {
        gap: 0.5rem;
    }
    
    .stat-item .value {
        font-size: 1.1rem;
    }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
