* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --accent: #e94560;
  --accent-glow: rgba(233,69,96,0.2);
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-pattern: none;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg-pattern), var(--bg);
  color: #eee;
  padding: 1rem 0;
}

.container {
  text-align: center;
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  margin: auto 0;
}

h1 {
  font-size: 2.4rem;
  margin-bottom: 0.3rem;
  background: linear-gradient(135deg, var(--accent), #0f3460);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #888;
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* ---- HOME SCREEN ---- */
.home { display: block; }
.home.hidden { display: none; }

.subject-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.subject-grid .subject-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.subject-card {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 2rem 1rem;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.3s, box-shadow 0.3s;
}

.subject-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.subject-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.subject-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.subject-desc {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.3rem;
}

/* ---- GAME SCREEN ---- */
.game { display: none; }
.game.active { display: block; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.back-btn {
  background: none;
  border: 1px solid #444;
  color: #aaa;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: none;
}

.mode-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.stats {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.stat {
  background: var(--bg-card);
  padding: 0.5rem 0.7rem;
  border-radius: 12px;
  min-width: 0;
  flex: 1;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--accent);
}

.level-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  margin: 0.4rem 0 0.9rem;
  overflow: hidden;
}

.level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #0f3460);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.level-name {
  font-size: 0.85rem;
  color: #aaa;
}

/* ── Zone progress dots ─────────────────────────────────── */
.zone-dots {
  justify-content: center;
  gap: 8px;
  margin: 0 0 0.7rem;
}

.zone-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
  flex-shrink: 0;
}

.zone-dot.filled {
  background: var(--accent);
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(78, 204, 163, 0.5);
}

.question-area {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 1.8rem 1.5rem;
  margin-bottom: 0.8rem;
}

.question {
  font-size: 2.5rem;
  font-weight: bold;
  letter-spacing: 2px;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.number-input {
  flex: 1;
  display: flex;
  min-width: 0;
}

#answer {
  flex: 1;
  padding: 0.9rem 0.5rem;
  font-size: 1.3rem;
  border: 2px solid #0f3460;
  border-radius: 0;
  background: var(--bg);
  color: #eee;
  outline: none;
  text-align: center;
  transition: border-color 0.3s;
  min-width: 0;
}

#answer:focus { border-color: var(--accent); }

/* Hide native spinner */
#answer::-webkit-inner-spin-button,
#answer::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#answer[type=number] { -moz-appearance: textfield; }

.step-btn {
  width: 44px;
  font-size: 1.4rem;
  font-weight: bold;
  border: 2px solid #0f3460;
  background: var(--bg-card);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.step-btn:hover {
  background: #1a2a4e;
  border-color: var(--accent);
}

.step-btn:active { transform: scale(0.95); }

#decBtn {
  border-radius: 12px 0 0 12px;
  border-right: none;
}

#incBtn {
  border-radius: 0 12px 12px 0;
  border-left: none;
}

#slashBtn {
  display: none;
  border-radius: 0;
  border-left: none;
}

.show-slash #slashBtn { display: block; }

.go-btn {
  padding: 0.9rem 1.8rem;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 0.1s, background 0.3s;
}

.go-btn:hover { filter: brightness(0.82); }
.go-btn:active { transform: scale(0.96); }

.feedback {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  padding: 0.25rem 0.5rem;
}

.feedback.correct { color: #4ecca3; }
.feedback.wrong { color: var(--accent); }

.stat.best-stat {
  border: 1px solid #ffd700;
}
@keyframes liveRecordPulse {
  0%, 100% { box-shadow: 0 0 6px #ffd700; border-color: #ffd700; }
  50%       { box-shadow: 0 0 18px #ffd700, 0 0 6px #fff; border-color: #fff; }
}
.stat.best-stat.live-record {
  animation: liveRecordPulse 1.2s ease-in-out infinite;
}
.stat.best-stat.live-record .stat-label {
  color: #ffd700;
  font-weight: 700;
}

.stat-value.gold {
  color: #ffd700;
}

.streak-info {
  font-size: 0.85rem;
  color: #888;
  margin-top: 0.5rem;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.shake { animation: shake 0.4s ease; }
.pop { animation: pop 0.3s ease; }

.question sup {
  font-size: 0.6em;
}

/* ---- HOME HEADER ---- */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.2rem 0.4rem;
  margin-bottom: 0;
}

.home-header h1 { margin-bottom: 0; flex: 1; text-align: center; }

/* ---- NAV TOGGLE BUTTON ---- */
.nav-toggle-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ccc;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s, transform 0.25s;
}
.nav-toggle-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-toggle-btn.open { transform: rotate(90deg); color: var(--accent); }

/* ---- NAV BAR ---- */
.nav-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
}
.nav-bar.open {
  max-height: 90px;
  opacity: 1;
  padding: 0 1rem 0.75rem;
}

.nav-bar-item {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: #ccc;
  border-radius: 14px;
  padding: 0.55rem 0.3rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  position: relative;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.nav-bar-item:hover { background: rgba(255,255,255,0.13); border-color: var(--accent); color: white; }


.nav-bar-icon { font-size: 1.15rem; line-height: 1; }

.award-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ---- AWARDS GRID ---- */
.awards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.5rem;
  max-height: 55vh;
  overflow-y: auto;
}

.award-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 0.7rem 0.5rem;
  text-align: center;
  border: 2px solid transparent;
  transition: opacity 0.3s, border-color 0.3s;
}
.award-card.earned { border-color: var(--accent); }
.award-card.locked { opacity: 0.35; filter: grayscale(1); }

