/* ═══════════════════════════════════════════════════════════════
   AXELLE — Modern Quiz App Styles
   Mobile-first, vibrant, fun for teens
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #6C5CE7;
  --primary-dark: #5A4BD1;
  --primary-light: #A29BFE;
  --secondary: #00CEC9;
  --accent: #FD79A8;
  --success: #00B894;
  --danger: #FF6B6B;
  --warning: #FDCB6E;
  --bg: #0F0F23;
  --bg-card: #1A1A3E;
  --bg-card-hover: #242457;
  --text: #FEFEFE;
  --text-muted: #A0A0C0;
  --border: rgba(255,255,255,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ── Screens ──────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes countdown {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 100.53; }
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-lg {
  padding: 18px 32px;
  font-size: 18px;
  width: 100%;
  border-radius: var(--radius-lg);
}
.btn-icon { font-size: 20px; }

/* ══════════════════════════════════════════════
   HOME SCREEN
   ══════════════════════════════════════════════ */
.home-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}
.home-hero { text-align: center; padding: 20px 0; }

/* Big logo on home screen */
.home-logo-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius: 50%;
  margin-bottom: 16px;
  animation: logoEntrance 1s ease forwards;
  filter: drop-shadow(0 0 20px rgba(108, 92, 231, 0.5)) drop-shadow(0 0 60px rgba(253, 121, 168, 0.3));
}
.home-logo-img:hover {
  animation: logoFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(108, 92, 231, 0.7)) drop-shadow(0 0 80px rgba(253, 121, 168, 0.4));
}
@keyframes logoEntrance {
  0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  50% { opacity: 1; transform: scale(1.08) rotate(3deg); }
  70% { transform: scale(0.96) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.03); }
}

/* Small logo on other pages */
.page-logo {
  text-align: center;
  margin-bottom: 8px;
}
.page-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 0 8px rgba(108, 92, 231, 0.4));
  animation: pop 0.4s ease;
}
.page-logo-img.header-logo {
  width: 32px;
  height: 32px;
  vertical-align: middle;
}

.logo-icon {
  font-size: 64px;
  margin-bottom: 12px;
  animation: pop 0.5s ease;
}
.app-title {
  font-size: 42px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}
.app-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin-top: 6px;
}
.home-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.home-stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  border: 1px solid var(--border);
}
.home-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-light);
}
.home-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.home-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ══════════════════════════════════════════════
   QUIZ SCREEN
   ══════════════════════════════════════════════ */
#screen-quiz {
  padding: 12px 16px;
  gap: 0;
}
.quiz-header { margin-bottom: 12px; }
.quiz-progress-bar {
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}
.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}
.quiz-header-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quiz-counter {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}
.quiz-category-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(108, 92, 231, 0.2);
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Timer */
.quiz-timer {
  position: relative;
  width: 44px;
  height: 44px;
}
.timer-ring {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}
.timer-ring-bg {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 3;
}
.timer-ring-fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100.53;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}
.timer-ring-fill.warning { stroke: var(--warning); }
.timer-ring-fill.danger { stroke: var(--danger); }
.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.timer-text.danger { color: var(--danger); }

/* Quiz Body */
.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.3s ease;
}
.question-image-container {
  width: 100%;
  height: 160px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  position: relative;
}
.question-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}
.question-image.loading { opacity: 0.3; }
.question-image-container.hidden { display: none; }
.question-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  padding: 0 4px;
}

/* Options */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-bottom: 20px;
}
.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  font-family: inherit;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  width: 100%;
}
.option-btn:active:not(.disabled) {
  transform: scale(0.98);
}
.option-btn .option-letter {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(108, 92, 231, 0.15);
  color: var(--primary-light);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.option-btn .option-text {
  flex: 1;
  font-weight: 500;
  line-height: 1.3;
}
.option-btn:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}
.option-btn.selected {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.15);
}
.option-btn.selected .option-letter {
  background: var(--primary);
  color: white;
}
.option-btn.correct {
  border-color: var(--success);
  background: rgba(0, 184, 148, 0.12);
  animation: pop 0.3s ease;
}
.option-btn.correct .option-letter {
  background: var(--success);
  color: white;
}
.option-btn.wrong {
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.12);
  animation: shake 0.4s ease;
}
.option-btn.wrong .option-letter {
  background: var(--danger);
  color: white;
}
.option-btn.disabled {
  pointer-events: none;
  opacity: 0.6;
}
.option-btn.disabled.correct {
  opacity: 1;
}

