:root {
  --paper: #fbf7ef;
  --bg: #f2ede0;
  --ink: #14231c;
  --ink-soft: #2b3f34;
  --orange: #c4674a;
  --orange-dark: #a9553b;
  --green: #3f7a52;
  --green-dark: #2f5d3e;
  --mustard: #e0b23c;
  --muted: #8a9a8f;
  --radius: 24px;
  --radius-sm: 14px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* The faint dot grid behind everything */
.dots {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(20, 35, 28, 0.13) 1.6px, transparent 1.6px);
  background-size: 24px 24px;
  background-position: 12px 12px;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0 auto;
  padding: 28px 18px 64px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
}

/* ---------- masthead ---------- */

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green);
  text-align: center;
  margin: 6px 0 0;
}

.logo {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(38px, 11vw, 58px);
  line-height: 1;
  text-align: center;
  margin: 4px 0 2px;
  letter-spacing: -0.01em;
}

.logo.small {
  font-size: clamp(21px, 5.5vw, 26px);
  margin: 0 0 2px;
  color: var(--ink-soft);
}

.eyebrow .amp,
.logo .amp {
  color: var(--orange);
  font-style: italic;
  padding: 0 0.06em;
}

.yours {
  margin: 18px 0 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink-soft);
}

/* ---------- cards ---------- */

.card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 24px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chip {
  display: inline-block;
  background: var(--green);
  color: var(--paper);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 15px;
  font-weight: 800;
}

.chip.mustard {
  background: var(--mustard);
  color: var(--ink);
}

.streak {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
}

.streak b {
  color: var(--orange);
  font-size: 17px;
}

.instruction {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
}

.prompt {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(22px, 6vw, 31px);
  line-height: 1.24;
  margin: 0 0 4px;
  white-space: pre-wrap;
}

.prompt.long {
  font-size: clamp(18px, 4.4vw, 22px);
  line-height: 1.42;
}

.groups {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(19px, 5vw, 25px);
  margin: 14px 0 2px;
  line-height: 1.35;
}

.figure {
  margin: 18px 0 6px;
  padding: 12px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
}

/* ---------- answering ---------- */

.answer-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  align-items: stretch;
}

.input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--ui);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  outline: none;
}

.input::placeholder {
  color: #9a9a92;
  font-weight: 600;
}

.input:focus {
  box-shadow: 0 0 0 4px rgba(196, 103, 74, 0.22);
}

.btn {
  font-family: var(--ui);
  font-size: 18px;
  font-weight: 800;
  color: var(--paper);
  background: var(--orange);
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 14px 26px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  -webkit-appearance: none;
}

.btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.btn.big {
  width: 100%;
  font-size: 22px;
  padding: 20px 26px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn.big:active {
  transform: translate(6px, 6px);
}

.btn.ghost {
  background: var(--paper);
  color: var(--ink);
}

.btn.green {
  background: var(--green);
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.options.two-col {
  grid-template-columns: 1fr 1fr;
}

.option {
  font-family: var(--ui);
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.12s ease;
}

.option:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.option .letter {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg);
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
}

.option.picked {
  background: var(--mustard);
}

.option.picked .letter {
  background: var(--paper);
}

.option.right {
  background: var(--green);
  color: var(--paper);
}

.option.right .letter {
  background: var(--paper);
  color: var(--ink);
}

.option.wrong {
  background: #e8d9d3;
}

.option[disabled] {
  cursor: default;
  transform: none;
}

.stuck {
  display: inline-block;
  margin-top: 16px;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.hint {
  margin-top: 14px;
  font-size: 16px;
  font-weight: 700;
  font-style: italic;
  color: var(--green-dark);
  line-height: 1.4;
}

/* ---------- feedback ---------- */

.verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
}

.verdict.yes {
  color: var(--green);
}

.verdict.no {
  color: var(--orange-dark);
}

.explain {
  margin-top: 8px;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-soft);
}

.explain .was {
  display: block;
  margin-top: 6px;
  font-weight: 800;
  color: var(--ink);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.badge {
  font-size: 13px;
  font-weight: 800;
  border-radius: 999px;
  padding: 6px 13px;
  background: var(--mustard);
  border: 2px solid var(--ink);
}

/* ---------- progress pips ---------- */

.pips {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 2px 0;
}

.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: transparent;
}

.pip.done {
  background: var(--green);
}

.pip.missed {
  background: var(--orange);
}

.pip.now {
  background: var(--mustard);
  transform: scale(1.25);
}

/* ---------- mission (assignment) ---------- */

.mission {
  background: var(--mustard);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.mission h2 {
  font-family: var(--display);
  font-size: 21px;
  margin: 4px 0 6px;
}

.mission p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.4;
}

.bar {
  height: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width 0.4s ease;
}

/* ---------- topic strip ---------- */

.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.tile {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  text-align: center;
}

.tile.active {
  background: var(--mustard);
}

.tile .name {
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.2;
}

.tile .pipset {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.tile .pipset span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}

.tile .pipset span.on {
  background: var(--green);
}

/* ---------- footers, misc ---------- */

.footnote {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.footnote b {
  color: var(--orange);
}

.centre {
  text-align: center;
}

.big-score {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(46px, 15vw, 76px);
  line-height: 1;
  margin: 6px 0;
}

.big-score span {
  color: var(--orange);
}

.subtle-link {
  background: none;
  border: none;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
}

.profile-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.profile-btn {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 800;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
}

.profile-btn.on {
  background: var(--ink);
  color: var(--paper);
}

.offline-note {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

/* ---------- grown-ups view ---------- */

.gu h1 {
  font-family: var(--display);
  font-size: 28px;
  margin: 0 0 4px;
}

.gu table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-weight: 600;
}

.gu th,
.gu td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid #e0dccf;
  white-space: nowrap;
}

.gu th {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
}

.gu .scroll {
  overflow-x: auto;
}

.gu .grp {
  font-family: var(--display);
  font-size: 18px;
  margin: 22px 0 6px;
}

.gu .low {
  color: var(--orange-dark);
  font-weight: 800;
}

/* ---------- topic switches (grown-ups only) ---------- */

.gu .grp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.gu .chip-btn {
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
}

.gu .chip-btn:active {
  transform: translateY(1px);
}

.gu .toggle-cell {
  width: 34px;
  padding-right: 0;
}

/* Big enough to hit with a thumb, small enough not to dominate the row. */
.gu .toggle {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--paper);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.gu .toggle.on {
  background: var(--green);
  color: var(--paper);
}

/* A switched-off topic is dimmed rather than hidden: the tutor needs to see what
   exists but is not yet taught, because that list is the teaching queue. */
.gu tr.off td {
  opacity: 0.45;
}

.gu tr.off .toggle-cell {
  opacity: 1;
}

.gu .token-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
}

.gu .token-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.gu .token-row input {
  flex: 1;
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 700;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  min-width: 0;
}

.gu .toggle-status {
  min-height: 18px;
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.gu .toggle-status.bad {
  color: var(--orange-dark);
}

@media (max-width: 420px) {
  .app {
    padding: 20px 14px 56px;
  }
  .card {
    padding: 18px 16px 20px;
  }
  .answer-row {
    flex-direction: column;
  }
  .options.two-col {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
