/* Site pages (tokens, resets and animations come from base.css): kid pages are a few big pastel
   cards on squared notebook paper; parent pages reuse the same cards in a calmer, denser list. */
body { line-height: 1.4; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 800; line-height: 1.08; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
h2 { font-size: 1.35rem; }
p { margin: 0; }
.muted { color: var(--ink-soft); }

.app {
  max-width: 980px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 36px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 52px;
  margin-bottom: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  text-decoration: none;
}
.brand img { width: 38px; height: 38px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav a, .nav button {
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--ink-soft);
  text-decoration: none;
}
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); }
.nav form { margin: 0; }
.back, .hold {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink-soft);
  text-decoration: none;
}
.back { width: 44px; }
.back svg { width: 22px; height: 22px; }
.hold {
  position: relative;
  overflow: hidden;
  padding: 0 14px;
  font-weight: 800;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.hold::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: color-mix(in srgb, var(--cJ) 30%, transparent);
}
.hold.holding::before { width: 100%; transition: width 1.4s linear; }
.hold span { position: relative; }

.notice {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 2px solid color-mix(in srgb, var(--ok) 50%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--ok) 14%, var(--surface));
}

/* ---------- cards & buttons (same look as the worksheets and the game) ---------- */
.card {
  --c: var(--cC);
  position: relative;
  border: 2px solid var(--c);
  border-radius: 24px;
  background: color-mix(in srgb, var(--c) 20%, var(--sheet));
  box-shadow: var(--shadow);
}
.card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed color-mix(in srgb, var(--c) 60%, transparent);
  border-radius: 18px;
  pointer-events: none;
}
.card > * { position: relative; }
.tinted { color: color-mix(in srgb, var(--c) 45%, var(--ink)); }

.btn {
  --c: var(--cD);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 10px 22px;
  border: 0;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c) 80%, var(--shade));
  color: var(--on-accent);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 50%, var(--shade));
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 50%, var(--shade)); }
.btn.quiet {
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--key-edge);
}
.btn.danger { --c: var(--cC); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: .95rem; }

/* ---------- friends ---------- */
.friends-page { display: grid; gap: 18px; max-width: 640px; margin: 0 auto; }
.friends-page h2 { margin-top: 6px; }
.code-card { display: grid; gap: 6px; padding: 18px 20px; text-align: center; }
.code {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.invite {
  padding: 14px 18px;
  border: 2px dashed color-mix(in srgb, var(--cD) 60%, var(--line));
  border-radius: 18px;
}
.invite summary { font-weight: 800; cursor: pointer; }
.invite p { margin: 10px 0 12px; }
.invite-link { display: flex; flex-wrap: wrap; gap: 10px; }
.invite-link .form-control { flex: 1 1 240px; min-width: 0; font-size: .95rem; }
.row form { margin-left: auto; }
.confirm-email h2 { margin: 0; }
.confirm-email .form-control { max-width: 12em; letter-spacing: .15em; font-variant-numeric: tabular-nums; }

/* ---------- kid pages ---------- */
/* One definite column: sized by content, the card grids inside would lay out wider than a phone. */
.who, .menu { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 24px; text-align: center; }
.who-grid, .games {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 760px;
}
.who-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 220px)); justify-content: center; }
.who-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 26px 16px 22px;
  text-decoration: none;
}
.who-card img { width: clamp(100px, 22vw, 140px); height: auto; }
.who-card span { font-family: var(--display); font-weight: 800; font-size: 1.7rem; line-height: 1.1; }
.hello { display: grid; justify-items: center; gap: 6px; }
.hello img { width: clamp(100px, 24vw, 140px); height: auto; }
/* Today's rounds against the daily goal, and the streak of days played. */
.goal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
  width: 100%;
  max-width: 760px;
  padding: 12px 18px;
}
.goal-dots { display: inline-flex; gap: 6px; }
.goal-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--c) 70%, var(--ink)); background: var(--surface); }
.goal-dots i.on { border-color: transparent; background: color-mix(in srgb, var(--c) 85%, var(--shade)); }
.goal .t { font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.goal .s { flex-basis: 100%; color: var(--ink-soft); font-size: .95rem; }
.games { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
/* The menu's level headings: a numbered badge, left-aligned above its row of games. */
.level {
  justify-self: start;
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px auto -12px;
  font-size: 1.1rem;
  color: var(--ink-soft);
  text-align: left;
}
.level span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding-top: 3px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--cJ) 85%, var(--shade));
  color: var(--on-accent);
  font-size: 1.2rem;
  line-height: 1;
}
.game-card {
  display: grid;
  gap: 6px;
  padding: 22px 22px 20px;
  text-align: left;
  text-decoration: none;
}
.game-card .t { font-family: var(--display); font-weight: 800; font-size: 1.55rem; line-height: 1.1; }
.game-card .s { color: var(--ink-soft); }
.due {
  justify-self: start;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cC) 85%, var(--shade));
  color: var(--on-accent);
  font-size: .95rem;
}
/* A friend is waiting for an answer: the same problems they played. */
.due.challenge { background: color-mix(in srgb, var(--cF) 85%, var(--shade)); }
.challenge-list .row { align-items: center; gap: 6px 12px; }
.challenge-list .row:first-child { border-top: 0; }
.challenge-list .score, .challenge-list .btn { margin-left: auto; }

