/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #191c17;
  --surface:   #232920;
  --surface2:  #2d352a;
  --border:    #465241;
  --text:      #eef2ea;
  --text-muted:#a9b6a2;
  --accent:    #7fae6b;
  --green:     #4CAF50;
  --red:       #E74C3C;
  --radius:    14px;
  --radius-sm: 8px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen { display: none; max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
.screen.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Auth screen ───────────────────────────────────────────────────────────── */
#screen-auth { align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; max-width: 100%; }
#screen-auth.active { display: flex; }

.auth-wrap { width: 100%; max-width: 400px; text-align: center; }
.auth-logo  { font-size: 56px; margin-bottom: 8px; }
.auth-brand { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; margin-bottom: 28px; }

.auth-form  { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.auth-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .95rem;
  padding: 12px 14px; outline: none; transition: border-color .15s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--text-muted); }

.auth-error {
  background: #E74C3C18; border: 1px solid #E74C3C40; color: #E74C3C;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: .85rem; text-align: left;
}

.auth-switch { font-size: .85rem; color: var(--text-muted); }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: inherit; text-decoration: underline; padding: 0;
}

/* ── App header ────────────────────────────────────────────────────────────── */
header { margin-bottom: 20px; }
.header-row {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.header-brand { font-weight: 800; font-size: 1.1rem; }
.header-user  { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--text-muted); }
.logout-btn {
  background: none; border: 1px solid var(--border); border-radius: 99px;
  color: var(--text-muted); font-size: .75rem; padding: 4px 10px; cursor: pointer;
  transition: border-color .15s;
}
.logout-btn:hover { border-color: var(--text-muted); color: var(--text); }

