/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:        #1e1b4b;
  --bg-card:   rgba(255, 255, 255, 0.06);
  --bg-card-2: rgba(255, 255, 255, 0.10);
  --primary:   #4f46e5;
  --primary-h: #4338ca;
  --violet:    #7c3aed;
  --accent:    #fb923c;
  --success:   #22c55e;
  --error:     #ef4444;
  --text:      #f8fafc;
  --text-muted:#a5b4fc;
  --radius:    14px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --timer-h:   6px;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
}

.screen.active {
  display: flex;
}

.screen-content {
  width: 100%;
  max-width: 480px;
  padding: 32px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s, background 0.15s;
  text-align: center;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-h); }

.btn-secondary {
  background: var(--bg-card-2);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
}
.btn-secondary:hover { background: rgba(255,255,255,0.15); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: #fff;
  border: none;
}
.btn-accent:hover { filter: brightness(1.1); }

.btn-share-top {
  width: 100%;
  max-width: 320px;
  font-size: 1.05rem;
  padding: 16px 24px;
}

.btn-large {
  width: 100%;
  max-width: 320px;
  padding: 18px 32px;
  font-size: 1.2rem;
  border-radius: 16px;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

/* ── Home screen ────────────────────────────────────────────────────────────── */
#screen-home {
  background: radial-gradient(ellipse at 50% 0%, #312e81 0%, var(--bg) 70%);
  justify-content: center;
}

.logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(99,102,241,0.5));
  animation: float 3s ease-in-out infinite;
}

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

.logo h1 {
  font-size: 2.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd, #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

/* ── Quiz screen ────────────────────────────────────────────────────────────── */
#screen-quiz {
  background: linear-gradient(180deg, #1e1b4b 0%, #0f0e2e 100%);
}

.quiz-header {
  width: 100%;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(30,27,75,0.95);
  backdrop-filter: blur(8px);
}

.timer-track {
  width: 100%;
  height: var(--timer-h);
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transition: width 0.05s linear, background-color 0.3s;
  transform-origin: left;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.question-card {
  width: 100%;
  max-width: 480px;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.q-media {
  font-size: 80px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.q-text {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  color: var(--text);
}

/* ── Choices ────────────────────────────────────────────────────────────────── */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  padding: 0 16px;
}

.choice-btn {
  padding: 16px 12px;
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice-btn:not(:disabled):hover {
  background: var(--bg-card-2);
  border-color: rgba(99,102,241,0.5);
}

.choice-btn:not(:disabled):active {
  transform: scale(0.97);
}

.choice-btn:disabled { cursor: default; }

.choice-btn.correct {
  background: rgba(34,197,94,0.2);
  border-color: var(--success);
  color: #bbf7d0;
}

.choice-btn.incorrect {
  background: rgba(239,68,68,0.2);
  border-color: var(--error);
  color: #fecaca;
}

/* ── Feedback ───────────────────────────────────────────────────────────────── */
.feedback {
  width: 100%;
  max-width: 480px;
  margin: 8px 16px 0;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.5;
  animation: slideUp 0.2s ease-out;
}

.feedback.hidden { display: none; }

.feedback.correct {
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.4);
  color: #bbf7d0;
}

.feedback.incorrect {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #fecaca;
}

.explication {
  font-weight: 400;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.7);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Results screen ─────────────────────────────────────────────────────────── */
#screen-results,
#screen-compare,
#screen-already-played {
  background: radial-gradient(ellipse at 50% 0%, #312e81 0%, var(--bg) 65%);
}

.results-content {
  padding-top: 28px;
}

.results-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: var(--text);
}

.total-score {
  text-align: center;
}

.total-score span {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #a5b4fc, #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#radar-canvas,
#radar-canvas-compare,
#radar-canvas-ap {
  width: 100% !important;
  max-width: 360px;
  aspect-ratio: 1;
}

/* ── Score breakdown ────────────────────────────────────────────────────────── */
.score-breakdown {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto 100px;
  align-items: center;
  gap: 10px;
}

.score-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.score-value {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

.score-bar-track {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--violet));
  border-radius: 99px;
  transition: width 0.6s ease-out;
}

/* ── Already played / Share box ─────────────────────────────────────────────── */
.share-box {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-box p {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.share-input-row {
  display: flex;
  gap: 8px;
}

.share-input-row input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  padding: 10px 12px;
  min-width: 0;
  outline: none;
}

.share-input-row .btn {
  padding: 10px 16px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ── Divider / utilities ────────────────────────────────────────────────────── */
.text-center { text-align: center; }

.muted {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

/* ── Best score banner ──────────────────────────────────────────────────────── */
.best-score-banner {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(124,58,237,0.2));
  border: 1px solid rgba(165,180,252,0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Notification button ────────────────────────────────────────────────────── */
.btn-notif {
  background: transparent;
  border: 1.5px solid rgba(165,180,252,0.3);
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-notif:hover {
  border-color: var(--primary);
  color: var(--text);
}
.btn-notif.notif-active {
  border-color: var(--success);
  color: var(--success);
  background: rgba(34,197,94,0.08);
}

/* ── PWA install button ─────────────────────────────────────────────────────── */
.btn-install {
  background: transparent;
  border: 1.5px dashed rgba(165,180,252,0.4);
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  transition: border-color 0.2s, color 0.2s;
}
.btn-install:hover {
  border-color: var(--primary);
  color: var(--text);
}

/* ── Encouraging message ────────────────────────────────────────────────────── */
.encouraging-msg {
  width: 100%;
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(251,146,60,0.1));
  border: 1px solid rgba(165,180,252,0.2);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.5;
}

/* ── Wrong answers section ──────────────────────────────────────────────────── */
.wrong-answers-section {
  width: 100%;
}

.section-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

.perfect-score {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--success);
  padding: 12px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: var(--radius);
}

/* ── Wrong answers carousel ─────────────────────────────────────────────────── */
.wrong-carousel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.carousel-counter {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255,255,255,0.07);
  padding: 3px 10px;
  border-radius: 99px;
}

.carousel-slide {
  width: 100%;
  min-height: 120px;
}

.wrong-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: var(--radius);
  padding: 16px;
}

.wrong-media {
  font-size: 36px;
  line-height: 1;
  text-align: center;
}

.wrong-question {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  text-align: center;
}

.wrong-user {
  font-size: 0.85rem;
  color: #fca5a5;
  font-weight: 600;
  text-align: center;
}

.wrong-answer-text {
  font-weight: 800;
  text-decoration: line-through;
}

.wrong-correct {
  font-size: 0.85rem;
  color: #bbf7d0;
  font-weight: 700;
  text-align: center;
}

.wrong-explication {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  font-weight: 400;
  line-height: 1.45;
  text-align: center;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Carousel nav */
.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.carousel-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 50%;
  color: var(--text);
  font-size: 1.5rem;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.carousel-btn:hover {
  background: rgba(255,255,255,0.15);
}

.carousel-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 0.2s, transform 0.2s;
}

.dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

/* ── Come back tomorrow ─────────────────────────────────────────────────────── */
.come-back-msg {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.come-back-icon {
  font-size: 28px;
}

.come-back-msg p {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.come-back-date {
  color: var(--text-muted) !important;
  font-size: 0.85rem !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .choices-grid {
    padding: 0 24px;
  }

  .question-card {
    padding: 32px 24px 20px;
  }

  .feedback {
    margin: 8px 24px 0;
  }
}