/* ══════════════════════════════════════════════
   RESULT SCREEN
   ══════════════════════════════════════════════ */
#screen-result {
  padding: 20px 16px;
}
.result-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.result-hero {
  text-align: center;
  padding: 30px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  animation: pop 0.5s ease;
}
.result-emoji { font-size: 56px; margin-bottom: 12px; }
.result-score {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-label {
  font-size: 18px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}
.result-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.result-detail-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  border: 1px solid var(--border);
}
.result-detail-value {
  font-size: 20px;
  font-weight: 700;
}
.result-detail-value.green { color: var(--success); }
.result-detail-value.red { color: var(--danger); }
.result-detail-value.blue { color: var(--primary-light); }
.result-detail-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
}

/* Answer Review */
.result-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.result-answer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
  font-size: 14px;
}
.result-answer-item.wrong {
  border-left-color: var(--danger);
}
.result-answer-item.timeout {
  border-left-color: var(--warning);
}
.result-answer-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.result-answer-text {
  flex: 1;
  line-height: 1.3;
}
.result-answer-text small {
  display: block;
  color: var(--text-muted);
  margin-top: 2px;
  font-size: 12px;
}
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
}

/* ══════════════════════════════════════════════
   HISTORY SCREEN
   ══════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-top: 8px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
}
.btn-back {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-back:active { transform: scale(0.95); }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  animation: slideUp 0.3s ease;
}
.history-score-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.history-score-circle.great {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
  border: 2px solid var(--success);
}
.history-score-circle.good {
  background: rgba(108, 92, 231, 0.15);
  color: var(--primary-light);
  border: 2px solid var(--primary-light);
}
.history-score-circle.ok {
  background: rgba(253, 203, 110, 0.15);
  color: var(--warning);
  border: 2px solid var(--warning);
}
.history-score-circle.bad {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 2px solid var(--danger);
}
.history-info { flex: 1; }
.history-info-score {
  font-weight: 600;
  font-size: 15px;
}
.history-info-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.history-info-time {
  font-size: 12px;
  color: var(--text-muted);
}
.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 15px;
}
.history-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ══════════════════════════════════════════════
   PROGRESS SCREEN
   ══════════════════════════════════════════════ */
.progress-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}
.stats-overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-card-value {
  font-size: 28px;
  font-weight: 800;
}
.stat-card-value.purple { color: var(--primary-light); }
.stat-card-value.green { color: var(--success); }
.stat-card-value.pink { color: var(--accent); }
.stat-card-value.blue { color: var(--secondary); }
.stat-card-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-top: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Category bars */
.category-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.category-bar-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--border);
}
.category-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.category-bar-name {
  font-weight: 600;
  font-size: 14px;
}
.category-bar-pct {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-light);
}
.category-bar-track {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.category-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

/* Score chart */
.score-chart {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}
.score-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  margin-top: 12px;
}
.score-chart-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.4s ease;
  position: relative;
}
.score-chart-bar.great { background: var(--success); }
.score-chart-bar.good { background: var(--primary); }
.score-chart-bar.ok { background: var(--warning); }
.score-chart-bar.bad { background: var(--danger); }
.score-chart-bar-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}
.progress-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Category Colors ──────────────────────────── */
.cat-maths { background: rgba(108, 92, 231, 0.2); color: #A29BFE; }
.cat-histoire { background: rgba(253, 203, 110, 0.2); color: #FDCB6E; }
.cat-geographie { background: rgba(0, 206, 201, 0.2); color: #00CEC9; }
.cat-sciences { background: rgba(0, 184, 148, 0.2); color: #00B894; }
.cat-art { background: rgba(253, 121, 168, 0.2); color: #FD79A8; }
.cat-actualites { background: rgba(116, 185, 255, 0.2); color: #74B9FF; }
.cat-nature { background: rgba(85, 239, 196, 0.2); color: #55EFC4; }
.cat-insolites { background: rgba(255, 118, 117, 0.2); color: #FF7675; }
.cat-images { background: rgba(129, 236, 236, 0.2); color: #81ECEC; }
.cat-culturepop { background: rgba(225, 112, 85, 0.2); color: #E17055; }

/* ── Image Options (flags, logos) ─────────── */
.options-grid.image-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.option-btn-image {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 130px;
}
.option-btn-image .option-letter {
  margin-bottom: 8px;
}
.option-btn-image .option-img {
  width: 100%;
  max-width: 120px;
  max-height: 80px;
  object-fit: contain;
  border-radius: 6px;
}
