/* ============================================================
   Leitner System — Shared Stylesheet
   P3-4 Mathematics | credit: weelookang@gmail.com
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --pack-a: #ef4444;
  --pack-b: #f59e0b;
  --pack-c: #22c55e;
  --correct: #16a34a;
  --wrong:   #dc2626;
  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --bg:      #f0f9ff;
  --surface: #ffffff;
  --text:    #1e293b;
  --muted:   #64748b;
  --border:  #e2e8f0;
  --radius:  16px;
  --shadow:  0 4px 24px rgba(0,0,0,0.09);
  --btn-h:   54px;   /* smartboard-safe minimum */
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 14px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: clamp(1.4rem, 4vw, 2rem);   font-weight: 800; }
h2 { font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 700; }
h3 { font-size: clamp(0.95rem, 2.5vw, 1.2rem); font-weight: 600; }
p  { line-height: 1.6; }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 900px; margin: 0 auto; }

/* ── Page Header (topic pages) ────────────────────────────── */
.page-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { flex: 1; min-width: 0; }

.back-btn {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1.1rem;
  padding: 0 14px;
  min-width: var(--btn-h);
  min-height: var(--btn-h);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text);
}
.back-btn:hover                  { background: #dbeafe; border-color: var(--primary); }
.back-btn:active,
.back-btn[data-touch-active="true"] { background: #bfdbfe; }

/* ── Pack Chips ───────────────────────────────────────────── */
.pack-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.pack-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 13px;
  border-radius: 100px;
  font-weight: 700; font-size: 0.82rem; color: white;
  min-height: 34px;
}
.pack-chip.A { background: var(--pack-a); }
.pack-chip.B { background: var(--pack-b); }
.pack-chip.C { background: var(--pack-c); }

/* ── Flash Card Scene ─────────────────────────────────────── */
.card-scene {
  perspective: 1000px;
  width: 100%; max-width: 520px;
  height: 220px;
  margin: 0 auto 18px;
  cursor: pointer;
}

.card-container {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.4,0,.2,1);
}
.card-container.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow); padding: 20px; text-align: center;
}
.card-front { background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: white; }
.card-back  { background: linear-gradient(135deg, #22c55e, #15803d); color: white; transform: rotateY(180deg); }

.card-pack-badge {
  position: absolute; top: 12px; right: 14px;
  font-size: 0.7rem; font-weight: 700; opacity: .85;
  background: rgba(255,255,255,.25); border-radius: 6px; padding: 2px 8px;
}
.card-question { font-size: clamp(2rem, 9vw, 3.5rem); font-weight: 900; line-height: 1.1; letter-spacing: -1px; }
.card-answer   { font-size: clamp(2.5rem,10vw, 4rem);  font-weight: 900; line-height: 1;   letter-spacing: -2px; }
.card-tap-hint { font-size: 0.8rem; opacity: .7; margin-top: 8px; }
.card-milestone{ font-size: 0.72rem; opacity: .7; margin-bottom: 6px; }

.listen-btn {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255,255,255,0.65);
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  color: inherit;
  font-size: 1.1rem;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.listen-btn:hover,
.listen-btn:focus-visible {
  background: rgba(255,255,255,0.28);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.24);
}
.card-listen-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
}
.wp-listen-btn,
.sentence-listen-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}
.sentence-listen-btn {
  margin-right: 8px;
  vertical-align: middle;
}

.card-scene:active .card-container:not(.flipped),
.card-scene[data-touch-active="true"] .card-container:not(.flipped) { transform: scale(0.97); }

/* ── Hint Panel ───────────────────────────────────────────── */
.hint-panel {
  background: #fefce8; border: 2px solid #fde68a;
  border-radius: 12px; padding: 12px 16px;
  margin: 0 auto 14px;
  max-width: 520px;
  font-size: 0.93rem; line-height: 1.6;
}
.hint-text { margin-bottom: 5px; }
.hint-text:last-child { margin-bottom: 0; }

.hint-svg { width: 100%; max-width: 360px; display: block; margin: 8px auto 0; overflow: visible; }

