* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  user-select: none;
  -webkit-user-select: none;
  font-family: "Inter", sans-serif;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

.page-wrap {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Header ── */
.header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Same height as the other pages' header row (which has a share button) */
  min-height: 44px;
}

.back-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.header-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.header-title {
  font-family: "Inter Tight", sans-serif;
  font-size: 48px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -1px;
}

.header-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Sections ── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.section-summary {
  font-size: 12px;
  color: var(--text-secondary);
}

.hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.hint:empty {
  display: none;
}

.empty-note {
  font-size: 14px;
  line-height: 1.5;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
}

/* ── Mastery colours ── */
.level-mastered {
  background: var(--mastery-mastered);
  color: var(--mastery-mastered-text);
}

.level-learning {
  background: var(--mastery-learning);
  color: var(--mastery-learning-text);
}

.level-practice {
  background: var(--mastery-practice);
  color: var(--mastery-practice-text);
}

/* On the small squares, a white dot tells "needs practice" apart from "mastered" without relying on colour */
.fact.level-practice,
.swatch.level-practice {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 22%, transparent 26%),
    var(--mastery-practice);
}

.level-new {
  background: var(--mastery-new);
  color: var(--text-muted);
}

/* ── Legend ── */
.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* ── Times-table grid ── */
.grid-scroll {
  overflow-x: auto;
}

.fact-grid,
.kind-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
}

.fact-grid {
  border-spacing: 2px;
}

.fact-grid th,
.kind-grid th {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.kind-grid th {
  font-size: 13px;
}

.fact-grid th[scope="row"],
.kind-grid th[scope="row"] {
  padding-right: 2px;
}

.fact {
  border-radius: 3px;
}

/* Keeps every square square, whatever the screen width */
.fact::before {
  content: "";
  display: block;
  aspect-ratio: 1;
}

/* ── Factor pairs: one square per number ── */
.number-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr));
  gap: 3px;
}

.number {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── Integers grid ── */
.kind-grid {
  border-spacing: 4px;
}

.kind-grid .corner {
  width: 24px;
}

.fact-grid th.corner {
  width: auto;
}

.kind {
  border-radius: 8px;
  padding: 12px 0;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Practice weak spots ── */
.go-button {
  display: block;
  width: 100%;
  padding: 15px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-color);
  border-radius: 12px;
  transition:
    background 0.1s,
    transform 0.08s;
}

.go-button[hidden] {
  display: none;
}

.go-button:hover {
  background: var(--btn-primary-bg-hover);
}

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

/* ── Recent quizzes ── */
.quiz-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.quiz {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--divider);
}

.quiz:last-child {
  border-bottom: none;
}

.quiz-name {
  font-size: 14px;
  font-weight: 500;
}

.quiz-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.quiz-accuracy {
  font-family: "Inter Tight", sans-serif;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Clear ── */
.clear-btn {
  align-self: center;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 4px;
}

.clear-btn[hidden] {
  display: none;
}

.clear-btn:hover {
  color: var(--text);
}

/* ── Footer ── */
.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer-link {
  color: inherit;
  text-decoration: underline;
}

.footer-link:hover {
  color: var(--text-muted);
}

@media (max-width: 359px) {
  .header-title {
    font-size: 40px;
  }

  .fact-grid {
    border-spacing: 1px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .go-button {
    transition: none;
  }

  .go-button:active {
    transform: none;
  }
}
