:root {
  /* Brand Colors from Auto-École Taouzar Logo */
  --brand-blue: #0066ee;
  --brand-blue-hover: #1a7eff;
  --brand-orange: #FE6106;
  --brand-orange-hover: #ff7424;
  --brand-navy: #05101c;
  --brand-navy-dark: #081728;
  --brand-navy-card: #0d2138;

  /* Theme Surfaces (Refined Midnight Navy Glassmorphism) */
  --bg-dark: #050d18;
  --bg-header: rgba(5, 14, 26, 0.85);
  --bg-card: rgba(13, 27, 46, 0.75);
  --bg-card-hover: rgba(18, 38, 64, 0.88);
  --bg-elevated: rgba(19, 41, 70, 0.82);
  --bg-subtle: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.085);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-highlight: rgba(255, 255, 255, 0.15);

  /* Primary & Accents */
  --primary: var(--brand-blue);
  --primary-hover: var(--brand-blue-hover);
  --accent: var(--brand-orange);
  --accent-hover: var(--brand-orange-hover);

  /* Status Colors */
  --success: #047857;
  --success-light: #10b981;
  --error: #e11d48;
  --error-light: #f43f5e;
  --warning: #f59e0b;

  /* Text Colors */
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #8ba2bf;
  --text-dim: #5c7491;

  /* Shadows & Radius System */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 9999px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.55);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);

  /* Motion Curves (Emil Kowalski Craft Standards) */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --duration-fast: 160ms;
  --duration-normal: 240ms;

  /* Keypad Hardware Controller Tokens */
  --keypad-bg: #071424;
  --keypad-chassis: linear-gradient(180deg, #0c1c30 0%, #06111e 100%);
  --keypad-bezel: #173254;
  --keypad-display: #030a13;
  --keypad-display-border: #143050;
  --keypad-display-text: #00e5ff;
  --keypad-btn-bg: linear-gradient(180deg, #132b49 0%, #0d1e34 100%);
  --keypad-btn-border: #1d406a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html[dir="rtl"],
html[dir="rtl"] * {
  font-family: 'CodeFont', 'Tajawal', 'Cairo', system-ui, -apple-system, sans-serif;
}

html[dir="ltr"],
html[dir="ltr"] * {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  direction: inherit;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 12%, rgba(1, 111, 252, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 90% 88%, rgba(254, 97, 6, 0.09) 0%, transparent 48%),
    radial-gradient(circle at 50% 50%, rgba(8, 25, 46, 0.6) 0%, transparent 100%);
  background-attachment: fixed;
}

/* Header */
header {
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.45);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  cursor: pointer;
  user-select: none;
  transition: transform 200ms var(--ease-spring);
}

.logo-container:hover {
  transform: scale(1.02);
}

.logo-container:active {
  transform: scale(0.99);
}

.logo-img {
  height: 46px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 10px rgba(1, 111, 252, 0.35));
}

.logo-text-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
  font-family: system-ui, -apple-system, sans-serif;
}

.logo-subtitle {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ff8533;
  letter-spacing: 0.02em;
}

