/* ============================================================
   SAFe Agilist Study Hub - Styles
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --color-primary: #1a365d;
  --color-primary-light: #2a4a7f;
  --color-secondary: #2b6cb0;
  --color-secondary-light: #3b82c4;
  --color-accent: #38b2ac;
  --color-accent-light: #4fd1c5;
  --color-success: #38a169;
  --color-success-light: #48bb78;
  --color-error: #e53e3e;
  --color-error-light: #fc8181;
  --color-warning: #d69e2e;
  --color-warning-light: #ecc94b;
  --color-bg: #f7fafc;
  --color-card: #ffffff;
  --color-text: #2d3748;
  --color-text-light: #718096;
  --color-text-lighter: #a0aec0;
  --color-border: #e2e8f0;
  --color-border-light: #edf2f7;

  /* --surface / --background / --border removed 2026-04-17 —
     these names collide with css/tokens.css (loaded first), whose
     [data-dark] overrides were being clobbered by this :root block.
     tokens.css now owns --surface / --border, and their dark-mode
     variants flip correctly. If any rule below needs a surface /
     border value, use var(--surface) or var(--border) from tokens.css,
     or use the --color-card / --color-border legacy aliases
     (which now flip in the [data-dark] block further down). */

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  --header-height: 58px; /* Was 80px pre-redesign; kept for legacy calc() uses */
  --max-width: 1200px;
  --max-width-wide: 1400px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--bg); /* tokens.css --bg flips in dark mode */
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Dark mode overrides for legacy --color-* tokens
   Unmigrated screens (the 21 game views, reinforce-weak-areas,
   exam config/question cards, matching board, glossary list) use
   --color-card / --color-text / --color-border / etc. Without
   these overrides they'd stay light in dark mode. Until each
   screen is migrated onto the new --bg/--surface/--text system,
   this block keeps them visually coherent when dark-mode is on.
   ============================================================ */
[data-dark] {
  --color-bg: #070e1c;
  --color-card: #0c1728;
  --color-text: #e2ecff;
  --color-text-light: #7a9dc4;
  --color-text-lighter: #3d5577;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-light: rgba(255, 255, 255, 0.05);
  --color-primary: #38bdf8;
  --color-primary-light: #7dd3fc;
  --color-secondary: #0ea5e9;
  --color-secondary-light: #38bdf8;
  --color-accent: #14b8a6;
  --color-accent-light: #2dd4bf;
  --color-warning: #fbbf24;
  --color-warning-light: #fcd34d;
  --color-success: #10b981;
  --color-success-light: #34d399;
  --color-error: #f87171;
  --color-error-light: #fca5a5;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.6);
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

input {
  font-family: inherit;
}

/* ---------- Focus States ---------- */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   HEADER — replaced by .nav in css/tokens.css
   (.app-header, .header-*, .app-title/subtitle, .stat-item/value/label
    removed 2026-04-17 as part of mobile-first redesign; see tokens.css)
   ============================================================ */

/* ============================================================
   MAIN CONTENT & VIEWS
   ============================================================ */
.main-content {
  min-height: calc(100vh - 58px);
}

.view {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem;
}

.view-container.wide {
  max-width: var(--max-width-wide);
}

/* View Header */
.view-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.view-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  flex: 1;
}

.view-actions {
  display: flex;
  gap: 0.5rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-secondary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--color-border-light);
  color: var(--color-text);
}
.btn-secondary:hover {
  background: var(--color-border);
}

.btn-outline {
  border: 2px solid var(--color-border);
  color: var(--color-text);
  background: transparent;
}
.btn-outline:hover {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}
.btn-outline.known {
  border-color: var(--color-success);
  color: var(--color-success);
}
.btn-outline.known:hover {
  background: var(--color-success);
  color: #fff;
}
.btn-outline.known.active {
  background: var(--color-success);
  color: #fff;
}
.btn-outline.needs-review {
  border-color: var(--color-warning);
  color: var(--color-warning);
}
.btn-outline.needs-review:hover {
  background: var(--color-warning);
  color: #fff;
}
.btn-outline.needs-review.active {
  background: var(--color-warning);
  color: #fff;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}
.btn-success:hover {
  background: var(--color-success-light);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover {
  background: var(--color-error-light);
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  transition: all var(--transition-fast);
}
.btn-icon:hover {
  background: var(--color-border-light);
  color: var(--color-secondary);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.btn-back:hover {
  background: var(--color-secondary);
  color: #fff;
}

/* ============================================================
   DASHBOARD — replaced by Phase 3 redesign (css/tokens.css).
   .dashboard, .section-heading, .card-grid, .mode-card (+::before,
   hover, .game::before), .mode-icon, .mode-title, .mode-desc,
   .progress-overview, .progress-cards, .progress-card,
   .progress-ring (+svg), .progress-ring-bg, .progress-ring-fill
   (+.accent, +.success), .progress-ring-text, .progress-card-label
   removed 2026-04-17. The new components are .dash-topbar, .sec-wrap,
   .prog-row, .prog-card, .ring-wrap, .ring-bg, .ring-fg, .ring-val,
   .prog-label, .methods-grid, .method-card, .weak-card, .arcade-zone,
   .games-grid, .game-card.
   ============================================================ */

/* Keep .dashboard as a mostly-empty container so legacy rules elsewhere
   that scope selectors under .dashboard continue to match. */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
}

/* ============================================================
   FILTER BAR / PILLS
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-pill {
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  border: 2px solid var(--color-border);
  color: var(--color-text-light);
  background: transparent;
  transition: all var(--transition-fast);
}

.filter-pill:hover {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

.filter-pill.active {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #fff;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--color-border-light);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-accent));
  border-radius: 999px;
  transition: width var(--transition-normal);
  min-width: 0;
}

.progress-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-light);
  white-space: nowrap;
}

/* ============================================================
   FLASHCARD — Phase 4 redesign lives in css/tokens.css scoped under
   #flashcardsView. Removed 2026-04-17:
     .flashcard-wrapper, .flashcard, .flashcard-inner,
     .flashcard.flipped, .flashcard-front, .flashcard-back,
     .flashcard-text, .flashcard-difficulty (+.easy/.medium/.hard),
     .flashcard-hint, .flashcard-controls, .flashcard-actions,
     .keyboard-hint
   The tokens.css rules re-apply the 3D flip using the same class
   names but with updated colors, padding, and typography.
   ============================================================ */

/* ============================================================
   MATCHING
   ============================================================ */
.game-stats-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.game-stat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.game-stat svg {
  color: var(--color-text-light);
}

.game-stat-label {
  color: var(--color-text-light);
  font-weight: 500;
}

.matching-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.matching-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.matching-item {
  padding: 0.85rem 1rem;
  background: var(--color-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.4;
}

.matching-item:hover {
  border-color: var(--color-secondary);
  box-shadow: var(--shadow-sm);
}

.matching-item.selected {
  border-color: var(--color-accent);
  background: #e6fffa;
  box-shadow: 0 0 0 3px rgba(56, 178, 172, 0.2);
}

.matching-item.matched {
  border-color: var(--color-success);
  background: #f0fff4;
  opacity: 0.7;
  cursor: default;
  pointer-events: none;
}

.matching-item.wrong {
  border-color: var(--color-error);
  background: #fff5f5;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

/* ============================================================
   GLOSSARY
   ============================================================ */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-lighter);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.925rem;
  color: var(--color-text);
  background: var(--color-card);
  transition: border-color var(--transition-fast);
}

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

.search-input::placeholder {
  color: var(--color-text-lighter);
}

.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.glossary-item {
  background: var(--color-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.glossary-item:hover,
.glossary-item:focus {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-primary-light, #93c5fd);
}

.glossary-term {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.glossary-term-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary);
}

.glossary-category-badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--color-border-light);
  color: var(--color-text-light);
  letter-spacing: 0.02em;
  line-height: 1.3;
  flex-shrink: 1;
  text-align: right;
}

.glossary-category-badge:empty {
  display: none;
}

.glossary-definition {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.65;
  padding-left: 0.125rem;
  border-top: 1px solid var(--color-border-light);
  padding-top: 0.5rem;
}

mark {
  background: #fefcbf;
  padding: 0 2px;
  border-radius: 2px;
}

/* ============================================================
   PRACTICE EXAM
   ============================================================ */

/* Config */
.exam-config {
  text-align: center;
  max-width: 600px;
  margin: 3rem auto;
}

.exam-config h3 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.exam-options {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.exam-option {
  cursor: pointer;
  flex: 1;
  min-width: 160px;
}

.exam-option input {
  display: none;
}

.exam-option-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}

.exam-option input:checked + .exam-option-card {
  border-color: var(--color-secondary);
  background: #ebf4ff;
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.exam-option-card:hover {
  border-color: var(--color-secondary);
}

.exam-option-card strong {
  font-size: 1rem;
  color: var(--color-primary);
}

/* Active Exam */
.exam-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.exam-timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.exam-timer.warning {
  color: var(--color-warning);
}

.exam-timer.danger {
  color: var(--color-error);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.exam-progress-info {
  flex: 1;
  font-size: 0.875rem;
  color: var(--color-text-light);
  font-weight: 600;
}

/* Nav Grid */
.exam-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.exam-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text-light);
  transition: all var(--transition-fast);
}

.exam-nav-btn:hover {
  border-color: var(--color-secondary);
}

.exam-nav-btn.current {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #fff;
}

.exam-nav-btn.answered {
  background: var(--color-border-light);
  border-color: var(--color-border);
  color: var(--color-text);
}

.exam-nav-btn.flagged {
  border-color: var(--color-warning);
  background: #fffff0;
}

.exam-nav-btn.flagged::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background: var(--color-warning);
  border-radius: 50%;
}

