/* ========================================================
   MCQ Practice Platform - Responsive Mobile-First Design
   Color Scheme: Navy Blue, Green, Red & White
   ======================================================== */

:root {
  /* Core Colors */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-muted: #f1f5f9;
  --bg-hover: #e2e8f0;

  /* Navy Palette */
  --navy-dark: #091428;
  --navy-primary: #1e3a8a;
  --navy-hover: #172554;
  --navy-light: #eff6ff;
  --navy-border: #cbd5e1;

  /* Green Palette */
  --green-primary: #15803d;
  --green-accent: #16a34a;
  --green-light: #ecfdf5;
  --green-border: #86efac;

  /* Red Palette */
  --red-primary: #dc2626;
  --red-accent: #ef4444;
  --red-light: #fef2f2;
  --red-border: #fca5a5;

  /* Text Colors */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;

  /* Radii & Shadows */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);

  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-urdu: 'Noto Nastaliq Urdu', Tahoma, Arial, sans-serif;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.rtl-text {
  direction: rtl;
  text-align: right;
  font-family: var(--font-urdu);
  line-height: 2.2;
}

.text-navy { color: var(--navy-primary) !important; }
.text-green { color: var(--green-primary) !important; }
.text-red { color: var(--red-primary) !important; }
.bg-navy-light { background-color: var(--navy-light) !important; }
.bg-green-light { background-color: var(--green-light) !important; }
.bg-red-light { background-color: var(--red-light) !important; }

.hidden { display: none !important; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

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

/* ========================================================
   HEADER BAR
   ======================================================== */
.app-header {
  background-color: var(--navy-dark);
  color: var(--text-white);
  min-height: 64px;
  display: flex;
  align-items: center;
  border-bottom: 3px solid var(--green-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background-color: var(--green-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  display: block;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.725rem;
  color: #94a3b8;
  display: block;
}

.quick-stats-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  font-size: 0.775rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background-color: var(--green-accent);
}

/* ========================================================
   HERO BANNER & SETTINGS TOOLBAR
   ======================================================== */
.hero-banner {
  background-color: #ffffff;
  border-bottom: 1px solid var(--navy-border);
  padding: 2rem 0 1.75rem;
}

.hero-container {
  text-align: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.85rem;
  background-color: var(--navy-light);
  color: var(--navy-primary);
  font-size: 0.775rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  margin-bottom: 0.65rem;
}

.hero-title {
  font-size: clamp(1.4rem, 4.5vw, 2.25rem);
  font-weight: 800;
  color: var(--navy-dark);
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero-subtitle {
  font-size: clamp(0.875rem, 2.5vw, 1rem);
  color: var(--text-muted);
  max-width: 650px;
  margin: 0 auto 1.5rem;
  padding: 0 0.5rem;
}

.quick-config-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-muted);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-lg);
  max-width: 850px;
  margin: 0 auto;
}

.config-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy-dark);
}

.custom-select {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--navy-border);
  background-color: #fff;
  color: var(--navy-dark);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  min-height: 38px;
}

.custom-select:focus {
  border-color: var(--navy-primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.85rem;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--navy-primary);
}

/* ========================================================
   SUBJECTS & CHAPTERS LIST
   ======================================================== */
.main-content-container {
  padding-top: 1.75rem;
  padding-bottom: 3.5rem;
}

.subjects-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.subject-block {
  background-color: var(--bg-card);
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}

.subject-block:hover {
  border-color: var(--navy-primary);
}

.subject-block-header {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-primary) 100%);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.subj-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.subj-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.subj-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.subj-summary-meta {
  font-size: 0.8rem;
  color: #cbd5e1;
}

.subj-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-practice-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-full);
  background-color: var(--green-primary);
  color: #fff;
  border: none;
  font-family: var(--font-main);
  font-size: 0.825rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(21, 128, 61, 0.3);
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-practice-all:hover, .btn-practice-all:active {
  background-color: var(--green-accent);
  transform: translateY(-1px);
}

.chapters-grid {
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  background-color: #fff;
}

.chapter-tile {
  background-color: var(--bg-body);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  transition: all 0.15s ease;
}

