/* ─── Base ──────────────────────────────────────────────────────────── */

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dfe6e9;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --radius: 10px;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Site Header ─────────────────────────────────────────────────── */

.site-header {
  background: #fff;
  text-align: center;
  padding: 14px 20px 10px;
  border-bottom: 2px solid var(--border);
}

.site-header-logo {
  height: 80px;
  width: auto;
}

.site-header-subtitle {
  font-size: 1em;
  font-weight: 400;
  color: var(--text-light);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* ─── Site Footer ─────────────────────────────────────────────────── */

.site-footer {
  background: var(--primary);
  text-align: center;
  padding: 14px 20px;
  margin-top: 40px;
}

.site-footer a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 1em;
  letter-spacing: 0.3px;
}

.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
}

/* ─── Screens ─────────────────────────────────────────────────────── */

.screen {
  display: none;
  max-width: 805px;
  margin: 0 auto;
  padding: 20px;
}

.screen.active {
  display: block;
}

/* ─── Setup Screen ────────────────────────────────────────────────── */

.app-title {
  text-align: center;
  font-size: 1.6em;
  font-weight: 700;
  color: var(--primary);
  margin: 24px 0 5px;
}

.app-subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 0.95em;
  margin-bottom: 24px;
}

.setup-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.setup-section h3 {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.15s;
  user-select: none;
}

.checkbox-group label:hover {
  border-color: var(--primary-light);
}

.checkbox-group input:checked + span {
  font-weight: 600;
}

.checkbox-group input:checked ~ span {
  color: var(--primary);
}

.checkbox-group label:has(input:checked) {
  border-color: var(--primary-light);
  background: #ebf5fb;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.15s;
  user-select: none;
}

.radio-group label:hover {
  border-color: var(--primary-light);
}

.radio-group label:has(input:checked) {
  border-color: var(--primary-light);
  background: #ebf5fb;
}

.question-counter {
  text-align: center;
  font-size: 1.1em;
  font-weight: 600;
  color: var(--primary);
  margin: 24px 0 16px;
}

.start-btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1.1em;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.start-btn:hover:not(:disabled) {
  background: var(--primary-light);
}

.start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Question Screen ─────────────────────────────────────────────── */

.progress-container {
  margin-bottom: 16px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-light);
  transition: width 0.3s ease;
  border-radius: 3px;
}

.progress-text {
  font-size: 0.85em;
  color: var(--text-light);
  text-align: center;
}

.question-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 600;
  color: #fff;
}

.form-badge {
  background: #95a5a6;
}

/* ─── Question Image ──────────────────────────────────────────────── */

.question-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.question-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* ─── Answer Label ────────────────────────────────────────────────── */

.answer-label {
  font-size: 0.9em;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ─── Choice Buttons (letter-only) ────────────────────────────────── */

.choices {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.choice-btn {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2em;
  font-weight: 700;
  color: var(--primary);
  transition: all 0.15s;
  user-select: none;
}

.choice-btn:hover:not(.disabled) {
  border-color: var(--primary-light);
  background: #ebf5fb;
  transform: scale(1.05);
}

.choice-btn.selected {
  border-color: var(--primary-light);
  background: #d4e6f1;
}

.choice-btn.correct {
  border-color: var(--success);
  background: #d5f5e3;
  color: var(--success);
}

.choice-btn.incorrect {
  border-color: var(--danger);
  background: #fadbd8;
  color: var(--danger);
}

.choice-btn.disabled {
  cursor: default;
  pointer-events: none;
}

/* ─── Action Buttons ──────────────────────────────────────────────── */

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  font-size: 0.95em;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

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

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

/* ─── Feedback ────────────────────────────────────────────────────── */

.feedback {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1em;
  margin-bottom: 16px;
}

.feedback.correct {
  background: #d5f5e3;
  color: #1e8449;
}

.feedback.incorrect {
  background: #fadbd8;
  color: #c0392b;
}

/* ─── Summary Screen ──────────────────────────────────────────────── */

.summary-header {
  text-align: center;
  padding: 30px 0;
}

.score-display {
  font-size: 2.5em;
  font-weight: 700;
  color: var(--primary);
}

.score-percent {
  font-size: 1.4em;
  color: var(--primary-light);
  margin-top: 4px;
}

.skipped-count {
  color: var(--text-light);
  font-size: 0.9em;
  margin-top: 8px;
}

.summary-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.summary-section h3 {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.breakdown-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.breakdown-label {
  width: 150px;
  font-size: 0.9em;
  flex-shrink: 0;
}

.breakdown-bar-container {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.breakdown-bar {
  display: block;
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.breakdown-value {
  width: 170px;
  font-size: 0.85em;
  text-align: right;
  color: var(--text-light);
  flex-shrink: 0;
}

/* ─── Incorrect List ──────────────────────────────────────────────── */

.incorrect-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.incorrect-item:last-child {
  border-bottom: none;
}

.incorrect-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  object-position: top left;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.incorrect-info {
  flex: 1;
}

.incorrect-meta {
  font-size: 0.85em;
  color: var(--text-light);
  margin-bottom: 2px;
}

.incorrect-answer {
  font-size: 0.9em;
  color: var(--danger);
  font-weight: 600;
}

.no-incorrect {
  color: var(--success);
  font-weight: 600;
  text-align: center;
  padding: 16px;
}

.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
  margin-bottom: 40px;
}

/* ─── Lightbox ───────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  background: #fff;
}

.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 1.4em;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover {
  background: #c0392b;
}

.incorrect-item {
  cursor: pointer;
}

.incorrect-item:hover {
  background: #f8f9fa;
}

/* ─── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .screen {
    padding: 12px;
  }

  .app-title {
    font-size: 1.3em;
  }

  .checkbox-group,
  .radio-group {
    flex-direction: column;
  }

  .choice-btn {
    width: 48px;
    height: 48px;
    font-size: 1.1em;
  }

  .breakdown-label {
    width: 100px;
  }

  .breakdown-value {
    width: 80px;
    font-size: 0.8em;
  }

  .score-display {
    font-size: 2em;
  }

  .incorrect-thumb {
    width: 60px;
    height: 45px;
  }
}
