:root {
  --fact-bg: #f6f8fc;
  --fact-panel: #ffffff;
  --fact-text: #10213a;
  --fact-muted: #58708d;
  --fact-line: #d6e0eb;
  --fact-accent: #0f766e;
  --fact-accent-soft: #dff7f3;
  --fact-correct: #166534;
  --fact-error: #b91c1c;
  --fact-shadow: 0 14px 36px rgba(16, 33, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--fact-bg);
  color: var(--fact-text);
}

.fast-facts-zine {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.page-content:has(.fast-facts-zine[data-page="practice"]) {
  padding: 10px 12px;
}

.fast-facts-zine[data-page="practice"] {
  padding: 0;
}

.zine-page {
  display: grid;
  gap: 16px;
  min-height: calc(100dvh - 154px);
}

.zine-page[hidden] {
  display: none !important;
}

.setup-page {
  min-height: 0;
}

.practice-page {
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  grid-template-rows: auto;
  min-height: 0;
}

.zine-card {
  min-width: 0;
  min-height: 0;
  background: var(--fact-panel);
  border: 1px solid var(--fact-line);
  border-top: 8px solid var(--fact-accent);
  border-radius: 8px;
  box-shadow: var(--fact-shadow);
  overflow: hidden;
}

.setup-card,
.question-card,
.answer-card {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.setup-card {
  gap: 20px;
  padding: clamp(20px, 4vw, 40px);
}

.setup-card h1 {
  font-size: clamp(2.4rem, 7vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: 0;
  margin: 0;
}

.setup-card p {
  color: var(--fact-muted);
  font-size: clamp(1.05rem, 2.6vw, 1.35rem);
  margin: 0;
  max-width: 680px;
}

.back-link {
  color: var(--fact-accent);
  font-weight: 800;
  text-decoration: none;
}

.setup-card h2 {
  font-size: 1.35rem;
  margin: 12px 0 0;
}

.row-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.answer-form input {
  border: 2px solid var(--fact-line);
  border-radius: 8px;
  color: var(--fact-text);
  font: inherit;
  padding: 12px 14px;
}

.row-grid button {
  background: var(--fact-accent-soft);
  border: 2px solid var(--fact-accent);
  border-radius: 8px;
  color: var(--fact-text);
  cursor: pointer;
  font: inherit;
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  font-weight: 900;
  min-height: 76px;
  touch-action: manipulation;
}

.row-grid button:hover,
.row-grid button:focus-visible {
  background: var(--fact-accent);
  color: #fff;
}

.row-grid button:focus-visible {
  outline: 3px solid var(--fact-text);
  outline-offset: 3px;
}

.question-card {
  align-content: space-between;
}

.practice-page .question-card,
.practice-page .answer-card {
  gap: 10px;
  padding: 16px;
}

.row-status {
  color: var(--fact-muted);
  display: flex;
  font-weight: 800;
  justify-content: space-between;
  gap: 12px;
}

.equation {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: clamp(3.2rem, 11vw, 7rem);
  font-weight: 900;
  gap: 0.35em;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1;
  min-height: 1.12em;
  text-align: center;
}

.feedback {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--fact-line);
  border-radius: 8px;
  color: var(--fact-muted);
  display: flex;
  font-size: clamp(1rem, 2.7vw, 1.25rem);
  font-weight: 900;
  justify-content: center;
  min-height: 58px;
  padding: 10px 14px;
  text-align: center;
  width: 100%;
}

.feedback.correct {
  color: var(--fact-correct);
}

.feedback.error {
  color: var(--fact-error);
}

.answer-card {
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.72fr);
  grid-template-rows: minmax(0, 1fr) auto;
}

.answer-form {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.answer-label {
  display: none;
}

.answer-form input {
  height: 1px;
  opacity: 0;
  padding: 0;
  position: absolute;
  width: 1px;
}

.answer-display {
  align-items: center;
  background: #f8fafc;
  border: 2px solid var(--fact-line);
  border-radius: 8px;
  color: var(--fact-text);
  display: flex;
  font-size: clamp(2.6rem, 9vw, 5.4rem);
  font-weight: 900;
  justify-content: center;
  min-height: 96px;
  text-align: center;
}

.numpad {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 0;
}

.numpad button {
  align-items: center;
  background: #eef4fb;
  border: 1px solid var(--fact-line);
  border-radius: 8px;
  color: var(--fact-text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  font-weight: 900;
  justify-content: center;
  min-height: 52px;
  padding: 8px;
  touch-action: manipulation;
}

.numpad button:active {
  transform: scale(0.98);
}

.check-button {
  min-height: 52px;
}

.progress-stack {
  align-content: center;
  display: grid;
  gap: 14px;
  min-height: 0;
}

.progress-row {
  display: grid;
  gap: 8px;
}

.progress-copy {
  align-items: center;
  color: var(--fact-muted);
  display: flex;
  font-weight: 900;
  justify-content: space-between;
  gap: 12px;
}

.progress-copy strong {
  color: var(--fact-text);
}

.progress-track {
  background: #e7edf4;
  border-radius: 999px;
  height: 16px;
  overflow: hidden;
}

.progress-fill {
  background: var(--fact-accent);
  border-radius: inherit;
  height: 100%;
  transition: width 0.28s ease;
  width: 0%;
}

.all-progress-fill {
  background: #2563eb;
}

.practice-actions {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.practice-actions .btn {
  min-height: 46px;
}

@media (max-width: 760px) {
  .fast-facts-zine {
    width: min(100% - 24px, 430px);
    padding: 10px 0;
  }

  .fast-facts-zine[data-page="practice"] {
    width: min(100% - 8px, 430px);
    padding: 0;
  }

  .practice-page {
    gap: 8px;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: 0;
  }

  .setup-card {
    padding: 16px;
  }

  .setup-card h1 {
    font-size: clamp(2.15rem, 10vw, 2.95rem);
  }

  .setup-card p {
    font-size: 1rem;
    line-height: 1.42;
  }

  .row-grid {
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .row-grid button {
    font-size: 1.05rem;
    min-height: 64px;
    white-space: nowrap;
  }

  .practice-page .question-card,
  .practice-page .answer-card {
    gap: 6px;
    padding: 10px 12px;
  }

  .practice-page .question-card {
    align-content: normal;
    grid-template-rows: auto auto auto;
  }

  .equation {
    font-size: clamp(1.8rem, 9vw, 3.5rem);
    min-height: 0;
  }

  .feedback {
    font-size: 0.9rem;
    min-height: 34px;
    padding: 4px 8px;
  }

  .practice-page .answer-card {
    grid-template-columns: minmax(0, 1.8fr) minmax(94px, 1fr);
    grid-template-rows: auto auto;
  }

  .answer-form {
    gap: 5px;
  }

  .answer-display {
    font-size: 2rem;
    min-height: 44px;
  }

  .numpad {
    gap: 5px;
  }

  .numpad button {
    font-size: 1rem;
    min-height: 38px;
    padding: 4px;
  }

  .check-button {
    min-height: 40px;
  }

  .progress-stack {
    align-content: center;
    gap: 10px;
  }

  .progress-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    font-size: 0.85rem;
  }

  .progress-track {
    height: 10px;
  }

  .practice-actions .btn {
    font-size: 0.88rem;
    min-height: 40px;
    padding: 8px 6px;
  }
}

@media (max-height: 700px) {
  body:has(.fast-facts-zine[data-page="practice"]) .site-header {
    display: none;
  }

  .practice-page .answer-card,
  .practice-page .question-card {
    padding: 10px;
  }

  .answer-display {
    min-height: 42px;
  }

  .numpad button {
    min-height: 34px;
  }

  .check-button,
  .practice-actions .btn {
    min-height: 36px;
  }
}

@media (min-width: 761px) and (max-height: 520px) {
  .practice-page .answer-card,
  .practice-page .question-card {
    gap: 6px;
    padding: 8px;
  }

  .equation {
    font-size: clamp(2.5rem, 8vw, 4.2rem);
    min-height: 0;
  }

  .feedback {
    min-height: 32px;
    padding: 2px 6px;
  }

  .answer-card {
    grid-template-rows: auto auto;
  }

  .answer-form,
  .numpad {
    gap: 4px;
  }

  .answer-display {
    font-size: 2rem;
    height: 42px;
  }

  .numpad button {
    font-size: 1rem;
    height: 28px;
    min-height: 28px;
    padding: 0;
  }

  .check-button,
  .practice-actions .btn {
    min-height: 32px;
  }

  .progress-stack {
    gap: 6px;
  }

  .progress-track {
    height: 10px;
  }
}