.chapter-tile:hover {
  border-color: var(--navy-primary);
  background-color: var(--navy-light);
}

.chapter-tile-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.chapter-tile-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.35;
  word-break: break-word;
}

.chapter-tile-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-tile-practice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  background-color: var(--navy-primary);
  color: #fff;
  border: none;
  font-family: var(--font-main);
  font-size: 0.775rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
  min-height: 34px;
}

.btn-tile-practice:hover, .btn-tile-practice:active {
  background-color: var(--green-primary);
}

/* ========================================================
   VIEW 2: TEST RUNNER
   ======================================================== */
.test-top-bar {
  background-color: var(--navy-dark);
  color: #fff;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--navy-primary);
  position: sticky;
  top: 64px;
  z-index: 90;
  gap: 0.5rem;
}

.test-meta-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.btn-quit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 36px;
}

.btn-quit:hover, .btn-quit:active {
  background-color: var(--red-primary);
  border-color: var(--red-primary);
}

.test-subject-info {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.test-sep {
  color: #64748b;
}

.test-chap-name {
  color: #cbd5e1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Timer Display Box */
.timer-box {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.timer-box.normal {
  background-color: var(--green-primary);
  color: #fff;
}

.timer-box.urgent {
  background-color: var(--red-primary);
  color: #fff;
  animation: timerPulse 0.8s infinite alternate;
}

@keyframes timerPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(220, 38, 38, 0); }
  100% { transform: scale(1.05); box-shadow: 0 0 10px rgba(220, 38, 38, 0.6); }
}

.btn-submit-header {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  background-color: var(--green-primary);
  color: #fff;
  border: none;
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 36px;
  white-space: nowrap;
}

.btn-submit-header:hover, .btn-submit-header:active {
  background-color: var(--green-accent);
}

.timer-progress-track {
  width: 100%;
  height: 4px;
  background-color: var(--navy-dark);
}

.timer-progress-fill {
  height: 100%;
  width: 100%;
  background-color: var(--green-accent);
  transition: width 1s linear, background-color 0.3s ease;
}

.timer-progress-fill.urgent {
  background-color: var(--red-primary);
}

/* Test Layout */
.test-layout {
  display: flex;
  gap: 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 3.5rem;
}

.question-main-col {
  flex-grow: 1;
  min-width: 0;
}

.question-card {
  background-color: #ffffff;
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.question-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1.5px solid var(--bg-muted);
  margin-bottom: 1.25rem;
}

.q-counter {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy-dark);
}

.q-num-total {
  color: var(--text-muted);
  font-weight: 600;
}

.btn-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--red-border);
  background-color: #fff;
  color: var(--red-primary);
  font-family: var(--font-main);
  font-size: 0.775rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 32px;
}

.btn-flag:hover {
  background-color: var(--red-light);
}

.btn-flag.flagged {
  background-color: var(--red-primary);
  color: #fff;
  border-color: var(--red-primary);
}

.question-content-box {
  margin-bottom: 1.5rem;
}

.question-text {
  font-size: clamp(1.05rem, 3.5vw, 1.25rem);
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.55;
  word-break: break-word;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.option-row {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.1rem;
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-md);
  background-color: #fff;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.option-row:hover {
  border-color: var(--navy-primary);
  background-color: var(--navy-light);
}

.option-row:active {
  transform: scale(0.99);
}

.option-row.selected {
  border-color: var(--navy-primary);
  background-color: var(--navy-light);
}

.opt-badge {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-muted);
  border: 1.5px solid var(--navy-border);
  color: var(--navy-dark);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.85rem;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.rtl-text .opt-badge {
  margin-right: 0;
  margin-left: 0.85rem;
}

.option-row.selected .opt-badge {
  background-color: var(--navy-primary);
  color: #fff;
  border-color: var(--navy-primary);
}

.opt-text {
  font-size: clamp(0.95rem, 3vw, 1.05rem);
  font-weight: 600;
  color: var(--navy-dark);
  flex-grow: 1;
  word-break: break-word;
}

/* Controls */
.question-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.25rem;
  border-top: 1.5px solid var(--bg-muted);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Generic Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
  min-height: 42px;
}

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

.btn-navy:hover, .btn-navy:active {
  background-color: var(--navy-hover);
}

