:root {
  --card: rgba(255, 255, 255, 0.95);
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --border: #e5e7eb;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(99, 102, 241, 0.55), transparent 34%),
    radial-gradient(circle at 80% 0%, rgba(14, 165, 233, 0.38), transparent 30%),
    linear-gradient(135deg, #0f172a 0%, #111827 45%, #1e1b4b 100%);
}

button,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.hero {
  text-align: center;
  color: #fff;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
  backdrop-filter: blur(18px);
  animation: riseIn 0.25s ease both;
}

.panel__header,
.quiz-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel h2,
.quiz-panel h2,
.result-panel h2 {
  margin: 6px 0 0;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  letter-spacing: -0.04em;
}

.stats-pill,
.score-live {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.score-live {
  border-radius: 16px;
  text-align: center;
}

.score-live span,
.result-box span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-live strong {
  display: block;
  margin-top: 2px;
  font-size: 1.15rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.field span {
  display: block;
  margin-bottom: 7px;
  color: #374151;
  font-weight: 900;
}

.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #fff;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.actions-row.centered {
  justify-content: center;
}

.btn {
  border: 0;
  border-radius: 15px;
  padding: 13px 17px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  box-shadow: 0 16px 32px rgba(79, 70, 229, 0.28);
}

.btn-secondary {
  color: #1f2937;
  background: #f3f4f6;
  border: 1px solid var(--border);
}

.history-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: #f9fafb;
  border: 1px solid var(--border);
}

.history-card h3 {
  margin: 0 0 8px;
}

.history-card ul {
  margin: 0;
  padding-left: 18px;
  color: #4b5563;
  line-height: 1.7;
}

.progress-wrap {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  margin-bottom: 11px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
  transition: width 0.25s ease;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
  margin-bottom: 12px;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 16px;
  padding: 11px 12px;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.answer-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(79, 70, 229, 0.42);
  background: #f8fafc;
}

.answer-btn:disabled {
  cursor: default;
}

.answer-letter {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.answer-text {
  line-height: 1.35;
}

.answer-btn.correct {
  border-color: rgba(21, 128, 61, 0.45);
  background: var(--success-soft);
}

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

.answer-btn.wrong {
  border-color: rgba(185, 28, 28, 0.42);
  background: var(--danger-soft);
}

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

.feedback {
  margin-top: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.feedback__title {
  font-weight: 900;
  margin-bottom: 5px;
}

.feedback p {
  margin: 0;
  color: #374151;
  line-height: 1.45;
}

.source-line {
  margin-top: 8px !important;
  font-size: 0.85rem;
  color: var(--muted) !important;
}

.source-line a {
  color: var(--primary-dark);
  font-weight: 900;
  text-decoration: none;
}

.source-line a:hover {
  text-decoration: underline;
}

.result-panel {
  text-align: center;
}

.result-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 22px;
  background: var(--primary-soft);
  font-size: 2rem;
}

.result-panel p {
  max-width: 680px;
  margin: 10px auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 22px;
}

.result-box {
  padding: 16px;
  border-radius: 18px;
  background: #f9fafb;
  border: 1px solid var(--border);
}

.result-box strong {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
  letter-spacing: -0.04em;
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  text-align: left;
}

.review-item {
  padding: 13px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
}

.review-item strong {
  display: block;
  margin-bottom: 5px;
}

.review-item small {
  color: var(--muted);
  line-height: 1.5;
}

/* Modul compact pentru test: fără scroll de pagină la întrebări/răspunsuri/butoane. */
body.quiz-active {
  height: 100dvh;
  overflow: hidden;
}

body.quiz-active .app-shell {
  width: min(100%, 920px);
  height: 100dvh;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

body.quiz-active .hero {
  display: none;
}

body.quiz-active main {
  flex: 1;
  min-height: 0;
  display: flex;
}

body.quiz-active .quiz-panel {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 7px;
  overflow: hidden;
  padding: 10px;
  border-radius: 18px;
}

body.quiz-active .quiz-topbar {
  align-items: center;
  margin-bottom: 0;
  gap: 8px;
}

body.quiz-active .quiz-title-wrap {
  min-width: 0;
}

body.quiz-active .section-kicker {
  font-size: 0.66rem;
}

body.quiz-active #questionTitle {
  margin-top: 3px;
  font-size: clamp(1rem, 3.6vw, 1.45rem);
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.quiz-active .score-live {
  padding: 7px 9px;
  border-radius: 13px;
}

body.quiz-active .score-live span {
  font-size: 0.62rem;
}

body.quiz-active .score-live strong {
  font-size: 0.95rem;
}

body.quiz-active .progress-wrap {
  height: 7px;
  margin-bottom: 0;
}

body.quiz-active .question-meta {
  margin-bottom: 0;
  font-size: 0.78rem;
  line-height: 1.25;
}

body.quiz-active .answers {
  align-content: start;
  min-height: 0;
  gap: 7px;
}

body.quiz-active .answer-btn {
  grid-template-columns: 34px 1fr;
  gap: 9px;
  min-height: 48px;
  padding: 8px 9px;
  border-radius: 13px;
}

body.quiz-active .answer-letter {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

body.quiz-active .answer-text {
  font-size: clamp(0.87rem, 2.8vw, 1rem);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.quiz-active .feedback {
  margin-top: 0;
  padding: 8px 10px;
  border-radius: 13px;
}

body.quiz-active .feedback__title {
  margin-bottom: 2px;
  font-size: 0.9rem;
}

body.quiz-active #feedbackText {
  font-size: 0.84rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.quiz-active .source-line {
  display: none;
}

body.quiz-active .quiz-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 0;
  gap: 8px;
}

body.quiz-active .quiz-actions .btn {
  width: 100%;
  padding: 11px 10px;
  border-radius: 13px;
}

body.result-active .app-shell {
  padding-top: 18px;
}

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

@media (min-width: 761px) {
  body.quiz-active .answers {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .hero h1 {
    font-size: clamp(1.85rem, 9vw, 3rem);
  }

  .panel__header {
    display: block;
  }

  .stats-pill {
    display: inline-block;
    margin-top: 12px;
  }

  .form-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .btn,
  .actions-row .btn {
    width: 100%;
  }

  body.quiz-active .btn,
  body.quiz-active .actions-row .btn {
    width: auto;
  }

  body.quiz-active .app-shell {
    padding: 6px;
  }

  body.quiz-active .quiz-panel {
    padding: 8px;
    gap: 6px;
  }

  body.quiz-active .quiz-topbar {
    display: flex;
  }
}

@media (max-height: 670px) {
  body.quiz-active .quiz-panel {
    padding: 7px;
    gap: 5px;
  }

  body.quiz-active #questionTitle {
    -webkit-line-clamp: 2;
    font-size: 1rem;
  }

  body.quiz-active .answer-btn {
    min-height: 42px;
    padding: 6px 8px;
  }

  body.quiz-active .answer-letter {
    width: 30px;
    height: 30px;
  }

  body.quiz-active .feedback {
    padding: 6px 8px;
  }

  body.quiz-active #feedbackText {
    -webkit-line-clamp: 1;
  }

  body.quiz-active .quiz-actions .btn {
    padding: 9px 8px;
  }
}


.load-error-card {
  padding: 8px 0;
}

.load-error-card h2 {
  color: var(--danger);
}

.load-error-card ul {
  margin: 14px 0;
  padding-left: 22px;
  color: #7f1d1d;
  font-weight: 700;
}

.code-hint {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  line-height: 1.55;
}

.code-hint code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 7px;
  background: rgba(124, 45, 18, 0.08);
  font-weight: 900;
}

/* Patch design clar: întrebarea este separată de scor și rămâne vizibilă. */
.quiz-status-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.position-pill,
.question-category-chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
}

.position-pill {
  color: #475569;
  background: #f1f5f9;
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
}

.question-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(79, 70, 229, 0.22);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.question-category-chip {
  margin-bottom: 8px;
  padding: 7px 10px;
  color: #3730a3;
  background: #eef2ff;
}

.question-card h2 {
  margin: 0;
  color: #0f172a;
  font-size: clamp(1.12rem, 3.4vw, 1.75rem);
  line-height: 1.25;
  letter-spacing: -0.035em;
}

body.quiz-active .quiz-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
}

