/* Líofa - shared styles. Loaded on every page, so importing the Google Font
   here applies the child-friendly Nunito typeface site-wide (Task 1). */
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,600;0,700;0,800;0,900;1,700&display=swap');

:root {
  --green: #1a5c38;
  --green-dark: #124027;
  --orange: #ff6b00;
  --gold: #ffd700;
  --cream: #fffdf0;
  --ink: #20281f;
  --muted: #5c6b5a;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(26, 92, 56, 0.15);
  /* Nunito = rounded, friendly, very readable for children; system fonts as a
     fast fallback before the webfont loads. */
  --font: 'Nunito', 'Segoe UI', 'Trebuchet MS', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over our display:flex layouts
   (a class selector otherwise overrides the UA [hidden] rule). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  min-height: 100%;
  line-height: 1.5;             /* airy + readable for children */
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); }

h1, h2, h3, h4 { font-weight: 900; letter-spacing: -0.01em; }
.btn, .game-name, .lb-name { letter-spacing: 0.01em; }

.app-bar {
  background: var(--green);
  color: var(--cream);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.app-bar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.5px;
}
.app-bar .brand .dot { color: var(--gold); }
.app-bar nav a {
  color: var(--cream);
  text-decoration: none;
  margin-left: 1rem;
  font-weight: 600;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.center-stage {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}

h1, h2, h3 { color: var(--green); margin-top: 0; }

.cu {
  width: 84px;
  height: 84px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: var(--shadow);
}

label { display: block; font-weight: 600; margin: 0.85rem 0 0.3rem; }

input, select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 2px solid #e2e6dc;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--orange);
}

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  box-shadow: 0 4px 0 #c95400;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  width: 100%;
  margin-top: 1.2rem;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c95400; }
.btn.secondary {
  background: var(--green);
  box-shadow: 0 4px 0 var(--green-dark);
}
.btn.ghost {
  background: transparent;
  color: var(--green);
  box-shadow: none;
  border: 2px solid var(--green);
}