.btn-navy-outline {
  background-color: #fff;
  border-color: var(--navy-primary);
  color: var(--navy-primary);
}

.btn-navy-outline:hover, .btn-navy-outline:active {
  background-color: var(--navy-light);
}

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

.btn-green:hover, .btn-green:active {
  background-color: var(--green-accent);
}

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

.btn-red:hover, .btn-red:active {
  background-color: var(--red-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover, .btn-ghost:active {
  background-color: var(--bg-muted);
  color: var(--text-main);
}

.btn-block {
  width: 100%;
}

.keyboard-helper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.75rem;
  font-size: 0.725rem;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 0.15rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--navy-dark);
  background-color: var(--bg-muted);
  border: 1px solid var(--navy-border);
  border-radius: 4px;
}

/* Palette Sidebar */
.palette-sidebar {
  width: 300px;
  flex-shrink: 0;
}

.palette-card {
  background-color: #ffffff;
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.palette-card-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy-dark);
  margin-bottom: 0.65rem;
}

.palette-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.legend-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.legend-badge.answered { background-color: var(--green-light); color: var(--green-primary); }
.legend-badge.flagged { background-color: var(--red-light); color: var(--red-primary); }
.legend-badge.current { background-color: var(--navy-light); color: var(--navy-primary); }

.palette-buttons-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.2rem;
  margin-bottom: 1rem;
}

.pal-btn {
  aspect-ratio: 1;
  border: 1.5px solid var(--navy-border);
  border-radius: var(--radius-sm);
  background-color: #fff;
  color: var(--navy-dark);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  min-height: 36px;
}

.pal-btn:hover {
  border-color: var(--navy-primary);
  background-color: var(--navy-light);
}

.pal-btn.current {
  border-color: var(--navy-primary);
  background-color: var(--navy-primary);
  color: #fff;
}

.pal-btn.answered {
  background-color: var(--green-primary);
  border-color: var(--green-primary);
  color: #fff;
}

.pal-btn.flagged {
  background-color: var(--red-primary);
  border-color: var(--red-primary);
  color: #fff;
}

.pal-btn.answered.flagged {
  background: linear-gradient(135deg, var(--green-primary) 50%, var(--red-primary) 50%);
  color: #fff;
}

.palette-summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  text-align: center;
  margin-bottom: 1rem;
}

.stat-box {
  padding: 0.4rem 0.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-border);
  display: flex;
  flex-direction: column;
}

.answered-box { background-color: var(--green-light); border-color: var(--green-border); }
.flagged-box { background-color: var(--red-light); border-color: var(--red-border); }
.left-box { background-color: var(--navy-light); border-color: var(--navy-border); }

.stat-num {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 800;
}

.answered-box .stat-num { color: var(--green-primary); }
.flagged-box .stat-num { color: var(--red-primary); }
.left-box .stat-num { color: var(--navy-primary); }