.logo-badge {
  background: #c2410c;
  color: #ffffff;
  font-size: 0.72rem;
  padding: 3px 11px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  align-self: center;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.flag-svg {
  display: inline-block;
  vertical-align: middle;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

/* Bilingual Language Switcher */
.lang-switch-group {
  display: inline-flex;
  align-items: center;
  background: rgba(9, 21, 37, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 3px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.25);
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border: 1px solid transparent;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms var(--ease-spring), color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  user-select: none;
}

.lang-btn .flag-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.lang-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.lang-btn:active {
  transform: scale(0.96);
}

.lang-btn.active {
  background: linear-gradient(135deg, var(--brand-blue) 0%, #0056c7 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Hero Bilingual Quick-Toggle Bar */
.hero-lang-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.35rem;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.hero-lang-prompt {
  font-size: 0.88rem;
  font-weight: 800;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hero-lang-options {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.hero-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  padding: 8px 16px;
  background: rgba(10, 22, 38, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform 180ms var(--ease-spring), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  text-align: start;
  color: #cbd5e1;
  user-select: none;
}

.hero-lang-btn:hover {
  background: rgba(18, 38, 64, 0.95);
  border-color: rgba(1, 111, 252, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  color: #ffffff;
}

.hero-lang-btn:active {
  transform: scale(0.98);
}

.hero-lang-btn.active {
  background: linear-gradient(135deg, rgba(1, 111, 252, 0.28) 0%, rgba(0, 78, 180, 0.38) 100%);
  border: 1px solid #016ffc;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.hero-lang-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-lang-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.hero-lang-desc {
  font-size: 0.74rem;
  font-weight: 600;
  color: #94a3b8;
  line-height: 1.2;
}

.hero-lang-btn.active .hero-lang-desc {
  color: #bfdbfe;
}

/* Series Section Language Toggle */
.series-lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(10, 22, 38, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  padding: 3px 6px 3px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[dir="ltr"] .series-lang-toggle {
  padding: 3px 12px 3px 6px;
}

.series-lang-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #94a3b8;
}

.brand-pill-badge {
  background: rgba(1, 111, 252, 0.08);
  border: 1px solid rgba(1, 111, 252, 0.28);
  color: #9bc8ff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.btn {
  background-color: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: transform 160ms var(--ease-spring), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  user-select: none;
}

.btn:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-blue) 0%, #0056c7 100%);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1b7fff 0%, #0056c7 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-accent {
  background: linear-gradient(135deg, var(--brand-orange) 0%, #e55200 100%);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-accent:hover {
  background: linear-gradient(135deg, #ff7424 0%, #d84d00 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.btn-danger {
  background: linear-gradient(135deg, var(--error) 0%, #be123c 100%);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--error-light) 0%, #e11d48 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Container */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  width: 100%;
}

/* Home / Series Screen */
.home-screen {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.hero-banner {
  background: 
    radial-gradient(ellipse at 85% 15%, rgba(1, 111, 252, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse at 15% 90%, rgba(254, 97, 6, 0.15) 0%, transparent 50%),
    linear-gradient(135deg, #07172b 0%, #0a2544 50%, #061527 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2.5rem 2.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -40%;
  inset-inline-end: -15%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(254, 97, 6, 0.1) 0%, transparent 65%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-brand-pill {
  background: rgba(254, 97, 6, 0.14);
  border: 1px solid rgba(254, 97, 6, 0.4);
  color: #ff9d5c;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.hero-brand-icon {
  height: 20px;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.hero-content h1 {
  font-size: 2.2rem;
  margin-bottom: 0.65rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -0.4px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.hero-content p {
  color: #cfe1f7;
  font-size: 1.05rem;
  max-width: 660px;
  line-height: 1.65;
}

.hero-stats {
  display: flex;
  gap: 1.25rem;
  z-index: 1;
}

.stat-box {
  background: transparent;
  border-inline-start: 2px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.4rem;
  text-align: center;
  min-width: 120px;
  transition: transform 200ms var(--ease-spring), border-color 200ms ease;
}

.stat-box:hover {
  transform: translateY(-2px);
  border-color: rgba(254, 97, 6, 0.6);
}

.stat-number {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--brand-orange);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.82rem;
  color: #cbd5e1;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.series-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.series-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #ffffff;
  border-inline-start: 4px solid var(--brand-orange);
  padding-inline-start: 0.85rem;
}

.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.95rem;
}

.serie-card {
  background: linear-gradient(180deg, rgba(14, 30, 52, 0.75) 0%, rgba(7, 17, 30, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 1.1rem 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: transform 180ms var(--ease-spring), border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  user-select: none;
}

.serie-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.serie-card-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.25rem;
  margin-bottom: 0.15rem;
}

.serie-category-tag {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--brand-orange);
  background: rgba(254, 97, 6, 0.12);
  border: 1px solid rgba(254, 97, 6, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
}

.serie-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.serie-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(254, 97, 6, 0.65);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, rgba(20, 42, 72, 0.88) 0%, rgba(10, 24, 42, 0.95) 100%);
}

.serie-card:active {
  transform: translateY(-1px) scale(0.99);
}

.serie-card:hover .serie-number {
  color: var(--brand-orange);
}

.serie-number {
  font-size: 1.85rem;
  font-weight: 900;
  color: #fff;
  transition: color 160ms ease;
  line-height: 1.1;
}

.serie-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.serie-badge {
  background-color: rgba(1, 111, 252, 0.12);
  border: 1px solid rgba(1, 111, 252, 0.28);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  color: #9ac7ff;
  display: inline-block;
  margin-top: 0.25rem;
  transition: all 160ms ease;
}

.serie-card.completed .serie-status-dot {
  background: #10b981;
}

.serie-card.completed.passed {
  border-color: rgba(16, 185, 129, 0.45);
}

.serie-card.completed.passed:hover {
  border-color: rgba(16, 185, 129, 0.8);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.serie-card.completed.passed .serie-badge {
  background-color: rgba(5, 150, 105, 0.22);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

.serie-card.completed.failed {
  border-color: rgba(244, 63, 94, 0.45);
}

.serie-card.completed.failed .serie-badge {
  background-color: rgba(225, 29, 72, 0.22);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

/* Modals & Dialog System */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(3, 10, 20, 0.78);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 1.25rem;
  animation: modalFadeIn 200ms var(--ease-out);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: linear-gradient(180deg, rgba(16, 35, 62, 0.95) 0%, rgba(8, 20, 36, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.85);
  animation: modalScaleIn 220ms var(--ease-spring);
  position: relative;
}

@keyframes modalScaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  transition: transform 160ms var(--ease-spring), color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.modal-close:hover {
  color: #fff;
  background-color: rgba(225, 29, 72, 0.25);
  border-color: rgba(244, 63, 94, 0.6);
  transform: rotate(90deg);
}

.modal-close:active {
  transform: scale(0.92);
}

.form-group {
  margin-bottom: 1.35rem;
}

.form-group label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.55rem;
  color: #cfe1f7;
}

.select-control {
  width: 100%;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  background: rgba(5, 14, 26, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  appearance: auto;
}

.select-control:focus {
  border-color: var(--brand-blue);
  outline: 2px solid var(--brand-blue);
  outline-offset: 1px;
}

/* Test / Question Screen */
.test-screen {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.test-top-bar {
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.badge-qnum {
  background: rgba(8, 20, 36, 0.85);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.5rem 1.35rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  letter-spacing: -0.2px;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.audio-controls .btn {
  background: rgba(1, 111, 252, 0.1);
  border: 1px solid rgba(1, 111, 252, 0.32);
  color: #9ac7ff;
  border-radius: var(--radius-pill);
  padding: 0.45rem 1.15rem;
  font-size: 0.9rem;
}

.audio-controls .btn:hover {
  background: rgba(1, 111, 252, 0.2);
  border-color: rgba(1, 111, 252, 0.6);
  color: #ffffff;
}

.audio-controls .btn:active {
  transform: scale(0.96);
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.1rem;
  background: rgba(1, 111, 252, 0.1);
  color: #8bc3ff;
  padding: 0.45rem 1.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(1, 111, 252, 0.32);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 200ms ease;
}

.timer-box.urgent {
  background: rgba(225, 29, 72, 0.25);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.75);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#btn-exit-test {
  background: rgba(225, 29, 72, 0.1);
  border: 1px solid rgba(225, 29, 72, 0.32);
  color: #fda4af;
  border-radius: var(--radius-pill);
  padding: 0.45rem 1.15rem;
  font-size: 0.9rem;
}

#btn-exit-test:hover {
  background: rgba(225, 29, 72, 0.22);
  border-color: rgba(244, 63, 94, 0.6);
  color: #ffffff;
}

#btn-exit-test:active {
  transform: scale(0.96);
}

/* Test Layout: Photo + Question on Right/Center, Keypad on Left */
.test-body {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .test-body {
    grid-template-columns: 1fr;
  }
}

.question-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.photo-wrapper {
  background: radial-gradient(circle at center, #091626 0%, #030811 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 310px;
  max-height: 480px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.question-photo {
  width: 100%;
  height: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  height: 320px;
}

.question-content {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: var(--shadow-glass);
}

.qpart {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.qpart-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.6;
  border-inline-start: 4px solid var(--brand-orange);
  padding-inline-start: 1rem;
  letter-spacing: -0.2px;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.95rem;
}

.choice-card {
  background: linear-gradient(180deg, rgba(19, 41, 70, 0.72) 0%, rgba(11, 25, 44, 0.82) 100%);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 1.05rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: transform 150ms var(--ease-spring), border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.choice-card:hover {
  background: linear-gradient(180deg, rgba(24, 52, 88, 0.85) 0%, rgba(15, 33, 58, 0.92) 100%);
  border-color: rgba(1, 111, 252, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.choice-card:active {
  transform: scale(0.985);
}

.choice-badge {
  background: rgba(5, 13, 24, 0.9);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.15rem;
  font-weight: 900;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: all 150ms ease;
}

.choice-text {
  font-size: 1.08rem;
  font-weight: 700;
  color: #f8fafc;
  flex: 1;
  line-height: 1.45;
}

.choice-card.selected {
  background: linear-gradient(180deg, rgba(1, 111, 252, 0.22) 0%, rgba(0, 77, 179, 0.3) 100%);
  border-color: var(--brand-blue);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.choice-card.selected .choice-badge {
  background: linear-gradient(135deg, var(--brand-blue) 0%, #0056c7 100%);
  border-color: #8ec3ff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Instant correction states */
.choice-card.correct {
  background: rgba(5, 150, 105, 0.25) !important;
  border-color: var(--success-light) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5) !important;
}

.choice-card.correct .choice-badge {
  background: var(--success) !important;
  border-color: #6ee7b7 !important;
}

.choice-card.wrong {
  background: rgba(225, 29, 72, 0.25) !important;
  border-color: var(--error-light) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5) !important;
}

.choice-card.wrong .choice-badge {
  background: var(--error) !important;
  border-color: #fda4af !important;
}

/* Authentic Moroccan Driving Simulator Keypad Panel */
.keypad-panel {
  background: linear-gradient(180deg, #0e2037 0%, #071322 100%);
  border: 2px solid #1a385f;
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65), 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  position: sticky;
  top: 90px;
}

.keypad-screen {
  background-color: var(--keypad-display);
  color: var(--keypad-display-text);
  border-radius: var(--radius-md);
  height: 62px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'SF Mono', 'Courier New', monospace, sans-serif;
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 6px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.85);
  border: 2px solid #143050;
}

.keypad-clear {
  width: 100%;
  padding: 0.95rem;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #e11d48 0%, #9f1239 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  box-shadow: 0 3px 0 #6b0c25, 0 6px 14px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 100ms var(--ease-spring), background 100ms ease, box-shadow 100ms ease;
  user-select: none;
}

.keypad-clear:hover {
  background: linear-gradient(180deg, #f43f5e 0%, #be123c 100%);
}

.keypad-clear:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #6b0c25, 0 2px 4px rgba(0, 0, 0, 0.35);
}

.keypad-choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.key-btn {
  background: linear-gradient(180deg, #17355a 0%, #0e223a 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  font-size: 1.6rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 100ms var(--ease-spring), background 100ms ease, box-shadow 100ms ease, border-color 100ms ease;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 3px 0 #081525, 0 6px 12px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.key-btn:hover {
  background: linear-gradient(180deg, #1d4372 0%, #122b49 100%);
  border-color: rgba(1, 111, 252, 0.6);
}

.key-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #081525, 0 2px 4px rgba(0, 0, 0, 0.4);
}

.key-btn.active {
  background: linear-gradient(180deg, #016FFC 0%, #004fb8 100%);
  border-color: #8ec3ff;
  color: #fff;
  box-shadow: 0 3px 0 #003680, 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.keypad-validate {
  width: 100%;
  padding: 1.05rem;
  font-size: 1.25rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #059669 0%, #065f46 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  box-shadow: 0 3px 0 #023829, 0 6px 14px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 100ms var(--ease-spring), background 100ms ease, box-shadow 100ms ease;
  user-select: none;
}

.keypad-validate:hover {
  background: linear-gradient(180deg, #10b981 0%, #047857 100%);
}

.keypad-validate:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #023829, 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* Explanation Box */
.explication-box {
  background: rgba(1, 111, 252, 0.09);
  border: 1px solid rgba(1, 111, 252, 0.32);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.explication-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #9ac7ff;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.explication-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: #e2eeff;
}

/* Results Screen */
.results-screen {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.score-banner {
  border-radius: var(--radius-xl);
  padding: 3rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.65);
  position: relative;
  overflow: hidden;
}

.score-banner.pass {
  background: 
    radial-gradient(circle at 50% 15%, rgba(16, 185, 129, 0.28) 0%, transparent 65%),
    linear-gradient(135deg, #053325 0%, #044b36 50%, #02241a 100%);
  border: 1px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.score-banner.fail {
  background: 
    radial-gradient(circle at 50% 15%, rgba(225, 29, 72, 0.28) 0%, transparent 65%),
    linear-gradient(135deg, #3d0916 0%, #540e20 50%, #29050e 100%);
  border: 1px solid rgba(244, 63, 94, 0.5);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.score-value {
  font-size: 4.8rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  direction: ltr;
  display: inline-block;
}

.score-banner.pass .score-value {
  color: #ffffff;
}

.score-banner.fail .score-value {
  color: #ffffff;
}

.score-status {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.3px;
}

.score-banner.pass .score-status {
  color: #34d399;
}

.score-banner.fail .score-status {
  color: #fb7185;
}

.score-sub {
  font-size: 1.15rem;
  color: #dbeafe;
  max-width: 620px;
  line-height: 1.6;
}

.score-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.75rem;
}

.grid-title {
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #ffffff;
  border-left: 4px solid var(--brand-blue);
  border-inline-start: 4px solid var(--brand-blue);
  padding: 0.25rem 0.85rem;
  padding-inline-start: 0.85rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 0.85rem;
}

.result-badge {
  height: 70px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-weight: 900;
  cursor: pointer;
  transition: transform 160ms var(--ease-spring), box-shadow 160ms ease;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  user-select: none;
}

.result-badge:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.result-badge:active {
  transform: scale(0.97);
}

.result-badge.correct {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  color: #fff;
  border-color: rgba(52, 211, 153, 0.4);
}

.result-badge.wrong {
  background: linear-gradient(180deg, #e11d48 0%, #be123c 100%);
  color: #fff;
  border-color: rgba(251, 113, 133, 0.4);
}

.result-badge .rb-num {
  font-size: 1.35rem;
  line-height: 1.1;
}

.result-badge .rb-icon {
  font-size: 0.85rem;
  margin-top: 2px;
}

/* Question Inspector Modal */
.inspector-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: 80vh;
  overflow-y: auto;
  padding-inline-end: 4px;
}

.inspector-img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  background: #030811;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.inspector-qnum-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  border-inline-start: 4px solid var(--brand-orange);
  padding-inline-start: 0.75rem;
}

.inspector-parts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inspector-part-text {
  font-weight: 700;
  color: #8bc3ff;
  font-size: 1.05rem;
}

.inspector-choices {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.inspector-choice {
  background: rgba(14, 30, 52, 0.85);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 0.95rem;
}

.inspector-choice.is-correct {
  border-color: #10b981;
  background: rgba(5, 150, 105, 0.22);
}

.inspector-choice.is-wrong {
  border-color: #f43f5e;
  background: rgba(225, 29, 72, 0.22);
}

.tag-correct {
  color: #34d399;
  font-weight: 800;
  margin-inline-start: 4px;
}

.tag-wrong {
  color: #fda4af;
  font-weight: 800;
  margin-inline-start: 4px;
}

.comparison-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.ans-box {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ans-box.user {
  background: rgba(14, 30, 52, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ans-box.correct {
  background: rgba(5, 150, 105, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.ans-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.ans-val {
  font-size: 1.45rem;
  font-weight: 900;
}
