* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --accent: #06b6d4;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
              radial-gradient(ellipse at bottom right, rgba(6, 182, 212, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-icon {
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Cards */
.card {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.welcome-card {
  max-width: 500px;
  text-align: center;
}

.welcome-icon {
  width: 100px;
  height: 100px;
  background: var(--gradient);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 48px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.welcome-card h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.welcome-card p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 1.1rem;
}

.input-group {
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  text-align: left;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-group input {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.3s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.options-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.toggle-option {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-option:hover {
  border-color: var(--primary);
}

.toggle-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.toggle-option span {
  font-size: 0.9rem;
}

/* Quiz Header */
.quiz-header {
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.quiz-header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.timer.warning { color: var(--warning); }
.timer.danger { color: var(--error); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.progress-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-text {
  font-weight: 600;
  color: var(--text-muted);
}

.progress-bar {
  width: 200px;
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Quiz Content */
.quiz-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 40px 20px;
}

.question-card {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.unit-badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.question-number {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.question-text {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 32px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-card:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.option-card.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.15);
}

.option-card.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
}

.option-card.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.15);
}

.option-card.disabled {
  cursor: default;
  opacity: 0.7;
}

.option-letter {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.option-card.selected .option-letter {
  background: var(--primary);
}

.option-card.correct .option-letter {
  background: var(--success);
}

.option-card.incorrect .option-letter {
  background: var(--error);
}

.option-text {
  flex: 1;
  font-size: 1rem;
}

.option-icon {
  font-size: 1.2rem;
}

/* Navigation */
.quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* Results Screen */
.results-screen {
  min-height: 100vh;
  padding: 40px 20px;
}

.results-card {
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}

.results-icon {
  font-size: 80px;
  margin-bottom: 20px;
}

.results-card h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.results-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 40px;
}

.score-display {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.score-item {
  padding: 24px 40px;
  background: var(--bg-dark);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.score-value {
  font-size: 3rem;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-item {
  padding: 16px;
  background: var(--bg-dark);
  border-radius: 12px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-value.correct { color: var(--success); }
.stat-value.incorrect { color: var(--error); }
.stat-value.time { color: var(--accent); }

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.results-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

/* Review Section */
.review-section {
  margin-top: 40px;
  text-align: left;
}

.review-section h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  text-align: center;
}

.review-filters {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover, .filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-item {
  padding: 20px;
  background: var(--bg-dark);
  border-radius: 14px;
  border-left: 4px solid var(--border);
}

.review-item.correct { border-left-color: var(--success); }
.review-item.incorrect { border-left-color: var(--error); }

.review-question {
  font-weight: 600;
  margin-bottom: 12px;
}

.review-answer {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.review-answer span { font-weight: 600; }
.review-answer .correct { color: var(--success); }
.review-answer .incorrect { color: var(--error); }

/* Leaderboard */
.leaderboard-screen {
  min-height: 100vh;
  padding: 40px 20px;
}

.leaderboard-card {
  max-width: 700px;
  margin: 0 auto;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 16px;
}

.leaderboard-header h1 {
  font-size: 2rem;
  display: flex;
  align-items: center;
  gap: 12px;
}

.leaderboard-actions {
  display: flex;
  gap: 10px;
}

.leaderboard-table {
  background: var(--bg-dark);
  border-radius: 16px;
  overflow: hidden;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr 100px 140px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.leaderboard-row.header {
  background: var(--bg-card);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.leaderboard-row.current-user {
  background: rgba(99, 102, 241, 0.15);
  border-left: 4px solid var(--primary);
}

.leaderboard-row:last-child { border-bottom: none; }

.rank {
  font-weight: 700;
  font-size: 1.1rem;
}

.rank.gold { color: #fbbf24; }
.rank.silver { color: #9ca3af; }
.rank.bronze { color: #d97706; }

.player-name {
  font-weight: 500;
}

.player-score {
  font-weight: 700;
  color: var(--accent);
}

.player-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.empty-leaderboard {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-leaderboard span {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal h2 {
  margin-bottom: 12px;
}

.modal p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .welcome-card h1 { font-size: 1.8rem; }
  .question-text { font-size: 1.2rem; }
  .quiz-header-content { justify-content: center; }
  .progress-bar { width: 120px; }
  .score-display { gap: 20px; }
  .score-item { padding: 20px 30px; }
  .score-value { font-size: 2.2rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .leaderboard-row { grid-template-columns: 50px 1fr 80px; }
  .player-date { display: none; }
}

@media (max-width: 480px) {
  .card { padding: 24px 20px; }
  .quiz-nav { flex-direction: column; gap: 12px; }
  .quiz-nav .btn { width: 100%; }
  .options-row { flex-direction: column; }
}