.role-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.role-tabs button {
  flex: 1;
  border: 2px solid #e2e6dc;
  background: #fff;
  border-radius: 12px;
  padding: 0.6rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.role-tabs button.active {
  border-color: var(--orange);
  background: var(--cream);
  color: var(--orange);
}

.msg {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-weight: 600;
  display: none;
}
.msg.error { display: block; background: #ffe7e0; color: #b23a00; }
.msg.success { display: block; background: #e3f5e9; color: var(--green); }

.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt { margin-top: 1rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

.hero {
  text-align: center;
  padding: 1.2rem 1rem 0.4rem;
}
.hero h1 { font-size: 2.6rem; margin-bottom: 0.25rem; }
.hero .tag { font-size: 1.2rem; color: var(--muted); margin: 0.2rem 0; }
.hero .muted { margin: 0.2rem 0; }
.hero .row.mt { margin-top: 0.9rem !important; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.6rem;
}
.container { padding-top: 1rem; }

.pill {
  display: inline-block;
  background: var(--gold);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-weight: 700;
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .hero h1 { font-size: 2rem; }
}

/* ===========================================================================
   Student dashboard (game-app style, icon-driven)
   ======================================================================== */

.app-bar .brand { text-decoration: none; color: inherit; }
.app-bar nav { display: flex; align-items: center; gap: 0.6rem; }
.app-bar nav a { font-size: 1.3rem; }

/* Account button (top right) - circular live avatar */
.account-btn {
  width: 42px; height: 42px;
  padding: 0; border: 2px solid var(--gold);
  border-radius: 50%; overflow: hidden;
  background: var(--cream); cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease;
}
.account-btn:hover { transform: scale(1.08); }
.account-btn .avatar-svg { width: 100%; height: 100%; display: block; object-fit: cover; }

.sd { display: flex; flex-direction: column; gap: 1.1rem; }
.sd-cols { display: grid; grid-template-columns: 1fr 340px; gap: 1.1rem; align-items: start; }
.sd-left, .sd-right { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.block-title { font-size: 1.2rem; margin: 0 0 0.8rem; }
.pill.gold { background: var(--gold); color: var(--ink); }

/* --- Weekly class battle bar (top) ------------------------------------- */
.battle {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: var(--cream);
}
.battle-head { font-weight: 800; font-size: 1.05rem; margin-bottom: 0.7rem; }
.battle-ico { font-size: 1.3rem; }
.battle-teams { display: flex; align-items: center; gap: 0.8rem; }
.team { flex: 1; min-width: 0; }
.team-b { text-align: right; }
.team-name { font-weight: 700; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-score { font-size: 1.8rem; font-weight: 800; color: var(--gold); }
.battle-vs { font-weight: 800; opacity: 0.8; }
.battle-bar {
  height: 22px;
  border-radius: 999px;
  margin: 0.7rem 0 0.5rem;
  overflow: hidden;
  background: #e74c3c; /* opponent share (right) */
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}
.battle-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ecc71, #1a5c38); /* my class share (left) */
  border-radius: 999px;
  transition: width 0.8s ease;
}
.battle-status { text-align: center; font-weight: 700; }

/* --- Player card (avatar + Cú + XP + level) ---------------------------- */
.player-top { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.avatar-stage { position: relative; width: 116px; flex-shrink: 0; }
.avatar-me {
  width: 116px; height: 116px;
  background: var(--cream);
  border: 4px solid var(--gold);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.avatar-svg { width: 100%; height: 100%; display: block; object-fit: cover; }

.cu-buddy {
  position: absolute;
  right: -14px; bottom: -10px;
  width: 52px; height: 52px;
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
  box-shadow: var(--shadow);
  animation: cubob 2.4s ease-in-out infinite;
}
.cu-buddy.big { position: static; width: 84px; height: 84px; font-size: 3rem; margin: 0 auto; }
.cu-buddy .cu-emoji { display: inline-block; transform-origin: 50% 85%; animation: cuwag 1.5s ease-in-out infinite; }
.cu-buddy.celebrate { animation: cujump 0.8s ease; }
@keyframes cubob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes cuwag { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes cujump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-18px) scale(1.18); }
  60% { transform: translateY(0) scale(1); }
  80% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.player-meta { flex: 1; min-width: 0; }
.player-meta h1 { font-size: 1.4rem; margin: 0 0 0.4rem; }
.level-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.level-line .lvl { font-weight: 600; color: var(--muted); }
.level-line .lvl b { color: var(--green); font-size: 1.1rem; }

.progress {
  position: relative;
  height: 24px;
  background: #e8ece4;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  border-radius: 999px;
  transition: width 0.6s ease;
  min-width: 0.4rem;
}
.progress-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.8rem; color: var(--ink);
}

.stat-chips { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.stat { flex: 1; background: var(--cream); border-radius: 12px; padding: 0.55rem; text-align: center; }
.stat-num { display: block; font-size: 1.4rem; font-weight: 800; color: var(--green); }
.stat-lbl { display: block; font-size: 0.75rem; color: var(--muted); }

.btn.small { width: auto; margin-top: 0.5rem; padding: 0.4rem 0.8rem; font-size: 0.95rem; }
.btn.small:disabled { opacity: 0.6; cursor: default; box-shadow: none; }

/* --- Games grid (compact, icon tiles) ---------------------------------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 0.6rem;
}
.game-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 0.7rem 0.3rem;
  background: var(--cream);
  border: 2px solid #e8ece4;
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease;
}
.game-tile:not(:disabled):hover { transform: translateY(-3px); border-color: var(--orange); }
.game-tile:disabled { cursor: default; opacity: 0.92; }
.game-tile.is-double { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.35); }
.game-ico { font-size: 1.9rem; line-height: 1; }
.game-name { font-size: 0.72rem; font-weight: 700; color: var(--ink); text-align: center; }
.game-tile .x2 {
  position: absolute; top: -8px; right: -6px;
  background: var(--orange); color: #fff;
  border-radius: 999px; padding: 0.05rem 0.4rem;
  font-size: 0.68rem; font-weight: 800;
  box-shadow: var(--shadow);
}

/* --- Leaderboards (right column) --------------------------------------- */
.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.lb-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.55rem;
  border-radius: 12px;
  background: var(--cream);
}
.lb-row.me { background: #fff4dd; outline: 2px solid var(--gold); }
.lb-rank { width: 1.6rem; text-align: center; font-weight: 800; font-size: 1rem; flex-shrink: 0; }
.lb-rank.r1, .lb-rank.r2, .lb-rank.r3 { font-size: 1.2rem; }
.lb-av { width: 30px; height: 30px; flex-shrink: 0; display: block; border-radius: 50%; overflow: hidden; background: #fff; }
.lb-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-xp { font-weight: 800; color: var(--green); flex-shrink: 0; font-size: 0.9rem; }
.lb-gap { text-align: center; color: var(--muted); font-weight: 800; letter-spacing: 2px; }
.lb-empty { background: var(--cream); border-radius: 12px; padding: 0.8rem; text-align: center; color: var(--muted); }
.lvl-badge {
  flex-shrink: 0;
  background: var(--green); color: var(--cream);
  border-radius: 8px; padding: 0.15rem 0.45rem;
  font-size: 0.72rem; font-weight: 800;
}

/* --- Avatar designer modal --------------------------------------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(18, 40, 28, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 50;
}
.modal-card {
  position: relative;
  background: #fff; border-radius: var(--radius);
  padding: 1.4rem; width: 100%; max-width: 460px;
  max-height: 92vh; overflow: auto; box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 0.3rem; }
.modal-close {
  position: absolute; top: 0.7rem; right: 0.7rem;
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: var(--cream); color: var(--ink);
  font-size: 1.1rem; font-weight: 800; cursor: pointer; line-height: 1;
}
.modal-close:hover { background: #ffe7e0; color: #b23a00; }
.designer-name { margin: 0 0 1rem; font-weight: 700; }
.jersey-sep {
  margin: 1rem 0 0.7rem; padding-top: 0.8rem;
  border-top: 2px dashed #e2e6dc;
  font-weight: 800; color: var(--green);
}
.color-pick {
  width: 38px; height: 38px; padding: 2px;
  border: 3px solid #e2e6dc; border-radius: 50%;
  background: #fff; cursor: pointer;
}
.color-pick::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick::-webkit-color-swatch { border: none; border-radius: 50%; }
.designer-preview {
  width: 150px; height: 150px; margin: 0 auto 1rem;
  background: var(--cream); border: 4px solid var(--gold);
  border-radius: 24px; overflow: hidden;
}
.ctrl-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.ctrl-ico { font-size: 1.3rem; width: 1.8rem; text-align: center; flex-shrink: 0; }
.swatches { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.swatch {
  width: 38px; height: 38px;
  border: 3px solid #e2e6dc; border-radius: 50%;
  cursor: pointer; padding: 0; overflow: hidden; background: var(--cream);
}
.swatch.active { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.3); }
.swatch.mini { background: var(--cream); }
.swatch.mini .avatar-svg { width: 100%; height: 100%; }

@media (max-width: 820px) {
  .sd-cols { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .player-top { flex-direction: column; text-align: center; }
  .avatar-stage { margin: 0 auto; }
}

/* ===========================================================================
   Student dashboard v2 - vibrant game cards, county dots, streak, banners
   ======================================================================== */

/* Dalta na Seachtaine banner (Task 12) */
.dalta-banner {
  background: linear-gradient(100deg, var(--gold), #ffb300);
  color: #3a2a00; border-radius: 16px; padding: 0.8rem 1rem; font-weight: 900;
  display: flex; align-items: center; gap: 0.6rem; box-shadow: var(--shadow);
  animation: daltaIn 0.6s ease; position: relative; overflow: hidden; font-size: 1.05rem;
}
.dalta-banner .crown { font-size: 1.8rem; animation: bob 1.4s ease-in-out infinite; }
.dalta-banner::after {
  content: ''; position: absolute; top: 0; left: -45%; width: 45%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
  animation: shine 2.8s ease-in-out infinite;
}
@keyframes daltaIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shine { 0% { left: -45%; } 60%, 100% { left: 120%; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Streak flame (Task 12) - grows with the streak length */
.streak-wrap {
  display: flex; align-items: center; gap: 0.55rem; margin-top: 0.9rem;
  justify-content: center; background: var(--cream); border-radius: 12px; padding: 0.45rem 0.6rem;
}
.streak-flame { line-height: 1; }
.streak-flame.s-small { font-size: 1.2rem; }
.streak-flame.s-med { font-size: 1.7rem; }
.streak-flame.s-large { font-size: 2.2rem; }
.streak-flame.s-massive { font-size: 2.9rem; filter: drop-shadow(0 0 10px rgba(255,120,0,0.9)); animation: flick 0.45s ease-in-out infinite alternate; }
.streak-num { font-weight: 900; color: var(--orange); font-size: 1.3rem; }
.streak-lbl { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
@keyframes flick { from { transform: scale(1) rotate(-5deg); } to { transform: scale(1.18) rotate(5deg); } }

/* Vibrant game cards (Task 2) - responsive 3/2/1 grid */
.games-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 880px) { .games-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .games-cards { grid-template-columns: 1fr; } }
.gcard {
  position: relative; min-height: 200px; border-radius: 22px; padding: 1.1rem;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff; cursor: pointer; border: none; font-family: inherit; text-align: left; width: 100%;
  box-shadow: 0 10px 22px rgba(0,0,0,0.18); overflow: hidden;
  background-image: linear-gradient(160deg, rgba(255,255,255,0.20), rgba(0,0,0,0.16));
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.gcard:not(.locked):hover { transform: translateY(-4px); box-shadow: 0 16px 30px rgba(0,0,0,0.28); }
.gcard:not(.locked):active { transform: translateY(-1px); }
.gcard .gico { font-size: 3.4rem; line-height: 1; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.3)); }
.gcard .gname { font-size: 1.5rem; font-weight: 900; margin: 0.3rem 0 0; text-shadow: 0 2px 4px rgba(0,0,0,0.4); }
.gcard .gen { font-size: 0.85rem; font-weight: 700; opacity: 0.88; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.gcard .gplay {
  align-self: flex-start; margin-top: 0.7rem; background: #fff; color: var(--ink);
  border-radius: 999px; padding: 0.45rem 1.2rem; font-weight: 900; font-size: 1.05rem;
  box-shadow: 0 4px 0 rgba(0,0,0,0.22);
}
.gcard.locked { cursor: default; }
.gcard.locked::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.30); }
.gcard .glock { position: absolute; top: 0.8rem; right: 0.9rem; font-size: 1.5rem; z-index: 2; }
.gcard .gsoon { z-index: 2; align-self: flex-start; margin-top: 0.7rem; background: rgba(255,255,255,0.28); color: #fff; border-radius: 999px; padding: 0.4rem 1rem; font-weight: 800; }
.gcard.dbl { animation: gpulse 1.3s ease-in-out infinite; }
.gcard .gx2 { position: absolute; top: 0.7rem; left: 0.8rem; z-index: 2; background: #fff; color: #c0392b; border-radius: 999px; padding: 0.15rem 0.6rem; font-weight: 900; box-shadow: var(--shadow); }
.gcard .gflame { position: absolute; top: 0.55rem; right: 0.8rem; z-index: 2; font-size: 1.7rem; animation: flick 0.5s ease-in-out infinite alternate; }
@keyframes gpulse { 0%, 100% { box-shadow: 0 10px 22px rgba(0,0,0,0.18); } 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 26px 6px rgba(255,160,0,0.7); } }

/* County colour dot + two-line label on national leaderboards (Task 3) */
.lb-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,0.12); }

/* Confetti burst on level-up (Task 12) */
.confetti-pc { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 300; pointer-events: none; border-radius: 2px; }
@keyframes confFall { to { transform: translateY(108vh) rotate(720deg); opacity: 0.85; } }

/* ===========================================================================
   Phase 4 - Teacher dashboard (clean, professional, traffic-light coded)
   ======================================================================== */
.app-bar nav { display: flex; align-items: center; gap: 0.6rem; }
.lang-toggle {
  border: 2px solid var(--cream); background: transparent; color: var(--cream);
  border-radius: 8px; padding: 0.25rem 0.55rem; font-weight: 800; cursor: pointer; font-family: inherit;
}
.lang-toggle:hover { background: rgba(255,255,255,0.15); }
.class-select { width: auto; padding: 0.35rem 0.5rem; border-radius: 8px; font-family: inherit; font-weight: 700; border: 2px solid #e2e6dc; }

.teacher-main .card { margin-bottom: 1rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.two-col .card { margin-bottom: 0; }

/* Tabs */
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  border: none; background: #eef0ea; color: var(--ink);
  padding: 0.55rem 1.1rem; border-radius: 999px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.95rem;
}
.tab.active { background: var(--green); color: var(--cream); }

/* Alert bar */
#alertBar:not(:empty) { padding: 0 1.25rem; }
.alert-bar {
  max-width: 1040px; margin: 0.9rem auto 0;
  background: #fdecea; border: 2px solid #e74c3c; color: #8a2b20;
  padding: 0.6rem 0.9rem; border-radius: 12px; font-size: 0.95rem;
}
.alert-ico { margin-right: 0.3rem; }
.alert-chip { display: inline-block; background: #fff; border-radius: 999px; padding: 0.15rem 0.2rem 0.15rem 0.6rem; margin: 0.2rem; font-weight: 600; }
.alert-x { border: none; background: transparent; cursor: pointer; color: #e74c3c; font-weight: 800; padding: 0 0.4rem; }

/* Horizontal bar charts */
.bar { display: flex; align-items: center; gap: 0.7rem; margin: 0.45rem 0; }
.bar-label { width: 132px; flex-shrink: 0; font-size: 0.9rem; font-weight: 600; }
.bar-track { flex: 1; height: 18px; background: #eef0ea; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.bar-fill.red { background: #e74c3c; }
.bar-fill.amber { background: #f39c12; }
.bar-fill.green { background: #27ae60; }
.bar-pct { width: 52px; text-align: right; font-weight: 800; font-size: 0.85rem; }
.bar.clickable { cursor: pointer; padding: 0.2rem; border-radius: 8px; }
.bar.clickable:hover { background: var(--cream); }

/* Topic of the week */
.tow-row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.tow-select { width: auto; min-width: 200px; }
.tow-check { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; margin: 0; }
.tow-check input { width: auto; }
.tow-status { margin: 0.7rem 0 0; }
.tow-checks { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tow-chk { display: inline-flex; align-items: center; gap: 0.35rem; border: 2px solid #e2e6dc; border-radius: 999px; padding: 0.35rem 0.85rem; font-weight: 700; font-size: 0.9rem; cursor: pointer; background: #fff; user-select: none; }
.tow-chk.on { border-color: var(--green); background: #e3f5e9; color: var(--green); }
.tow-chk input { width: auto; margin: 0; }

/* Student table */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.sort-lbl { font-size: 0.9rem; font-weight: 600; }
.sort-lbl select { width: auto; }
.stu-table { width: 100%; border-collapse: collapse; }
.stu-table th { text-align: left; font-size: 0.78rem; color: var(--muted); padding: 0.4rem; border-bottom: 2px solid #eef0ea; }
.stu-table td { padding: 0.5rem 0.4rem; border-bottom: 1px solid #f0f2ec; }
.srow { cursor: pointer; }
.srow:hover { background: var(--cream); }
.td-av { width: 44px; }
.t-av { display: inline-block; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: #fff; vertical-align: middle; }
.t-av .avatar-svg { width: 100%; height: 100%; display: block; object-fit: cover; }
.dot-alert { color: #e74c3c; }

/* Student detail */
.stu-head { display: flex; align-items: center; gap: 1rem; }
.stu-head .t-av { width: 64px; height: 64px; }
.stu-head h2 { margin: 0; }
.topic-meta { display: flex; gap: 1.5rem; margin: 1rem 0 0; flex-wrap: wrap; }
.missed-hdr { margin: 1.1rem 0 0.5rem; font-size: 1rem; color: var(--green); }
.missed-list { margin: 0; padding-left: 1.2rem; }
.missed-list li { margin: 0.25rem 0; }

/* Stars + battle (white-card overrides) */
.star-card2 { display: flex; align-items: center; gap: 1rem; }
.star-card2 .t-av { width: 52px; height: 52px; }
.teacher .team-name { color: var(--ink); }
.teacher .team-score { color: var(--green); }
.teacher .battle-vs { color: var(--muted); }
.contrib { margin: 0.5rem 0 0; padding-left: 1.4rem; }
.contrib li { margin: 0.35rem 0; }
.contrib .t-av { width: 28px; height: 28px; }

@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } .bar-label { width: 96px; } }
@media print { .app-bar, .tabs, #alertBar, .btn { display: none !important; } }

/* Question editor (Phase 5) */
.q-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.q-toolbar select { width: auto; padding: 0.4rem 0.5rem; border-radius: 8px; border: 2px solid #e2e6dc; font-family: inherit; }
.q-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 0.8rem; }
.q-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.badge { background: #eef0ea; color: var(--ink); border-radius: 999px; padding: 0.1rem 0.55rem; font-size: 0.75rem; font-weight: 700; }
.qs-pill { color: #fff; border-radius: 999px; padding: 0.1rem 0.55rem; font-size: 0.75rem; font-weight: 700; }
.q-prompt { font-size: 1.05rem; font-weight: 600; margin: 0.3rem 0; }
.q-emoji { font-size: 1.8rem; }
.q-opts { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.4rem 0; }
.q-opt { background: var(--cream); border: 2px solid #e8ece4; border-radius: 8px; padding: 0.2rem 0.6rem; font-size: 0.9rem; }
.q-opt.correct { border-color: #27ae60; background: #e9f9ef; font-weight: 700; }
.q-flagnote { background: #fff4e5; border-left: 3px solid #e67e22; padding: 0.4rem 0.6rem; border-radius: 6px; margin: 0.4rem 0; font-size: 0.9rem; }
.q-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem; }
.q-stats { font-size: 0.85rem; color: var(--muted); }
.q-actions { display: flex; gap: 0.4rem; }
.review { color: #e67e22; font-weight: 700; }
.json-area { width: 100%; font-family: 'Consolas', monospace; font-size: 0.85rem; border: 2px solid #e2e6dc; border-radius: 10px; padding: 0.6rem; }
.q-pager { text-align: center; margin: 1rem 0; }
.q-pager .btn { width: auto; }
.dash-links { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; }
.dash-links .btn { width: auto; margin-top: 0; }