.stat-lbl {
  font-size: 0.675rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ========================================================
   VIEW 3: RESULTS SCREEN
   ======================================================== */
.results-container {
  padding-top: 1.75rem;
  padding-bottom: 4rem;
}

.results-score-hero {
  background-color: #ffffff;
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.score-circle-container {
  width: 130px;
  height: 130px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-svg-bg {
  fill: none;
  stroke: var(--bg-muted);
  stroke-width: 10;
}

.score-svg-fill {
  fill: none;
  stroke: var(--green-primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.72;
  stroke-dashoffset: 326.72;
  transition: stroke-dashoffset 1.2s ease-out;
}

.score-svg-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-pct-text {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy-dark);
}

.score-grade-text {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.results-center {
  flex-grow: 1;
}

.results-subj-pill {
  display: inline-block;
  font-size: 0.775rem;
  font-weight: 800;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--navy-light);
  color: var(--navy-primary);
  margin-bottom: 0.35rem;
}

.results-heading {
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 800;
  color: var(--navy-dark);
  margin-bottom: 0.25rem;
}

.results-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.results-cta-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* Results 4-Box Metrics */
.results-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.res-metric-card {
  background-color: #ffffff;
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--navy-border);
}

.green-border { border-left: 5px solid var(--green-primary); }
.red-border { border-left: 5px solid var(--red-primary); }
.navy-border { border-left: 5px solid var(--navy-primary); }

.metric-icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.metric-data {
  display: flex;
  flex-direction: column;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
}

.metric-name {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Solutions Review List */
.review-wrapper {
  background-color: #ffffff;
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.review-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1.5px solid var(--bg-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.review-title-bar h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy-dark);
}

.review-title-bar p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--navy-border);
  background-color: #fff;
  color: var(--navy-dark);
  font-family: var(--font-main);
  font-size: 0.775rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
}

.tab-btn:hover {
  background-color: var(--navy-light);
}

.tab-btn.active {
  background-color: var(--navy-primary);
  border-color: var(--navy-primary);
  color: #fff;
}

.review-cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rev-card {
  border: 1.5px solid var(--navy-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  background-color: #fff;
}

.rev-card.is-correct { border-left: 5px solid var(--green-primary); }
.rev-card.is-wrong { border-left: 5px solid var(--red-primary); }
.rev-card.is-skipped { border-left: 5px solid var(--text-muted); }

.rev-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.rev-q-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rev-badge {
  font-size: 0.725rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
}

.rev-badge.correct { background-color: var(--green-light); color: var(--green-primary); }
.rev-badge.wrong { background-color: var(--red-light); color: var(--red-primary); }
.rev-badge.skipped { background-color: var(--bg-muted); color: var(--text-muted); }

.rev-q-text {
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 0.75rem;
  word-break: break-word;
}

.rev-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rev-option-item {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-border);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  word-break: break-word;
}

.rev-option-item.correct-answer {
  background-color: var(--green-light);
  border-color: var(--green-accent);
  color: var(--green-primary);
  font-weight: 700;
}

.rev-option-item.user-wrong-choice {
  background-color: var(--red-light);
  border-color: var(--red-accent);
  color: var(--red-primary);
  text-decoration: line-through;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(9, 20, 40, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background-color: #fff;
  border: 2px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal-icon {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy-dark);
  margin-bottom: 0.35rem;
}

.modal-message {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ========================================================
   RESPONSIVE MEDIA QUERIES (TABLETS & PHONES)
   ======================================================== */
@media (max-width: 900px) {
  .test-layout {
    flex-direction: column;
  }
  
  .palette-sidebar {
    width: 100%;
  }

  .palette-buttons-grid {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    max-height: 240px;
  }

  .results-score-hero {
    flex-direction: column;
    text-align: center;
  }

  .results-cta-row {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 0.75rem;
  }

  .hero-banner {
    padding: 1.5rem 0 1.25rem;
  }

  .quick-config-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }

  .config-item {
    justify-content: space-between;
    width: 100%;
  }

  .custom-select {
    flex-grow: 1;
    max-width: 60%;
  }

  .subject-block-header {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1rem;
  }

  .subj-header-right {
    width: 100%;
  }

  .btn-practice-all {
    width: 100%;
  }

  .chapters-grid {
    grid-template-columns: 1fr;
    padding: 0.75rem 0.85rem;
  }

  .chapter-tile {
    padding: 0.7rem 0.8rem;
  }

  .test-top-bar {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
  }

  .test-meta-left {
    order: 1;
  }

  .test-actions-right {
    order: 2;
  }

  .test-timer-center {
    order: 3;
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 0.25rem;
  }

  .timer-box {
    width: 100%;
    justify-content: center;
    font-size: 1rem;
    padding: 0.35rem 0.75rem;
  }

  .question-card {
    padding: 1.25rem 1rem;
  }

  .option-row {
    padding: 0.75rem 0.85rem;
  }

  .question-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .controls-left, .controls-right {
    width: 100%;
    justify-content: space-between;
  }

  .controls-left .btn, .controls-right .btn {
    flex-grow: 1;
  }

  .keyboard-helper {
    display: none;
  }

  .results-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .results-cta-row {
    flex-direction: column;
    width: 100%;
  }

  .results-cta-row .btn {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
    width: 100%;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .brand-subtitle {
    display: none;
  }

  .quick-stats-pill {
    display: none;
  }

  .results-metrics-grid {
    grid-template-columns: 1fr;
  }
}
