:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --primary: #38bdf8;
  --primary-dim: #0ea5e9;
  --success: #4ade80;
  --error: #f87171;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 1rem;
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.header-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.header-link:hover {
  background: var(--surface);
}
.header-link.install-btn {
  background: var(--primary);
  color: var(--bg);
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.header-link.install-btn:hover {
  filter: brightness(1.1);
}
.header-link.hidden {
  display: none !important;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition);
}
.icon-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.05);
}
.icon-btn.muted .icon { opacity: 0.5; }

/* Main */
.main {
  flex: 1;
  max-width: 56rem;
  margin: 0 auto;
  width: 100%;
  padding: 1rem;
}

/* Stats card + footer dans la carte */
.stats-card {
  margin-top: 1rem;
}
.stats-footer {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}
.stats-footer a {
  color: var(--primary);
  text-decoration: none;
}
.stats-footer a:hover {
  text-decoration: underline;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.4s ease;
}
.screen.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Home */
.hero {
  text-align: center;
  margin-bottom: 2rem;
}
.hero-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.2));
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  50% { opacity: 0.9; }
}
.hero h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}
.hero p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.search-wrap {
  margin-bottom: 1.25rem;
  position: relative;
}
.search-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--transition);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
}
.search-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  padding-left: 0.1rem;
}
.abreviations-card-wrap {
  margin-bottom: 1rem;
}
.abreviations-card-wrap:not(.hidden) {
  display: block !important;
}
.abreviations-card-wrap.hidden {
  display: none !important;
}
.search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
}
.no-results.hidden,
.categories.hidden {
  display: none !important;
}
.install-ios-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.install-ios-banner.hidden {
  display: none !important;
}
.install-ios-dismiss {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
  transition: background var(--transition);
}
.install-ios-dismiss:hover {
  background: var(--surface-hover);
}

.categories {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.category-card {
  display: block;
  padding: 1.25rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: inherit;
}
.category-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.category-card:active {
  transform: translateY(0);
}
.category-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.category-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.category-card .count {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}

.stats-bar {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

/* Quiz */
.quiz-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.back-btn {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: none;
  border-radius: 0.5rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition);
}
.back-btn:hover {
  background: var(--surface-hover);
}
.quiz-progress {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 999px;
  transition: width var(--transition);
}
.quiz-score {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.quiz-score span:first-of-type { color: var(--success); }
.quiz-score span:last-of-type { color: var(--error); }

.quiz-questions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.question-block {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: slideUp 0.35s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.question-block h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.45;
}
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid transparent;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
}
.choice:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(56, 189, 248, 0.4);
}
.choice .radio {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition);
}
.choice.selected .radio {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3);
}
.choice.correct .radio { border-color: var(--success); background: var(--success); }
.choice.wrong .radio { border-color: var(--error); background: var(--error); }
.choice.correct { border-color: var(--success); background: rgba(74, 222, 128, 0.1); }
.choice.wrong { border-color: var(--error); background: rgba(248, 113, 113, 0.1); }
.choice.disabled { pointer-events: none; opacity: 0.8; }

.feedback {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: slideUp 0.35s ease;
}
.feedback.hidden { display: none !important; }
.feedback-content p { margin-bottom: 0.75rem; line-height: 1.5; }
.feedback .explanation {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.feedback.correct .feedback-content { border-left: 4px solid var(--success); padding-left: 1rem; margin-left: -1rem; }
.feedback.wrong .feedback-content { border-left: 4px solid var(--error); padding-left: 1rem; margin-left: -1rem; }

/* Results */
.results-card {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: scaleIn 0.5s ease;
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.results-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 0.6s ease;
}
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
.results-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.results-score {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.results-message {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  border-radius: 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 25px -5px rgba(56, 189, 248, 0.3); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: var(--bg);
}
.btn-primary:active { transform: translateY(0); }

/* Toast */
/* Notification en haut pour ne pas gêner le bouton « Question suivante » */
.toast {
  position: fixed;
  top: 4rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
  max-width: 90vw;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1rem;
  z-index: 90;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  opacity: 0;
  visibility: hidden;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.back-to-top:hover {
  transform: scale(1.05);
}
.back-to-top:active {
  transform: scale(0.98);
}
.back-to-top.hidden {
  display: none !important;
}

/* Confetti placeholder (handled in JS) */
.confetti {
  position: fixed;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
}