/* ── Stats bar ─────────────────────────────────────────────────────────────── */
.stats-bar { display: flex; gap: 10px; margin-bottom: 14px; }
.stat {
  flex: 1; background: var(--surface); border-radius: var(--radius);
  padding: 12px 8px; text-align: center; border: 1px solid var(--border);
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.stat-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* ── Rank bar ──────────────────────────────────────────────────────────────── */
.rank-bar-wrap { margin-bottom: 20px; }
.rank-label { font-weight: 700; margin-bottom: 6px; font-size: .88rem; }
.rank-bar  { height: 10px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.rank-fill { height: 100%; background: linear-gradient(90deg, #7fae6b, #4d8f6a); border-radius: 99px; transition: width .6s ease; }
.rank-next { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }

/* ── Start box (home primary CTA) ─────────────────────────────────────────── */
.start-box { margin-bottom: 24px; }

/* ── Push notification opt-in banner ──────────────────────────────────────── */
.push-banner {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px;
  font-size: .88rem;
}
.push-banner-actions { display: flex; gap: 8px; }
.push-banner-actions .btn-primary, .push-banner-actions .btn-secondary { margin: 0; flex: 1; padding: 9px; font-size: .85rem; }

/* ── Section (batch group) ────────────────────────────────────────────────── */
.tier-section  { margin-bottom: 28px; }
.tier-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.tier-header-left { display: flex; align-items: center; gap: 12px; }
.tier-icon     { font-size: 1.6rem; flex-shrink: 0; }
.tier-name     { font-weight: 800; font-size: .95rem; }
.tier-tagline  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.tier-prog     { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tier-prog-bar { width: 70px; height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.tier-prog-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.tier-prog-count { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

/* ── Batch tile grid ───────────────────────────────────────────────────────── */
.move-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.move-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-top: 3px solid var(--tile-color, var(--accent));
  border-radius: var(--radius-sm); padding: 10px 8px 8px;
  cursor: pointer; text-align: left; color: var(--text);
  transition: transform .12s, border-color .12s;
  min-height: 70px; display: flex; flex-direction: column; justify-content: space-between;
}
.move-tile:hover:not(.move-locked):not(.move-readonly) { transform: translateY(-2px); border-color: var(--tile-color, var(--accent)); }
.move-tile.move-done { background: color-mix(in srgb, var(--tile-color) 6%, var(--surface)); border-color: color-mix(in srgb, var(--tile-color) 40%, transparent); }
.move-tile.move-locked  { opacity: .4; cursor: default; filter: grayscale(80%); }
.move-tile.move-readonly { cursor: default; }
.move-tile-name   { font-size: .82rem; font-weight: 700; line-height: 1.3; margin-bottom: 6px; }
.move-tile-bottom { display: flex; justify-content: space-between; align-items: center; }
.move-xp          { font-size: .68rem; font-weight: 700; color: var(--tile-color, var(--accent)); opacity: .8; }
.move-stars       { font-size: .65rem; }
.move-lock-icon   { font-size: .8rem; }

/* ── Back button ───────────────────────────────────────────────────────────── */
.back-btn {
  background: none; border: none; color: var(--text-muted); font-size: .9rem;
  cursor: pointer; padding: 6px 0; margin-bottom: 20px; display: flex; align-items: center; gap: 4px;
}
.back-btn:hover { color: var(--text); }

/* ── Batch detail ──────────────────────────────────────────────────────────── */
.move-breadcrumb  { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; }
.move-title       { font-size: 1.6rem; font-weight: 800; margin-bottom: 12px; }
.move-meta-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.xp-pill   { background: #7fae6b20; color: #7fae6b; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; }
.unit-pill { background: #9B59B620; color: #9B59B6; padding: 2px 10px; border-radius: 99px; font-size: .75rem; }

.best-box {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; font-size: .85rem; color: var(--text-muted); margin-bottom: 18px;
}

/* ── Log input / activity entries (parent batch view) ───────────────────────── */
.log-input-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 20px;
}
.log-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 10px; }
.entry-total {
  font-size: .8rem; font-weight: 700; color: var(--accent);
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.entry-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .85rem;
}
.entry-row:last-child { border-bottom: none; }
.entry-date  { color: var(--text-muted); font-size: .78rem; min-width: 60px; }
.entry-value { flex: 1; font-weight: 600; }

/* ── Practice session ──────────────────────────────────────────────────────── */
.practice-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.practice-top-info {
  flex: 1; display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: .9rem;
}
.practice-count { color: var(--text-muted); font-weight: 600; }
.practice-exit-btn {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted);
  font-size: 1rem; line-height: 1; cursor: pointer; transition: border-color .15s, color .15s;
}
.practice-exit-btn:hover { border-color: var(--red); color: var(--red); }

.q-dots { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 18px; }
.q-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); }
.q-dot-done    { background: var(--accent); border-color: var(--accent); }
.q-dot-current { background: var(--text); border-color: var(--text); }

/* ── The board itself ─────────────────────────────────────────────────────── */
.board-box {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; margin-bottom: 16px; transition: border-color .2s, background .2s;
}
.board-box.board-good { border-color: var(--green); background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
.board-box.board-help { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.board-box.board-bad   { border-color: var(--red);   background: color-mix(in srgb, var(--red) 8%, var(--surface)); }

.board-instructions-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.board-instructions { flex: 1; font-size: 1.05rem; font-weight: 700; text-align: left; min-height: 2.6em; }
.speak-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 1.1rem; cursor: pointer; transition: border-color .15s;
}
.speak-btn:hover { border-color: var(--accent); }
.chessboard-el {
  width: 100%; max-width: 420px; aspect-ratio: 1; margin: 0 auto;
  border-radius: var(--radius-sm); overflow: hidden;
}
.board-status { font-size: .85rem; color: var(--text-muted); margin-top: 12px; min-height: 1.2em; }
.feedback { margin-top: 10px; font-size: 1.1rem; font-weight: 700; }

.board-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.board-actions .btn-secondary { margin: 0; flex: 1; }

/* ── Session results ───────────────────────────────────────────────────────── */
.results-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 36px 24px; text-align: center; margin-top: 40px;
}
.results-emoji { font-size: 3rem; margin-bottom: 10px; }
.results-stars { font-size: 1.8rem; margin-bottom: 12px; letter-spacing: 4px; }
.results-score { font-size: 1.4rem; font-weight: 800; margin-bottom: 8px; }
.results-msg   { color: var(--text-muted); margin-bottom: 10px; font-size: .9rem; }
.results-xp    { font-size: 1.1rem; font-weight: 800; color: var(--accent); margin-bottom: 20px; }
.results-actions { margin-top: 12px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; background: var(--accent); color: #14180f; border: none;
  border-radius: var(--radius); font-size: 1rem; font-weight: 700; padding: 14px;
  cursor: pointer; margin-bottom: 10px; transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-large { font-size: 1.1rem; padding: 16px; }
.btn-secondary {
  display: block; width: 100%; background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem;
  padding: 12px; cursor: pointer; transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--text-muted); }

/* ── Parent dashboard ──────────────────────────────────────────────────────── */
.parent-hero {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.parent-hero-title { font-size: 1.4rem; font-weight: 800; }

.btn-add {
  background: var(--accent); color: #14180f; border: none;
  border-radius: var(--radius-sm); font-size: .9rem; font-weight: 700;
  padding: 8px 16px; cursor: pointer; transition: opacity .15s;
}
.btn-add:hover { opacity: .9; }

.add-kid-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 12px;
}
.form-title { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.form-hint  { font-size: .8rem; color: var(--text-muted); }

.mode-select { display: flex; flex-direction: column; gap: 8px; }
.mode-option {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; font-size: .9rem;
}
.mode-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface2)); }
.mode-option input { accent-color: var(--accent); }
.mode-option small { flex-basis: 100%; color: var(--text-muted); font-size: .72rem; }

.form-row   { display: flex; gap: 10px; }
.form-row .btn-primary   { margin: 0; }
.form-row .btn-secondary { margin: 0; }
.form-error {
  background: #E74C3C18; border: 1px solid #E74C3C40; color: #E74C3C;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: .85rem;
}

.trainee-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.trainee-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent);
  color: #14180f; font-size: 1.2rem; font-weight: 800; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.trainee-info      { flex: 1; min-width: 0; }