/* ---------- parent pages ---------- */
.parents { display: grid; gap: 18px; }
.narrow { max-width: 640px; }
.head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  padding: 18px 20px;
}
.kid img { width: 76px; height: 76px; }
.kid-text { flex: 1 1 220px; min-width: 0; display: grid; gap: 4px; }
.kid-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.empty { display: grid; gap: 14px; justify-items: start; padding: 22px; }

.form { display: grid; gap: 16px; padding: 22px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* FormKit renders Bootstrap 5 field markup; these rules give it the site's look. */
.form .mb-3 { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.form-label { padding: 0; font-weight: 800; }
.form-label .text-danger { color: var(--bad); }
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
}
.form-control::placeholder { color: color-mix(in srgb, var(--ink-soft) 70%, transparent); font-weight: 600; }
.form-control:focus { outline: none; border-color: var(--cJ); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cJ) 25%, transparent); }
.form-control.is-invalid { border-color: var(--bad); }
.invalid-feedback { color: var(--bad); font-weight: 800; }
.form-text { color: var(--ink-soft); font-weight: 600; font-size: .95rem; }
.form-check { display: inline-flex; align-items: center; gap: 10px; }
.form-check-input { width: 22px; height: 22px; margin: 0; accent-color: var(--cJ); }
.avatar-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.pick {
  --c: var(--cJ);
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 6px 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  font-size: .95rem;
  text-align: center;
  cursor: pointer;
}
.pick img { width: 64px; height: 64px; }
.pick input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.pick:has(input:checked) {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 25%, transparent);
}
.pick:has(input:focus-visible) { outline: 3px solid var(--cJ); outline-offset: 2px; }
.danger-zone {
  padding: 14px 18px;
  border: 2px dashed color-mix(in srgb, var(--bad) 50%, var(--line));
  border-radius: 18px;
}
.danger-zone summary { color: var(--bad); font-weight: 800; cursor: pointer; }
.danger-zone p { margin: 10px 0 12px; }
.danger-zone .form { padding: 0; }
.devices h3 { margin: 12px 0 2px; font-size: 1.05rem; }
.device { align-items: center; }
.device-name { flex: 1 1 14em; }
.parents-list .invite { margin-top: 14px; }

.kid-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.kid-head img { width: 80px; height: 80px; }
.kid-head > div { flex: 1 1 200px; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.stat .v { font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--ink-soft); font-size: .95rem; }
.panel {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}
.panel h2 { margin-bottom: 6px; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.eq { font-family: var(--display); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.session { border-top: 1px solid var(--line); }
.session summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 0;
  list-style: none;
  cursor: pointer;
}
.session summary::-webkit-details-marker { display: none; }
.when { min-width: 10.5em; }
.what { flex: 1 1 14em; color: var(--ink-soft); }
.score { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.chip {
  --c: var(--cD);
  padding: 1px 10px;
  border: 1.5px solid var(--c);
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  font-size: .9rem;
}
.mastery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 6px 24px; }
.mastery-row { display: grid; grid-template-columns: 3.2em minmax(0, 1fr) 3em; align-items: center; gap: 10px; }
.meter { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.meter i { height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--cF) 16%, var(--surface)); border: 1px solid var(--line); }
.meter i.on { background: color-mix(in srgb, var(--cF) 85%, var(--shade)); border-color: transparent; }
.mistake-list { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.mistake-list li {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sheet);
}
.was, .should { font-family: var(--hand); font-weight: 400; font-size: 1.25em; }
.was { color: var(--bad); }
.should { color: var(--ok); }
.session > p { padding-bottom: 12px; }

.login {
  max-width: 440px;
  margin: 5vh auto 0;
  padding: 28px 24px;
  display: grid;
  gap: 14px;
  text-align: center;
}
.login > img { width: 96px; justify-self: center; }
.login .form { padding: 0; text-align: left; }
.switch { justify-self: center; color: var(--ink-soft); font-weight: 800; }

/* kids sign in with the same big keypad as in the game */
.kid-login { max-width: 400px; }
.pin-dots { display: flex; justify-content: center; gap: 18px; padding: 4px 0; }
.pin-dots span {
  width: 24px;
  height: 24px;
  border: 3px solid color-mix(in srgb, var(--c) 70%, var(--ink));
  border-radius: 50%;
  background: var(--surface);
}
.pin-dots span.on { border-color: transparent; background: color-mix(in srgb, var(--c) 85%, var(--shade)); }
.pin-dots.shake { animation: shake .42s; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  height: 64px;
  padding-top: 4px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--key-edge);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.9rem;
  line-height: 1;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--key-edge); }
.key svg { width: 30px; height: 30px; margin-top: -4px; }
.key.del { color: var(--ink-soft); }
.key.ok {
  border-color: transparent;
  background: var(--go);
  color: var(--on-accent);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--go) 55%, var(--shade));
}
.signout button {
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  text-decoration: underline;
}
.signin {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 2px dashed color-mix(in srgb, var(--c) 40%, var(--line));
}
.signin legend { float: left; width: 100%; padding: 0; font-weight: 800; }
.signin .muted { font-weight: 600; }
