:root {
  --bg: #0f1420;
  --bg-raised: #1a2233;
  --line: #2a3550;
  --text: #eef2fb;
  --text-dim: #9aa8c4;
  --accent: #5b8def;
  --good: #3fb984;
  --warn: #f0a447;
  --bad: #e2626b;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

#app { width: 100%; max-width: 480px; }

.hidden { display: none !important; }

.screen {
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fade 240ms ease both;
}

@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.title {
  margin: 8px 0 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}

.subtle { color: var(--text-dim); font-size: 14px; margin: 0; }
.center { text-align: center; }
.push-right { margin-left: auto; }

/* ---------- sign-in ---------- */

.people {
  display: grid;
  /* Fixed at two columns: with four of us that's a tidy 2×2 at any width,
     instead of reflowing to 3-and-a-lonely-1 on a wider screen. */
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.person {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.person:active { transform: scale(0.97); }
.person:hover { border-color: var(--accent); }

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  color: #0b1020;
  background: var(--accent);
  flex: none;
}

.signin-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.whoami { margin: 0; color: var(--text-dim); font-size: 15px; }
.whoami strong { color: var(--text); }

/* ---------- home ---------- */

.home-header { display: flex; align-items: center; gap: 12px; }
.home-header .avatar { width: 44px; height: 44px; font-size: 18px; }
.hello { margin: 0; font-size: 20px; font-weight: 650; }

.clock { position: relative; display: grid; place-items: center; margin: 6px 0; }
.ring { width: min(260px, 70vw); transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--bg-raised); stroke-width: 14; }
.ring-value {
  fill: none;
  stroke: var(--good);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 500ms ease, stroke 300ms ease;
}

.clock-center { position: absolute; text-align: center; }
.minutes { margin: 0; font-size: 58px; font-weight: 720; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.minutes-label { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }

.actions { display: flex; flex-direction: column; gap: 12px; }

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 15px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); color: #071026; }
.btn-secondary { background: var(--bg-raised); color: var(--text); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-link { background: none; border: none; color: var(--text-dim); padding: 8px; font-size: 14px; }

.soon {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 1px 7px;
}

.error { color: var(--bad); font-size: 14px; text-align: center; margin: 0; }

/* ---------- parent ---------- */

.kid-cards { display: flex; flex-direction: column; gap: 12px; }

.kid-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kid-card .avatar { width: 40px; height: 40px; font-size: 16px; }
.kid-card h2 { margin: 0; font-size: 17px; }
.kid-card .bar { height: 6px; border-radius: 3px; background: #0f1420; margin-top: 8px; overflow: hidden; }
.kid-card .bar span { display: block; height: 100%; background: var(--good); }

/* ---------- misc ---------- */

.spinner {
  width: 28px; height: 28px;
  margin: 60px auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- search + player (phase 2) ---------- */

.topbar { display: flex; align-items: center; gap: 12px; }

.time-pill {
  margin-left: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.time-pill.low { border-color: var(--warn); color: var(--warn); }
.time-pill.out { border-color: var(--bad); color: var(--bad); }

.search-form { display: flex; gap: 10px; }

.search-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  -webkit-appearance: none;
}

.search-form input:focus { outline: none; border-color: var(--accent); }

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

.result {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.result:active { transform: scale(0.99); }

.result img {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  background: #000;
  flex: none;
}

.result .meta { min-width: 0; }
.result .name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result .who { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.stage { position: relative; }

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
}

.frame iframe { width: 100%; height: 100%; border: 0; display: block; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 32, 0.94);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
}

.overlay h2 { margin: 0; font-size: 24px; }

.video-title { margin: 0; font-size: 17px; font-weight: 650; line-height: 1.3; }

/* ---------- quiz (phase 3) ---------- */

.dots { display: flex; gap: 7px; justify-content: center; }

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: transparent;
}

.dot.right { background: var(--good); border-color: var(--good); }
.dot.wrong { background: var(--bad); border-color: var(--bad); }

.quiz-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prompt {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.quiz-form { display: flex; flex-direction: column; gap: 12px; }

.quiz-form input {
  font: inherit;
  font-size: 22px;
  font-weight: 650;
  text-align: center;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  -webkit-appearance: none;
}

.quiz-form input:focus { outline: none; border-color: var(--accent); }

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.choice {
  font: inherit;
  font-size: 19px;
  font-weight: 650;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px 10px;
  cursor: pointer;
}

.choice.picked { border-color: var(--accent); background: rgba(91, 141, 239, 0.16); }

.feedback {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 4px solid var(--good);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feedback.miss { border-left-color: var(--bad); }
.feedback p { margin: 0; }
.feedback-headline { font-size: 18px; font-weight: 700; }
.feedback.miss .feedback-headline { color: var(--bad); }
.feedback:not(.miss) .feedback-headline { color: var(--good); }

.learn { color: var(--accent); font-size: 14px; text-decoration: none; font-weight: 600; }

.won {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.won-emoji { font-size: 56px; margin: 10px 0 0; }
.won h2 { margin: 0; font-size: 26px; }
.won .btn { width: 100%; }

#quiz.finished .topbar,
#quiz.finished .dots { display: none; }

/* ---------- parent detail (phase 4) ---------- */

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title { margin: 0; font-size: 15px; font-weight: 700; }
.panel-title .subtle { font-weight: 500; }

.kid-clock { margin: 0; font-size: 22px; font-weight: 700; }

.grant-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grant-row .btn { padding: 12px 4px; font-size: 15px; }

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

.standard { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.standard .name { font-size: 14px; font-weight: 600; }
.standard .code { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.standard .score { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.standard .track {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
}
.standard .track span { display: block; height: 100%; }
.standard.untested .score { color: var(--text-dim); font-weight: 500; }

.rows { display: flex; flex-direction: column; gap: 9px; }

.row-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.rows .row-item:last-child { border-bottom: none; padding-bottom: 0; }
.row-item .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .when { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.row-item .tag { font-size: 12px; font-weight: 700; }
.row-item .tag.pass { color: var(--good); }
.row-item .tag.quit { color: var(--text-dim); }

.kid-card { cursor: pointer; text-align: left; width: 100%; font: inherit; color: var(--text); }
.kid-card:active { transform: scale(0.995); }