/* Question Card */
.exam-question-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.exam-question-text {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.exam-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.exam-option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.exam-option-btn:hover {
  border-color: var(--color-secondary);
  background: #f7faff;
}

.exam-option-btn.selected {
  border-color: var(--color-secondary);
  background: #ebf4ff;
}

.exam-option-btn.correct {
  border-color: var(--color-success);
  background: #f0fff4;
}

.exam-option-btn.incorrect {
  border-color: var(--color-error);
  background: #fff5f5;
}

.exam-option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--color-border-light);
  color: var(--color-text-light);
}

.exam-option-btn.selected .exam-option-letter {
  background: var(--color-secondary);
  color: #fff;
}

.exam-controls {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

/* Results */
.exam-results {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
}

.results-header {
  margin-bottom: 1.5rem;
}

.results-header h3 {
  font-size: 1.5rem;
}

.results-header.pass {
  color: var(--color-success);
}

.results-header.fail {
  color: var(--color-error);
}

.results-score {
  margin-bottom: 2rem;
}

.results-score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  border: 6px solid var(--color-border-light);
  transition: border-color var(--transition-normal);
}

.results-score-circle.pass {
  border-color: var(--color-success);
}

.results-score-circle.fail {
  border-color: var(--color-error);
}

.results-score-value {
  font-size: 2rem;
  font-weight: 800;
}

.results-domains {
  text-align: left;
  margin-bottom: 2rem;
}

.domain-bar {
  margin-bottom: 1rem;
}

.domain-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.domain-bar-name {
  font-weight: 600;
  color: var(--color-text);
}

.domain-bar-score {
  font-weight: 700;
  color: var(--color-text-light);
}

.domain-bar-track {
  height: 10px;
  background: var(--color-border-light);
  border-radius: 999px;
  overflow: hidden;
}

.domain-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
  background: var(--color-secondary);
}

.domain-bar-fill.good {
  background: var(--color-success);
}

.domain-bar-fill.ok {
  background: var(--color-warning);
}

.domain-bar-fill.bad {
  background: var(--color-error);
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.exam-review {
  text-align: left;
}

.review-question {
  background: var(--color-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--color-error);
}

.review-question.correct-review {
  border-left-color: var(--color-success);
}

.review-question p {
  margin-bottom: 0.5rem;
}

.review-correct {
  color: var(--color-success);
  font-weight: 600;
}

.review-wrong {
  color: var(--color-error);
  font-weight: 600;
}

.review-explanation {
  color: var(--color-text-light);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border-light);
}

/* Exam Mode Section */
.exam-mode-section,
.exam-length-section {
  margin-bottom: 1.5rem;
}