body.quiz-active .quiz-status-row {
  align-items: center;
  margin-bottom: 0;
}

body.quiz-active .quiz-status-left {
  gap: 5px;
}

body.quiz-active .position-pill {
  padding: 6px 9px;
  font-size: 0.7rem;
}

body.quiz-active .question-card {
  padding: 12px 13px;
  border-radius: 16px;
  max-height: 28dvh;
  overflow: auto;
  scrollbar-width: thin;
}

body.quiz-active .question-category-chip {
  margin-bottom: 7px;
  padding: 6px 9px;
  font-size: 0.68rem;
}

body.quiz-active #questionTitle {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  margin: 0;
  font-size: clamp(1.02rem, 4vw, 1.45rem);
  line-height: 1.25;
}

body.quiz-active .answers {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

body.quiz-active .answer-btn {
  min-height: 50px;
}

body.quiz-active .answer-text {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
  font-size: clamp(0.9rem, 3vw, 1rem);
  line-height: 1.3;
}

body.quiz-active .quiz-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 15px;
  padding: 6px;
  backdrop-filter: blur(12px);
}

@media (max-width: 760px) {
  body.quiz-active .quiz-panel {
    padding: 7px;
    gap: 6px;
  }

  body.quiz-active .score-live {
    min-width: 78px;
  }

  body.quiz-active .question-card {
    padding: 11px 12px;
    max-height: 30dvh;
  }

  body.quiz-active #questionTitle {
    font-size: clamp(1rem, 4.8vw, 1.24rem);
    line-height: 1.22;
  }

  body.quiz-active .answer-btn {
    grid-template-columns: 32px 1fr;
    min-height: 48px;
    padding: 8px;
  }

  body.quiz-active .answer-letter {
    width: 32px;
    height: 32px;
  }
}

@media (max-height: 670px) {
  body.quiz-active .question-card {
    max-height: 24dvh;
    padding: 9px 10px;
  }

  body.quiz-active #questionTitle {
    font-size: 0.98rem;
    line-height: 1.18;
  }

  body.quiz-active .question-category-chip {
    margin-bottom: 5px;
  }

  body.quiz-active .answer-text {
    font-size: 0.86rem;
    line-height: 1.22;
  }

  body.quiz-active .answer-btn {
    min-height: 42px;
  }
}