/* Multiplication grid */
.hint-grid-wrap { overflow-x: auto; }
.hint-grid { border-collapse: collapse; margin: 6px auto; font-size: 0.82rem; }
.hint-grid th,
.hint-grid td { width: 28px; height: 28px; text-align: center; border: 1px solid var(--border); font-weight: 600; }
.hint-grid th   { background: #dbeafe; }
.hint-grid .hrow th,
.hint-grid tr.hrow td { background: #fef3c7; }
.hint-grid .hcol      { background: #fef3c7; }
.hint-grid .hcell     { background: #f59e0b !important; color: white; font-size: 1rem; }
.hint-grid .hpart     { background: #fef9c3; }

.bar-model-hint { display: grid; gap: 10px; }
.bar-model {
  display: flex;
  min-height: 48px;
  overflow: hidden;
  border: 2px solid #334155;
  border-radius: 8px;
  background: #dcfce7;
  font-size: 0.82rem;
  font-weight: 800;
}
.bar-model span {
  display: grid;
  place-items: center;
  padding: 6px;
  text-align: center;
}
.bar-away {
  background: #fee2e2;
  color: #991b1b;
  border-right: 2px solid #334155;
}
.bar-left {
  flex: 1;
  color: #166534;
}

/* ── Misconception Tip ────────────────────────────────────── */
.misconception-tip {
  background: #fef2f2; border: 2px solid #fca5a5;
  border-radius: 12px; padding: 10px 14px;
  font-size: 0.88rem; color: #991b1b;
  max-width: 520px; margin: 0 auto 14px;
  display: flex; align-items: flex-start; gap: 8px;
}
.misconception-tip::before { content: '🤔'; font-size: 1.1rem; flex-shrink: 0; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--btn-h); min-width: 130px;
  padding: 12px 22px;
  border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 700;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s, background .1s;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18);
  letter-spacing: .01em;
}
.btn:active,
.btn[data-touch-active="true"] { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.18); }

.btn-know     { background: var(--correct); color: white; }
.btn-know:hover { background: #15803d; }
.btn-learning { background: var(--wrong);   color: white; }
.btn-learning:hover { background: #b91c1c; }
.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline  { background: var(--surface); color: var(--text); border: 2px solid var(--border); box-shadow: none; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger   { background: #fef2f2; color: var(--wrong); border: 2px solid #fca5a5; box-shadow: none; }
.btn-sm       { min-height: 44px; min-width: 80px; padding: 8px 16px; font-size: 0.875rem; }

/* ── Response Buttons Row ─────────────────────────────────── */
.response-buttons {
  display: flex; gap: 12px; justify-content: center;
  margin-bottom: 18px; flex-wrap: wrap;
}

/* ── Pack Visualiser ──────────────────────────────────────── */
.pack-visualiser {
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 14px; flex-wrap: wrap;
}
.pack-box {
  background: var(--surface); border-radius: 12px;
  padding: 12px 16px; text-align: center;
  box-shadow: var(--shadow); border-left: 5px solid;
  min-width: 88px;
}
.pack-box.A { border-color: var(--pack-a); }
.pack-box.B { border-color: var(--pack-b); }
.pack-box.C { border-color: var(--pack-c); }
.pack-box .pack-label    { font-size: 0.72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.pack-box .pack-count    { font-size: 1.9rem; font-weight: 900; line-height: 1.1; }
.pack-box.A .pack-count  { color: var(--pack-a); }
.pack-box.B .pack-count  { color: var(--pack-b); }
.pack-box.C .pack-count  { color: var(--pack-c); }
.pack-box .pack-schedule { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

/* ── Progress Bar ─────────────────────────────────────────── */
.progress-wrap { margin: 0 auto 16px; max-width: 520px; }
.progress-labels { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; }
.progress-bar  { height: 12px; background: var(--border); border-radius: 100px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 100px; transition: width .4s ease; min-width: 0; }

/* ── Session Complete Banner ──────────────────────────────── */
.session-complete {
  background: linear-gradient(135deg, #22c55e, #15803d);
  border-radius: var(--radius); padding: 32px;
  text-align: center; color: white;
  box-shadow: var(--shadow); max-width: 520px; margin: 0 auto 20px;
}
.session-complete h2 { font-size: 1.8rem; margin-bottom: 8px; }
.session-complete p  { opacity: .85; margin-bottom: 16px; }

/* ── Analytics Panel ──────────────────────────────────────── */
.analytics-panel {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-top: 18px; overflow: hidden;
}
.analytics-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #1e293b; color: white;
  cursor: pointer; min-height: 44px; gap: 8px;
}
.analytics-header h3 { font-size: 0.88rem; margin: 0; flex: 1; }
.analytics-toggle-icon { font-size: 1rem; transition: transform .25s; }
.analytics-toggle-icon.open { transform: rotate(180deg); }

.analytics-body {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
}
.analytics-body.open { max-height: 420px; overflow-y: auto; }

.analytics-tabs { display: flex; border-bottom: 1px solid var(--border); }
.analytics-tab {
  flex: 1; padding: 10px; font-size: 0.8rem; font-weight: 600;
  background: none; border: none; border-bottom: 3px solid transparent;
  cursor: pointer; color: var(--muted); min-height: 44px; transition: all .15s;
}
.analytics-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.log-container { padding: 8px 12px; }
.log-entry {
  display: grid; grid-template-columns: 60px 1fr;
  gap: 6px; padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem; align-items: start;
}
.log-entry:last-child { border-bottom: none; }
.log-time { color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }

.quiz-table { width: 100%; border-collapse: collapse; font-size: 0.74rem; }
.quiz-table th { background: #f8fafc; padding: 7px 6px; text-align: left; border-bottom: 2px solid var(--border); }
.quiz-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.quiz-table tr.qcorrect td { background: #f0fdf4; }
.quiz-table tr.qwrong   td { background: #fef2f2; }

.analytics-controls {
  display: flex; gap: 8px; padding: 8px 12px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.analytics-device { font-size: 0.72rem; color: var(--muted); align-self: center; margin-left: auto; }

/* ── Index: Welcome Banner ────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius); padding: 22px 24px;
  color: white; margin-bottom: 16px; box-shadow: var(--shadow);
}
.welcome-banner h1 { font-size: clamp(1.4rem,4vw,2rem); margin-bottom: 6px; }
.welcome-banner p  { opacity: .85; font-size: 0.92rem; }
.student-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.student-name-input {
  background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.4);
  border-radius: 8px; color: white; font-size: 1rem;
  padding: 8px 14px; min-height: 44px; min-width: 180px;
  outline: none; flex: 1; max-width: 260px;
  user-select: text; -webkit-user-select: text;
}
.student-name-input::placeholder { color: rgba(255,255,255,.6); }
.student-name-input:focus { border-color: white; }

/* ── Index: Today Banner ──────────────────────────────────── */
.today-banner {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.today-day  { font-size: 1.05rem; font-weight: 700; }
.today-note { font-size: 0.82rem; color: var(--muted); }

/* ── Index: Stats Bar ─────────────────────────────────────── */
.stats-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px,1fr));
  gap: 10px; margin-bottom: 16px;
}
.stat-card {
  background: var(--surface); border-radius: 12px;
  padding: 14px 10px; text-align: center; box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 900; color: var(--primary); }
.stat-label { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

/* ── Index: Topic Grid ────────────────────────────────────── */
.topic-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
  gap: 12px; margin-bottom: 20px;
}
.topic-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px 14px; text-align: center; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  min-height: 120px; justify-content: center;
  border-top: 5px solid;
  transition: transform .15s, box-shadow .15s;
}
.topic-card:hover        { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,0.14); }
.topic-card:active,
.topic-card[data-touch-active="true"] { transform: scale(0.97); }
.topic-icon { font-size: 2rem; line-height: 1; }
.topic-name { font-weight: 700; font-size: 0.92rem; }
.topic-due  { font-size: 0.72rem; color: var(--muted); }
.topic-card.addition       { border-color: #3b82f6; }
.topic-card.subtraction    { border-color: #8b5cf6; }
.topic-card.multiplication { border-color: #f59e0b; }
.topic-card.division       { border-color: #ef4444; }
.topic-card.wordproblems   { border-color: #22c55e; }
.topic-card.record         { border-color: #64748b; }
.topic-card.achievement    { border-color: #d97706; }

/* ── Index: Milestone Map ─────────────────────────────────── */
.milestone-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.milestone-section h2 { margin-bottom: 14px; }
.milestone-track {
  display: flex; gap: 4px; overflow-x: auto;
  padding-bottom: 8px; align-items: center;
}
.milestone-badge {
  flex-shrink: 0; width: 54px; height: 54px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; border: 3px solid var(--border);
  background: #f8fafc; color: var(--muted);
  cursor: pointer; transition: all .2s;
  position: relative;
}
.milestone-badge:hover      { border-color: var(--primary); color: var(--primary); }
.milestone-badge.achieved   { background: linear-gradient(135deg, #f59e0b, #d97706); border-color: #d97706; color: white; }
.milestone-num              { font-size: 1rem; line-height: 1; }
.milestone-pct              { font-size: 0.58rem; margin-top: 1px; }
.milestone-connector        { flex-shrink: 0; height: 3px; width: 16px; background: var(--border); border-radius: 2px; }
.milestone-connector.done   { background: #f59e0b; }

/* ── Multiplication Table Selector ────────────────────────── */
.table-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; justify-content: center; }
.table-btn {
  min-width: 54px; min-height: 54px; padding: 8px 12px;
  border-radius: 10px; border: 2px solid var(--border);
  background: var(--surface); font-size: 0.92rem; font-weight: 700;
  cursor: pointer; transition: all .15s; color: var(--text);
}
.table-btn:hover   { border-color: var(--primary); color: var(--primary); }
.table-btn.active  { background: var(--primary); border-color: var(--primary); color: white; }
.table-btn:active  { transform: scale(0.95); }

/* ── Word Problems ────────────────────────────────────────── */
.wp-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px 20px; box-shadow: var(--shadow);
  max-width: 580px; margin: 0 auto 16px;
}
.wp-question {
  font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 600;
  line-height: 1.7; margin-bottom: 18px;
}
.wp-question .highlight { background: #fef9c3; border-radius: 4px; padding: 0 3px; font-weight: 700; }
.wp-input-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wp-answer-input {
  flex: 1; min-width: 100px; max-width: 160px;
  padding: 12px 16px; font-size: 1.4rem; font-weight: 700;
  border: 3px solid var(--border); border-radius: 10px;
  text-align: center; outline: none; min-height: var(--btn-h);
  transition: border-color .15s;
  user-select: text; -webkit-user-select: text;
}
.wp-answer-input:focus { border-color: var(--primary); }
.wp-feedback {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem;
}
.wp-feedback.correct { background: #f0fdf4; color: #15803d; border: 2px solid #86efac; }
.wp-feedback.wrong   { background: #fef2f2; color: #b91c1c; border: 2px solid #fca5a5; }
.wp-milestone-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; justify-content: center; }
.milestone-select-btn {
  padding: 8px 14px; min-height: 44px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface);
  font-size: 0.82rem; font-weight: 600; cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.milestone-select-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ── Record Sheet ─────────────────────────────────────────── */
.record-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.record-table th,
.record-table td { padding: 9px 11px; border: 1px solid var(--border); text-align: center; }
.record-table th { background: #f8fafc; font-weight: 700; }
.record-table .day-cell { text-align: left; font-weight: 600; min-width: 90px; }
.record-table .week-header { background: #1e293b; color: white; }
.record-table input[type="number"],
.record-table input[type="text"] {
  width: 62px; text-align: center;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 4px; font-size: 0.9rem; min-height: 40px;
  background: white; color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.record-table input:focus { border-color: var(--primary); outline: none; }
.record-table .total-row td { background: #f0f9ff; font-weight: 700; }
.record-overflow { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }

.teacher-dashboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.teacher-dashboard-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.86rem;
}
.teacher-dashboard-status.ok {
  background: #ecfdf5;
  color: #047857;
}
.class-summary-grid,
.student-quest-grid,
.pack-dashboard-row,
.topic-dashboard-grid {
  display: grid;
  gap: 10px;
}
.class-summary-grid {
  grid-template-columns: repeat(5, minmax(95px, 1fr));
  margin-top: 14px;
}
.class-summary-grid div,
.quest-stat-card,
.pack-dashboard-row div,
.topic-dashboard-grid div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}
.class-summary-grid strong,
.quest-stat-card strong,
.pack-dashboard-row strong,
.topic-dashboard-grid strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1;
}
.class-summary-grid span,
.quest-stat-card span,
.pack-dashboard-row span,
.topic-dashboard-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.teacher-dashboard-layout {
  grid-template-columns: minmax(210px, 0.8fr) minmax(280px, 1.7fr);
  gap: 14px;
  margin-top: 14px;
}
.student-roster-panel,
.student-record-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}
.student-roster-head,
.student-record-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.student-roster-head span,
.student-record-head strong {
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}
.student-roster-list {
  display: grid;
  gap: 8px;
  max-height: 440px;
  overflow: auto;
}
.student-roster-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}
.student-roster-btn.active {
  border-color: var(--primary);
  background: #eff6ff;
}
.student-roster-btn strong,
.student-roster-btn span {
  display: block;
}
.student-roster-btn span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.student-record-head h3 {
  margin: 0 0 3px;
  font-size: 1.2rem;
}
.student-record-head span {
  color: var(--muted);
  font-size: 0.82rem;
}
.student-quest-grid {
  grid-template-columns: repeat(4, minmax(100px, 1fr));
}
.pack-dashboard-row,
.topic-dashboard-grid {
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  margin-top: 10px;
}
.mini-meter {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 10px;
}
.mini-meter i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
}

/* ── Achievement Booklet ──────────────────────────────────── */
.milestone-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px;
  display: grid; grid-template-columns: 58px 1fr auto;
  gap: 14px; align-items: center;
}
.milestone-card.achieved { border-left: 5px solid #d97706; }
.milestone-num-badge {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 900;
}
.milestone-card.achieved .milestone-num-badge { background: linear-gradient(135deg, #f59e0b, #d97706); }
.milestone-card-content h3 { font-size: 0.92rem; margin-bottom: 3px; }
.milestone-card-content p  { font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.milestone-progress-bar { height: 8px; background: var(--border); border-radius: 100px; overflow: hidden; margin-top: 4px; }
.milestone-progress-fill { height: 100%; background: var(--primary); border-radius: 100px; transition: width .4s; }
.milestone-card-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.achieved-date { font-size: 0.72rem; color: var(--muted); text-align: right; }
.trophy { font-size: 1.8rem; }

/* ── Confetti ─────────────────────────────────────────────── */
@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.confetti-piece {
  position: fixed; width: 10px; height: 10px; border-radius: 2px;
  pointer-events: none; z-index: 9999;
  animation: confetti-fall linear forwards;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}
.shake { animation: shake 0.4s ease; }

@keyframes correct-glow {
  0%   { box-shadow: 0 0 0 0   rgba(34,197,94,.6); }
  70%  { box-shadow: 0 0 0 16px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0   rgba(34,197,94,0); }
}
.correct-pulse { animation: correct-glow 0.6s ease; }

@keyframes pop-in {
  0%   { transform: scale(0.8); opacity: 0; }
  80%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
.pop-in { animation: pop-in 0.3s ease; }

/* ── Prevent accidental selection on interactive controls only ── */
.btn, .back-btn, .table-btn, .milestone-select-btn, .analytics-tab,
.card-scene, .card-container, .topic-card, .milestone-badge,
.pack-box, .pack-chip, .analytics-header {
  user-select: none;
  -webkit-user-select: none;
}

/* ── Touch device overrides ───────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .btn           { min-height: 58px; font-size: 1.05rem; }
  .table-btn     { min-width: 58px; min-height: 58px; }
  .topic-card    { min-height: 130px; }
  .pack-chip     { min-height: 38px; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  body          { padding: 10px; }
  .card-scene   { height: 185px; }
  .card-question{ font-size: 2rem; }
  .milestone-card { grid-template-columns: 48px 1fr; }
  .milestone-card-actions { grid-column: 1/-1; flex-direction: row; justify-content: flex-start; }
  .wp-card      { padding: 16px 14px; }
  .class-summary-grid,
  .student-quest-grid,
  .pack-dashboard-row,
  .topic-dashboard-grid,
  .teacher-dashboard-layout { grid-template-columns: 1fr; }
}

@media (min-width: 768px) {
  .topic-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  margin-top: 28px; text-align: center;
  font-size: 0.72rem; color: var(--muted); padding-bottom: 14px;
}
.footer a { color: var(--primary); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Mood / SE Check-in ───────────────────────────────────── */
.mood-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.mood-overlay.hidden { display: none; }
.mood-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px 28px 28px;
  max-width: 420px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
  animation: pop-in .3s ease;
}
.mood-card h2 { font-size: 1.3rem; margin-bottom: 6px; }
.mood-card p  { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.mood-faces {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.mood-btn {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 12px 10px 8px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: .75rem; color: var(--muted);
  min-width: 62px; min-height: 72px;
  transition: border-color .15s, background .15s, transform .1s;
  font-family: inherit;
}
.mood-btn:hover  { border-color: var(--primary); background: #eff6ff; transform: translateY(-2px); }
.mood-btn.selected,
.mood-btn:focus  { border-color: var(--primary); background: #dbeafe; outline: none; }
.mood-emoji      { font-size: 2rem; line-height: 1; }
.mood-alert {
  display: none;
  background: #fef3c7; border: 1.5px solid #f59e0b;
  border-radius: 12px; padding: 14px 16px;
  font-size: .9rem; line-height: 1.5;
  color: #92400e; margin-bottom: 16px;
  text-align: left;
}
.mood-alert.visible { display: block; }
.mood-ok-btn {
  background: var(--primary); color: white;
  border: none; border-radius: 12px; padding: 14px 28px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  min-height: 50px; width: 100%;
  font-family: inherit;
  transition: background .15s;
}
.mood-ok-btn:hover { background: var(--primary-dark); }
.mood-ok-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Goal Setting Panel ───────────────────────────────────── */
.goal-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.goal-panel h2 { margin-bottom: 4px; }
.goal-panel > p { color: var(--muted); font-size: .9rem; margin-bottom: 16px; }
.goal-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.goal-row {
  background: #f8fafc; border: 1.5px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.goal-row label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 6px; }
.goal-date-input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: .9rem; font-family: inherit;
  background: white; color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.goal-date-input:focus { border-color: var(--primary); outline: none; }
.goal-days-left { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.goal-days-left.close { color: var(--pack-a); font-weight: 600; }

/* ── Typed-Answer Input (replaces self-mark flip) ─────────── */
.answer-input-wrap {
  display: flex; gap: 10px; align-items: stretch;
  max-width: 520px; margin: 0 auto 14px;
}
.answer-input {
  flex: 1;
  border: 2.5px solid var(--border); border-radius: 14px;
  padding: 0 18px; font-size: 1.6rem; font-weight: 700;
  font-family: inherit; color: var(--text); background: white;
  min-height: 64px; text-align: center;
  transition: border-color .15s;
  user-select: text; -webkit-user-select: text;
}
.answer-input:focus { border-color: var(--primary); outline: none; }
.answer-input.correct-border { border-color: var(--correct); }
.answer-input.wrong-border   { border-color: var(--wrong); }
.answer-submit-btn {
  background: var(--primary); color: white;
  border: none; border-radius: 14px;
  padding: 0 22px; font-size: 1.05rem; font-weight: 700;
  cursor: pointer; min-height: 64px; min-width: 80px;
  font-family: inherit;
  transition: background .15s;
}
.answer-submit-btn:hover  { background: var(--primary-dark); }
.answer-submit-btn:active { background: #1e40af; }

.hint-request-btn {
  display: block; margin: 0 auto 12px;
  background: none; border: 1.5px dashed var(--border);
  border-radius: 10px; padding: 8px 20px;
  font-size: .88rem; color: var(--muted); cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, color .15s;
}
.hint-request-btn:hover { border-color: var(--primary); color: var(--primary); }

.answer-feedback {
  text-align: center; font-size: 1rem; font-weight: 600;
  padding: 10px 16px; border-radius: 12px; margin: 0 auto 12px;
  max-width: 520px; display: none;
}
.answer-feedback.correct-fb { background: #dcfce7; color: #15803d; display: block; }
.answer-feedback.wrong-fb   { background: #fee2e2; color: #b91c1c; display: block; }

/* ── Box-move animation (Card levelling up) ───────────────── */
.box-move-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.35);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
.box-move-overlay.show { opacity: 1; pointer-events: auto; }
.box-move-card {
  background: white; border-radius: 20px;
  padding: 28px 36px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: pop-in .35s ease;
}
.box-move-card .box-arrow { font-size: 2.2rem; margin: 10px 0; }
.box-move-card .box-label { font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.box-move-card h3 { font-size: 1.15rem; }
.box-row {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin: 10px 0 16px;
}
.box-pill {
  border-radius: 10px; padding: 8px 16px; font-weight: 700; font-size: .9rem;
  display: flex; flex-direction: column; align-items: center;
}
.box-pill.from { background: #fee2e2; color: var(--pack-a); }
.box-pill.to   { background: #dcfce7; color: var(--correct); }
.box-pill.to.mastery { background: #fef3c7; color: #92400e; }
.box-move-next { font-size: 1.5rem; color: var(--correct); }

/* ── Reflection Panel (end of session) ───────────────────── */
.reflection-panel {
  background: #f0f9ff;
  border: 2px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 16px; max-width: 520px;
  margin-left: auto; margin-right: auto;
  color: var(--text);          /* reset: parent .session-complete forces white */
  text-align: left;
}
.reflection-panel h3 { margin-bottom: 14px; font-size: 1.05rem; color: var(--text); }
.reflection-q {
  margin-bottom: 14px;
}
.reflection-q label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; color: var(--text); }
.reflection-faces {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.reflection-face-btn {
  background: white; border: 2px solid var(--border);
  border-radius: 10px; padding: 8px 12px; cursor: pointer;
  font-size: 1.2rem; min-height: 48px; min-width: 52px;
  font-family: inherit; transition: border-color .12s, background .12s;
}
.reflection-face-btn.selected,
.reflection-face-btn:hover { border-color: var(--primary); background: #eff6ff; }
.reflection-text {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: .9rem; font-family: inherit;
  resize: vertical; min-height: 72px;
  user-select: text; -webkit-user-select: text;
}
.reflection-text:focus { border-color: var(--primary); outline: none; }
.reflection-save-btn {
  background: var(--primary); color: white;
  border: none; border-radius: 12px; padding: 12px 24px;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  min-height: 50px; font-family: inherit;
  transition: background .15s; margin-top: 4px;
}
.reflection-save-btn:hover { background: var(--primary-dark); }
.reflection-saved { color: #15803d; font-size: .9rem; font-weight: 700; display: none; margin-top: 8px; }
.reflection-saved.show { display: block; }

/* ── Print (record.html) ──────────────────────────────────── */
@media print {
  body              { background: white; padding: 0; font-size: 11px; }
  .no-print         { display: none !important; }
  .analytics-panel  { display: none; }
  .record-table th,
  .record-table td  { padding: 5px 8px; }
  .record-overflow  { box-shadow: none; }
}

/* Arena home */
.game-home {
  --arena-ink: #172033;
  --arena-blue: #2563eb;
  --arena-green: #10b981;
  --arena-gold: #f59e0b;
  background:
    radial-gradient(circle at 18% 8%, rgba(16,185,129,.18), transparent 28%),
    linear-gradient(135deg, #eef7ff 0%, #f8fafc 44%, #fff7ed 100%);
}
.arena-shell { max-width: 1120px; }
.arena-hero {
  min-height: 360px;
  border-radius: 8px;
  padding: 28px;
  margin-bottom: 18px;
  color: white;
  background:
    linear-gradient(135deg, rgba(15,23,42,.82), rgba(30,64,175,.74)),
    linear-gradient(120deg, #0f766e, #2563eb 55%, #f59e0b);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 24px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.arena-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 54px 54px;
  opacity: .35;
}
.arena-copy,
.player-pass { position: relative; z-index: 1; }
.eyebrow {
  color: #0f766e;
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.arena-hero .eyebrow { color: #bef264; }
.arena-copy h1 {
  font-size: clamp(2.2rem, 7vw, 4.7rem);
  line-height: .95;
  margin: 8px 0 14px;
}
.arena-copy p {
  max-width: 610px;
  font-size: 1.05rem;
  color: rgba(255,255,255,.86);
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.player-pass,
.mission-panel,
.league-panel,
.quest-panel,
.roadmap-panel {
  background: rgba(255,255,255,.95);
  color: var(--arena-ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15,23,42,.08);
}
.player-pass { padding: 18px; }
.pass-top { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.avatar-disc {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #10b981, #2563eb);
  color: white;
  font-weight: 900;
  font-size: 1.35rem;
  border: 4px solid rgba(255,255,255,.8);
}
.player-name { font-size: 1.25rem; font-weight: 900; }
.player-handle { color: var(--muted); font-size: .82rem; }
.pass-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.pass-stats div {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.pass-stats strong { display: block; font-size: 1.05rem; }
.pass-stats span,
.goal-label,
.quest-row span,
.system-list span { color: var(--muted); font-size: .75rem; }
.goal-label { display: flex; justify-content: space-between; margin-bottom: 6px; }
.arena-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
  gap: 16px;
  margin-bottom: 18px;
}
.mission-panel,
.league-panel,
.quest-panel,
.roadmap-panel { padding: 18px; }
.panel-heading,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.mission-copy { color: var(--muted); font-size: .92rem; margin-bottom: 18px; }
.mission-map {
  display: grid;
  grid-template-columns: 1fr 28px 1fr 28px 1fr;
  align-items: center;
  gap: 8px;
}
.mission-step {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-height: 108px;
}
.mission-step.active { border-color: var(--arena-green); background: #ecfdf5; }
.mission-step span {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--arena-blue);
  color: white;
  font-weight: 900;
  margin-bottom: 8px;
}
.mission-step strong,
.mission-step small { display: block; }
.mission-step small { color: var(--muted); margin-top: 4px; }
.mission-line { height: 4px; border-radius: 99px; background: var(--border); }
.season-chip,
#accuracyBadge,
.mini-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 4px 12px;
  background: #ecfeff;
  color: #0e7490;
  font-size: .78rem;
  font-weight: 800;
  text-decoration: none;
}
.leaderboard {
  list-style: none;
  display: grid;
  gap: 8px;
}
.leaderboard li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  background: #f8fafc;
  border-radius: 8px;
  padding: 9px 10px;
}
.leaderboard li.me {
  background: #eff6ff;
  border: 2px solid #93c5fd;
}
.leaderboard li span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--arena-gold);
  color: white;
  font-weight: 900;
}
.leaderboard em {
  font-style: normal;
  color: var(--muted);
  font-weight: 800;
  font-size: .82rem;
}
.quickplay-section {
  background: rgba(255,255,255,.74);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.arena-topics .topic-card { border-radius: 8px; }
.arena-topics .topic-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f1f5f9;
  font-weight: 900;
}
.quest-list,
.system-list { display: grid; gap: 10px; }
.quest-row,
.system-list div {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
}
.quest-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: center;
}
.quest-row strong,
.quest-row span,
.system-list strong,
.system-list span { display: block; }
.quest-meter {
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.quest-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--arena-green), var(--arena-blue));
}
.debug-refresh {
  border: none;
  cursor: pointer;
}
.debug-footer-panel {
  background: rgba(255,255,255,.94);
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 0 20px;
}
.debug-note {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.5;
  margin-bottom: 12px;
}
.debug-user-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.debug-empty,
.debug-user-row {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
}
.debug-empty {
  color: var(--muted);
  font-size: .82rem;
}
.debug-user-row {
  display: grid;
  gap: 5px;
  border-left: 5px solid #93c5fd;
}
.debug-user-row.event-account_created { border-left-color: #10b981; }
.debug-user-row.event-login { border-left-color: #2563eb; }
.debug-user-row.event-logout { border-left-color: #64748b; }
.debug-user-row.event-login_failed { border-left-color: #ef4444; }
.debug-user-row.event-teacher_pending { border-left-color: #f59e0b; }
.debug-user-row.event-teacher_approved { border-left-color: #10b981; }
.debug-user-row.event-password_reset { border-left-color: #8b5cf6; }
.debug-user-row strong,
.debug-user-row span,
.debug-user-row em {
  display: block;
}
.debug-user-row span,
.debug-user-row em {
  color: var(--muted);
  font-size: .75rem;
  font-style: normal;
}
.teacher-tools-panel {
  border-color: #c4b5fd;
}
.teacher-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.teacher-tool-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 9px;
}
.teacher-tool-card strong,
.teacher-tool-card span {
  display: block;
}
.teacher-tool-card span {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}
.teacher-select {
  width: 100%;
  min-height: 46px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 8px 10px;
  font-size: .92rem;
}
.teacher-tool-status {
  margin-top: 12px;
}
.arena-milestones { border-radius: 8px; }
/* ── Login dialog — step-based flow ─────────────────────── */
.login-dialog {
  border: none;
  padding: 0;
  background: transparent;
  width: min(94vw, 440px);
  max-height: 92vh;
}
.login-dialog::backdrop { background: rgba(15,23,42,.55); backdrop-filter: blur(3px); }
.login-card {
  background: white;
  border-radius: 16px;
  padding: 28px 24px 20px;
  box-shadow: 0 24px 80px rgba(15,23,42,.35);
  max-height: 90vh;
  overflow-y: auto;
}

/* Header row: back button, title, close */
.login-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.login-header-text { flex: 1; }
.login-header-text .eyebrow { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.login-header-text h2 { margin: 0; font-size: 1.25rem; color: var(--text); }
.login-back-btn {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  flex-shrink: 0;
}
.login-back-btn:hover { background: #e2e8f0; }
.icon-btn {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}
.icon-btn:hover { background: #e2e8f0; }

/* Path selector cards (view: choose) */
.login-path-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: #f8fafc;
  transition: border-color .15s, background .15s;
  margin-bottom: 10px;
}
.login-path-card:hover, .login-path-card:focus-within { border-color: var(--primary); background: #eff6ff; }
.login-path-icon { font-size: 1.6rem; flex-shrink: 0; }
.login-path-card > div { flex: 1; }
.login-path-card strong { display: block; color: var(--text); font-size: .95rem; }
.login-path-card span { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; line-height: 1.4; }
.login-path-arrow { color: var(--muted); font-size: 1.2rem; flex-shrink: 0; }

/* "or" divider */
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 6px;
  color: var(--muted); font-size: .8rem;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Form fields */
.login-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
  margin-top: 12px;
}
.login-input {
  background: #f8fafc;
  color: var(--text);
  border-color: var(--border);
  max-width: none;
  width: 100%;
}
.login-input::placeholder { color: #94a3b8; }
.login-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.login-wide-btn { width: 100%; margin-top: 14px; min-width: 0; }

/* "New here? / Already have one?" switch line */
.login-switch {
  margin-top: 16px;
  text-align: center;
  font-size: .84rem;
  color: var(--muted);
}
.login-text-btn {
  background: none; border: none; padding: 0;
  color: var(--primary); font-weight: 700; cursor: pointer;
  font-size: inherit;
}
.login-text-btn:hover { text-decoration: underline; }
.login-intro {
  color: var(--muted); font-size: .86rem; line-height: 1.5; margin: 0 0 4px;
}

/* Registration grid */
.cloud-login-grid { display: grid; gap: 8px; }
.cloud-login-grid label span {
  display: block; color: var(--muted);
  font-size: .74rem; font-weight: 700; margin-bottom: 4px; margin-top: 10px;
}

/* Status bar */
.cloud-status {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: #fff7ed; color: #92400e; font-size: .82rem; line-height: 1.45;
  display: none;
}
.cloud-status:not(:empty) { display: block; }
.cloud-status.ok { background: #ecfdf5; color: #047857; }

/* ── Live activity ticker ────────────────────────────────── */
.activity-ticker {
  background: #0f172a;
  color: #e2e8f0;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  height: 36px;
  position: relative;
  border-radius: 10px;
  margin: 0 0 18px;
}
.ticker-left {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: #1e293b;
  height: 100%;
  flex-shrink: 0;
  border-radius: 10px 0 0 10px;
  white-space: nowrap;
}
.ticker-live {
  background: #ef4444;
  color: white;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 4px;
  animation: ticker-pulse 1.8s ease-in-out infinite;
}
@keyframes ticker-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .55; }
}
.ticker-online {
  color: #94a3b8;
  white-space: nowrap;
}
.ticker-online strong { color: #22c55e; }
.ticker-scroll-wrap {
  flex: 1;
  overflow: hidden;
  height: 100%;
  position: relative;
}
.ticker-track {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  animation: ticker-scroll 40s linear infinite;
  height: 100%;
}
.ticker-track:hover { animation-play-state: paused; }
@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 24px;
  color: #cbd5e1;
  border-right: 1px solid #1e293b;
  height: 100%;
}
.ticker-item .ticker-time {
  color: #64748b;
  font-size: .75rem;
  flex-shrink: 0;
}

@media (max-width: 820px) {
  .arena-hero,
  .arena-grid { grid-template-columns: 1fr; }
  .arena-hero { padding: 20px; min-height: auto; }
  .mission-map { grid-template-columns: 1fr; }
  .mission-line { width: 4px; height: 18px; justify-self: center; }
}

@media (max-width: 520px) {
  .pass-stats { grid-template-columns: 1fr; }
  .quest-row { grid-template-columns: 1fr; }
  .panel-heading,
  .section-title { align-items: stretch; flex-direction: column; }
}

/* ── Teacher Dashboard page ─────────────────────────────────── */
.td-roster-table,
.td-fact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.td-roster-table th,
.td-fact-table th {
  text-align: left;
  padding: 8px 10px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.td-roster-table td,
.td-fact-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.td-roster-table tr:hover td { background: #f8fafc; }
.td-fact-table tr:hover td { background: #f8fafc; }
.td-student-row { cursor: pointer; }
@media (max-width: 640px) {
  .td-roster-table { font-size: .78rem; }
  .td-roster-table th, .td-roster-table td { padding: 7px 6px; }
}
