:root {
  --bg-page: #f1f5f9;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #2563eb;
  --success: #10b981;
  --error: #ef4444;
  --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  --font-arab: 'Amiri', serif;
  --font-ui: 'Plus Jakarta Sans', sans-serif;
}

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.main-wrapper { width: 100%; max-width: 500px; position: relative; }

/* Header & Screens */
header { text-align: center; margin-bottom: 24px; }
.screen { display: none; opacity: 0; transition: opacity 0.3s ease; }
.screen.active { display: block; opacity: 1; }
.hidden { display: none !important; }

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  border: 1px solid #e2e8f0;
}

/* Config Inputs */
.input-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; background: #f8fafc; padding: 16px; border-radius: 12px; }
.input-group { display: flex; flex-direction: column; align-items: center; width: 45%; }
.input-group-full { margin-bottom: 20px; text-align: center; }
.input-group-full label { font-size: 0.75rem; color: var(--text-muted); display: block; margin-bottom: 8px;}
select { width: 100%; padding: 10px; border-radius: 8px; border: 2px solid #e2e8f0; font-family: inherit; }

input {
  width: 100%; text-align: center; border: 2px solid #e2e8f0; border-radius: 8px;
  padding: 8px; font-size: 1.2rem; font-weight: 700; color: var(--primary); outline: none;
}
.divider-vertical { width: 1px; height: 30px; background: #cbd5e1; }
.badges { display: flex; justify-content: center; gap: 10px; margin-bottom: 24px; margin-top: 10px; }
.badges span { background: #dbeafe; color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }

/* Buttons */
.btn-primary {
  width: 100%; background: var(--primary); color: white; border: none; padding: 16px;
  border-radius: 16px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: 0.2s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-outline { background: white; color: var(--primary); border: 2px solid var(--primary); margin-top: 16px; }
.btn-next { width: 100%; background: var(--text-main); color: white; border: none; padding: 14px; border-radius: 50px; font-weight: 600; margin-top: 24px; cursor: pointer; }

/* Quiz Styles */
.progress-track { height: 8px; background: #e2e8f0; border-radius: 10px; overflow: hidden; margin-top: 8px;}
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.4s ease; }
.progress-info { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }

.surah-badge { text-align: center; font-size: 0.8rem; background: #f1f5f9; display: inline-block; padding: 4px 12px; border-radius: 12px; margin-bottom: 10px; width: 100%; color: var(--primary); font-weight: 600;}

.arab-text {
  font-family: var(--font-arab); font-size: 2.2rem; line-height: 2; text-align: center;
  color: var(--text-main); direction: rtl; margin-bottom: 10px;
}
.arab-text-sm { font-family: var(--font-arab); font-size: 1.4rem; color: var(--text-main); direction: rtl; }

/* Choices Styles */
.choices-grid { display: grid; gap: 12px; }
.choice {
  background: white; border: 2px solid #e2e8f0; color: var(--text-main);
  padding: 12px 16px; border-radius: 12px; 
  display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between;
  cursor: pointer; transition: all 0.2s; width: 100%;
}
.choice:hover { border-color: #cbd5e1; transform: translateY(-2px); }

.choice-text { font-family: var(--font-arab); font-size: 1.5rem; text-align: right; width: 100%; }
.choice-idx { 
    font-size: 0.9rem; font-weight: 700; color: var(--text-muted); background: #f1f5f9; 
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; 
    border-radius: 50%; flex-shrink: 0; margin-right: 12px;
}

/* Status Colors */
.choice.correct { background: #d1fae5; border-color: var(--success); color: #065f46; pointer-events: none; }
.choice.correct .choice-idx { background: var(--success); color: white; }

.choice.wrong { background: #fee2e2; border-color: var(--error); color: #991b1b; pointer-events: none; }
.choice.wrong .choice-idx { background: var(--error); color: white; }

/* Reveal Box */
.reveal-box { margin-top: 20px; padding-top: 15px; border-top: 1px dashed #e2e8f0; display: flex; align-items: center; gap: 12px; }
.reveal-icon { width: 28px; height: 28px; background: var(--success); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Animations */
.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Result Screen & History */
.result-card { text-align: center; }
.score-ring { width: 100px; height: 100px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 2.5rem; font-weight: 800; }

.history-container { 
    margin-top: 24px; text-align: left; max-height: 300px; overflow-y: auto; 
    border-top: 1px solid #e2e8f0; padding-top: 16px;
}
.history-item { 
    margin-bottom: 12px; padding: 10px; border-radius: 8px; background: #f8fafc; border-left: 4px solid #ccc; 
}
.history-item.correct { border-left-color: var(--success); }
.history-item.wrong { border-left-color: var(--error); }
.h-header { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 4px; color: var(--text-muted); }
.h-q, .h-ans { font-family: var(--font-arab); font-size: 1.1rem; direction: rtl; }
.h-ans { color: var(--success); margin-top: 4px; }
.h-wrong-ans { color: var(--error); text-decoration: line-through; font-size: 1rem; }

/* Loader */
.loader { border: 4px solid #e2e8f0; border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { 100% { transform: rotate(360deg); } }