:root {
  --bg-canvas: #FFFBF5;
  --surface: #FFFFFF;
  --surface-soft: #FFF7ED;
  --ink-900: #1E293B;
  --ink-700: #334155;
  --ink-500: #475569;
  --border-soft: #CBD5E1;

  --thai-primary: #C2410C;
  --thai-accent: #F97316;
  --thai-soft: #FFF7ED;
  --thai-deep: #9A3412;

  --math-primary: #2563EB;
  --math-soft: #EFF6FF;
  --math-deep: #1D4ED8;

  --sci-primary: #047857;
  --sci-soft: #ECFDF5;
  --sci-deep: #065F46;

  --eng-primary: #8B5CF6;
  --eng-soft: #F5F3FF;
  --eng-deep: #5B21B6;

  --accent-amber: #B45309;
  --accent-red: #DC2626;
  --accent-green: #047857;

  --active-primary: var(--thai-primary);
  --active-accent: var(--thai-accent);
  --active-soft: var(--thai-soft);
  --active-deep: var(--thai-deep);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 6px 20px -6px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 12px 24px -6px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 96px;
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--ink-900);
  font-family: 'Sarabun', system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  caret-color: var(--thai-primary);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #FFEDD5;
  color: #7C2D12;
}

h1, h2, h3, h4, .font-display {
  font-family: 'Mali', 'Sarabun', sans-serif;
  margin: 0;
  line-height: 1.35;
  text-wrap: balance;
}

button, input, select, textarea, a {
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(194, 65, 12, 0.14);
}

:focus-visible {
  outline: 3px solid #2563EB;
  outline-offset: 2px;
}

.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;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 120;
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid #FDE68A;
  transition: top 0.15s ease;
}

.skip-link:focus-visible {
  top: 12px;
}

.icon-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* =========================================================
   TOP DEMO PREVIEW BAR
   ========================================================= */
.demo-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: #0F172A;
  color: #F8FAFC;
  border-bottom: 3px solid var(--thai-accent);
  padding: 10px 16px;
}

.demo-bar:empty {
  display: none;
  padding: 0;
  border: none;
}

.demo-bar-inner {
  max-width: 1220px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.demo-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: #E2E8F0;
}

.demo-pill-badge {
  font-family: 'Mali', 'Sarabun', sans-serif;
  background: #FDE68A;
  color: #451A03;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  white-space: nowrap;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tier-group, .role-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #1E293B;
  padding: 4px;
  border-radius: 12px;
}

.demo-btn {
  border: none;
  background: transparent;
  color: #E2E8F0;
  padding: 7px 12px;
  min-height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.demo-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
}

.demo-btn.active {
  background: var(--thai-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.demo-btn.role-active {
  background: #1D4ED8;
  color: #FFFFFF;
}

/* =========================================================
   APP HEADER & SHELL
   ========================================================= */
.app-container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 16px calc(88px + env(safe-area-inset-bottom, 0px));
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 2px solid #FED7AA;
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-avatar {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  object-fit: cover;
  border: 3px solid var(--thai-accent);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
  background: #FFF7ED;
  flex-shrink: 0;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-900);
}

.brand-subtitle {
  font-size: 13.5px;
  color: var(--ink-500);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.student-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFF7ED;
  border: 1.5px solid #FDBA74;
  padding: 6px 12px;
  min-height: 44px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
}

.student-chip:focus-within {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.student-chip select {
  border: none;
  background: transparent;
  font-weight: 700;
  color: var(--thai-deep);
  cursor: pointer;
  min-height: 36px;
}

.student-pin-btn {
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid #F59E0B;
  background: #FFFFFF;
  color: #9A3412;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.student-pin-btn:hover {
  background: #FEF3C7;
}

.student-pin-btn.is-locked {
  background: #ECFDF5;
  border-color: #6EE7B7;
  color: #065F46;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FEF3C7;
  color: #92400E;
  border: 1.5px solid #F59E0B;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  white-space: nowrap;
}

.sfx-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.sfx-toggle-btn:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
}

.xp-pill {
  background: #FEF3C7;
  color: #92400E;
  border: 1.5px solid #F59E0B;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
}

/* =========================================================
   BUTTONS & BADGES (ALL >= 4.5:1 CONTRAST)
   ========================================================= */
.btn {
  font-family: 'Mali', 'Sarabun', sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: var(--active-primary);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background: var(--active-deep);
}

.btn-secondary {
  background: #E2E8F0;
  color: var(--ink-900);
}

.btn-secondary:hover:not(:disabled) {
  background: #CBD5E1;
}

.btn-outline {
  background: #FFFFFF;
  border: 2px solid var(--border-soft);
  color: var(--ink-700);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--active-primary);
  color: var(--active-deep);
  background: #FFF7ED;
}

