:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f2f5f8;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button { font: inherit; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  background: #0f4c81;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

.site-header h1 { margin: 0; font-size: clamp(1.35rem, 3vw, 2rem); }
.eyebrow { margin: 0 0 .2rem; font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .78; }
.container { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.panel { background: #fff; border-radius: 18px; padding: clamp(1rem, 3vw, 2rem); box-shadow: 0 8px 30px rgba(25,45,70,.09); }
.center-view { min-height: 220px; display: grid; place-items: center; text-align: center; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
h2 { margin: 0; }
.muted { color: #667085; }

.message { margin-bottom: 1rem; border-radius: 12px; padding: .9rem 1rem; font-weight: 700; }
.message.info { background: #eaf4ff; color: #164f7b; }
.message.error { background: #ffeaea; color: #8e2222; }
.message.success { background: #e9f8ee; color: #20633a; }

.card-list, .question-stack { display: grid; gap: 1rem; }
.question-set-card { border: 1px solid #dce4ec; border-radius: 14px; padding: 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.question-set-card h3 { margin: 0 0 .3rem; }
.question-set-card p { margin: 0; color: #667085; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: .75rem; margin-top: 1rem; }
.group-button { min-height: 60px; border: 1px solid #b9c9d8; border-radius: 12px; background: #f8fbfd; font-weight: 800; cursor: pointer; }
.group-button:hover, .group-button:focus-visible { border-color: #0f4c81; background: #edf6fd; }

.primary-button, .secondary-button, .text-button {
  border-radius: 10px;
  padding: .75rem 1rem;
  cursor: pointer;
  font-weight: 800;
}
.primary-button { border: 1px solid #0f4c81; background: #0f4c81; color: #fff; }
.secondary-button { border: 1px solid #9fb0c0; background: #fff; color: #1f3a50; }
.text-button { border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }

.warning-panel { border: 2px solid #e2a62f; }
.session-summary { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.score-summary { display: grid; grid-template-columns: auto auto; gap: .25rem .65rem; text-align: right; }

.question-card { background: #fff; border-radius: 18px; padding: 1rem; box-shadow: 0 8px 30px rgba(25,45,70,.08); }
.question-card.solved { border: 2px solid #3b9b5f; }
.question-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .45rem; }
.question-header h3 { margin: 0; }
.question-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .88rem; color: #667085; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: .2rem .65rem; border-radius: 999px; background: #edf2f7; font-weight: 800; }
.badge.correct { background: #e4f7ea; color: #20633a; }
.scratch-instruction { margin: .35rem 0 .85rem; color: #526477; font-size: .92rem; }

.choice-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: .85rem;
  align-items: stretch;
}

.scratch-choice {
  position: relative;
  min-width: 0;
  width: 100%;
  min-height: 142px;
  aspect-ratio: 1.35 / 1;
  border: 2px solid #aebbc6;
  border-radius: 18px;
  overflow: hidden;
  background: #eef1f3;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.65), 0 5px 14px rgba(25,45,70,.12);
  isolation: isolate;
}

.scratch-result,
.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.scratch-result {
  z-index: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .4rem;
  background: radial-gradient(circle at 50% 42%, #fff 0, #eef2f5 72%);
  text-align: center;
  padding: .75rem;
}

.scratch-result strong {
  font-size: clamp(1.15rem, 3vw, 1.8rem);
  line-height: 1.1;
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
}

.scratch-result-label {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
  border-radius: 50%;
  background: rgba(15,76,129,.1);
  color: #173d5b;
  font-size: 1.35rem;
  font-weight: 900;
}

.scratch-result.is-correct { background: radial-gradient(circle at 50% 42%, #f9fff9 0, #dff4e6 76%); }
.scratch-result.is-incorrect { background: radial-gradient(circle at 50% 42%, #fff 0, #e8edf2 76%); }

.scratch-canvas {
  z-index: 2;
  display: block;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.scratch-canvas:active { cursor: grabbing; }
.scratch-canvas:focus-visible { outline: 4px solid #ffca3a; outline-offset: -5px; }
.scratch-canvas.is-submitting { cursor: progress; }
.scratch-canvas.is-disabled { cursor: not-allowed; opacity: .78; }
.scratch-canvas.is-complete { pointer-events: none; }
.scratch-choice.is-revealed { border-style: solid; }

.result-message { margin: .9rem 0 0; min-height: 1.5em; font-weight: 800; }
.spinner { width: 42px; height: 42px; border: 5px solid #d9e3ec; border-top-color: #0f4c81; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 681px) and (max-width: 1180px) {
  .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .question-set-card, .session-summary { align-items: stretch; flex-direction: column; }
  .question-set-card .primary-button { width: 100%; }
  .score-summary { text-align: left; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scratch-choice { min-height: 124px; }
}

@media (max-width: 390px) {
  .choice-grid { grid-template-columns: 1fr; }
  .scratch-choice { aspect-ratio: 1.8 / 1; }
}


.question-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: .85rem 1rem;
  border-radius: 14px;
  background: #eaf2f8;
  color: #173d5b;
  font-weight: 800;
}

.completion-card {
  background: #fff;
  border: 2px solid #3b9b5f;
  border-radius: 18px;
  padding: clamp(1.25rem, 4vw, 2.25rem);
  text-align: center;
  box-shadow: 0 8px 30px rgba(25,45,70,.09);
}

.completion-card h3 {
  margin: 0 0 .65rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.page-transition {
  animation: questionIn .28s ease-out;
}

@keyframes questionIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.scratch-canvas {
  transition: opacity .18s ease-out;
}

.next-question-prompt {
  margin-top: 1rem;
  padding: 1.1rem;
  border: 2px solid #0f4c81;
  border-radius: 16px;
  background: #f3f8fc;
  box-shadow: 0 8px 24px rgba(25,45,70,.08);
}

.next-question-prompt h3 { margin: 0 0 .4rem; }
.next-question-prompt p { margin: 0; }

.completion-total {
  margin: .5rem 0 1rem;
  font-size: 1.25rem;
  font-weight: 900;
}

.score-breakdown {
  width: min(520px, 100%);
  margin: 1rem auto 1.25rem;
  border: 1px solid #dce4ec;
  border-radius: 14px;
  overflow: hidden;
  text-align: left;
}

.score-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  background: #fff;
}

.score-breakdown > div:nth-child(even) { background: #f5f8fa; }
.score-breakdown dt, .score-breakdown dd { margin: 0; }
.score-breakdown dd { font-weight: 900; }


/* Unified GRAT SCRATCH 5 brand */
.brand-name {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 900;
  white-space: nowrap;
}
