:root {
  --bg: #0a0e1a;
  --card: #0d1526;
  --card-hover: #111c33;
  --text: #f0f4ff;
  --muted: #8b9dc3;
  --border: rgba(99, 130, 200, .15);
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, .4);
  --secondary: #8b5cf6;
  --accent: #06b6d4;
  --good: #10b981;
  --bad: #ef4444;
  --shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-glow: 0 0 80px rgba(59, 130, 246, .15), 0 0 40px rgba(139, 92, 246, .1);
  --radius: 24px;
  --radius-sm: 16px;
}

:root.light {
  --bg: #f8faff;
  --card: #ffffff;
  --card-hover: #f0f5ff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .08);
  --primary: #2563eb;
  --primary-glow: rgba(37, 99, 235, .2);
  --shadow: 0 20px 60px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .05);
  --shadow-glow: 0 0 80px rgba(37, 99, 235, .08), 0 0 40px rgba(139, 92, 246, .05);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Tajawal', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(ellipse 1400px 800px at 10% -10%, rgba(59, 130, 246, .2), transparent 60%),
    radial-gradient(ellipse 1200px 700px at 90% -5%, rgba(139, 92, 246, .15), transparent 55%),
    radial-gradient(ellipse 800px 600px at 50% 100%, rgba(6, 182, 212, .1), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===== HEADER ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, .9);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  gap: 24px;
}

:root.light .topbar {
  background: rgba(255, 255, 255, .9);
}

.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo-img {
  height: 120px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

:root.light .logo-img {
  filter: none;
}

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.title {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -.3px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.logo {
  display: none;
}

/* ===== MOBILE RESPONSIVE HEADER ===== */
@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    padding: 16px 20px;
    gap: 12px;
  }

  .logo-img {
    height: 100px;
    padding: 8px 0;
  }

  .header-title {
    position: static;
    transform: none;
  }

  .title {
    font-size: 16px;
  }

  .subtitle {
    font-size: 12px;
  }

  #btnTheme {
    position: absolute;
    top: 16px;
    left: 16px;
  }
}

/* ===== MAIN CONTAINER ===== */
.container {
  max-width: 900px;
  margin: 32px auto 100px;
  padding: 0 20px;
}

/* ===== CARDS ===== */
.card {
  background: linear-gradient(145deg, rgba(255, 255, 255, .04) 0%, rgba(255, 255, 255, .01) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow), var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .1), transparent);
}

:root.light .card {
  background: var(--card);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

/* ===== TYPOGRAPHY ===== */
h1 {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* ===== FORM GRID ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

@media (max-width:720px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.field {
  position: relative;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--muted);
}

select {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all .25s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238b9dc3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 18px;
}

select:hover {
  border-color: var(--primary);
  background-color: rgba(59, 130, 246, .05);
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

:root.light select {
  background-color: rgba(15, 23, 42, .02);
}

/* ===== BUTTONS ===== */
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

button {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity .3s ease;
}

button:hover::before {
  opacity: 1;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  color: white;
  box-shadow: 0 8px 24px rgba(59, 130, 246, .35), inset 0 1px 0 rgba(255, 255, 255, .2);
}

button.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(59, 130, 246, .45), inset 0 1px 0 rgba(255, 255, 255, .2);
}

button.ghost {
  background: transparent;
  border-color: var(--border);
}

button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, .05);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ===== QUIZ TOP BAR ===== */
.quizTop {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.progressWrap {
  flex: 1;
}

.progressBar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border);
}

.progressBar>div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #3b82f6, #8b5cf6);
  transition: width .4s cubic-bezier(.4, 0, .2, 1);
  border-radius: 999px;
  box-shadow: 0 0 20px rgba(59, 130, 246, .5);
}

.progressMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pill {
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(239, 68, 68, .1);
  color: #ef4444;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .7;
  }
}

.scoreBox {
  min-width: 100px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  background: linear-gradient(145deg, rgba(16, 185, 129, .1) 0%, rgba(59, 130, 246, .05) 100%);
}

.score {
  font-size: 32px;
  font-weight: 900;
  color: var(--good);
}

/* ===== LIVES BOX ===== */
.livesBox {
  min-width: 100px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  background: linear-gradient(145deg, rgba(239, 68, 68, .1) 0%, rgba(239, 68, 68, .05) 100%);
}

.hearts {
  font-size: 22px;
  letter-spacing: 2px;
  transition: transform 0.3s ease;
}

.hearts.shake {
  animation: heartShake 0.5s ease;
}

@keyframes heartShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

/* ===== QUESTION ===== */
.topic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(59, 130, 246, .15) 0%, rgba(139, 92, 246, .1) 100%);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, .2);
}

.qText {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.8;
  margin-bottom: 24px;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width:720px) {
  .options {
    grid-template-columns: 1fr;
  }
}

.opt {
  text-align: right;
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  line-height: 1.6;
  font-size: 16px;
  font-weight: 500;
  transition: all .25s ease;
}

.opt:hover:not(:disabled) {
  background: rgba(59, 130, 246, .08);
  border-color: var(--primary);
  transform: translateX(-4px);
}

.opt.good {
  border-color: var(--good);
  background: rgba(16, 185, 129, .12);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .2), inset 0 0 20px rgba(16, 185, 129, .05);
}

.opt.bad {
  border-color: var(--bad);
  background: rgba(239, 68, 68, .1);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15), inset 0 0 20px rgba(239, 68, 68, .05);
}

/* ===== FEEDBACK ===== */
.feedback {
  margin-top: 20px;
  padding: 20px 24px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(255, 255, 255, .03) 0%, rgba(255, 255, 255, .01) 100%);
  line-height: 1.8;
  animation: fadeIn .4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback .ref {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ===== RESULTS ===== */
.resultGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

@media (max-width:720px) {
  .resultGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .03) 0%, transparent 100%);
  text-align: center;
}

.big {
  font-size: 28px;
  font-weight: 900;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== REVIEW ===== */
.review {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rItem {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  background: rgba(255, 255, 255, .02);
  transition: all .25s ease;
}

.rItem:hover {
  background: rgba(255, 255, 255, .04);
}

.rQ {
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 12px;
  line-height: 1.7;
}

.rMeta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, .02);
}

.rAns {
  line-height: 1.8;
  font-size: 15px;
}

.rAns b.good {
  color: var(--good);
}

.rAns b.bad {
  color: var(--bad);
}

/* ===== INSTRUCTIONS ===== */
.how {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.how summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 600;
  background: rgba(255, 255, 255, .02);
  transition: background .25s ease;
}

.how summary:hover {
  background: rgba(255, 255, 255, .05);
}

.how ul {
  padding: 20px 40px;
  line-height: 2;
  border-top: 1px solid var(--border);
}

.how li {
  margin-bottom: 8px;
}

/* ===== FOOTER ===== */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 26, .9);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

:root.light .footer {
  background: rgba(255, 255, 255, .9);
}

/* ===== THEME TOGGLE ===== */
#btnTheme {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .05);
}

#btnTheme:hover {
  background: rgba(255, 255, 255, .1);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, .2);
}

/* ===== SELECTION ===== */
::selection {
  background: var(--primary);
  color: white;
}