.btn-blue {
  background: #1D4ED8;
  color: #FFFFFF;
}

.btn-blue:hover:not(:disabled) {
  background: #1E40AF;
}

.btn-green {
  background: #047857;
  color: #FFFFFF;
}

.btn-green:hover:not(:disabled) {
  background: #065F46;
}

.btn-danger {
  background: #B91C1C;
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  background: #991B1B;
}

.btn-sm {
  padding: 6px 12px;
  min-height: 38px;
  font-size: 13.5px;
  border-radius: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}

.badge-orange { background: #FFEDD5; color: #9A3412; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-amber { background: #FEF3C7; color: #92400E; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-slate { background: #E2E8F0; color: #1E293B; }

/* =========================================================
   SUBJECT TABS & HERO BANNER
   ========================================================= */
.subject-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.subject-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 74px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-soft);
  background: var(--surface);
  color: var(--ink-900);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.subject-tab:hover {
  border-color: #94A3B8;
  transform: translateY(-1px);
}

.subject-tab.active-thai {
  border-color: var(--thai-accent);
  background: #FFF7ED;
  box-shadow: var(--shadow-hover);
}

.subject-tab.locked-subject {
  background: #F8FAFC;
  color: var(--ink-700);
}

.subject-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #FFFFFF;
  flex-shrink: 0;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 20px;
  background: #FFF7ED;
  border: 2px solid #FDBA74;
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}

.hero-speech {
  background: #FFFFFF;
  border: 1.5px solid #FED7AA;
  border-radius: 16px;
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 15px;
  color: var(--ink-700);
}

.quick-actions-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.action-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  min-height: 62px;
  border-radius: 14px;
  border: 2px solid #FED7AA;
  background: #FFFFFF;
  color: var(--ink-900);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.action-tile:hover {
  transform: translateY(-2px);
  border-color: var(--thai-primary);
  box-shadow: var(--shadow-hover);
}

.niets-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #EFF6FF;
  border: 1.5px solid #93C5FD;
  border-radius: 14px;
  padding: 12px 18px;
  margin-bottom: 22px;
  font-size: 14.5px;
  color: var(--ink-900);
}

/* =========================================================
   LEADERBOARD & TEAM CUP WIDGETS (LV.3 & LV.4)
   ========================================================= */
