:root {
  --page-bg: #f7f7f5;
  --surface: #ffffff;
  --surface-soft: #fbfbfb;
  --border: #e5e7eb;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --accent: #111827;
  --accent-soft: #f1f5f9;
  --success-bg: #f0fdf4;
  --success-border: #86efac;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

body {
  margin-bottom: 60px;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.95), rgba(247, 247, 245, 0.7) 36%),
    linear-gradient(180deg, #ffffff 0%, var(--page-bg) 100%);
  color: var(--text-main);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.navbar,
.footer {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(12px);
}

.quiz-page {
  padding: 2rem 0 4rem;
}

.quiz-shell {
  max-width: 920px;
  margin: 0 auto;
}

.quiz-intro {
  margin-bottom: 1.5rem;
}

.quiz-kicker {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiz-intro h1 {
  margin: 1rem 0 0.5rem;
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.quiz-intro p {
  max-width: 620px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.quiz-card,
.result-card {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quiz-topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.quiz-category,
.quiz-progress {
  margin: 0;
}

.quiz-category {
  color: var(--text-muted);
  font-weight: 600;
}

.quiz-progress {
  font-size: 1.1rem;
  font-weight: 700;
}

.quiz-score-chip {
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-weight: 700;
  white-space: nowrap;
}

.quiz-setup {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
}

.quiz-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.quiz-setup-label {
  font-weight: 700;
}

.quiz-select,
.quiz-input {
  min-width: 90px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text-main);
}

.quiz-total {
  align-self: center;
  color: var(--text-muted);
  font-weight: 600;
}

.quiz-count-message {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.quiz-summary {
  margin-bottom: 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
}

.question-list,
.result-list {
  display: grid;
  gap: 1rem;
}

.question-panel,
.result-item {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.question-panel h2 {
  margin-bottom: 0.5rem;
  font-size: 1.45rem;
  line-height: 1.25;
}

.question-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0.75rem 0 1rem;
  border: none;
  border-radius: 0;
  background: transparent;
}

.question-help {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.answers-grid {
  display: grid;
  gap: 0.9rem;
}

.answer-option {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  transition: border-color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.answer-option:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.answer-option input {
  margin-top: 0.25rem;
}

.answer-option span {
  line-height: 1.5;
}

.answer-option.answer-correct {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.answer-option.answer-incorrect {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.question-feedback {
  margin-top: 1rem;
  font-weight: 700;
}

.question-panel-correct {
  border-color: var(--success-border);
  background: #f9fffb;
}

.question-panel-incorrect {
  border-color: var(--danger-border);
  background: #fff9f9;
}

.question-panel-neutral {
  border-color: #cbd5e1;
}

.custom-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.custom-inline-block {
  margin-top: 1rem;
}

.custom-inline-fields {
  display: grid;
  gap: 0.9rem;
}

.custom-match-list {
  display: grid;
  gap: 0.9rem;
}

.custom-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.custom-field-label {
  min-width: 72px;
  font-weight: 700;
}

.custom-control {
  flex: 1;
}

.custom-field-correct {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.custom-field-incorrect {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.quiz-button {
  padding: 0.9rem 1.4rem;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.quiz-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.quiz-state-error {
  color: #b91c1c;
}

.result-card {
  margin-top: 1.5rem;
}

.result-card h2 {
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.result-summary {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.result-item.correct {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.result-item.incorrect {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.result-item h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.result-item p {
  margin-bottom: 0.4rem;
}

.result-label {
  font-weight: 700;
}

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

@media (max-width: 768px) {
  .quiz-topbar,
  .question-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-setup {
    grid-template-columns: 1fr;
  }

  .quiz-card,
  .result-card {
    padding: 1.1rem;
    border-radius: 20px;
  }

  .question-panel h2 {
    font-size: 1.25rem;
  }

  .quiz-button,
  .quiz-select,
  .quiz-input {
    width: 100%;
  }

  .custom-fields-grid {
    grid-template-columns: 1fr;
  }

  .custom-field {
    flex-direction: column;
    align-items: stretch;
  }

  .custom-field-label {
    min-width: auto;
  }
}