.exam-mode-section h4,
.exam-length-section h4 {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.exam-modes {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Nav grid correct/incorrect in survey mode */
.exam-nav-btn.nav-correct {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.exam-nav-btn.nav-incorrect {
  background: var(--color-error);
  border-color: var(--color-error);
  color: #fff;
}

/* Disabled option buttons (after survey submit) */
.exam-option-btn.disabled {
  cursor: default;
  pointer-events: none;
}

.exam-option-btn.correct .exam-option-letter {
  background: var(--color-success);
  color: #fff;
}

.exam-option-btn.incorrect .exam-option-letter {
  background: var(--color-error);
  color: #fff;
}

/* Survey Feedback Panel */
.survey-feedback {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  border-left: 5px solid var(--color-border);
}

.survey-feedback-header {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border-light);
}

.survey-feedback-header.correct {
  color: var(--color-success);
  border-color: var(--color-success);
}

.survey-feedback-header.correct + .survey-feedback-section {
  border-left-color: var(--color-success);
}

.survey-feedback-header.incorrect {
  color: var(--color-error);
  border-color: var(--color-error);
}

.survey-feedback.correct-border {
  border-left-color: var(--color-success);
}

.survey-feedback-section {
  margin-bottom: 1rem;
}

.survey-feedback-section h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.survey-feedback-section p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.survey-distractor {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #fff5f5;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-error);
}

.survey-distractor-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
  display: block;
  margin-bottom: 0.25rem;
}

.survey-distractor-reason {
  font-size: 0.85rem;
  color: var(--color-text-light);
  line-height: 1.45;
  margin: 0;
}

/* ============================================================
   JEOPARDY
   ============================================================ */
.jeopardy-score {
  font-size: 1.1rem !important;
}

.jeopardy-board {
  display: grid;
  grid-template-columns: repeat(var(--jeo-cols, 6), 1fr);
  gap: 4px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  padding: 4px;
  overflow: hidden;
}

.jeopardy-header {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 0.85rem 0.5rem;
  line-height: 1.3;
}

.jeopardy-cell {
  background: var(--color-secondary);
  color: #ffd700;
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  padding: 1.25rem 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.jeopardy-cell:hover {
  background: var(--color-accent);
  transform: scale(1.03);
}

.jeopardy-cell.used {
  background: var(--color-primary-light);
  color: rgba(255, 255, 255, 0.15);
  cursor: default;
  pointer-events: none;
}

/* Jeopardy Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn var(--transition-fast);
  padding: 1rem;
}

.modal {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: scaleIn var(--transition-normal);
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.jeopardy-modal {
  text-align: center;
  max-width: 650px;
}

.jeopardy-value {
  font-size: 2rem;
  font-weight: 800;
  color: #ffd700;
  background: var(--color-primary);
  display: inline-block;
  padding: 0.4rem 1.5rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.jeopardy-question-text {
  font-size: 1.15rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.jeopardy-answer p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-success);
  background: #f0fff4;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.jeopardy-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   RAPID FIRE
   ============================================================ */
.rapid-fire-start,
.rapid-fire-results {
  text-align: center;
  padding: 3rem 1rem;
}

.rapid-fire-start h3,
.rapid-fire-results h3 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.rapid-fire-start p {
  color: var(--color-text-light);
  margin-bottom: 2rem;
}

.rapid-fire-timer {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rapid-fire-progress {
  margin-bottom: 1.5rem;
}

.timer-fill {
  background: linear-gradient(90deg, var(--color-error), var(--color-warning), var(--color-success));
  transition: width 1s linear;
}

.rapid-fire-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.rapid-fire-statement {
  font-size: 1.15rem;
  line-height: 1.6;
  text-align: center;
  animation: slideIn var(--transition-normal);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-40px); }
}

.rapid-fire-feedback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.rapid-fire-feedback-icon {
  font-size: 5rem;
  animation: popIn 0.4s ease;
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

.rapid-fire-buttons {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.btn-true {
  background: var(--color-success);
  color: #fff;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
}
.btn-true:hover {
  background: var(--color-success-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-false {
  background: var(--color-error);
  color: #fff;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
}
.btn-false:hover {
  background: var(--color-error-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.combo-badge {
  background: var(--color-warning);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  animation: popIn 0.3s ease;
}

/* Rapid Fire Results */
.rapid-fire-final-score {
  margin: 1.5rem 0;
}

.rapid-fire-final-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--color-primary);
  display: block;
}

.rapid-fire-final-label {
  font-size: 0.9rem;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rapid-fire-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.rapid-fire-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.rapid-fire-stat span:first-child {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.rapid-fire-stat span:last-child {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* ============================================================
   PRINCIPLE SORTER
   ============================================================ */
.sorter-item-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
  text-align: center;
  border: 2px solid var(--color-border-light);
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sorter-item-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.5;
}

.sorter-buckets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.sorter-bucket {
  background: var(--color-card);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sorter-bucket:hover {
  border-color: var(--color-accent);
  background: #e6fffa;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.sorter-bucket-label {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 0.95rem;
}

.sorter-feedback {
  text-align: center;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 1rem;
  animation: fadeIn var(--transition-fast);
}

.sorter-feedback.correct {
  background: #f0fff4;
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.sorter-feedback.incorrect {
  background: #fff5f5;
  color: var(--color-error);
  border: 1px solid var(--color-error);
}

/* ============================================================
   SCENARIO CHALLENGE
   ============================================================ */
.scenario-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.scenario-text {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
}

.scenario-question {
  margin-bottom: 1rem;
}

.scenario-question p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
}

.scenario-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.scenario-option {
  padding: 0.85rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.4;
}

.scenario-option:hover {
  border-color: var(--color-secondary);
}

.scenario-option.selected {
  border-color: var(--color-secondary);
  background: #ebf4ff;
}

.scenario-option.correct {
  border-color: var(--color-success);
  background: #f0fff4;
}

.scenario-option.incorrect {
  border-color: var(--color-error);
  background: #fff5f5;
}

.scenario-explanation {
  background: #ebf8ff;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  border-left: 4px solid var(--color-secondary);
}

/* ============================================================
   CONCENTRATION
   ============================================================ */
.concentration-grid {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  justify-content: center;
}

.concentration-grid.size-4x4 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.concentration-grid.size-4x6 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.concentration-grid.size-6x6 {
  grid-template-columns: repeat(6, 1fr);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.concentration-grid.size-6x8 {
  grid-template-columns: repeat(6, 1fr);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.concentration-grid.size-8x8 {
  grid-template-columns: repeat(8, 1fr);
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.concentration-card {
  aspect-ratio: 1;
  perspective: 800px;
  cursor: pointer;
}

.concentration-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.concentration-card.flipped .concentration-card-inner {
  transform: rotateY(180deg);
}

.concentration-card-front,
.concentration-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  text-align: center;
}

.concentration-card-front {
  background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-primary) 100%);
  color: #fff;
  font-size: 1.5rem;
}

.concentration-card-back {
  background: var(--color-card);
  border: 2px solid var(--color-border);
  transform: rotateY(180deg);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  overflow: hidden;
}

.concentration-card.matched .concentration-card-back {
  border-color: var(--color-success);
  background: #f0fff4;
}

.concentration-card.matched {
  pointer-events: none;
}

.concentration-card.wrong .concentration-card-back {
  border-color: var(--color-error);
  background: #fff5f5;
}

/* ============================================================
   FILL IN THE BLANK
   ============================================================ */
.fill-blank-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.fill-blank-statement {
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.fill-blank-blank {
  display: inline-block;
  min-width: 120px;
  border-bottom: 3px solid var(--color-accent);
  margin: 0 0.25rem;
  padding: 0.15rem 0.5rem;
  font-weight: 700;
  color: var(--color-accent);
}

.fill-blank-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 500px;
  margin: 0 auto 1rem;
}

.fill-blank-option {
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.fill-blank-option:hover {
  border-color: var(--color-secondary);
}

.fill-blank-option.correct {
  border-color: var(--color-success);
  background: #f0fff4;
}

.fill-blank-option.incorrect {
  border-color: var(--color-error);
  background: #fff5f5;
}

.fill-blank-explanation {
  background: #ebf8ff;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  border-left: 4px solid var(--color-secondary);
  text-align: left;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: calc(58px + 1rem); /* 58px = --nav height */
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(15,35,63,0.08));
  border-left: 4px solid var(--accent, #0ea5e9);
  border-radius: var(--r, 14px);
  padding: 0.85rem 1.1rem 0.85rem 1rem;
  box-shadow: var(--shadow2, 0 10px 40px rgba(15,35,63,0.18));
  font-family: var(--font-display, system-ui);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text, #0d1f38);
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 260px;
  max-width: 420px;
  animation: toastIn 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Leading icon glyph per variant -- uses ::before so JS stays clean */
.toast::before {
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1.25;
  opacity: 0.85;
}
.toast.info::before,
.toast:not(.success):not(.error):not(.warning)::before { content: '\2139\FE0F'; }
.toast.success::before { content: '\2705'; }
.toast.error::before   { content: '\26D4'; }
.toast.warning::before { content: '\26A0\FE0F'; }

.toast.success  { border-left-color: var(--green,  #10b981); }
.toast.error    { border-left-color: #ef4444; }
.toast.warning  { border-left-color: var(--gold,   #f59e0b); }

.toast.removing {
  animation: toastOut 220ms ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(24px) scale(0.96); }
}

/* Narrow viewports: slide up from bottom, full-width minus gutter */
@media (max-width: 560px) {
  .toast-container {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    align-items: stretch;
  }
  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  @keyframes toastIn {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  @keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(24px) scale(0.98); }
  }
}

/* New high-score banner used on game-over screens */
.new-high-banner {
  display: inline-block;
  margin: 0.75rem auto 0;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1a1a;
  font-family: var(--font-display, system-ui);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.35);
  animation: newHighPulse 1.4s ease-in-out infinite;
}

@keyframes newHighPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(245, 158, 11, 0.35); }
  50%      { transform: scale(1.04); box-shadow: 0 6px 28px rgba(245, 158, 11, 0.5); }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn-finish {
  background: var(--color-success);
  color: #fff;
}
.btn-finish:hover {
  background: var(--color-success-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .jeopardy-cell {
    font-size: 1rem;
    padding: 1rem 0.35rem;
  }

  .jeopardy-header {
    font-size: 0.65rem;
    padding: 0.6rem 0.25rem;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: auto;
  }

  .app-header {
    height: auto;
    padding: 1rem 1.5rem;
  }

  .header-content {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .header-stats {
    gap: 1rem;
  }

  .dashboard {
    padding: 1rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
  }

  .mode-card {
    padding: 1rem;
  }

  .mode-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .view-container {
    padding: 1rem;
  }

  .flashcard-wrapper {
    margin: 1rem auto;
  }

  .flashcard-inner,
  .flashcard {
    min-height: 220px;
  }

  .flashcard-controls {
    flex-direction: column;
  }

  .matching-board {
    grid-template-columns: 1fr;
  }

  .exam-options {
    flex-direction: column;
  }

  .rapid-fire-buttons {
    flex-direction: column;
    gap: 0.75rem;
  }

  .jeopardy-board {
    grid-template-columns: repeat(3, 1fr);
  }

  .sorter-buckets {
    grid-template-columns: 1fr 1fr;
  }

  .concentration-grid.size-6x6,
  .concentration-grid.size-6x8,
  .concentration-grid.size-8x8 {
    grid-template-columns: repeat(4, 1fr);
  }

  .progress-cards {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .concentration-grid.size-4x4,
  .concentration-grid.size-4x6,
  .concentration-grid.size-6x6,
  .concentration-grid.size-6x8,
  .concentration-grid.size-8x8 {
    grid-template-columns: repeat(3, 1fr);
  }

  .sorter-buckets {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
/* ---------- Weak Areas Reinforcement ---------- */
/* .mode-card.reinforce (+:hover) removed 2026-04-17 — replaced by
   .weak-card in css/tokens.css (Phase 3). */

.reinforce-intro {
  text-align: center;
  margin-bottom: 1.5rem;
}

.reinforce-intro h3 {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.reinforce-intro p {
  color: var(--color-text-light);
}

.reinforce-domain-group {
  margin-bottom: 1.5rem;
  background: var(--color-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 1rem 1.25rem;
}

.reinforce-domain-heading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border-light);
}

.reinforce-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  gap: 1rem;
}

.reinforce-score-row + .reinforce-score-row {
  border-top: 1px solid var(--color-border-light);
}

.reinforce-score-label {
  font-size: 0.9rem;
  color: var(--color-text);
  flex: 1;
}

.reinforce-score-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.reinforce-score-input {
  width: 60px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  text-align: center;
  background: var(--color-bg);
  transition: border-color var(--transition-fast);
}

.reinforce-score-input:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.reinforce-score-suffix {
  color: var(--color-text-light);
  font-size: 0.85rem;
}

.reinforce-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Summary */
.reinforce-summary {
  margin-bottom: 1.5rem;
}

.reinforce-summary-header {
  text-align: center;
  margin-bottom: 1rem;
}

.reinforce-summary-header h3 {
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.reinforce-summary-header p {
  color: var(--color-text-light);
  font-size: 0.9rem;
}

.reinforce-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.reinforce-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.reinforce-chip.critical {
  background: #fed7d7;
  color: #9b2c2c;
}

.reinforce-chip.weak {
  background: #fefcbf;
  color: #975a16;
}

.reinforce-chip.moderate {
  background: #feebc8;
  color: #9c4221;
}

.reinforce-chip-score {
  font-weight: 700;
  font-size: 0.75rem;
}

/* Topic filter bar in reinforce */
.reinforce-topic-bar {
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 0.5rem;
}

.reinforce-topic-bar .filter-pill small {
  opacity: 0.7;
  margin-left: 0.2rem;
}

/* Reinforce study card */
.reinforce-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 1rem;
}

.reinforce-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: var(--color-primary);
  color: white;
}

.reinforce-card-type {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reinforce-card-topic {
  font-size: 0.8rem;
  opacity: 0.85;
  display: inline-block;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reinforce-card-body {
  padding: 1.5rem 1.25rem;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reinforce-card-footer {
  padding: 1rem 1.25rem;
  background: #f0fff4;
  border-top: 1px solid #c6f6d5;
}

.reinforce-explanation {
  font-size: 0.9rem;
  color: #276749;
  line-height: 1.5;
}

.reinforce-empty {
  color: var(--color-text-light);
  font-style: italic;
}

/* Reinforce flashcard (inline flip card) */
.reinforce-flashcard {
  width: 100%;
  min-height: 180px;
  perspective: 1000px;
  cursor: pointer;
}

.reinforce-flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 180px;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

.reinforce-flashcard.flipped .reinforce-flashcard-inner {
  transform: rotateY(180deg);
}

.reinforce-flashcard-front,
.reinforce-flashcard-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 180px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

.reinforce-flashcard-front p,
.reinforce-flashcard-back p {
  font-size: 1.1rem;
  line-height: 1.5;
}

.reinforce-flashcard-back {
  transform: rotateY(180deg);
  background: #f0f7ff;
  border-radius: var(--radius-md);
}

.reinforce-difficulty {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.reinforce-difficulty.easy { background: #c6f6d5; color: #276749; }
.reinforce-difficulty.medium { background: #feebc8; color: #9c4221; }
.reinforce-difficulty.hard { background: #fed7d7; color: #9b2c2c; }

/* Reinforce question */
.reinforce-question {
  width: 100%;
}

.reinforce-question-text {
  font-size: 1.05rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.reinforce-question-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reinforce-q-option.correct {
  border-color: var(--color-success) !important;
  background: #f0fff4 !important;
  color: var(--color-success);
}

.reinforce-q-option.incorrect {
  border-color: var(--color-error) !important;
  background: #fff5f5 !important;
  color: var(--color-error);
}

/* Reinforce controls */
.reinforce-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.reinforce-center-actions {
  display: flex;
  gap: 0.5rem;
}

.reinforce-bottom-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

/* Quiz card in reinforce */
.reinforce-quiz-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.reinforce-quiz-card .reinforce-card-topic {
  display: block;
  color: var(--color-secondary);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.reinforce-quiz-card .reinforce-explanation {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f0fff4;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-success);
}

.reinforce-quiz-opt.correct {
  border-color: var(--color-success) !important;
  background: #f0fff4 !important;
  color: var(--color-success);
}

.reinforce-quiz-opt.incorrect {
  border-color: var(--color-error) !important;
  background: #fff5f5 !important;
  color: var(--color-error);
}

@media (max-width: 600px) {
  .reinforce-score-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .reinforce-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .reinforce-card-topic {
    display: none;
  }

  .reinforce-bottom-actions {
    flex-direction: column;
  }

  .reinforce-actions {
    flex-direction: column;
    align-items: center;
  }
}

@media print {
  .app-header,
  .btn-back,
  .filter-bar,
  .search-bar,
  .view-actions,
  .flashcard-controls,
  .keyboard-hint,
  .toast-container {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .glossary-item {
    break-inside: avoid;
    border: 1px solid #ccc;
    margin-bottom: 0.5rem;
  }

  .view {
    display: block !important;
  }

  .main-content {
    min-height: auto;
  }
}

/* ============================================
   BREAKOUT
   ============================================ */
.breakout-container {
  max-width: 520px;
  margin: 0 auto;
}

.breakout-start, .breakout-gameover {
  text-align: center;
  padding: 2rem 1rem;
}

.breakout-start-content {
  max-width: 400px;
  margin: 0 auto;
}

.breakout-logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.breakout-start-content h3 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.breakout-start-content p {
  color: var(--text2);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.breakout-rules {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}

.breakout-rules li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text2);
}

.breakout-settings {
  margin: 0 auto 1.5rem;
  max-width: 340px;
  text-align: center;
}

.breakout-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.breakout-timer-options {
  display: flex;
  gap: 0.5rem;
}

.breakout-timer-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.breakout-timer-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.breakout-timer-btn:hover {
  border-color: var(--accent);
}

.breakout-timer-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.breakout-timer-btn.active span {
  color: rgba(255,255,255,0.8);
}

.breakout-game {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.breakout-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  background: #0f0f2e;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  gap: 0.5rem;
}

#breakoutCanvas {
  display: block;
  border: 2px solid #1a1a4e;
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: #0f0f2e;
  max-width: 100%;
  cursor: pointer;
  touch-action: none;
}

/* Breakout question overlay */
.breakout-question {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 15, 46, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.breakout-question.hidden { display: none; }

.breakout-question-box {
  background: #12123a;
  border: 2px solid #aa4444;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 40px rgba(200, 60, 60, 0.3);
}

.breakout-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.breakout-q-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ffcc00;
  text-transform: uppercase;
}

.breakout-q-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff4444;
  font-family: 'Courier New', monospace;
  min-width: 2rem;
  text-align: center;
}

.breakout-q-text {
  font-size: 1rem;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.breakout-q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.breakout-q-btn {
  background: #1a1a5e;
  border: 1px solid #3344aa;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #ccccff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.breakout-q-btn:hover:not(:disabled) {
  background: #2a2a7e;
  border-color: #5566cc;
  color: #ffffff;
}

.breakout-q-btn:disabled { cursor: default; opacity: 0.7; }
.breakout-q-btn.correct { background: #0a4a0a; border-color: #44ff44; color: #44ff44; opacity: 1 !important; }
.breakout-q-btn.wrong { background: #4a0a0a; border-color: #ff4444; color: #ff4444; opacity: 1 !important; }

/* Game Over stats */
.breakout-final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.breakout-stat {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.breakout-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.breakout-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.breakout-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.breakout-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  min-width: 44px;
}
.breakout-score-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-family: var(--font-display);
}
.breakout-score-display span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ============================================
   SPACE SHOOTER
   ============================================ */
.shooter-container {
  max-width: 520px;
  margin: 0 auto;
}

.shooter-start, .shooter-gameover {
  text-align: center;
  padding: 2rem 1rem;
}

.shooter-start-content {
  max-width: 400px;
  margin: 0 auto;
}

.shooter-logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.shooter-start-content h3 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.shooter-start-content p {
  color: var(--text2);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.shooter-rules {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}

.shooter-rules li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text2);
}

.shooter-settings {
  margin: 0 auto 1.5rem;
  max-width: 340px;
  text-align: center;
}

.shooter-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.shooter-timer-options {
  display: flex;
  gap: 0.5rem;
}

.shooter-timer-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.shooter-timer-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.shooter-timer-btn:hover {
  border-color: var(--accent);
}

.shooter-timer-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.shooter-timer-btn.active span {
  color: rgba(255,255,255,0.8);
}

.shooter-game {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.shooter-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  background: #0a0a2e;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  gap: 0.5rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.hud-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #8888aa;
  text-transform: uppercase;
}

.hud-value {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  font-family: 'Courier New', monospace;
}

/* Wide Paddle countdown pip — pulses cyan when active */
.hud-wide-pip .hud-label { color: #00e5ff; }
.hud-wide-timer {
  color: #00e5ff;
  animation: widePulse 1s ease-in-out infinite;
}
@keyframes widePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

#shooterCanvas {
  display: block;
  border: 2px solid #1a1a4e;
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: #0a0a2e;
  max-width: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* Question overlay */
.shooter-question {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 46, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.shooter-question.hidden { display: none; }

.shooter-question-box {
  background: #12123a;
  border: 2px solid #3344aa;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 40px rgba(50, 60, 200, 0.3);
}

.shooter-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.shooter-q-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #44ff44;
  text-transform: uppercase;
}

.shooter-q-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff4444;
  font-family: 'Courier New', monospace;
  min-width: 2rem;
  text-align: center;
}

.shooter-q-text {
  font-size: 1rem;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.shooter-q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shooter-q-btn {
  background: #1a1a5e;
  border: 1px solid #3344aa;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #ccccff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.shooter-q-btn:hover:not(:disabled) {
  background: #2a2a7e;
  border-color: #5566cc;
  color: #ffffff;
}

.shooter-q-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.shooter-q-btn.correct {
  background: #0a4a0a;
  border-color: #44ff44;
  color: #44ff44;
  opacity: 1 !important;
}

.shooter-q-btn.wrong {
  background: #4a0a0a;
  border-color: #ff4444;
  color: #ff4444;
  opacity: 1 !important;
}

/* Game Over stats */
.shooter-final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.shooter-stat {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.shooter-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.shooter-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.shooter-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.shooter-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  min-width: 44px;
}
.shooter-score-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-family: var(--font-display);
}
.shooter-score-display span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ============================================
   SUBJECT SELECT VIEW
   ============================================ */
/* .subject-select-*, .subject-grid, .subject-card, .subject-icon,
   .subject-title, .subject-desc, .subject-meta, .add-subject-card,
   .add-subject-icon removed 2026-04-17 — replaced by .home-hero,
   .subject-grid (new), .subj-card, .add-card rules in css/tokens.css.
   The .subject-card.loading opacity behavior is preserved below for
   the .subj-card replacement. */
.subj-card.loading,
.add-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Add Subject dedicated view */
.add-subject-view-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.add-subject-form-wrap {
  margin-top: 1rem;
}

.add-subject-desc {
  color: var(--color-text-light);
  margin-bottom: 1.5rem;
}

.add-subject-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 600px;
}

.add-subject-input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.add-subject-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: var(--color-card);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.add-subject-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.input-hint {
  font-size: 0.8rem;
  color: var(--color-text-lighter);
  margin-top: 0.25rem;
  display: block;
}

/* URL textarea */
.url-textarea {
  resize: vertical;
  min-height: 7rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* URL input rows (enrich modal still uses these) */
.url-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.url-input-row .add-subject-input {
  flex: 1;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--color-text-light);
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--color-border-light);
  color: var(--color-error);
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.btn-outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Crawl toggle */
.crawl-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.crawl-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* .subject-card-actions, .btn-enrich removed 2026-04-17 — replaced by
   .subj-foot and .enrich-btn in css/tokens.css. */

/* Generation progress */
.generation-progress {
  margin-top: 1.5rem;
  max-width: 600px;
}

.progress-status {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.75rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--color-border-light);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-bar-fill.indeterminate {
  width: 30%;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.progress-log {
  font-size: 0.85rem;
  color: var(--color-text-light);
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  line-height: 1.6;
}

.progress-log-entry {
  padding: 0.15rem 0;
}

.progress-log-entry.error {
  color: var(--color-error);
}

.progress-log-entry.warning {
  color: var(--color-warning);
}

.progress-log-entry.success {
  color: var(--color-success);
}

/* ---- Managed file list (source files section) ---- */
.file-pick-btn {
  display: inline-block;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.selected-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.selected-file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text);
}

.selected-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-size {
  color: var(--color-text-lighter);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---- Token budget panel ---- */
.token-budget-panel {
  margin-top: 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-warning);
  background: #fefce8; /* fallback for older browsers */
  background: color-mix(in srgb, var(--color-warning) 8%, var(--color-card));
  padding: 1rem 1.25rem;
  max-width: 600px;
}

.token-budget-panel.token-budget-ok {
  border-color: var(--color-success);
  background: #f0fdf4; /* fallback */
  background: color-mix(in srgb, var(--color-success) 8%, var(--color-card));
}

.token-budget-header {
  margin-bottom: 0.75rem;
}

.token-budget-meter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.token-budget-meter-bar {
  flex: 1;
  height: 8px;
  background: var(--color-border-light);
  border-radius: 4px;
  overflow: hidden;
}

.token-budget-meter-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--color-warning);
  transition: width 0.3s ease, background 0.3s ease;
}

.token-budget-panel.token-budget-ok .token-budget-meter-fill {
  background: var(--color-success);
}

.token-budget-numbers {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-warning);
  white-space: nowrap;
  flex-shrink: 0;
}

.token-budget-panel.token-budget-ok .token-budget-numbers {
  color: var(--color-success);
}

.token-budget-message {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #92400e; /* dark amber — readable on light bg */
  background: #fef3c7; /* fallback */
  background: color-mix(in srgb, var(--color-warning) 22%, var(--color-card));
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0 0;
  line-height: 1.4;
}

.token-budget-panel.token-budget-ok .token-budget-message {
  color: #14532d; /* dark green */
  background: #dcfce7; /* fallback */
  background: color-mix(in srgb, var(--color-success) 22%, var(--color-card));
}

.token-budget-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
}

.token-source-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 0.875rem;
}

.token-source-row:last-child {
  border-bottom: none;
}

.token-source-type {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.token-source-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
  min-width: 0;
}

.token-source-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-warning);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  text-align: right;
  min-width: 5.5rem;
}

.token-budget-panel.token-budget-ok .token-source-count {
  color: var(--color-success);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 14, 28, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  animation: overlayIn 180ms ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(15,35,63,0.1));
  border-radius: var(--r2, 20px);
  max-width: 580px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow2, 0 6px 32px rgba(15,35,63,0.18));
  animation: modalIn 220ms ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border, rgba(15,35,63,0.1));
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display, system-ui);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text, #0d1f38);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text2, #4a5e7a);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 150ms;
}
.modal-close:hover { background: var(--bg3, #e6ecf6); }

.modal-body {
  padding: 1.5rem 2rem 2rem;
}

.modal-body .add-subject-input-group {
  margin-bottom: 1rem;
}

.modal-body .btn-primary {
  width: 100%;
  margin-top: 0.5rem;
}

/* ============================================
   FROGGER
   ============================================ */
.frogger-container {
  max-width: 520px;
  margin: 0 auto;
}

.frogger-start, .frogger-gameover {
  text-align: center;
  padding: 2rem 1rem;
}

.frogger-start-content {
  max-width: 400px;
  margin: 0 auto;
}

.frogger-logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.frogger-start-content h3 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.frogger-start-content p {
  color: var(--text2);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.frogger-rules {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}

.frogger-rules li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text2);
}

.frogger-settings {
  margin: 0 auto 1.5rem;
  max-width: 340px;
  text-align: center;
}

.frogger-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.frogger-timer-options {
  display: flex;
  gap: 0.5rem;
}

.frogger-timer-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.frogger-timer-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.frogger-timer-btn:hover {
  border-color: var(--accent);
}

.frogger-timer-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.frogger-timer-btn.active span {
  color: rgba(255,255,255,0.8);
}

.frogger-game {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.frogger-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  background: #0a2a0a;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  gap: 0.5rem;
}

#froggerCanvas {
  display: block;
  border: 2px solid #1a4a1a;
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: #0a2a0a;
  max-width: 100%;
  touch-action: none;
}

/* Question overlay */
.frogger-question {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 42, 10, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.frogger-question.hidden { display: none; }

.frogger-question-box {
  background: #0f2a12;
  border: 2px solid #22cc66;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 40px rgba(34, 204, 102, 0.25);
}

.frogger-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.frogger-q-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #44ff88;
  text-transform: uppercase;
}

.frogger-q-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff4444;
  font-family: 'Courier New', monospace;
  min-width: 2rem;
  text-align: center;
}

.frogger-q-text {
  font-size: 1rem;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.frogger-q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.frogger-q-btn {
  background: #1a3a1e;
  border: 1px solid #22884a;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #bbffcc;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.frogger-q-btn:hover:not(:disabled) {
  background: #2a5a2e;
  border-color: #44cc66;
  color: #ffffff;
}

.frogger-q-btn:disabled { cursor: default; opacity: 0.7; }
.frogger-q-btn.correct { background: #0a4a0a; border-color: #44ff44; color: #44ff44; opacity: 1 !important; }
.frogger-q-btn.wrong { background: #4a0a0a; border-color: #ff4444; color: #ff4444; opacity: 1 !important; }

/* Game Over stats */
.frogger-final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.frogger-stat {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.frogger-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.frogger-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.frogger-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.frogger-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  min-width: 44px;
}
.frogger-score-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-family: var(--font-display);
}
.frogger-score-display span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ============================================
   TIC-TAC-TOE
   ============================================ */
.ttt-container {
  max-width: 520px;
  margin: 0 auto;
}

.ttt-start, .ttt-gameover {
  text-align: center;
  padding: 2rem 1rem;
}

.ttt-start-content {
  max-width: 400px;
  margin: 0 auto;
}

.ttt-logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.ttt-start-content h3 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.ttt-start-content p {
  color: var(--text2);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.ttt-rules {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}

.ttt-rules li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text2);
}

.ttt-settings {
  margin: 0 auto 1.5rem;
  max-width: 340px;
  text-align: center;
}

.ttt-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.ttt-timer-options {
  display: flex;
  gap: 0.5rem;
}

.ttt-timer-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.ttt-timer-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.ttt-timer-btn:hover {
  border-color: var(--accent);
}

.ttt-timer-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ttt-timer-btn.active span {
  color: rgba(255,255,255,0.8);
}

.ttt-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem;
}

.ttt-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 360px;
  padding: 0.5rem 0.75rem;
  background: #1a1a3e;
  border-radius: var(--radius-md);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ttt-status {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 1rem;
  min-height: 1.5em;
}

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  background: #2a2a5e;
  padding: 6px;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.ttt-cell {
  background: #12123a;
  border: none;
  border-radius: var(--radius-md);
  font-size: 3rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  aspect-ratio: 1;
}

.ttt-cell:hover:not(:disabled) {
  background: #1e1e5a;
  transform: scale(1.03);
}

.ttt-cell:disabled {
  cursor: default;
}

.ttt-cell.ttt-x {
  color: #4a9eff;
  text-shadow: 0 0 12px rgba(74, 158, 255, 0.4);
}

.ttt-cell.ttt-o {
  color: #ff6b6b;
  text-shadow: 0 0 12px rgba(255, 107, 107, 0.4);
}

.ttt-cell.ttt-winner {
  background: #2a4a2a;
  animation: tttPulse 0.6s ease-in-out 3;
}

@keyframes tttPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.ttt-round-result {
  text-align: center;
  padding: 1rem;
}

.ttt-round-result p {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1rem;
}

/* Question overlay */
.ttt-question {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18, 18, 58, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.ttt-question.hidden { display: none; }

.ttt-question-box {
  background: #12123a;
  border: 2px solid #4a9eff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 40px rgba(74, 158, 255, 0.25);
}

.ttt-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.ttt-q-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #4a9eff;
  text-transform: uppercase;
}

.ttt-q-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff4444;
  font-family: 'Courier New', monospace;
  min-width: 2rem;
  text-align: center;
}

.ttt-q-text {
  font-size: 1rem;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.ttt-q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ttt-q-btn {
  background: #1a1a5e;
  border: 1px solid #3344aa;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #ccccff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.ttt-q-btn:hover:not(:disabled) {
  background: #2a2a7e;
  border-color: #5566cc;
  color: #ffffff;
}

.ttt-q-btn:disabled { cursor: default; opacity: 0.7; }
.ttt-q-btn.correct { background: #0a4a0a; border-color: #44ff44; color: #44ff44; opacity: 1 !important; }
.ttt-q-btn.wrong { background: #4a0a0a; border-color: #ff4444; color: #ff4444; opacity: 1 !important; }

/* Game Over stats */
.ttt-final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.ttt-stat {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.ttt-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.ttt-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.ttt-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.ttt-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  min-width: 44px;
}
.ttt-score-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-family: var(--font-display);
}
.ttt-score-display span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ============================================
   BATTLESHIP
   ============================================ */
.bship-container {
  max-width: 580px;
  margin: 0 auto;
}

.bship-start, .bship-gameover {
  text-align: center;
  padding: 2rem 1rem;
}

.bship-start-content {
  max-width: 400px;
  margin: 0 auto;
}

.bship-logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.bship-start-content h3 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.bship-start-content p {
  color: var(--text2);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.bship-rules {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}

.bship-rules li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text2);
}

.bship-settings {
  margin: 0 auto 1.5rem;
  max-width: 340px;
  text-align: center;
}

.bship-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.bship-timer-options {
  display: flex;
  gap: 0.5rem;
}

.bship-timer-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.bship-timer-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.bship-timer-btn:hover {
  border-color: var(--accent);
}

.bship-timer-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.bship-timer-btn.active span {
  color: rgba(255,255,255,0.8);
}

.bship-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0.5rem;
}

.bship-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  background: #0a1628;
  border-radius: var(--radius-md);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.bship-status {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 0.75rem;
  min-height: 1.5em;
}

.bship-grids {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.bship-grid-section {
  width: 100%;
}

.bship-grid-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bship-ships-left {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-light);
}

.bship-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #1a2a4a;
  border: 2px solid #1a2a4a;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.bship-row {
  display: flex;
  gap: 1px;
}

.bship-header-row {
  background: transparent;
}

.bship-label {
  width: calc(100% / 11);
  min-width: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #6688aa;
  padding: 2px 0;
  background: #0a1628;
}

.bship-cell {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  background: #0d1f3c;
  border: none;
  cursor: pointer;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  padding: 0;
  color: #446;
}

.bship-cell:hover:not(:disabled) {
  background: #1a3366;
}

.bship-cell:disabled {
  cursor: default;
}

.bship-cell.bship-hit {
  background: #4a1a1a;
  font-size: 0.8rem;
}

.bship-cell.bship-miss {
  background: #0a1628;
  color: #335;
  font-size: 0.6rem;
}

.bship-cell.bship-ship {
  border: 1px solid rgba(255,255,255,0.1);
}

/* Question overlay */
.bship-question {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 22, 40, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.bship-question.hidden { display: none; }

.bship-question-box {
  background: #0d1f3c;
  border: 2px solid #3498db;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 40px rgba(52, 152, 219, 0.25);
}

.bship-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.bship-q-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #f39c12;
  text-transform: uppercase;
}

.bship-q-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff4444;
  font-family: 'Courier New', monospace;
  min-width: 2rem;
  text-align: center;
}

.bship-q-text {
  font-size: 1rem;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.bship-q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bship-q-btn {
  background: #142a4e;
  border: 1px solid #2a5088;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #aaccee;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.bship-q-btn:hover:not(:disabled) {
  background: #1a3a6e;
  border-color: #4488cc;
  color: #ffffff;
}

.bship-q-btn:disabled { cursor: default; opacity: 0.7; }
.bship-q-btn.correct { background: #0a4a0a; border-color: #44ff44; color: #44ff44; opacity: 1 !important; }
.bship-q-btn.wrong { background: #4a0a0a; border-color: #ff4444; color: #ff4444; opacity: 1 !important; }

/* Sunk ship fire animation */
@keyframes bshipFire {
  0%   { background: #6b1a0a; box-shadow: 0 0 5px #ff4400; }
  30%  { background: #8b2800; box-shadow: 0 0 11px #ff6600; }
  60%  { background: #7a1f00; box-shadow: 0 0 7px #ff3300; }
  100% { background: #6b1a0a; box-shadow: 0 0 5px #ff4400; }
}

.bship-cell.bship-sunk {
  animation: bshipFire 1.2s ease-in-out infinite;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 80, 0, 0.6) !important;
  cursor: default;
}

/* Sunk ship toast */
@keyframes bshipSunkToastAnim {
  0%   { opacity: 0; transform: translate(-50%, -60%) scale(0.75); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  45%  { transform: translate(-50%, -50%) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -42%); }
}

.bship-sunk-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #3d0000, #8b2000);
  border: 2px solid #ff5500;
  border-radius: 14px;
  padding: 0.8rem 2.2rem;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
  z-index: 400;
  pointer-events: none;
  animation: bshipSunkToastAnim 2.4s ease-out forwards;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Hit / miss toast */
@keyframes bshipHitMissAnim {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.7); }
  20%  { opacity: 1; transform: translateX(-50%) scale(1.08); }
  50%  { transform: translateX(-50%) scale(1); opacity: 1; }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(0.95); }
}

.bship-hit-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 10px;
  padding: 0.45rem 1.6rem;
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center;
  z-index: 350;
  pointer-events: none;
  animation: bshipHitMissAnim 1.3s ease-out forwards;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* Player fires — HIT */
.bship-hit-toast.bht-hit {
  top: 36%;
  background: rgba(160, 30, 0, 0.92);
  border: 2px solid #ff5500;
  color: #fff;
}

/* Player fires — MISS */
.bship-hit-toast.bht-miss {
  top: 36%;
  background: rgba(10, 40, 80, 0.92);
  border: 2px solid #4488cc;
  color: #aaddff;
}

/* Enemy fires — HIT on player ship */
.bship-hit-toast.bht-enemy-hit {
  top: 70%;
  background: rgba(120, 10, 0, 0.92);
  border: 2px solid #ff2200;
  color: #fff;
}

/* Game Over stats */
.bship-final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.bship-stat {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.bship-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.bship-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.bship-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.bship-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  min-width: 44px;
}
.bship-score-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-family: var(--font-display);
}
.bship-score-display span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ============================================
   DUCK HUNT
   ============================================ */
.duckhunt-container {
  max-width: 540px;
  margin: 0 auto;
}

.duckhunt-start, .duckhunt-gameover {
  text-align: center;
  padding: 2rem 1rem;
}

.duckhunt-start-content {
  max-width: 400px;
  margin: 0 auto;
}

.duckhunt-logo {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.duckhunt-start-content h3 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.duckhunt-start-content p {
  color: var(--text2);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.duckhunt-rules {
  list-style: none;
  padding: 0;
  text-align: left;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}

.duckhunt-rules li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: var(--text2);
}

.duckhunt-settings {
  margin: 0 auto 1.5rem;
  max-width: 340px;
  text-align: center;
}

.duckhunt-setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.duckhunt-timer-options {
  display: flex;
  gap: 0.5rem;
}

.duckhunt-timer-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.duckhunt-timer-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.duckhunt-timer-btn:hover {
  border-color: var(--accent);
}

.duckhunt-timer-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.duckhunt-timer-btn.active span {
  color: rgba(255,255,255,0.8);
}

.duckhunt-game {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.duckhunt-hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  padding: 0.5rem 0.75rem;
  background: #1a3d1a;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  gap: 0.5rem;
}

#duckCanvas {
  display: block;
  border: 2px solid #2d5a2d;
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: #87CEEB;
  max-width: 100%;
  cursor: crosshair;
  touch-action: none;
}

.duckhunt-round-info {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1.5em;
}

/* Question overlay */
.duckhunt-question {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26, 61, 26, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.duckhunt-question.hidden { display: none; }

.duckhunt-question-box {
  background: #1a3a1a;
  border: 2px solid #e67e22;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 40px rgba(230, 126, 34, 0.25);
}

.duckhunt-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.duckhunt-q-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #e67e22;
  text-transform: uppercase;
}

.duckhunt-q-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff4444;
  font-family: 'Courier New', monospace;
  min-width: 2rem;
  text-align: center;
}

.duckhunt-q-text {
  font-size: 1rem;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.duckhunt-q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.duckhunt-q-btn {
  background: #2a4a2a;
  border: 1px solid #4a7a4a;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #bbddbb;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.duckhunt-q-btn:hover:not(:disabled) {
  background: #3a6a3a;
  border-color: #6aaa6a;
  color: #ffffff;
}

.duckhunt-q-btn:disabled { cursor: default; opacity: 0.7; }
.duckhunt-q-btn.correct { background: #0a4a0a; border-color: #44ff44; color: #44ff44; opacity: 1 !important; }
.duckhunt-q-btn.wrong { background: #4a0a0a; border-color: #ff4444; color: #ff4444; opacity: 1 !important; }

/* Game Over stats */
.duckhunt-final-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.duckhunt-stat {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.duckhunt-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.duckhunt-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.duckhunt-gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.duckhunt-score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  min-width: 44px;
}

.duckhunt-score-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.duckhunt-score-display span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ==========================================================
   CONNECT 4
   ========================================================== */
.c4-container { --c4-blue: #1a3a6b; --c4-red: #e74c3c; --c4-yellow: #f1c40f; position: relative; }
.c4-start, .c4-gameover {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; text-align: center;
}
.c4-start-content { max-width: 420px; margin: 0 auto; }
.c4-logo { font-size: 3.5rem; margin-bottom: 0.5rem; }
.c4-start-content h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.c4-rules {
  list-style: none; padding: 0; margin: 1rem 0;
  text-align: left; font-size: 0.9rem;
}
.c4-rules li { padding: 0.3rem 0; }
.c4-settings { margin: 1.25rem 0; }
.c4-setting-label { display: block; font-weight: 600; margin-bottom: 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.c4-timer-options { display: flex; gap: 0.4rem; justify-content: center; }
.c4-timer-btn {
  padding: 0.4rem 0.75rem; border-radius: 0.5rem;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 0.85rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  transition: all 0.15s;
}
.c4-timer-btn span { font-size: 0.65rem; font-weight: 400; opacity: 0.7; }
.c4-timer-btn.active { border-color: var(--c4-red); background: rgba(231,76,60,0.15); color: var(--c4-red); }

/* Board */
.c4-board-wrapper { display: flex; flex-direction: column; align-items: center; margin: 1rem auto; }
.c4-drop-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; width: fit-content; margin-bottom: 4px; }
.c4-col-btn {
  width: 48px; height: 28px; border: none; border-radius: 6px;
  background: var(--c4-blue); color: #fff; font-size: 1rem;
  cursor: pointer; transition: all 0.15s; opacity: 0.7;
}
.c4-col-btn:hover:not(:disabled) { opacity: 1; background: #2a5aa0; transform: translateY(-2px); }
.c4-col-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.c4-board {
  display: grid; grid-template-columns: repeat(7, 48px); gap: 4px;
  background: var(--c4-blue); padding: 8px; border-radius: 12px;
  box-shadow: 0 4px 20px rgba(26,58,107,0.4);
}
.c4-cell {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface); border: 2px solid rgba(255,255,255,0.1);
  transition: all 0.3s; box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}
.c4-cell.c4-player {
  background: var(--c4-red);
  box-shadow: 0 0 10px rgba(231,76,60,0.5), inset 0 -2px 4px rgba(0,0,0,0.2);
  border-color: #c0392b;
}
.c4-cell.c4-computer {
  background: var(--c4-yellow);
  box-shadow: 0 0 10px rgba(241,196,15,0.5), inset 0 -2px 4px rgba(0,0,0,0.2);
  border-color: #d4ac0d;
}
.c4-cell.c4-winner {
  animation: c4Pulse 0.5s ease-in-out infinite alternate;
  box-shadow: 0 0 20px 6px rgba(255,255,255,0.5);
}
@keyframes c4Pulse {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

.c4-hud {
  display: flex; justify-content: center; gap: 1.5rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.c4-status {
  text-align: center; font-weight: 600; margin-top: 0.75rem;
  font-size: 0.95rem; min-height: 1.5em;
}
.c4-round-result {
  text-align: center; margin-top: 1rem; padding: 1rem;
  background: var(--surface); border-radius: 12px;
  border: 2px solid var(--border);
}
.c4-round-result span { display: block; font-size: 1.3rem; font-weight: 700; margin-bottom: 0.75rem; }

/* Question overlay */
.c4-question {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26,58,107,0.92);
  overflow-y: auto; padding: 1rem 0;
}
.c4-question-box {
  background: var(--surface); border-radius: 16px; padding: 1.5rem;
  max-width: 500px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.c4-q-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.c4-q-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--c4-red); background: rgba(231,76,60,0.15);
  padding: 0.2rem 0.6rem; border-radius: 4px;
}
.c4-q-timer {
  font-size: 1.4rem; font-weight: 700; color: var(--c4-red);
  min-width: 2ch; text-align: center;
}
.c4-q-text { font-size: 1rem; margin-bottom: 1rem; line-height: 1.5; }
.c4-q-options { display: flex; flex-direction: column; gap: 0.5rem; }
.c4-q-btn {
  padding: 0.6rem 1rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 0.9rem; text-align: left;
  transition: all 0.15s;
}
.c4-q-btn:hover:not(:disabled) { border-color: var(--c4-blue); background: rgba(26,58,107,0.1); }
.c4-q-btn.correct { border-color: #2ecc71; background: rgba(46,204,113,0.15); color: #2ecc71; }
.c4-q-btn.wrong { border-color: var(--c4-red); background: rgba(231,76,60,0.15); color: var(--c4-red); }

/* Game over stats */
.c4-final-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1.25rem 0; }
.c4-stat { text-align: center; padding: 0.75rem; background: var(--background); border-radius: 8px; }
.c4-stat-label { display: block; font-size: 0.75rem; text-transform: uppercase; opacity: 0.7; margin-bottom: 0.25rem; }
.c4-stat-value { display: block; font-size: 1.25rem; font-weight: 700; color: var(--color-primary); }
.c4-gameover-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.c4-score-display { font-weight: 700; }

@media (max-width: 420px) {
  .c4-board { grid-template-columns: repeat(7, 38px); gap: 3px; padding: 6px; }
  .c4-cell { width: 38px; height: 38px; }
  .c4-col-btn { width: 38px; height: 24px; font-size: 0.8rem; }
  .c4-drop-row { gap: 3px; }
}

/* ==========================================================
   BATTLE CITY
   ========================================================== */
.bc-container { --bc-green: #2d5016; --bc-orange: #e67e22; position: relative; }
.bc-start, .bc-gameover {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; text-align: center;
}
.bc-start-content { max-width: 420px; margin: 0 auto; }
.bc-logo { font-size: 3.5rem; margin-bottom: 0.5rem; }
.bc-start-content h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.bc-rules {
  list-style: none; padding: 0; margin: 1rem 0;
  text-align: left; font-size: 0.9rem;
}
.bc-rules li { padding: 0.3rem 0; }
.bc-settings { margin: 1.25rem 0; }
.bc-setting-label { display: block; font-weight: 600; margin-bottom: 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.bc-timer-options { display: flex; gap: 0.4rem; justify-content: center; }
.bc-timer-btn {
  padding: 0.4rem 0.75rem; border-radius: 0.5rem;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 0.85rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  transition: all 0.15s;
}
.bc-timer-btn span { font-size: 0.65rem; font-weight: 400; opacity: 0.7; }
.bc-timer-btn.active { border-color: var(--bc-orange); background: rgba(230,126,34,0.15); color: var(--bc-orange); }

/* Game area */
.bc-game {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; padding: 0.75rem 0.5rem 1.5rem;
}
.bc-hud { display: flex; gap: 1.5rem; justify-content: center; }
.bc-status { font-size: 0.9rem; color: var(--color-text-light); min-height: 1.4rem; text-align: center; }
.bc-score-display { font-weight: 700; }

#bcCanvas {
  border: 3px solid #555; border-radius: 4px;
  background: #000; display: block; max-width: 100%;
  image-rendering: pixelated;
}

/* Question overlay */
.bc-question {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(45,80,22,0.92);
  overflow-y: auto; padding: 1rem 0;
}
.bc-question-box {
  background: var(--surface); border-radius: 16px; padding: 1.5rem;
  max-width: 500px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.bc-q-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.bc-q-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--bc-orange); background: rgba(230,126,34,0.15);
  padding: 0.2rem 0.6rem; border-radius: 4px;
}
.bc-q-timer { font-size: 1.4rem; font-weight: 700; color: var(--bc-orange); min-width: 2ch; text-align: center; }
.bc-q-text { font-size: 1rem; margin-bottom: 1rem; line-height: 1.5; }
.bc-q-options { display: flex; flex-direction: column; gap: 0.5rem; }
.bc-q-btn {
  padding: 0.6rem 1rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 0.9rem; text-align: left; transition: all 0.15s;
}
.bc-q-btn:hover:not(:disabled) { border-color: var(--bc-orange); background: rgba(230,126,34,0.1); }
.bc-q-btn.correct { border-color: #2ecc71; background: rgba(46,204,113,0.15); color: #2ecc71; }
.bc-q-btn.wrong { border-color: #e74c3c; background: rgba(231,76,60,0.15); color: #e74c3c; }

/* Game over */
.bc-final-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1.25rem 0; }
.bc-stat { text-align: center; padding: 0.75rem; background: var(--background); border-radius: 8px; }
.bc-stat-label { display: block; font-size: 0.75rem; text-transform: uppercase; opacity: 0.7; margin-bottom: 0.25rem; }
.bc-stat-value { display: block; font-size: 1.25rem; font-weight: 700; color: var(--color-primary); }
.bc-gameover-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }

@media (max-width: 420px) {
  #bcCanvas { width: 100%; height: auto; }
}

/* ============================================================
   Host Loading Overlay (js/core/host-factory.js)
   ============================================================ */
#_hostLoading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
#_hostLoading.host-loading--visible {
  display: flex;
}
.host-loading__spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent, #4a90d9);
  border-radius: 50%;
  animation: hostSpinnerRotate 0.75s linear infinite;
}
.host-loading__msg {
  color: #fff;
  font-size: 0.95rem;
  text-align: center;
  max-width: 18rem;
  opacity: 0.9;
}
@keyframes hostSpinnerRotate {
  to { transform: rotate(360deg); }
}

