/* =========================================================================
   CLANG LEARNING PORTAL - DESIGN SYSTEM & STYLESHEET
   การเรียนรู้ผังงานและการเขียนโปรแกรมภาษาซี (CLang Learning Portal)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Core Color Palette */
  --primary: #1d4ed8;         /* Deep Royal Blue */
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --primary-focus: rgba(29, 78, 216, 0.15);

  --secondary: #0f766e;       /* Forest Teal */
  --secondary-light: #f0fdfa;

  --accent: #f59e0b;          /* Amber */
  --accent-light: #fffbeb;

  --success: #10b981;        /* Emerald */
  --success-light: #ecfdf5;
  --danger: #ef4444;         /* Rose Red */
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;

  /* Neutrals */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  
  --text-dark: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Typography */
  --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-body);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-dark);
  font-weight: 600;
  line-height: 1.3;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-hover);
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (min-width: 768px) {
  .md\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .md\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: var(--font-mono); }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-dark { color: var(--text-dark); }

.bg-white { background-color: #ffffff; }
.bg-light { background-color: var(--bg-main); }
.border { border: 1px solid var(--border-light); }
.rounded-lg { border-radius: var(--radius-md); }
.rounded-xl { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }

/* Header & Top Bar */
.main-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.student-pill {
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-align: center;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(29, 78, 216, 0.2);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  color: #ffffff;
  box-shadow: 0 4px 8px rgba(29, 78, 216, 0.3);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
  color: #ffffff;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-medium);
  color: var(--text-body);
}

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

.btn-teacher {
  background-color: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-teacher:hover {
  background-color: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 13px 26px;
  font-size: 1.05rem;
  font-weight: 600;
}

.btn-block {
  width: 100%;
}

.btn-pulse-glow {
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Badge System */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-success { background-color: var(--success-light); color: var(--success); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }
.badge-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-class { background-color: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-gain-pos { background-color: #ecfdf5; color: #047857; font-weight: 700; }
.badge-gain-neg { background-color: #fef2f2; color: #b91c1c; font-weight: 700; }

/* Step Navigation Bar */
.step-nav-bar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 10px 0;
  margin-bottom: 1.5rem;
}

.step-nav-list {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.step-nav-list::-webkit-scrollbar {
  display: none;
}

.step-nav-item {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background-color: #ffffff;
  border: 1.5px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.step-nav-item:hover:not(.locked) {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.step-nav-item.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.1);
}

.step-nav-item.completed {
  background-color: #f8fafc;
  border-color: var(--success);
}

.step-nav-item.locked {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: #f8fafc;
}

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

.step-nav-item.active .step-circle {
  background-color: var(--primary);
  color: #ffffff;
}

.step-nav-item.completed .step-circle {
  background-color: var(--success);
  color: #ffffff;
}

.step-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.step-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.2;
}

.step-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.2;
  white-space: nowrap;
}

/* Step Content Sections */
.step-content-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.step-content-section.active {
  display: block;
}

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

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background-color: #ffffff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-dark);
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

/* Quiz Interface */
.quiz-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 76px;
  z-index: 30;
}

.quiz-progress-bar-container {
  height: 8px;
  background-color: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
  width: 160px;
}

.quiz-progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.quiz-timer-badge {
  background-color: #fee2e2;
  color: #dc2626;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-nav-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-bottom: 1.5rem;
  background-color: #ffffff;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.quiz-nav-dot {
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quiz-nav-dot:hover {
  background-color: #e2e8f0;
}

.quiz-nav-dot.answered {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.question-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.question-card:hover {
  box-shadow: var(--shadow-md);
}

.choice-option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  background-color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.choice-option-label:hover {
  border-color: #93c5fd;
  background-color: #f8fafc;
}

.choice-option-label.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.choice-option-label input[type="radio"] {
  display: none;
}

.choice-letter {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #f1f5f9;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.choice-option-label.selected .choice-letter {
  background-color: var(--primary);
  color: #ffffff;
}

.choice-text {
  font-size: 0.95rem;
  color: var(--text-dark);
}

/* Game Studio Container */
.game-studio-wrapper {
  background-color: #0f172a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  border: 1px solid #334155;
  margin-bottom: 1.5rem;
}

.game-studio-toolbar {
  background-color: #1e293b;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #334155;
}

.game-iframe-holder {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  background-color: #000000;
}

.game-iframe-holder iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Quest Tracker Cards & Horizontal Grid */
.quest-stage-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 1rem;
}

@media (max-width: 1024px) {
  .quest-stage-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .quest-stage-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.quest-stage-card {
  background-color: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  min-height: 86px;
}

.quest-stage-card.completed {
  border-color: #86efac;
  background-color: #f0fdf4;
}

.quest-stage-card.active-playing {
  border-color: #93c5fd;
  background-color: #eff6ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Certificate Styling */
.certificate-frame {
  max-width: 800px;
  margin: 0 auto 2rem auto;
  background: #ffffff;
  padding: 40px;
  border-radius: 12px;
  border: 8px double #1e3a8a;
  box-shadow: var(--shadow-xl);
  position: relative;
  text-align: center;
  background-image: radial-gradient(#eff6ff 15%, transparent 16%);
  background-size: 20px 20px;
}

.certificate-header-icon {
  font-size: 3.5rem;
  color: #eab308;
  margin-bottom: 10px;
}

.certificate-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: #1e3a8a;
  letter-spacing: 1px;
}

.certificate-subtitle {
  font-size: 1.1rem;
  color: #475569;
  margin-bottom: 24px;
}

.certificate-name {
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 2px solid #cbd5e1;
  display: inline-block;
  padding: 0 40px 8px 40px;
  margin-bottom: 16px;
}

/* Teacher Dashboard */
.dashboard-kpi-card {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.dashboard-kpi-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* Data Table */
.data-table-container {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background-color: #f8fafc;
  padding: 12px 14px;
  font-family: var(--font-heading);
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

/* Toast Popups */
.toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transform: translateY(30px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-popup.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-popup.toast-success { background-color: #065f46; border-left: 4px solid #34d399; }
.toast-popup.toast-warning { background-color: #854d0e; border-left: 4px solid #facc15; }
.toast-popup.toast-error { background-color: #991b1b; border-left: 4px solid #f87171; }
.toast-popup.toast-info { background-color: #1e3a8a; border-left: 4px solid #60a5fa; }

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
}

/* =========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN FOR PHONES & TABLETS
   ========================================================================= */

/* =========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN FOR PHONES & TABLETS
   ========================================================================= */

/* Tablets & Medium Screens (max-width: 1024px) */
@media (max-width: 1024px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .step-nav-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    gap: 8px;
  }

  .step-nav-item {
    flex: 0 0 auto;
    width: auto;
    padding: 8px 14px;
    white-space: nowrap;
  }

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

/* Small Tablets & Mobile Devices (max-width: 768px) */
@media (max-width: 768px) {
  /* Header adjustments */
  .header-inner {
    height: auto;
    padding: 8px 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .brand-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .brand-title {
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .brand-subtitle {
    font-size: 0.68rem;
    line-height: 1.1;
    color: var(--text-muted);
  }

  .header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
    padding-top: 4px;
    border-top: 1px solid var(--border-light);
  }

  .student-pill {
    padding: 4px 8px;
    font-size: 0.75rem;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Step Navigation Horizontal Scroll (No Text Overflow) */
  .step-nav-bar {
    padding: 6px 0;
    margin-bottom: 1rem;
  }

  .step-nav-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 2px 2px 6px 2px;
    scrollbar-width: none;
  }

  .step-nav-list::-webkit-scrollbar {
    display: none;
  }

  .step-nav-item {
    flex: 0 0 auto;
    width: max-content;
    min-width: auto;
    padding: 6px 12px;
    gap: 8px;
    white-space: nowrap;
    border-radius: var(--radius-md);
  }

  .step-circle {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    flex-shrink: 0;
  }

  .step-info {
    min-width: 0;
  }

  .step-label {
    font-size: 0.65rem;
    white-space: nowrap;
    line-height: 1.1;
  }

  .step-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
  }

  /* Quiz UI */
  .quiz-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    top: 0;
  }

  .quiz-progress-bar-container {
    width: 100%;
  }

  .quiz-nav-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
  }

  .choice-option-label {
    padding: 10px 12px;
    gap: 8px;
  }

  .choice-letter {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
  }

  .choice-text {
    font-size: 0.88rem;
  }

  /* Game Studio */
  .game-studio-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
  }

  .game-studio-toolbar .flex {
    justify-content: space-between;
  }

  #gameSourceSelect {
    max-width: 100%;
    font-size: 0.75rem;
  }

  /* Certificate Frame */
  .certificate-frame {
    padding: 20px 14px;
    border-width: 4px;
    border-radius: 8px;
    margin-bottom: 1rem;
  }

  .certificate-title {
    font-size: 1.4rem;
    letter-spacing: 0;
  }

  .certificate-subtitle {
    font-size: 0.82rem;
    margin-bottom: 14px;
  }

  .certificate-name {
    font-size: 1.3rem;
    padding: 0 16px 6px 16px;
    margin-bottom: 12px;
  }

  .certificate-header-icon {
    font-size: 2.2rem;
    margin-bottom: 4px;
  }

  /* Modal Box */
  .modal-box {
    padding: 16px;
    max-width: 95vw;
    margin: 10px;
  }
}

/* Smartphone Screens (max-width: 480px) */
@media (max-width: 480px) {
  .quest-stage-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .quest-stage-card {
    padding: 6px 8px;
    min-height: 72px;
    gap: 4px;
  }

  .quest-stage-card .text-xs {
    font-size: 0.7rem;
  }

  .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .btn-lg {
    padding: 9px 14px;
    font-size: 0.88rem;
  }

  .toast-popup {
    left: 10px;
    right: 10px;
    bottom: 10px;
    font-size: 0.82rem;
    padding: 9px 12px;
  }
}

/* Print Styles */
@media print {
  body {
    background-color: #ffffff;
    color: #000000;
  }
  .main-header, .step-nav-bar, .no-print, .btn, .header-actions {
    display: none !important;
  }
  .certificate-frame {
    box-shadow: none;
    border: 6px double #000000;
    max-width: 100%;
    margin: 0;
    page-break-inside: avoid;
  }
}