.social-arena-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card-panel {
  background: var(--surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.cup-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.cup-bar-row {
  margin-bottom: 10px;
}

.cup-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.progress-track {
  width: 100%;
  height: 14px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 10px;
  background: #F8FAFC;
  margin-bottom: 6px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.leaderboard-row.top-1 { background: #FEF3C7; border: 1.5px solid #F59E0B; font-weight: 700; }
.leaderboard-row.top-2 { background: #F1F5F9; border: 1.5px solid #94A3B8; }
.leaderboard-row.top-3 { background: #FFEDD5; border: 1.5px solid #FB923C; }

/* =========================================================
   UNIT ROADMAP CARDS & FILTER BAR
   ========================================================= */
.unit-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  background: #FFFFFF;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1.5px solid var(--border-soft);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.filter-chip:hover {
  border-color: #64748B;
  background: #F1F5F9;
}

.filter-chip.active {
  background: #1E293B;
  border-color: #1E293B;
  color: #FFFFFF;
}

.strand-section {
  margin-bottom: 28px;
}

.strand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--strand-border, #FDBA74);
}

.strand-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.strand-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--strand-tint, #FFF7ED);
  border: 1.5px solid var(--strand-border, #FDBA74);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 16px;
}

.unit-card {
  background: var(--surface);
  border: 2px solid #E2E8F0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.unit-card:hover {
  border-color: var(--strand-accent, var(--thai-accent));
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.unit-card-top {
  background: var(--strand-tint, #FFF7ED);
  padding: 13px 16px 11px;
  border-bottom: 1.5px solid var(--strand-border, #FED7AA);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.unit-card-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.unit-icon-tile {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1.5px solid var(--strand-border, #FED7AA);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.unit-ep-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.unit-ep-num {
  font-weight: 800;
  font-size: 14px;
  color: var(--strand-accent, #C2410C);
}

.unit-ind-code {
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
}

.unit-stars-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.unit-stars {
  font-size: 16px;
  letter-spacing: 2px;
  line-height: 1;
}

.unit-star-on {
  color: #D97706;
}

.unit-star-off {
  color: #CBD5E1;
}

.unit-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  flex: 1;
}

.unit-hook-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--strand-badge-text, #9A3412);
  background: var(--strand-tint, #FFF7ED);
  border: 1px solid var(--strand-border, #FED7AA);
  border-radius: 10px;
  padding: 6px 10px;
  line-height: 1.35;
}

.unit-mini-progress {
  width: 100%;
  height: 7px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.unit-mini-fill {
  height: 100%;
  background: var(--strand-accent, #C2410C);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.stage-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  min-height: 36px;
  padding: 5px 10px;
  border-radius: 10px;
  border: 1.5px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  font-weight: 700;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.stage-pill-btn:hover {
  border-color: var(--strand-accent, #C2410C);
  background: var(--strand-tint, #FFF7ED);
  color: var(--ink-900);
}

.stage-pill-btn.done {
  background: #D1FAE5;
  border-color: #6EE7B7;
  color: #065F46;
}

.unit-cta-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  background: var(--strand-accent, #C2410C);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12);
}

.unit-cta-btn:hover:not(:disabled) {
  filter: brightness(0.92);
}

.unit-cta-btn.is-mastered {
  background: #047857;
}

/* =========================================================
   3-STAGE UNIT VIEW (STAGE 1, 2, 3)
   ========================================================= */
.stepper-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  background: #FFFFFF;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--border-soft);
}

.step-tab {
  flex: 1;
  min-width: 170px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #CBD5E1;
  background: #F8FAFC;
  color: var(--ink-900);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.step-tab:hover:not(.active) {
  border-color: var(--thai-primary);
  background: #FFF7ED;
}

.step-tab.active {
  background: var(--thai-primary);
  border-color: var(--thai-primary);
  color: #FFFFFF;
}

.knowledge-box {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 2px solid #FED7AA;
  box-shadow: var(--shadow-card);
}

.callout-block {
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 14px;
}

.callout-formula { background: #EFF6FF; border: 1.5px solid #93C5FD; color: #1E293B; }
.callout-example { background: #ECFDF5; border: 1.5px solid #6EE7B7; color: #1E293B; }
.callout-trap { background: #FEF2F2; border: 1.5px solid #FCA5A5; color: #1E293B; }

/* =========================================================
   MINIGAMES & BOSS BATTLE RPG
   ========================================================= */
.game-arena {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 2px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}

.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.match-btn {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  color: var(--ink-900);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.match-btn:hover:not(:disabled) {
  border-color: var(--thai-primary);
}

.match-btn.selected {
  border-color: #1D4ED8;
  background: #EFF6FF;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.match-btn.matched {
  border-color: #047857;
  background: #ECFDF5;
  color: #065F46;
  opacity: 0.78;
  cursor: default;
}

.match-btn.wrong {
  border-color: #DC2626;
  background: #FEF2F2;
  color: #991B1B;
}

.tf-big-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.token-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  min-height: 42px;
  border-radius: 12px;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  color: var(--ink-900);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  margin: 4px;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.token-chip:hover:not(:disabled) {
  border-color: var(--thai-primary);
  background: #FFF7ED;
}

.token-chip.used {
  opacity: 0.35;
  cursor: not-allowed;
}

.boss-stage {
  background: #1E293B;
  color: #FFFFFF;
  border: 2px solid #DC2626;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.25);
}

.boss-hp-bar {
  width: 100%;
  height: 18px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.boss-hp-fill {
  height: 100%;
  background: #EF4444;
  transition: width 0.3s ease;
}

/* =========================================================
   EXAM ENGINE (MCQ4, Q21 ORDERING, Q22 SUMMARY)
   ========================================================= */
.exam-card {
  background: #FFFFFF;
  border: 2px solid #E2E8F0;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 13px 16px;
  border-radius: 13px;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  color: var(--ink-900);
  font-size: 15.5px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--thai-primary);
  background: #FFF7ED;
}

.choice-btn.selected {
  border-color: #1D4ED8;
  background: #EFF6FF;
}

.choice-btn.correct {
  border-color: #047857;
  background: #DCFCE7;
  color: #064E3B;
}

.choice-btn.incorrect {
  border-color: #DC2626;
  background: #FEE2E2;
  color: #7F1D1D;
}

.choice-key {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #E2E8F0;
  color: #0F172A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

/* Q21 Ordering Slots */
.scene-prompt-card {
  background: #FFFBEB;
  border: 2px dashed #D97706;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.ordering-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  padding: 14px;
  background: #F8FAFC;
  border-radius: 14px;
  border: 1.5px solid #CBD5E1;
}

.order-slot {
  min-width: 96px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px dashed #64748B;
  background: #FFFFFF;
  color: var(--ink-900);
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.order-slot.filled {
  border-style: solid;
  border-color: #1D4ED8;
  background: #EFF6FF;
}

.order-slot.locked {
  border-style: solid;
  border-color: #B45309;
  background: #FEF3C7;
  cursor: default;
}

.order-slot.slot-ok {
  border-color: #047857;
  background: #DCFCE7;
}

.order-slot.slot-bad {
  border-color: #DC2626;
  background: #FEE2E2;
}

/* Q22 3-Line Summary Paper */
.passage-box {
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 16px;
  line-height: 1.75;
  margin-bottom: 16px;
  white-space: pre-line;
  max-width: 72ch;
}

.summary-ruled-textarea {
  width: 100%;
  min-height: 112px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid #64748B;
  background: #FFFFFF;
  color: var(--ink-900);
  font-size: 16px;
  line-height: 1.75;
  resize: vertical;
}

.rubric-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #E2E8F0;
}

/* =========================================================
   TEACHER ADMIN & A4 PRINT STUDIO
   ========================================================= */
.teacher-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  background: #FFFFFF;
  padding: 6px;
  border-radius: 16px;
  border: 1.5px solid var(--border-soft);
}

.teacher-tabs .btn {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  padding: 8px 8px;
  font-size: 14px;
  border-radius: 12px;
  white-space: nowrap;
}

.teacher-tabs .btn-outline {
  border-color: transparent;
  background: transparent;
}

.teacher-tabs .btn-outline:hover {
  background: #F1F5F9;
}

.growth-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 14px;
}

.growth-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.growth-swatch-pre {
  width: 14px;
  height: 10px;
  border-radius: 4px;
  background: #94A3B8;
  display: inline-block;
}

.growth-swatch-post {
  width: 14px;
  height: 10px;
  border-radius: 4px;
  background: #047857;
  display: inline-block;
}

.growth-row {
  padding: 10px 0;
  border-bottom: 1px solid #F1F5F9;
}

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

.growth-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.growth-track {
  width: 100%;
  height: 10px;
  background: #F1F5F9;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}

.growth-fill-pre {
  height: 100%;
  background: #94A3B8;
  border-radius: 999px;
}

.growth-fill-post {
  height: 100%;
  background: #047857;
  border-radius: 999px;
}

.grading-card {
  border: 2px solid #E2E8F0;
  border-radius: 16px;
  padding: 16px 18px;
  background: #FFFFFF;
  margin-bottom: 14px;
}

.grading-card.is-pending {
  border-color: #FDBA74;
  background: #FFFBF7;
}

.grading-answer-box {
  background: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink-900);
  margin: 10px 0;
}

.advanced-settings-box {
  margin-top: 18px;
  border: 1.5px solid #CBD5E1;
  border-radius: 12px;
  background: #F8FAFC;
  padding: 10px 14px;
}

.advanced-settings-box summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  color: #334155;
  padding: 4px 0;
}

.advanced-settings-box[open] summary {
  margin-bottom: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}

.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #E2E8F0;
  text-align: left;
}

.data-table th {
  background: #F8FAFC;
  font-weight: 700;
  color: var(--ink-700);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-items: start;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field-full {
  grid-column: 1 / -1;
}

.form-field label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 6px;
  color: var(--ink-900);
  line-height: 1.35;
}

.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid #94A3B8;
  background: #FFFFFF;
  color: var(--ink-900);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: #1D4ED8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
  outline: none;
}

.field-hint {
  font-size: 13px;
  color: #475569;
  margin-top: 5px;
  line-height: 1.45;
}

.settings-section {
  padding-top: 18px;
  margin-top: 20px;
  border-top: 1.5px solid #E2E8F0;
}

.settings-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.settings-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-logo-preview {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 1.5px solid #CBD5E1;
  background: #F8FAFC;
  flex-shrink: 0;
}

.subject-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.settings-actions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1.5px solid #E2E8F0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.a4-studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #FFFFFF;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--border-soft);
  margin-bottom: 16px;
}

.a4-studio-viewport {
  background: #334155;
  padding: 28px 16px;
  border-radius: 18px;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.a4-zoom-wrap {
  transform-origin: top center;
  transition: transform 0.15s ease;
}

.roster-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.roster-grid > *,
.social-arena-grid > *,
.hero-card > * {
  min-width: 0;
}

.kpi-num {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.timer-num {
  font-variant-numeric: tabular-nums;
}

/* Non-blocking Toast */
.toast-region {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast-item {
  background: #0F172A;
  color: #FFFFFF;
  border: 2px solid #FDBA74;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
  pointer-events: auto;
}

.toast-item.toast-success {
  border-color: #34D399;
}

/* Student Own Level Progress Strip & Buddy Evolution */
.student-lvl-badge {
  font-family: 'Mali', 'Sarabun', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #FEF3C7;
  color: #92400E;
  border: 1.5px solid #F59E0B;
  font-weight: 700;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.header-buddy-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #D97706;
  background: #FFFBEB;
  flex-shrink: 0;
}

.buddy-evolution-box {
  margin-top: 12px;
  background: #FFFBF5;
  border: 1.5px solid #FED7AA;
  border-radius: 16px;
  padding: 12px 14px;
}

.buddy-stage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.buddy-stage-portrait {
  width: 74px;
  height: 74px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid #FDBA74;
  background: #FFFBEB;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

.buddy-stage-meta {
  flex: 1;
  min-width: 190px;
}

.buddy-evo-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.buddy-evo-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1.5px solid #E2E8F0;
  background: #FFFFFF;
  color: #334155;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.buddy-evo-node:hover {
  transform: translateY(-1px);
  border-color: #FB923C;
}

.buddy-evo-node.is-current {
  border-color: #C2410C;
  background: #FFF7ED;
  color: #9A3412;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10);
}

.buddy-evo-node.is-locked {
  background: #F8FAFC;
  color: #475569;
}

.buddy-evo-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #FFFBEB;
}

.buddy-evo-node.is-locked .buddy-evo-thumb {
  filter: grayscale(1) contrast(1.15) brightness(0.78) blur(1.8px);
  opacity: 0.72;
}

.unit-master-stamp {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #D97706;
  background: #FFFBEB;
  flex-shrink: 0;
}

.evo-modal-card {
  background: #FFFFFF;
  width: 100%;
  max-width: 740px;
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 22px;
  padding: 22px 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
  border: 2px solid #FDBA74;
}

.evo-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.evo-gallery-card {
  border: 2px solid #E2E8F0;
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
  background: #FFFFFF;
}

.evo-gallery-card.is-current {
  border-color: #C2410C;
  background: #FFF7ED;
}

.evo-gallery-card.is-locked {
  background: #F8FAFC;
}

.evo-gallery-img {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  object-fit: cover;
  display: block;
  margin: 0 auto 8px;
  border: 2px solid #FED7AA;
  background: #FFFBEB;
}

.evo-gallery-card.is-locked .evo-gallery-img {
  filter: grayscale(1) contrast(1.2) brightness(0.76) blur(4px);
  opacity: 0.78;
  border-color: #CBD5E1;
}

.evo-celebrate-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.evo-celebrate-img {
  width: 108px;
  height: 108px;
  border-radius: 20px;
  object-fit: cover;
  border: 3px solid #F59E0B;
  background: #FFFBEB;
  box-shadow: var(--shadow-hover);
}

.buddy-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 640px) {
  .buddy-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.buddy-pick-card {
  border: 2px solid #E2E8F0;
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  background: #FFFFFF;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.buddy-pick-card:hover {
  transform: translateY(-2px);
  border-color: #FB923C;
  box-shadow: var(--shadow-hover);
}

.buddy-pick-card.is-selected {
  border-color: #C2410C;
  background: #FFF7ED;
  box-shadow: var(--shadow-card);
}

.buddy-pick-img {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid #FED7AA;
  background: #FFFBEB;
}

.buddy-vibe-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  background: #F1F5F9;
  padding: 2px 8px;
  border-radius: 999px;
}

.student-level-strip {
  margin-top: 12px;
  background: #FFFBF5;
  border: 1.5px solid #FED7AA;
  border-radius: 12px;
  padding: 10px 14px;
}

.student-level-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #9A3412;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

/* Subtle App Footer & Teacher PIN Modal */
.app-footer {
  margin-top: 40px;
  padding: 16px 4px 8px;
  border-top: 1.5px solid #E2E8F0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  color: #475569;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.footer-link-btn {
  background: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  color: #334155;
  border-radius: 10px;
  padding: 6px 12px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.footer-link-btn:hover {
  border-color: var(--thai-primary);
  color: var(--thai-deep);
  background: #FFF7ED;
}

.pin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overscroll-behavior: contain;
}

.pin-modal-card {
  width: 100%;
  max-width: 400px;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.25);
  overscroll-behavior: contain;
}

@media print {
  #pinModalRoot,
  .app-footer,
  .toast-region {
    display: none !important;
  }
}

/* =========================================================
   STAGE 1 INTERACTIVE KNOWLEDGE STUDIO
   ========================================================= */
.ks-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.ks-controls-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.ks-mode-tabs,
.ks-audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ks-tutor-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFF7ED;
  border: 1.5px solid #FDBA74;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.ks-tutor-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--thai-accent);
  flex-shrink: 0;
  background: #FFFFFF;
}

.ks-tutor-bubble {
  font-size: 14.5px;
  color: var(--ink-900);
  line-height: 1.5;
}

.ks-card-dots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.ks-dot-btn {
  font-family: 'Mali', 'Sarabun', sans-serif;
  padding: 9px 12px;
  min-height: 42px;
  border-radius: 12px;
  border: 2px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.ks-dot-btn:hover:not(.active) {
  border-color: var(--thai-primary);
  background: #FFF7ED;
}

.ks-dot-btn.visited {
  border-color: #6EE7B7;
  background: #ECFDF5;
  color: #065F46;
}

.ks-dot-btn.active {
  border-color: var(--thai-primary);
  background: var(--thai-primary);
  color: #FFFFFF;
}

.ks-story-card {
  background: #FFFBF5;
  border: 2px solid #FED7AA;
  border-radius: 18px;
  padding: 20px;
}

.ks-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ks-idea-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ks-idea-item,
.step-reveal-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #FFFFFF;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  padding: 14px 16px;
}

.ks-num-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--thai-primary);
  color: #FFFFFF;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.hl-mark {
  background: #FEF08A;
  color: #713F12;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 700;
}

.hl-lead {
  color: #9A3412;
  font-weight: 700;
}

.hl-arrow {
  color: #C2410C;
  font-weight: 800;
  margin: 0 4px;
}

.rule-check-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  color: var(--ink-900);
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.rule-check-card:hover {
  border-color: #1D4ED8;
}

.rule-check-card.checked {
  border-color: #047857;
  background: #ECFDF5;
  color: #064E3B;
}

.rule-check-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-answer-card {
  margin-top: 14px;
  background: #ECFDF5;
  border: 2px solid #047857;
  color: #064E3B;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.65;
}

.trap-flip-card {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px dashed #D97706;
  background: #FFFBEB;
  color: #78350F;
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.trap-flip-card:hover {
  border-color: #B45309;
  background: #FEF3C7;
}

.trap-flip-card.revealed {
  border-style: solid;
  border-color: #DC2626;
  background: #FEF2F2;
  color: #7F1D1D;
}

.ks-card-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1.5px dashed #FDBA74;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ordering-scene-img {
  display: block;
  width: 100%;
  max-width: 460px;
  height: auto;
  border-radius: 12px;
  border: 1.5px solid #FDBA74;
  margin: 8px auto 6px;
}

.cloud-room-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid #93C5FD;
  background: #EFF6FF;
  color: #1E40AF;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.cloud-room-btn:hover {
  border-color: #2563EB;
  background: #DBEAFE;
  transform: translateY(-1px);
}

.cloud-room-btn.is-active {
  border-color: #059669;
  background: #ECFDF5;
  color: #065F46;
}

.cloud-toolbar-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 16px;
  border: 1.5px solid #A7F3D0;
  background: #ECFDF5;
}

.cloud-demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 16px;
  border: 1.5px solid #FCD34D;
  background: #FFFBEB;
  color: #92400E;
}

.cloud-modal-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.cloud-code-banner {
  background: #FFF7ED;
  border: 2px dashed #FB923C;
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  margin: 12px 0;
}

.cloud-code-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #C2410C;
  font-variant-numeric: tabular-nums;
}

.cloud-share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.cloud-share-row input {
  flex: 1;
  min-width: 190px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px solid #CBD5E1;
  font-size: 13.5px;
  background: #F8FAFC;
  color: #1E293B;
}

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

.admin-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.admin-handover-box {
  background: #F8FAFC;
  border: 1.5px dashed #3B82F6;
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.admin-handover-box textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid #CBD5E1;
  font-size: 13.5px;
  line-height: 1.55;
  background: #FFFFFF;
  color: #1E293B;
}

.admin-room-card {
  border: 1.5px solid #E2E8F0;
  border-radius: 16px;
  padding: 14px 16px;
  background: #FFFFFF;
  margin-bottom: 12px;
}

.admin-room-card.is-suspended {
  border-color: #FCA5A5;
  background: #FEF2F2;
}

.admin-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 6px;
}

.admin-check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}

.unit-card.is-demo-locked {
  background: #F8FAFC;
  border-color: #CBD5E1;
  opacity: 0.94;
}

.unit-card.is-demo-locked .unit-hook-tag {
  background: #F1F5F9;
  color: #475569;
  border-color: #CBD5E1;
}

@media (max-width: 820px) {
  .ks-controls-col {
    align-items: flex-start;
  }
}

@media (max-width: 960px) {
  .teacher-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .hero-card,
  .roster-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .matching-grid,
  .tf-big-buttons {
    grid-template-columns: 1fr;
  }
  .demo-bar {
    padding: 8px 12px;
  }
}

@media (max-width: 480px) {
  .teacher-tabs {
    grid-template-columns: 1fr;
  }
  .settings-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px), (pointer: coarse) {
  .demo-btn,
  .student-chip select,
  .student-pin-btn,
  .btn-sm,
  .stage-pill-btn,
  .footer-link-btn,
  .cloud-room-btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