/* ── Streak — red ──────────────────────────────────── */
.award-card.award-cat-streak.earned {
  border-color: #ff4444;
  background: linear-gradient(135deg, rgba(255,68,68,0.13) 0%, var(--bg) 100%);
  box-shadow: 0 0 12px rgba(255, 68, 68, 0.25);
}
.award-card.award-cat-streak .award-name { color: #ff6b6b; }

/* ── Speed — orange ────────────────────────────────── */
.award-card.award-cat-speed.earned {
  border-color: #ff8c00;
  background: linear-gradient(135deg, rgba(255,140,0,0.13) 0%, var(--bg) 100%);
  box-shadow: 0 0 12px rgba(255, 140, 0, 0.25);
}
.award-card.award-cat-speed .award-name { color: #ffa833; }

/* ── Gold — yellow / mastery ───────────────────────── */
.award-card.award-cat-gold.earned {
  border-color: #ffd700;
  background: linear-gradient(135deg, rgba(255,215,0,0.13) 0%, var(--bg) 100%);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.25);
}
.award-card.award-cat-gold .award-name { color: #ffe44d; }

/* ── Explore — green ───────────────────────────────── */
.award-card.award-cat-explore.earned {
  border-color: #44dd88;
  background: linear-gradient(135deg, rgba(68,221,136,0.13) 0%, var(--bg) 100%);
  box-shadow: 0 0 12px rgba(68, 221, 136, 0.25);
}
.award-card.award-cat-explore .award-name { color: #55ee99; }

/* ── Lesson — teal (existing, keep) ───────────────── */
.award-card.award-cat-lesson.earned {
  border-color: #4ecca3;
  background: linear-gradient(135deg, rgba(78,204,163,0.13) 0%, var(--bg) 100%);
  box-shadow: 0 0 12px rgba(78, 204, 163, 0.25);
}
.award-card.award-cat-lesson .award-name { color: #4ecca3; }

.award-icon { font-size: 1.8rem; }
.award-name { font-size: 0.78rem; font-weight: bold; margin: 0.25rem 0 0.1rem; color: #eee; }
.award-desc { font-size: 0.65rem; color: #888; }

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.settings-overlay.hidden { display: none; }

.settings-panel {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 2rem 2.5rem;
  text-align: center;
  min-width: 300px;
}

.settings-panel h2 {
  font-size: 1.6rem;
  margin-bottom: 0.3rem;
  color: var(--accent);
}

.settings-section {
  margin: 1.5rem 0;
}

.settings-section p {
  font-size: 0.85rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.9rem;
}

.color-swatches {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Volume slider ───────────────────────────────────────── */
.volume-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.volume-icon { font-size: 1.2rem; }
.volume-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-card);
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(78,204,163,0.5);
}
.volume-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, opacity 0.2s;
  outline: none;
  position: relative;
  overflow: hidden;
}

.swatch:hover { transform: scale(1.15); }

.swatch.locked-swatch { cursor: not-allowed; opacity: 0.5; }
.swatch.locked-swatch:hover { transform: none; }
.swatch-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  pointer-events: none;
}

.swatch.active {
  border-color: #fff;
  transform: scale(1.15);
}

/* ---- SWATCH TOOLTIP ---- */
.swatch-wrap {
  position: relative;
  display: inline-flex;
}

.swatch-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0d0d1a;
  border: 1px solid #444;
  color: #eee;
  font-size: 0.68rem;
  font-weight: bold;
  white-space: nowrap;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  transform: translateX(-50%) translateY(4px);
  z-index: 200;
}

.swatch-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #444;
}

.swatch-wrap:hover .swatch-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.theme-swatch { border-color: #555; }
.theme-swatch.active { border-color: #fff; }

.close-settings-btn {
  margin-top: 1.5rem;
  padding: 0.65rem 2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.2s;
}

.close-settings-btn:hover { filter: brightness(0.85); }

/* ---- ALGEBRA ---- */
.algebra-x {
  color: var(--accent);
  font-style: italic;
}

/* ---- PATTERNS ---- */
.pattern-seq {
  font-size: 1.55rem;
  font-weight: bold;
  line-height: 2;
  word-spacing: 0.1rem;
}
.pattern-arrow { color: #555; margin: 0 0.1rem; }
.pattern-q { color: var(--accent); font-size: 2rem; }

/* ---- HINT ---- */
.hint-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 0.6rem;
  padding: 0;
  text-decoration: underline;
  transition: color 0.2s;
}
.hint-btn:hover { color: var(--accent); }
.hint-text {
  margin-top: 0.45rem;
  background: rgba(255,255,255,0.05);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: #bbb;
  text-align: left;
}
.hint-text.hidden { display: none; }

/* ---- SIMULTANEOUS EQUATIONS ---- */
.simul-eq {
  font-size: 1.85rem;
  line-height: 1.8;
}

.number-input.hidden-input { display: none; }

.dual-input {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dual-input.hidden { display: none; }

.input-row.dual-mode {
  flex-direction: column;
}

.input-row.dual-mode .go-btn {
  width: 100%;
}

.game.simul-active .stats       { margin: 0.4rem 0; }
.game.simul-active .level-bar   { margin: 0.4rem 0 0.8rem; }
.game.simul-active .streak-info { margin-top: 0.2rem; }

.question-area.simul-active {
  padding: 1rem 1.5rem;
  margin-bottom: 0.8rem;
}

.question-area.simul-active .simul-eq {
  font-size: 1.55rem;
  line-height: 1.6;
}

.question-area.simul-active .dual-field input {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.dual-field {
  flex: 1;
  display: flex;
  align-items: center;
  border: 2px solid #0f3460;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
  transition: border-color 0.3s;
}

.dual-field:focus-within { border-color: var(--accent); }

.dual-label {
  padding: 0 0.4rem 0 0.75rem;
  font-size: 1.1rem;
  font-style: italic;
  color: var(--accent);
  white-space: nowrap;
}

.dual-field input {
  flex: 1;
  padding: 0.9rem 0.5rem 0.9rem 0;
  font-size: 1.3rem;
  border: none;
  background: transparent;
  color: #eee;
  outline: none;
  text-align: center;
  min-width: 0;
  -moz-appearance: textfield;
}

.dual-field input::-webkit-inner-spin-button,
.dual-field input::-webkit-outer-spin-button { -webkit-appearance: none; }

.dual-step-btn {
  background: none;
  border: none;
  border-left: 2px solid #0f3460;   /* separator on left (for + button) */
  color: #c0cce0;
  font-size: 1.45rem;
  font-weight: bold;
  padding: 0 0.65rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s, background 0.15s, transform 0.1s;
  flex-shrink: 0;
  user-select: none;
  align-self: stretch;              /* stretch to full field height */
  display: flex;
  align-items: center;
}

/* The − button sits right after the label → separator goes on its right instead */
.dual-label + .dual-step-btn {
  border-left: none;
  border-right: 2px solid #0f3460;
}

.dual-step-btn:hover  { color: var(--accent); background: rgba(255,255,255,0.06); }
.dual-step-btn:active { transform: scale(0.88); }

/* ---- PLAYER CHIP ---- */
.player-chip-row {
  margin: 0.3rem 0 0;
}
.player-chip {
  background: none;
  border: 1px solid #444;
  color: #aaa;
  padding: 0.25rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.player-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- PLAYER MODAL ---- */
.player-panel { min-width: 290px; }
.player-panel h2 { color: var(--accent); }

.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 0.5rem;
  max-height: 38vh;
  overflow-y: auto;
}
.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0.55rem 0.85rem;
  transition: border-color 0.2s;
}
.player-item.active { border-color: var(--accent); }

/* Left side: name + stats stacked */
.player-item-info  { display: flex; flex-direction: column; gap: 0.12rem; flex: 1; min-width: 0; }
.player-item-name  { font-size: 0.9rem; font-weight: bold; color: #eee; }
.player-item-stats { font-size: 0.66rem; color: #666; }

/* Right side: badge/switch + delete */
.player-item-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.player-item-badge   { font-size: 0.72rem; color: var(--accent); font-weight: bold; }
.player-select-btn   {
  background: none; border: 1px solid #555; color: #aaa;
  padding: 0.22rem 0.65rem; border-radius: 8px; font-size: 0.76rem;
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.player-select-btn:hover { border-color: var(--accent); color: var(--accent); }
.player-delete-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.88rem; padding: 0.15rem 0.25rem; border-radius: 6px;
  opacity: 0.4; transition: opacity 0.2s;
  line-height: 1;
}
.player-delete-btn:hover { opacity: 1; }
.no-players { color: #555; font-size: 0.82rem; font-style: italic; padding: 0.4rem 0; text-align: center; }

.new-player-section {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.new-player-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid #444;
  border-radius: 10px;
  color: #eee;
  padding: 0.48rem 0.75rem;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}
.new-player-input:focus { border-color: var(--accent); }
.new-player-add-btn {
  padding: 0.48rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.2s;
}
.new-player-add-btn:hover { filter: brightness(0.85); }

.random-name-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.1rem 0;
  text-decoration: underline dotted;
  transition: color 0.2s;
}
.random-name-btn:hover { color: var(--accent); }

.new-player-error {
  font-size: 0.78rem;
  color: #ff6b6b;
  margin: 0.3rem 0 0;
  text-align: center;
}

/* ---- TOP SCORES BUTTON ---- */
.top-scores-link {
  background: none;
  border: 1px solid #444;
  color: #888;
  padding: 0.28rem 0.9rem;
  font-size: 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  margin-bottom: 1.2rem;
  transition: border-color 0.2s, color 0.2s;
}
.top-scores-link:hover { border-color: var(--accent); color: var(--accent); }

.top-scores-icon-btn {
  background: none;
  border: 1px solid #444;
  color: #aaa;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.6rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.3s, color 0.3s;
}
.top-scores-icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- TOP SCORES MODAL ---- */
.top-scores-panel {
  min-width: 300px;
  max-width: 380px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 1.2rem;
}
.top-scores-panel h2 { color: var(--accent); }

.top-scores-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 0.6rem;
}
.ts-tab {
  flex: 1;
  padding: 0.45rem 0;
  background: var(--bg);
  border: 2px solid #444;
  border-radius: 10px;
  color: #888;
  font-size: 0.82rem;
  font-weight: bold;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.ts-tab.active { border-color: var(--accent); color: var(--accent); }

.ts-content {
  margin: 0.1rem 0;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.ts-content::-webkit-scrollbar { width: 4px; }
.ts-content::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }
.ts-content::-webkit-scrollbar-track { background: transparent; }
.ts-content.hidden { display: none; }

/* Regular tab — one row per subject */
.ts-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.4rem;
  border-radius: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ts-row:last-child { border-bottom: none; }
.ts-row.ts-unplayed { opacity: 0.35; }
.ts-icon { font-size: 1rem; width: 26px; text-align: center; flex-shrink: 0; font-style: normal; }
.ts-name { flex: 1; text-align: left; font-size: 0.83rem; color: #ccc; }
.ts-stat { text-align: center; min-width: 46px; line-height: 1.1; }
.ts-val  { font-size: 1rem; font-weight: bold; color: var(--accent); display: block; }
.ts-lbl  { font-size: 0.55rem; text-transform: uppercase; color: #666; letter-spacing: 0.5px; display: block; }
.ts-date { font-size: 0.5rem; color: #555; display: block; margin-top: 1px; }

/* Timed tab — one row per time limit */
.ts-timed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ts-timed-row:last-child { border-bottom: none; }
.ts-timed-label { font-size: 0.9rem; color: #ccc; }
.ts-timed-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 0.05rem; }
.ts-timed-best  { font-size: 1.5rem; font-weight: bold; color: var(--accent); line-height: 1; }
.ts-timed-best.empty { font-size: 1.1rem; color: #555; }
.ts-timed-date  { font-size: 0.6rem; color: #555; }

/* Timed setup back bar — flex so Back + 📊 sit side by side */
.timed-setup-back {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* ---- TIMED SETUP ---- */
.timed-setup { display: none; }
.timed-setup.active { display: block; }
.timed-setup-back { text-align: left; margin-bottom: 1rem; }
.timed-setup h2 {
  font-size: 2rem; font-weight: bold; margin: 0.2rem 0 0.2rem;
  background: linear-gradient(135deg, var(--accent), #0f3460);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.timed-section-label {
  font-size: 0.72rem; text-transform: uppercase; color: #888;
  letter-spacing: 1px; margin: 1rem 0 0.5rem;
}
.time-picker { display: flex; gap: 0.5rem; }
.time-btn {
  flex: 1; padding: 0.65rem 0; font-size: 0.95rem; font-weight: bold;
  background: var(--bg-card); border: 2px solid #444; border-radius: 12px;
  color: #aaa; cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.time-btn:hover { border-color: var(--accent); color: var(--accent); }
.time-btn.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.timed-sub-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.6rem; max-height: 38vh; overflow-y: auto; margin-top: 0;
}
.timed-sub-card {
  background: var(--bg-card); border: 2px solid transparent; border-radius: 12px;
  padding: 0.85rem 0.5rem; cursor: pointer; text-align: center;
  transition: transform 0.15s, border-color 0.2s;
}
.timed-sub-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.timed-sub-card.selected { border-color: var(--accent); background: var(--accent-glow); }
.timed-sub-card .t-icon { font-size: 1.5rem; margin-bottom: 0.2rem; }
.timed-sub-card .t-name { font-size: 0.82rem; font-weight: bold; }
.start-timed-btn {
  margin-top: 1rem; width: 100%; padding: 0.95rem;
  font-size: 1.15rem; font-weight: bold; background: var(--accent);
  color: #fff; border: none; border-radius: 14px;
  cursor: pointer; transition: filter 0.2s, opacity 0.2s;
}
.start-timed-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.start-timed-btn:not(:disabled):hover { filter: brightness(0.85); }

/* ---- TIMED HUD ---- */
.timed-hud { display: none; margin-bottom: 0.6rem; }
.game.timed-active .timed-hud { display: block; }
.game.timed-active .stats,
.game.timed-active .level-name,
.game.timed-active .level-bar,
.game.timed-active .streak-info { display: none; }
.timer-track {
  width: 100%; height: 10px; background: var(--bg-card);
  border-radius: 5px; overflow: hidden; margin-bottom: 0.5rem;
}
.timer-fill {
  height: 100%; background: linear-gradient(90deg, #4ecca3, var(--accent));
  border-radius: 5px; transition: width 0.85s linear;
}
.timer-fill.danger { background: linear-gradient(90deg, #f97316, #e94560); }
.timed-row { display: flex; gap: 0.5rem; }
.timed-box {
  background: var(--bg-card); border-radius: 12px;
  padding: 0.35rem 0; flex: 1; text-align: center;
}
.timed-box-lbl { font-size: 0.62rem; text-transform: uppercase; color: #888; letter-spacing: 1px; }
.timed-box-val { font-size: 1.45rem; font-weight: bold; color: var(--accent); line-height: 1.15; }
.timed-box-val.time-val { color: #4ecca3; }
.timed-box-val.danger { color: var(--accent); animation: blink 0.5s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.35} }

/* ---- WORD PROBLEMS ---- */
.word-problem {
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: 0;
  text-align: left;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 0.75rem 1.1rem 0.9rem;
  color: #dce6f5;
  margin: 0 auto 0.2rem;
}
.word-scene {
  font-size: 1.7rem;
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 0.55rem;
  line-height: 1;
}
.word-text {
  line-height: 1.65;
}

/* ---- FORMS PROBLEM ---- */
.forms-problem {
  text-align: center;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 0.9rem 1.2rem 1rem;
  color: #dce6f5;
  margin: 0 auto 0.2rem;
}
.forms-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 0.6rem;
  opacity: 0.85;
}
.forms-eq {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

/* ---- SCORE POPUP ---- */
.question-area { position: relative; }
.score-popup {
  position: absolute; top: 0.6rem; right: 0.9rem;
  font-size: 1rem; font-weight: bold; color: #4ecca3;
  pointer-events: none; opacity: 0;
}
.score-popup.bonus { color: #f97316; }
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0); }
  80%  { opacity: 1; transform: translateY(-22px); }
  100% { opacity: 0; transform: translateY(-32px); }
}
.score-popup.show { animation: floatUp 0.85s forwards; }

/* ---- AWARD TOAST ---- */
.award-toast {
  position: fixed;
  top: 1rem;
  left: 1rem;
  background: linear-gradient(135deg, #1a1a3e 0%, #2a1040 100%);
  border: 2px solid var(--accent);
  border-radius: 14px;
}
/* Category-coloured toast borders & labels */
.award-toast[data-cat="streak"] { border-color: #ff4444; }
.award-toast[data-cat="streak"] .award-toast-label { color: #ff6b6b; }
.award-toast[data-cat="speed"]  { border-color: #ff8c00; }
.award-toast[data-cat="speed"]  .award-toast-label { color: #ffa833; }
.award-toast[data-cat="gold"]   { border-color: #ffd700; }
.award-toast[data-cat="gold"]   .award-toast-label { color: #ffe44d; }
.award-toast[data-cat="explore"]{ border-color: #44dd88; }
.award-toast[data-cat="explore"] .award-toast-label { color: #55ee99; }
.award-toast[data-cat="lesson"] { border-color: #4ecca3; }
.award-toast[data-cat="lesson"] .award-toast-label { color: #4ecca3; }
.award-toast {
  padding: 0.7rem 1rem 0.7rem 0.85rem;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  z-index: 2000;
  max-width: 240px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  transform: translateX(calc(-100% - 1.5rem));
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.award-toast.show {
  transform: translateX(0);
}
.award-toast-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}
.award-toast-body {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}
.award-toast-label {
  font-size: 0.6rem;
  font-weight: bold;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}
.award-toast-name {
  font-size: 0.92rem;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.award-toast-desc {
  font-size: 0.72rem;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- TIMED RESULTS ---- */
.timed-results { display: none; text-align: center; padding: 0.5rem 0; }
.timed-results.active { display: block; }
.timed-results-icon { font-size: 2.8rem; margin-bottom: 0.3rem; }
.timed-results h2 {
  font-size: 2rem; font-weight: bold; margin-bottom: 0.7rem;
  background: linear-gradient(135deg, var(--accent), #0f3460);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.new-best-badge {
  display: inline-block; background: linear-gradient(135deg,#ffd700,#f59e0b);
  color: #111; font-size: 0.78rem; font-weight: bold;
  padding: 0.3rem 0.9rem; border-radius: 20px; margin-bottom: 0.9rem;
}
.new-best-badge.hidden { display: none; }
.result-cards { display: flex; gap: 0.6rem; margin-bottom: 1.2rem; }
.result-card {
  background: var(--bg-card); border-radius: 14px;
  padding: 0.75rem 0.5rem; flex: 1;
}
.result-card-val { font-size: 2rem; font-weight: bold; color: var(--accent); }
.result-card-val.gold { color: #ffd700; }
.result-card-lbl { font-size: 0.62rem; text-transform: uppercase; color: #888; letter-spacing: 1px; margin-top: 0.15rem; }
.result-btns { display: flex; gap: 0.75rem; }
.result-btn {
  flex: 1; padding: 0.85rem; font-size: 1rem; font-weight: bold;
  border-radius: 12px; cursor: pointer; border: none; transition: filter 0.2s;
}
.result-btn.primary { background: var(--accent); color: #fff; }
.result-btn.secondary { background: var(--bg-card); color: #aaa; border: 1px solid #444; }
.result-btn:hover { filter: brightness(0.88); }

/* ============================================================
   LESSONS SCREEN
   ============================================================ */
.lessons-screen.hidden { display: none; }
.lessons-screen {
  padding-bottom: 2rem;
}

.lessons-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.2rem 1rem 0.85rem;
  background: rgba(0,0,0,0.15);
  margin-bottom: 0.6rem;
}

.lessons-title {
  flex: 1;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.lessons-back-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #aaa;
  padding: 0.45rem 1rem;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}
.lessons-back-btn:hover { border-color: var(--accent); color: var(--accent); }

.chapter-list {
  padding: 0 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chapter-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 0.85rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.chapter-num {
  font-size: 0.62rem;
  color: #555;
  font-weight: 700;
  min-width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.chapter-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.chapter-info { flex: 1; min-width: 0; }
.chapter-name { font-size: 0.95rem; font-weight: 700; color: white; line-height: 1.2; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.chapter-stars { font-size: 0.72rem; letter-spacing: -0.02em; flex-shrink: 0; }
.chapter-tagline { font-size: 0.7rem; color: #777; margin-top: 0.12rem; }

.chapter-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.chapter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: #ccc;
  padding: 0.45rem 0.65rem;
  font-size: 1rem;
  cursor: pointer;
  min-width: 50px;
  transition: background 0.2s, border-color 0.2s;
}
.chapter-btn span { font-size: 0.58rem; color: #888; }
.chapter-btn:hover { background: rgba(255,255,255,0.13); border-color: var(--accent); }
.chapter-zone-btn:hover { background: rgba(233,69,96,0.15); border-color: var(--accent); }

/* ---- MILESTONE CARD ---- */
.chapter-card.chapter-milestone {
  background: rgba(255, 200, 50, 0.06);
  border-color: rgba(255, 200, 50, 0.3);
  margin: 0.2rem 0;   /* slightly more breathing room around checkpoints */
}
.chapter-card.chapter-milestone .chapter-circle {
  background: #7a5a10;
}
.chapter-card.chapter-milestone.chapter-complete {
  border-color: #4ecca3;
  background: rgba(78, 204, 163, 0.07);
}
.chapter-card.chapter-milestone.chapter-complete .chapter-circle {
  background: #1b6b52;
}
.chapter-milestone-marker {
  font-size: 0.85rem;
  color: #ffd700;
  min-width: 16px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 700;
}
.chapter-milestone-btn {
  border-color: rgba(255, 200, 50, 0.4);
  color: #ffd700;
}
.chapter-milestone-btn span { color: #ffd700; }
.chapter-milestone-btn:hover {
  background: rgba(255, 200, 50, 0.15);
  border-color: #ffd700;
}

/* ---- LOCKED LESSON ---- */
.chapter-card.chapter-locked {
  opacity: 0.38;
  border-color: rgba(255,255,255,0.05);
  pointer-events: none;
}
.chapter-card.chapter-locked .chapter-circle {
  background: #333;
}
.chapter-locked-msg {
  font-size: 1.3rem;
  padding: 0.4rem 0.6rem;
  opacity: 0.6;
}

/* ---- COMPLETE LESSON ---- */
.chapter-card.chapter-complete {
  border-color: #4ecca3;
  background: rgba(78, 204, 163, 0.07);
}
.chapter-card.chapter-complete .chapter-circle {
  background: #1b6b52;
}
.chapter-zone-btn.chapter-zone-done {
  border-color: #4ecca3;
  color: #4ecca3;
}
.chapter-zone-btn.chapter-zone-done span { color: #4ecca3; }
.chapter-zone-btn.chapter-zone-done:hover {
  background: rgba(78, 204, 163, 0.15);
  border-color: #4ecca3;
}

/* ============================================================
   BOOK OVERLAY
   ============================================================ */
.book-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.book-overlay.hidden { display: none; }

.book-modal {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.book-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.book-icon-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.book-title {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.book-close-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #aaa;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: background 0.2s;
}
.book-close-btn:hover { background: rgba(255,255,255,0.2); color: white; }

.book-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.book-section {
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.book-heading {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.book-text {
  font-size: 0.87rem;
  color: #ccc;
  line-height: 1.65;
  margin: 0;
}

.book-example {
  background: rgba(0,0,0,0.3);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.6rem 0.9rem;
  font-family: 'Courier New', monospace;
  font-size: 0.83rem;
  color: #dce8ff;
  white-space: pre;
  margin: 0.65rem 0 0;
  overflow-x: auto;
}

.book-note {
  font-size: 0.75rem;
  color: #666;
  font-style: italic;
  margin: 0.35rem 0 0;
}

.book-practice-btn {
  padding: 1rem;
  background: var(--accent);
  border: none;
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  transition: filter 0.2s;
}
.book-practice-btn:hover { filter: brightness(1.1); }

/* ============================================================
   ONLINE LEADERBOARD
   ============================================================ */

/* Setup / loading / empty state */
.lb-setup-msg {
  padding: 0.6rem 0.3rem;
  text-align: center;
}
.lb-setup-icon { font-size: 1.8rem; margin-bottom: 0.25rem; }
.lb-setup-title { font-size: 0.95rem; font-weight: 700; color: white; margin-bottom: 0.2rem; }
.lb-setup-text {
  font-size: 0.77rem;
  color: #888;
  line-height: 1.5;
}
/* "How to set it up" toggle button */
.lb-howto-btn {
  margin-top: 0.55rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #ccc;
  padding: 0.4rem 1.1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.lb-howto-btn:hover { background: rgba(255,255,255,0.14); border-color: var(--accent); color: white; }

/* Instructions panel */
.lb-instructions {
  margin-top: 0.5rem;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 0.55rem 0.7rem 0.5rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.lb-instructions.hidden { display: none; }

.lb-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.74rem;
  color: #bbb;
  line-height: 1.45;
  overflow-wrap: break-word;
  word-break: break-word;
}
.lb-step-num {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.lb-step strong { color: white; }
.lb-step code {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  font-size: 0.68rem;
  color: var(--accent);
  word-break: break-all;
}

/* Firebase link inside instructions */
.lb-firebase-link {
  display: inline-block;
  margin-top: 0.4rem;
  align-self: center;
  background: #ff6d00;
  color: white;
  text-decoration: none;
  padding: 0.45rem 1.2rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  transition: filter 0.2s;
}
.lb-firebase-link:hover { filter: brightness(1.15); }

.lb-setup-text code {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.78rem;
  color: var(--accent);
}
.lb-loading {
  padding: 1.5rem;
  text-align: center;
  color: #777;
  font-size: 0.88rem;
}

/* Scores table */
/* ── Online leaderboard bar graph ───────────────────────── */
/* ── Horizontal bar graph ────────────────────────────────── */
.lb-graph {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.1rem 0;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lb-rank {
  font-size: 1.1rem;
  width: 1.8rem;
  text-align: center;
  flex-shrink: 0;
}

.lb-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.lb-bar-track {
  width: 100%;
}

.lb-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}

.lb-bar-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ddd;
}

.lb-bar-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.lb-bar {
  height: 12px;
  border-radius: 6px;
  min-width: 6px;
  width: 0%;
  max-width: 100%;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* "You" badge */
.lb-you {
  font-size: 0.55rem;
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

.lb-row-me .lb-bar { box-shadow: 0 0 10px rgba(78,204,163,0.4); }
.lb-row-me .lb-bar-val { color: #fff; }

/* Sub-tabs inside Online leaderboard */
.lb-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 0.7rem;
}
.lb-subtab {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid #444;
  color: #888;
  border-radius: 20px;
  padding: 0.3rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.lb-subtab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(78, 204, 163, 0.1);
}
.lb-subtab:not(.active):hover { border-color: #666; color: #bbb; }

/* Refresh button */
.lb-refresh-btn {
  margin: 0.7rem auto 0.2rem;
  display: block;
  background: none;
  border: 1px solid #444;
  color: #777;
  border-radius: 20px;
  padding: 0.35rem 1.2rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.lb-refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Nickname nudge banner */
.lb-nudge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 200, 50, 0.1);
  border: 1px solid rgba(255, 200, 50, 0.35);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.8rem;
  text-align: center;
}

.lb-nudge-icon { font-size: 1.4rem; }

.lb-nudge-text {
  font-size: 0.82rem;
  color: #ffd060;
  font-weight: 600;
}

.lb-nudge-dismiss {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: #888;
  cursor: pointer;
  margin-top: 0.2rem;
}

.lb-nudge-dismiss input { cursor: pointer; accent-color: var(--accent); }

/* Toast notification */
.online-post-toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,40,60,0.95);
  border: 1px solid var(--accent);
  color: white;
  padding: 0.6rem 1.3rem;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  transition: bottom 0.35s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  pointer-events: none;
}
.online-post-toast.show { bottom: 2rem; }

/* ---- Streak Flame Burst ---- */
@keyframes flameBurst {
  0%   { transform: translateY(0) scale(1);    opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translateY(-110px) scale(1.6); opacity: 0; }
}
.streak-flame-particle {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  font-size: 1.8rem;
  line-height: 1;
  animation: flameBurst 0.9s ease-out forwards;
}
@keyframes streakFlash {
  0%   { transform: scale(1);   }
  30%  { transform: scale(1.6); color: var(--accent); }
  100% { transform: scale(1);   }
}
.streak-flash {
  animation: streakFlash 0.5s ease;
}

/* ============================================================
   DAILY CHALLENGE
   ============================================================ */
.daily-panel {
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 1rem;
  max-width: 460px;
  width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.4rem 1.4rem 1.2rem;
  box-sizing: border-box;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55);
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}
.daily-panel::-webkit-scrollbar { width: 4px; }
.daily-panel::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

/* ---- Info screen ---- */
.daily-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.daily-header-icon { font-size: 2rem; flex-shrink: 0; }
.daily-header-title { font-size: 1.25rem; font-weight: 800; }
.daily-header-date { font-size: 0.78rem; color: #aaa; margin-top: 0.1rem; }
.daily-header .close-settings-btn { margin-left: auto; flex-shrink: 0; }

.daily-desc {
  font-size: 0.82rem;
  color: #aaa;
  text-align: center;
  margin-bottom: 0.5rem;
}
.daily-best-lbl {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  margin-bottom: 1rem;
}
.daily-play-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 0.6rem;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: filter 0.2s;
}
.daily-play-btn:hover { filter: brightness(1.15); }

.daily-lb-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 1.1rem 0 0.5rem;
}
.daily-lb-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 40px;
}
.daily-lb-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.38rem 0.5rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
}
.daily-lb-row.lb-gold   { background: rgba(255,215,0,0.1);  }
.daily-lb-row.lb-silver { background: rgba(192,192,192,0.1); }
.daily-lb-row.lb-bronze { background: rgba(205,127,50,0.1);  }
.daily-lb-rank  { min-width: 1.6rem; text-align: center; font-weight: 700; }
.daily-lb-name  { flex: 1; }
.daily-lb-score { font-weight: 700; color: var(--primary); }
.daily-lb-empty { font-size: 0.82rem; color: #666; padding: 0.5rem 0; text-align: center; }

/* ---- Game screen ---- */
.daily-game-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.daily-prog-track {
  height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.9rem;
}
.daily-prog-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
.daily-timer-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}
.daily-timer-num {
  font-size: 1.5rem;
  font-weight: 900;
  min-width: 2rem;
  text-align: center;
  transition: color 0.3s;
  color: var(--primary);
}
.daily-timer-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.daily-timer-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 1s linear, background 0.3s;
}
.daily-subject-chip {
  display: inline-block;
  background: rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 0.22rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 0.8rem;
}
.daily-q {
  min-height: 64px;
  text-align: center;
  margin-bottom: 0.9rem;
}
.daily-plain-q {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
}
.daily-input-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.daily-input-row input {
  flex: 1;
  padding: 0.65rem 0.8rem;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 0.5rem;
  border: 1.5px solid #444;
  background: rgba(255,255,255,0.05);
  color: white;
  text-align: center;
  transition: border-color 0.2s;
}
.daily-input-row input:focus { outline: none; border-color: var(--primary); }
.daily-fb {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  min-height: 1.6rem;
}
.daily-fb.correct { color: #4caf50; }
.daily-fb.wrong   { color: var(--accent); }

/* ---- End screen ---- */
.daily-end-trophy { font-size: 3.5rem; text-align: center; margin: 0.5rem 0; }
.daily-end-score  {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--primary);
  text-align: center;
}
.daily-end-sub    { font-size: 0.9rem; color: #aaa; text-align: center; margin-bottom: 0.4rem; }
.daily-end-record {
  font-size: 1rem;
  font-weight: 700;
  color: #ffd700;
  text-align: center;
  margin-bottom: 1rem;
}
.daily-end-btns {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 0.5rem;
}
.daily-end-btns .daily-play-btn,
.daily-end-btns .close-settings-btn { flex: 1; }

/* ============================================================
   BOSS FIGHT
   ============================================================ */
.boss-overlay.hidden { display: none !important; }
.boss-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a0a0a 0%, #0a0008 100%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.2rem 1rem;
  overflow-y: auto;
  text-align: center;
  box-sizing: border-box;
}

/* Screen-shake on wrong answer */
@keyframes bossShake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-10px); }
  35%       { transform: translateX( 10px); }
  55%       { transform: translateX(-6px);  }
  75%       { transform: translateX( 6px);  }
}
.boss-screen-shake { animation: bossShake 0.5s ease; }

/* Flash overlay */
.boss-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3001;
  opacity: 0;
  transition: opacity 0.1s;
}
.boss-flash-show { opacity: 1; transition: opacity 0.45s ease-out; }

/* ---- Intro screen ---- */
@keyframes bossFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-14px); }
}
.boss-intro-dragon {
  font-size: 7rem;
  animation: bossFloat 2.5s ease-in-out infinite;
  display: block;
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 0 30px rgba(220, 50, 50, 0.7));
}
.boss-intro-title {
  font-size: 2.6rem;
  font-weight: 900;
  color: #ff4444;
  letter-spacing: 0.1em;
  text-shadow: 0 0 20px rgba(255, 68, 68, 0.8);
  margin-bottom: 0.2rem;
}
.boss-intro-name {
  font-size: 1rem;
  color: #aaa;
  margin-bottom: 1.2rem;
  letter-spacing: 0.08em;
}
.boss-intro-rules {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.boss-rule {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.boss-fight-btn {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 0.6rem;
  padding: 0.9rem;
  font-size: 1.2rem;
  font-weight: 900;
  border: none;
  border-radius: 0.7rem;
  background: linear-gradient(135deg, #cc1111, #880000);
  color: white;
  cursor: pointer;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 20px rgba(200, 0, 0, 0.5);
  transition: filter 0.2s, transform 0.15s;
}
.boss-fight-btn:hover   { filter: brightness(1.2); transform: scale(1.03); }
.boss-fight-btn-alt {
  background: rgba(255,255,255,0.08);
  box-shadow: none;
  border: 1px solid rgba(255,255,255,0.15);
}
.boss-back-link {
  background: none;
  border: none;
  color: #666;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.3rem;
  padding: 0.4rem;
  text-decoration: underline;
}

/* ---- Game screen ---- */
.boss-hp-wrap {
  width: 100%;
  max-width: 400px;
  margin-bottom: 0.9rem;
}
.boss-hp-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #cc3333;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.3rem;
  text-align: left;
}
.boss-hp-track {
  height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,0,0,0.3);
}
.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #880000, #cc1111);
  border-radius: 6px;
  transition: width 0.6s ease;
  box-shadow: 0 0 8px rgba(200, 0, 0, 0.6);
}

/* Dragon + hearts arena */
.boss-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0.7rem;
}
@keyframes bossDragonIdle {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.boss-dragon {
  font-size: 5.5rem;
  animation: bossDragonIdle 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(200, 60, 60, 0.6));
  display: block;
  line-height: 1;
  margin-bottom: 0.5rem;
}
/* Boss hit animation */
@keyframes bossDragonHit {
  0%   { transform: translateX(0) scale(1);    filter: drop-shadow(0 0 20px rgba(200,60,60,0.6)); }
  20%  { transform: translateX(-12px) scale(1.1); filter: drop-shadow(0 0 30px rgba(255,215,0,0.9)); }
  40%  { transform: translateX( 12px) scale(0.95); }
  70%  { transform: translateX(-5px); }
  100% { transform: translateX(0) scale(1);    filter: drop-shadow(0 0 20px rgba(200,60,60,0.6)); }
}
.boss-dragon-hit { animation: bossDragonHit 0.5s ease forwards; }

/* Dragon roar on player hit */
@keyframes bossRoar {
  0%   { transform: scale(1);    }
  30%  { transform: scale(1.25); filter: drop-shadow(0 0 30px rgba(255,80,0,0.9)); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1);    }
}
.boss-dragon-roar { animation: bossRoar 0.55s ease forwards; }

.boss-hearts {
  font-size: 1.8rem;
  letter-spacing: 0.15rem;
}

/* Meta row: progress + subject chip */
.boss-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  margin-bottom: 0.7rem;
}
.boss-prog {
  font-size: 0.88rem;
  font-weight: 700;
  color: #888;
}
.boss-subject-chip {
  background: rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 0.2rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #aaa;
}

/* Question */
.boss-q {
  width: 100%;
  max-width: 400px;
  min-height: 60px;
  margin-bottom: 0.9rem;
  text-align: center;
}
.boss-plain-q {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.2;
}

/* Input */
.boss-input-row {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  max-width: 400px;
  margin-bottom: 0.5rem;
}
.boss-input-row input {
  flex: 1;
  padding: 0.7rem 0.8rem;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 0.6rem;
  border: 1.5px solid #444;
  background: rgba(255,255,255,0.05);
  color: white;
  text-align: center;
  transition: border-color 0.2s;
}
.boss-input-row input:focus { outline: none; border-color: #cc3333; }
.boss-go-btn {
  padding: 0.7rem 1.2rem;
  font-size: 1.3rem;
  border: none;
  border-radius: 0.6rem;
  background: linear-gradient(135deg, #cc1111, #880000);
  color: white;
  cursor: pointer;
  transition: filter 0.2s;
}
.boss-go-btn:hover { filter: brightness(1.2); }

.boss-fb {
  font-size: 1rem;
  font-weight: 700;
  min-height: 1.6rem;
  text-align: center;
}
.boss-hit-fb  { color: #ffd700; text-shadow: 0 0 10px rgba(255,215,0,0.6); }
.boss-ouch-fb { color: #ff4444; text-shadow: 0 0 10px rgba(255, 68, 68, 0.5); }

/* ---- Result screens ---- */
@keyframes bossDefeated {
  0%   { transform: scale(1) rotate(0deg);   filter: grayscale(0);   }
  50%  { transform: scale(0.8) rotate(-15deg); filter: grayscale(0.5); }
  100% { transform: scale(1) rotate(0deg);   filter: grayscale(1);   }
}
.boss-result-dragon { font-size: 6rem; margin-bottom: 0.5rem; display: block; }
#bossWinScreen  .boss-result-dragon { animation: bossDefeated 1s ease forwards; }

.boss-result-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.boss-win-title  { color: #ffd700; text-shadow: 0 0 20px rgba(255,215,0,0.7); }
.boss-lose-title { color: #ff4444; text-shadow: 0 0 20px rgba(255,68,68,0.7); }

.boss-result-sub {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 0.8rem;
}
.boss-win-award {
  font-size: 1rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 1.2rem;
  padding: 0.6rem 1rem;
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 0.6rem;
  background: rgba(255,215,0,0.08);
}
.boss-result-btns {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  max-width: 340px;
  margin: 0 auto;
}
.boss-result-btns .boss-fight-btn { flex: 1; }

/* Boss card in lessons list */
.chapter-card.chapter-boss {
  background: linear-gradient(135deg, rgba(40,0,0,0.8), rgba(20,0,10,0.9));
  border: 1px solid rgba(200,30,30,0.5);
  box-shadow: 0 0 20px rgba(200, 30, 30, 0.15);
}
.chapter-card.chapter-boss .chapter-name {
  color: #ff6666;
  font-weight: 800;
}
.chapter-boss-btn {
  background: linear-gradient(135deg, #cc1111, #880000) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(200,0,0,0.4);
}
