:root {
  --ink: #1b201f;
  --muted: #6b706e;
  --paper: #fbf7ee;
  --paper-strong: #fffdf7;
  --line: #ded2bf;
  --green: #146c5b;
  --green-soft: #d9f0e8;
  --red: #9d2f2f;
  --red-soft: #f5dddd;
  --gold: #b8751a;
  --gold-soft: #f6dfad;
  --shadow: 0 22px 70px rgba(61, 50, 34, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Nunito Sans", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(20, 108, 91, 0.14), transparent 24rem),
    radial-gradient(circle at 92% 12%, rgba(184, 117, 26, 0.18), transparent 22rem),
    linear-gradient(135deg, #f9efd9 0%, var(--paper) 42%, #eef4ec 100%);
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px);
  gap: 24px;
  align-items: stretch;
  min-height: 240px;
}

.hero-copy {
  position: relative;
  padding: 38px clamp(24px, 4vw, 52px);
  overflow: hidden;
  border: 1px solid rgba(91, 73, 45, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(255, 253, 247, 0.92), rgba(255, 253, 247, 0.66)),
    repeating-linear-gradient(90deg, rgba(20, 108, 91, 0.08) 0 1px, transparent 1px 74px);
  box-shadow: var(--shadow);
}

.hero-copy::after {
  content: "";
  position: absolute;
  right: 34px;
  bottom: 24px;
  width: 150px;
  height: 150px;
  border: 16px solid rgba(20, 108, 91, 0.12);
  border-left-color: rgba(184, 117, 26, 0.25);
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: 0.88;
  letter-spacing: 0;
}

.subtitle {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 22px 0 0;
  color: #3d4542;
  font-size: clamp(1.02rem, 2vw, 1.26rem);
  line-height: 1.5;
}

.score-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(91, 73, 45, 0.22);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.score-panel > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 28px 16px;
  background: rgba(255, 253, 247, 0.82);
  text-align: center;
}

.score-number {
  color: var(--green);
  font-family: "Fraunces", serif;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  font-weight: 800;
  line-height: 1;
}

.score-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  text-transform: uppercase;
}

.topic-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0 18px;
}

.topic-button {
  display: grid;
  min-height: 132px;
  cursor: pointer;
  align-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid rgba(91, 73, 45, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 253, 247, 0.96), rgba(239, 246, 238, 0.82)),
    repeating-linear-gradient(135deg, rgba(184, 117, 26, 0.08) 0 1px, transparent 1px 18px);
  box-shadow: 0 16px 42px rgba(61, 50, 34, 0.1);
  color: var(--ink);
  text-align: left;
  transition: transform 160ms ease, border 160ms ease, box-shadow 160ms ease;
}

.topic-button:hover {
  transform: translateY(-2px);
  border-color: rgba(20, 108, 91, 0.46);
  box-shadow: 0 22px 50px rgba(61, 50, 34, 0.14);
}

.topic-button span {
  font-family: "Fraunces", serif;
  font-size: clamp(1.28rem, 2.4vw, 2rem);
  font-weight: 800;
  line-height: 1.05;
}

.topic-button small {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.3;
  text-transform: uppercase;
}

.topic-button strong,
.topic-button em {
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.topic-button strong {
  background: rgba(20, 108, 91, 0.1);
  color: var(--green);
}

.topic-button em {
  background: rgba(184, 117, 26, 0.16);
  color: #7a4a0d;
}

.toolbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) minmax(150px, 210px) auto auto auto;
  gap: 12px;
  align-items: end;
  margin: 24px 0 14px;
}

.search-box,
.select-box {
  display: grid;
  gap: 6px;
  color: #515855;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select,
.tool-button {
  min-height: 48px;
  border: 1px solid rgba(91, 73, 45, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.9);
  color: var(--ink);
  outline: none;
}

input[type="search"],
select {
  width: 100%;
  padding: 0 14px;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(20, 108, 91, 0.13);
}

.tool-button {
  cursor: pointer;
  padding: 0 18px;
  color: #fffdf7;
  background: var(--green);
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tool-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(20, 108, 91, 0.18);
}

.tool-button.quiet {
  color: var(--green);
  background: rgba(255, 253, 247, 0.78);
}

.tool-button.danger-soft {
  color: var(--red);
}

.tool-button.danger {
  color: #fffdf7;
  background: var(--red);
}

.back-button {
  align-self: end;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(91, 73, 45, 0.2);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.72);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 260ms ease;
}

.questions {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.question-card {
  border: 1px solid rgba(91, 73, 45, 0.22);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: 0 16px 42px rgba(61, 50, 34, 0.1);
}

.question-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 22px 22px 12px;
}

.question-number {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--gold-soft);
  color: #6b4108;
  font-weight: 900;
}

.question-text {
  margin: 5px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.45;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.question-meta span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(20, 108, 91, 0.1);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 900;
}

.status-pill {
  min-width: 116px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #f1eadf;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.question-card.correct .status-pill {
  background: var(--green-soft);
  color: var(--green);
}

.question-card.wrong .status-pill {
  background: var(--red-soft);
  color: var(--red);
}

.options {
  display: grid;
  gap: 10px;
  padding: 0 22px 18px;
}

.option {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(91, 73, 45, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  cursor: pointer;
  transition: border 160ms ease, background 160ms ease, transform 160ms ease;
}

.option:hover {
  transform: translateX(2px);
  border-color: rgba(20, 108, 91, 0.38);
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-letter {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #ede3d1;
  color: #5f543f;
  font-weight: 900;
}

.option-text {
  line-height: 1.45;
}

.option:has(input:checked) {
  border-color: var(--green);
  background: rgba(217, 240, 232, 0.7);
}

.option.reveal-correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.option.reveal-wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px 22px;
  border-top: 1px solid rgba(91, 73, 45, 0.15);
}

.check-button {
  min-height: 44px;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--ink);
  color: #fffdf7;
  font-weight: 900;
}

.feedback {
  flex: 1;
  min-width: 220px;
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.question-card.correct .feedback {
  color: var(--green);
}

.question-card.wrong .feedback {
  color: var(--red);
}

.note {
  margin: -4px 22px 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: rgba(246, 223, 173, 0.52);
  color: #61440d;
  line-height: 1.45;
}

.empty-state {
  margin: 32px 0 0;
  padding: 26px;
  border: 1px dashed rgba(91, 73, 45, 0.38);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .hero,
  .toolbar,
  .topic-picker {
    grid-template-columns: 1fr;
  }

  .score-panel {
    min-height: 150px;
  }

  .question-top {
    grid-template-columns: auto 1fr;
  }

  .status-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .feedback {
    text-align: left;
  }
}

@media (max-width: 540px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .hero-copy,
  .question-top,
  .options,
  .card-actions {
    padding-left: 14px;
    padding-right: 14px;
  }

  .score-panel {
    grid-template-columns: 1fr;
  }

  .question-text {
    font-size: 1rem;
  }

  .option {
    grid-template-columns: 34px 1fr;
  }
}