.trainee-name      { font-weight: 700; font-size: .95rem; }
.trainee-meta      { font-size: .75rem; color: var(--text-muted); margin-top: 2px; margin-bottom: 6px; }
.trainee-prog-row  { display: flex; align-items: center; gap: 8px; }
.trainee-prog-bar  { flex: 1; height: 5px; background: var(--surface2); border-radius: 99px; overflow: hidden; max-width: 120px; }
.trainee-prog-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.trainee-prog-count { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.trainee-actions   { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }

.btn-view {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: .8rem; padding: 6px 12px; cursor: pointer; white-space: nowrap;
  transition: border-color .15s;
}
.btn-view:hover { border-color: var(--accent); }

.empty-state {
  text-align: center; color: var(--text-muted); padding: 40px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ── Kid view (read-only) ──────────────────────────────────────────────────── */
.trainee-view-hero {
  display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.trainee-view-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--accent);
  color: #14180f; font-size: 1.4rem; font-weight: 800; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.trainee-view-name { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.trainee-view-meta { font-size: .8rem; color: var(--text-muted); }

.mode-switch-row {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 20px; font-size: .85rem;
}
.mode-switch-select {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: .82rem; padding: 6px 10px; cursor: pointer;
}

/* ── Activity log (parent view) ────────────────────────────────────────────── */
.activity-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-top: 12px;
}
.activity-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted); margin-bottom: 12px;
}
.activity-empty { font-size: .85rem; color: var(--text-muted); text-align: center; padding: 8px 0; }
.activity-move {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--border); font-size: .85rem;
}
.activity-move:last-child { border-bottom: none; }
.activity-move-name { color: var(--text); }
.activity-move-stars { font-size: .78rem; white-space: nowrap; }
.activity-move-value { color: var(--text-muted); font-size: .75rem; }

.activity-day-summary {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: .85rem;
}
.activity-day-summary:last-of-type { border-bottom: none; }
.activity-day-label { flex: 1; color: var(--text); font-weight: 600; text-transform: capitalize; }
.activity-day-meta { color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
.activity-day-toggle { color: var(--accent); font-size: .72rem; white-space: nowrap; flex-shrink: 0; }
.activity-day-details { padding: 4px 0 10px 4px; }
.activity-day-details.hidden { display: none; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 20px; border-radius: 99px;
  font-size: .9rem; pointer-events: none; z-index: 100; white-space: nowrap;
  animation: fadeIn .2s ease;
}
.hidden { display: none !important; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .stats-bar { gap: 6px; }
  .trainee-card { flex-wrap: wrap; }
  .trainee-actions { flex-direction: row; }
  .board-instructions { font-size: .95rem; }
}
