/* =========================================================================
   DUOLINGO-STYLE FLASHCARD & QUIZ APP - STYLESHEET
   Unified with Flashcard/ai_studio_code.html Assets & Architecture
   Auto-scaling responsive layout with zero unintended scroll bars
   ========================================================================= */

/* Font Definitions */
@font-face {
  font-family: 'Nunito';
  src: url('Fonts/Nunito-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Nunito';
  src: url('Fonts/Nunito-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

/* Global Reset & Base Layout */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  background-color: #0F171E;
  color: #E2E8F0;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  overflow: hidden; /* Fully eliminates the global window scroll bar */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* KaTeX formula compact styling */
.katex-display {
  margin: 4px 0 !important;
}

.katex {
  font-size: 1em !important;
}

/* Fluid Responsive Container Scaling */
#app-container {
  width: 100%;
  max-width: 720px;
  height: 100%;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #0F171E;
  overflow: hidden;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(12px, 2.2vh, 20px) clamp(16px, 3vw, 28px);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background-color: #0F171E;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  box-sizing: border-box;
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#btn-back-nav {
  margin: 0;
  padding: 0;
  width: auto;
  height: auto;
  min-width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  color: #94A3B8;
  font-size: clamp(1.4rem, 3.2vh, 1.8rem);
  font-weight: 800;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.1s ease;
}

#btn-back-nav:hover {
  color: #FFFFFF;
  background: none;
  transform: translateX(-2px);
}

#btn-back-nav:not([style*="display: none"]):not([style*="visibility: hidden"]) ~ .top-nav-title {
  margin-left: 0;
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-nav-title {
  font-size: clamp(1.4rem, 3.5vh, 2.2rem);
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 0.5px;
}

/* Reset Progress Button in Courses Top Bar */
.btn-reset-progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: #15202B;
  border: 2px solid #37464F;
  color: #94A3B8;
  padding: clamp(6px, 1.2vh, 8px) clamp(10px, 1.8vw, 16px);
  border-radius: 9999px;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(0.78rem, 1.6vh, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 3px 0 #243342;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
  user-select: none;
  outline: none;
}

.btn-reset-progress:hover {
  color: #EE5555;
  border-color: rgba(238, 85, 85, 0.6);
  background-color: #1A1820;
  box-shadow: 0 3px 0 rgba(238, 85, 85, 0.3);
}

.btn-reset-progress:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-reset-progress .reset-icon {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.btn-reset-progress:hover .reset-icon {
  transform: rotate(-45deg);
}

/* Quiz Top Bar - Inline (X button, Progress Bar Track, Skip Button, Heart Counter) */
.quiz-top-bar-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.5vw, 14px);
  width: 100%;
  padding: clamp(10px, 1.8vh, 18px) clamp(14px, 2.5vw, 24px) clamp(6px, 1vh, 12px) clamp(14px, 2.5vw, 24px);
  background-color: #0F171E;
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
}

.btn-quiz-top-skip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border-radius: 9999px;
  background-color: #1A2733;
  border: 1.5px solid #37464F;
  color: #94A3B8;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(0.72rem, 1.4vh, 0.82rem);
  font-weight: 800;
  letter-spacing: 0.8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 0 #243342;
  transition: all 0.12s ease;
  user-select: none;
  outline: none;
}

.btn-quiz-top-skip:hover {
  background-color: #243342;
  border-color: #52656D;
  color: #E2E8F0;
  box-shadow: 0 2px 0 #52656D;
  transform: translateY(-1px);
}

.btn-quiz-top-skip:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-close-quiz {
  background: none;
  border: none;
  color: #94A3B8;
  font-size: clamp(1.5rem, 3.2vh, 2rem);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(32px, 5vh, 40px);
  height: clamp(32px, 5vh, 40px);
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.2s, background-color 0.2s;
}

.btn-close-quiz:hover {
  color: #FFFFFF;
  background-color: #15202B;
}

/* Learn Phase Pill Badge */
.learn-phase-pill {
  font-size: clamp(0.7rem, 1.5vh, 0.8rem);
  font-weight: 800;
  letter-spacing: 1px;
  padding: clamp(4px, 0.8vh, 6px) clamp(10px, 1.5vw, 14px);
  border-radius: 9999px;
  background: rgba(36, 51, 66, 0.9);
  color: #58CC02;
  border: 1px solid rgba(88, 204, 2, 0.4);
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* Progress Track & Widget Centered */
.progress-bar-widget {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  box-sizing: border-box;
  position: relative;
  height: clamp(12px, 2vh, 16px);
}

.streak-headline {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.7rem, 1.5vh, 0.85rem);
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  white-space: nowrap;
  margin-bottom: 4px;
  pointer-events: none;
  transition: color 0.2s ease;
  color: transparent;
}

.progress-track {
  width: 100%;
  height: clamp(12px, 2vh, 16px);
  background-color: #37464F;
  border-radius: 9999px;
  overflow: visible;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 9999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* 3-Phase Streak Linear Gradients */
.progress-fill-green {
  background: linear-gradient(to bottom, #A8DB5B 0%, #A8DB5B 35%, #93D333 35%, #93D333 100%);
}

.progress-fill-yellow {
  background: linear-gradient(to bottom, #FFD233 0%, #FFD233 35%, #FFC700 35%, #FFC700 100%);
}

.progress-fill-orange {
  background: linear-gradient(to bottom, #FFBB5B 0%, #FFBB5B 35%, #FFAB33 35%, #FFAB33 100%);
}

/* Sparkle Particles Burst Container */
.sparkle-container {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  background-color: #93D333;
}

@keyframes burst-sparkle {
  0% { transform: translate(0, 0) scale(0.3); opacity: 1; }
  40% { opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(1.3); opacity: 0; }
}

.sparkle-active .particle {
  animation: burst-sparkle 0.45s cubic-bezier(0.1, 0.8, 0.25, 1) forwards;
}

.heart-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: clamp(1rem, 2.2vh, 1.3rem);
  font-weight: 800;
  color: #EE5555;
  flex-shrink: 0;
}

/* =========================================================================
   VIEWS MANAGEMENT & LOADING SCREEN
   ========================================================================= */
.view-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  animation: fadeIn 0.25s ease-out;
}

.view-screen.active {
  display: flex;
}

/* Specific view scrolling permissions */
#view-main-menu {
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(16px, 2.5vh, 24px) clamp(16px, 3vw, 28px) clamp(24px, 4vh, 40px) clamp(16px, 3vw, 28px);
  -webkit-overflow-scrolling: touch;
}

#view-level-map {
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(12px, 2vh, 20px) clamp(16px, 3vw, 28px) clamp(30px, 5vh, 60px) clamp(16px, 3vw, 28px);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Scrollbars strictly for Courses Selection & Levels Selection */
#view-main-menu,
#view-level-map {
  scrollbar-width: thin;
  scrollbar-color: #37464F transparent;
}

#view-main-menu::-webkit-scrollbar,
#view-level-map::-webkit-scrollbar {
  display: block;
  width: 6px;
}

#view-main-menu::-webkit-scrollbar-track,
#view-level-map::-webkit-scrollbar-track {
  background: transparent;
}

#view-main-menu::-webkit-scrollbar-thumb,
#view-level-map::-webkit-scrollbar-thumb {
  background: #37464F;
  border-radius: 9999px;
}

#view-main-menu::-webkit-scrollbar-thumb:hover,
#view-level-map::-webkit-scrollbar-thumb:hover {
  background: #52656D;
}

/* Duolingo-Style Fullscreen Loading Screen */
#view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #0F171E;
  z-index: 9999;
  text-align: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  overflow: hidden;
}

#view-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-spinner-outer {
  position: relative;
  width: clamp(60px, 10vh, 84px);
  height: clamp(60px, 10vh, 84px);
  margin-bottom: clamp(16px, 3vh, 24px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner-ring {
  width: 100%;
  height: 100%;
  border: 6px solid #243342;
  border-top: 6px solid #58CC02;
  border-radius: 50%;
  animation: spinRing 0.8s linear infinite;
}

@keyframes spinRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: clamp(0.95rem, 2vh, 1.2rem);
  font-weight: 800;
  color: #58CC02;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes pulseText {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

#view-quiz {
  padding: 0;
  height: 100%;
  max-height: 100%;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

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

/* Swipe Left Dissolve Question Transition */
@keyframes swipeLeftDissolve {
  0% { transform: translateX(0); opacity: 1; }
  35% { transform: translateX(-35px) scale(0.97); opacity: 0; }
  36% { transform: translateX(35px) scale(0.97); opacity: 0; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}

.swipe-transition {
  animation: swipeLeftDissolve 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Phase Entrance Animation with subtle bounce */
@keyframes phaseSlideIn {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  70% {
    opacity: 1;
    transform: translateY(-2px) scale(1.005);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Shake Animation for Wrong Answers */
@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* =========================================================================
   SCREEN 1: MAIN MENU (COURSE DISPLAY)
   ========================================================================= */

.courses-container {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.5vh, 24px);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.course-card {
  border-radius: clamp(16px, 3vw, 24px);
  padding: clamp(20px, 3.5vh, 36px) clamp(16px, 3vw, 28px) clamp(18px, 3vh, 28px) clamp(16px, 3vw, 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(8px, 1.5vh, 14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}

.course-code {
  font-size: clamp(1.8rem, 4vh, 2.6rem);
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 1px;
  margin-bottom: 2px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.course-title {
  font-size: clamp(1.05rem, 2.2vh, 1.35rem);
  font-weight: 700;
  color: #FFFFFF;
  opacity: 0.95;
  max-width: 520px;
  line-height: 1.4;
  margin-bottom: clamp(6px, 1.2vh, 12px);
}

.course-progress-container {
  width: 100%;
  max-width: 480px;
  margin-bottom: clamp(6px, 1vh, 10px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.course-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: clamp(0.75rem, 1.5vh, 0.85rem);
  font-weight: 800;
  color: #FFFFFF;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

.course-progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 9999px;
  overflow: hidden;
}

.course-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #58CC02, #FFD233);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.btn-view-lessons {
  width: 100%;
  max-width: 480px;
  height: clamp(44px, 6vh, 54px);
  border-radius: clamp(12px, 2vw, 16px);
  border: none;
  background-color: #FFFFFF;
  color: #1B242C;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(0.95rem, 2vh, 1.15rem);
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s;
}

.btn-view-lessons:hover {
  background-color: #F8FAFC;
}

.btn-view-lessons:active {
  transform: translateY(6px);
  box-shadow: none;
}

/* =========================================================================
   SCREEN 2: LEVEL MAP VIEW (DUOLINGO SERPENTINE / S-CURVE PATH)
   ========================================================================= */

.map-node-container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.module-section-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: clamp(16px, 3vh, 30px);
}

.unit-banner {
  border-radius: clamp(12px, 2vw, 16px);
  padding: clamp(14px, 2.2vh, 20px) clamp(16px, 3vw, 24px);
  margin-bottom: clamp(16px, 3vh, 28px);
  color: #FFFFFF;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.unit-banner-info h3 {
  font-size: clamp(0.75rem, 1.5vh, 0.85rem);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.9;
  margin-bottom: 2px;
  font-weight: 700;
}

.unit-banner-info h2 {
  font-size: clamp(1.05rem, 2.2vh, 1.3rem);
  font-weight: 700;
}

.serpentine-map-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 0 clamp(20px, 4vh, 50px) 0;
  gap: clamp(14px, 2.5vh, 20px);
  position: relative;
  width: 100%;
}

.level-node-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  z-index: 5;
}

.level-node-wrapper.active-popover {
  z-index: 999 !important;
}

.level-node-outer {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}

/* SVG Progress Ring */
.progress-ring-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 120px;
  height: 120px;
  pointer-events: none;
}

.ring-track {
  stroke: #37464F;
}

.ring-fill {
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

/* Level Button */
.level-btn {
  position: absolute;
  width: 72px;
  height: 64px;
  left: 24px;
  top: 24px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #62E302 0%, #58CC02 60%, #4CB801 100%);
  box-shadow: 0 8px 0 #147A00;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.1s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 6;
  padding: 0;
  overflow: hidden;
}

.level-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    transparent 0%,
    transparent 32%,
    rgba(255, 255, 255, 0.22) 32%,
    rgba(255, 255, 255, 0.22) 48%,
    transparent 48%,
    transparent 100%
  );
  pointer-events: none;
}

.star-icon {
  width: 34px;
  height: 34px;
  fill: #FFFFFF;
  stroke: #FFFFFF;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  display: block;
}

.check-icon {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: none;
}

.star-sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: #58CC02;
  clip-path: polygon(50% 0%, 66% 34%, 100% 50%, 66% 66%, 50% 100%, 34% 66%, 0% 50%, 34% 34%);
  opacity: 0;
  pointer-events: none;
  animation: sparkle-twinkle 2s infinite ease-in-out;
}

@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.1) rotate(45deg); }
}

.node-sp-1 { top: 10px; left: 16px; animation-delay: 0s; }
.node-sp-2 { bottom: 12px; right: 12px; animation-delay: 0.6s; }
.node-sp-3 { top: 16px; right: 12px; animation-delay: 1.2s; }

.level-node-outer:hover .level-btn {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #147A00;
}

.level-node-outer:active .level-btn {
  transform: translateY(8px);
  box-shadow: none;
}

/* Lesson Popover Card */
.lesson-card {
  position: absolute;
  top: 120px;
  width: clamp(290px, 85vw, 320px);
  background-color: var(--card-bg, #58CC02);
  border-radius: 20px;
  padding: 16px 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  transform: translateY(-20px) scale(0.85);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
}

.lesson-card.active {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.lesson-card::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 10px 10px;
  border-style: solid;
  border-color: var(--card-bg, #58CC02) transparent;
  display: block;
  width: 0;
}

.lesson-card-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: #FFFFFF;
  margin: 0 0 2px 0;
  line-height: 1.3;
}

.lesson-card-progress {
  font-size: 0.82rem;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0 0 2px 0;
  opacity: 0.95;
}

/* 5-Session Selector in Level Popover */
.session-selector-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 8px 0 10px 0;
  background: rgba(0, 0, 0, 0.22);
  padding: 8px 6px;
  border-radius: 14px;
  box-sizing: border-box;
}

.session-tabs-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #FFFFFF;
  opacity: 0.9;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.session-tabs-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

.session-tab-btn {
  flex: 1;
  max-width: 48px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.3);
  color: #FFFFFF;
  font-family: 'Nunito', sans-serif;
  font-size: 0.84rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
}

.session-tab-btn:hover {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.15);
}

.session-tab-btn.active {
  background: #FFFFFF !important;
  color: var(--card-bg, #58CC02) !important;
  border-color: #FFFFFF !important;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}

.session-tab-btn.completed {
  border-color: #FFD233;
}

.session-tab-btn.completed::after {
  content: '✓';
  position: absolute;
  top: -5px;
  right: -4px;
  background: #FFD233;
  color: #0F171E;
  font-size: 0.62rem;
  font-weight: 900;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.session-info-detail {
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFFFFF;
  opacity: 0.95;
  text-align: center;
  line-height: 1.25;
}

.lesson-card-mastery-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #FFFFFF;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.lesson-card-mastery-pill.fully-mastered {
  background: rgba(255, 215, 0, 0.25);
  border-color: #FFD233;
  color: #FFE680;
}

.lesson-card-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-mode-learn {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: none;
  background-color: #FFFFFF;
  color: var(--card-bg, #58CC02);
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  outline: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.05s ease, box-shadow 0.05s ease, filter 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-mode-learn:hover {
  filter: brightness(1.05);
}

.btn-mode-learn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.btn-mode-recall {
  width: 100%;
  height: 38px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.25);
  color: #FFFFFF;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  outline: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.05s ease, box-shadow 0.05s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-mode-recall:hover {
  background: rgba(0, 0, 0, 0.4);
}

.btn-mode-recall:active {
  transform: translateY(3px);
  box-shadow: none;
}

/* =========================================================================
   LEARN STEP 1: VISUAL / CONTEXT CARD (From ai_studio_code.html)
   ========================================================================= */

.learn-context-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(8px, 1.5vh, 20px) clamp(16px, 3vw, 24px);
  gap: clamp(8px, 1.8vh, 18px);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  animation: phaseSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.context-hero-emoji {
  font-size: clamp(2.2rem, 6vh, 3.8rem);
  line-height: 1;
  margin-bottom: 2px;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

.context-title {
  font-size: clamp(1.15rem, 2.8vh, 1.65rem);
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.2px;
}

.context-text {
  font-size: clamp(0.9rem, 2vh, 1.2rem);
  color: #CBD5E1;
  line-height: 1.5;
  max-width: 560px;
}

/* Clean KaTeX Formula Container */
.context-formula-card {
  background: #15202B;
  border: 2px solid #243342;
  border-radius: clamp(12px, 2vw, 18px);
  padding: clamp(8px, 1.5vh, 16px) clamp(14px, 2.5vw, 24px);
  width: 100%;
  max-width: 520px;
  font-size: clamp(1.05rem, 2.5vh, 1.45rem);
  color: #60A5FA;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.recognition-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.question-container {
  display: flex;
  flex-direction: column;
  margin-top: clamp(2px, 0.8vh, 10px);
  margin-bottom: clamp(8px, 1.6vh, 18px);
  width: 100%;
  text-align: left;
}

/* Authentic 3D Green Continue Button from ai_studio_code.html */
.btn-learn-continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  height: clamp(42px, 5.5vh, 50px);
  border-radius: clamp(12px, 2vw, 16px);
  border: none;
  color: #1B242C;
  background-color: #93D333;
  box-shadow: 0 6px 0 #79B933;
  font-family: "Segoe UI", 'Nunito', sans-serif;
  font-size: clamp(0.95rem, 2.2vh, 1.25rem);
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  outline: none;
  box-sizing: border-box;
  margin-top: clamp(4px, 1.2vh, 12px);
  transition: background-color 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease;
}

.btn-learn-continue:hover {
  background-color: #A2E838;
  box-shadow: 0 6px 0 #85CC38;
}

.btn-learn-continue:active {
  background-color: #93D333;
  box-shadow: 0 2px 0 #79B933;
  transform: translateY(4px);
}

/* =========================================================================
   LEARN STEP 2: RECOGNITION (Worded Choice from ai_studio_code.html)
   ========================================================================= */

.learn-recognition-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(8px, 1.5vh, 20px) clamp(16px, 3vw, 24px);
  gap: clamp(10px, 2vh, 22px);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  animation: phaseSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.recognition-prompt-text {
  font-size: clamp(1.05rem, 2.5vh, 1.45rem);
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.4;
  max-width: 560px;
}

.recognition-chips-grid {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vh, 14px);
  width: 100%;
  max-width: 520px;
}

/* =========================================================================
   CHOICE CONTAINER & MULTIPLE CHOICE QUIZ (From ai_studio_code.html)
   ========================================================================= */

.learn-choice-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(4px, 1vh, 12px) clamp(16px, 3vw, 28px);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  animation: phaseSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.question-container {
  margin-top: clamp(2px, 0.8vh, 10px);
  margin-bottom: clamp(8px, 1.6vh, 18px);
  width: 100%;
  text-align: left;
}

.question-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  margin-bottom: clamp(6px, 1.2vh, 10px);
}

.quiz-question-idx-pill {
  display: inline-block;
  text-align: center;
  font-size: clamp(0.78rem, 1.6vh, 0.9rem);
  font-weight: 800;
  color: #94A3B8;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.quiz-mastered-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: clamp(0.7rem, 1.3vh, 0.78rem);
  font-weight: 800;
  color: #FFD233;
  background: rgba(255, 210, 51, 0.15);
  border: 1px solid rgba(255, 210, 51, 0.4);
  padding: 2px 8px;
  border-radius: 9999px;
  letter-spacing: 0.5px;
}

.question-text {
  font-size: clamp(1.05rem, 2.4vh, 1.5rem);
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.35;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.3vh, 14px);
  width: 100%;
  margin-bottom: clamp(4px, 1vh, 10px);
}

/* Authentic Worded Choice Button from ai_studio_code.html */
.worded-card-base {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: clamp(42px, 5.8vh, 58px);
  border-radius: clamp(12px, 1.8vw, 16px);
  padding: clamp(6px, 1vh, 12px) clamp(12px, 2vw, 18px);
  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
  background-color: #131F24;
  border: 2px solid #37464F;
  color: #F8FAFC;
  box-shadow: 0 4px 0 #37464F;
  transform: translateY(0);
  transition: background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease;
}

.worded-card-base:hover {
  background-color: #202F36;
}

.worded-card-base:active {
  transform: translateY(4px);
  box-shadow: none !important;
}

.worded-card-base.selected {
  background-color: #202F36;
  border: 2px solid #1CB0F6;
  color: #1CB0F6;
  box-shadow: 0 4px 0 #1CB0F6;
  transform: translateY(0);
}

.worded-card-base.selected:active {
  transform: translateY(4px);
  box-shadow: none !important;
}

.worded-card-base.correct-choice {
  background-color: #131F24 !important;
  border: 2px solid #93D333 !important;
  color: #93D333 !important;
  box-shadow: 0 4px 0 #93D333 !important;
  transform: translateY(0) !important;
}

.worded-card-base.wrong-choice {
  background-color: #131F24 !important;
  border: 2px solid #EE5555 !important;
  color: #EE5555 !important;
  box-shadow: 0 4px 0 #EE5555 !important;
  transform: translateY(0) !important;
  animation: shakeWrong 0.4s ease-in-out !important;
}

.choice-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(24px, 3.8vh, 32px);
  height: clamp(24px, 3.8vh, 32px);
  border-radius: 8px;
  font-size: clamp(0.8rem, 1.6vh, 0.95rem);
  font-weight: 800;
  border: 2px solid #37464F;
  color: #52656D;
  margin-right: clamp(10px, 1.8vw, 16px);
  flex-shrink: 0;
  transition: border-color 0.1s ease, color 0.1s ease;
}

.worded-card-base.selected .choice-badge {
  border-color: #1CB0F6;
  color: #1CB0F6;
}

.worded-card-base.correct-choice .choice-badge {
  border-color: #93D333;
  color: #93D333;
}

.worded-card-base.wrong-choice .choice-badge {
  border-color: #EE5555;
  color: #EE5555;
}

.worded-content {
  font-size: clamp(0.9rem, 2vh, 1.15rem);
  font-weight: 700;
  line-height: 1.35;
  flex-grow: 1;
}

/* =========================================================================
   BOTTOM ACTION BAR & BUTTONS (ai_studio_code.html)
   ========================================================================= */

.btn-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: clamp(42px, 5.5vh, 50px);
  border-radius: clamp(12px, 1.8vw, 16px);
  font-family: 'Segoe UI', 'Nunito', sans-serif;
  font-size: clamp(0.95rem, 2vh, 1.15rem);
  font-weight: 800;
  letter-spacing: 1.5px;
  cursor: pointer;
  user-select: none;
  outline: none;
  box-sizing: border-box;
  transition: background-color 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease;
}

.btn-check-main {
  width: clamp(180px, 32vw, 260px);
  border: none;
  color: #1B242C;
  background-color: #93D333;
  box-shadow: 0 6px 0 #79B933;
}

.btn-check-main:hover {
  background-color: #A2E838;
  box-shadow: 0 6px 0 #85CC38;
}

.btn-check-main:active {
  background-color: #93D333;
  box-shadow: 0 2px 0 #79B933;
  transform: translateY(4px);
}

.btn-check-main:disabled {
  background-color: #243342;
  color: #52656D;
  box-shadow: 0 4px 0 #1B242C;
  cursor: not-allowed;
  transform: none;
}

.btn-skip-secondary {
  width: clamp(100px, 18vw, 160px);
  background-color: #131F24;
  border: 2px solid #37464F;
  color: #52656D;
  box-shadow: 0 4px 0 #37464F;
}

.btn-skip-secondary:hover {
  background-color: #111C20;
}

.btn-skip-secondary:active {
  background-color: #111C20;
  box-shadow: none;
  transform: translateY(4px);
}

.btn-continue-full {
  width: 100%;
  height: clamp(42px, 5.5vh, 50px);
  border-radius: clamp(12px, 1.8vw, 16px);
  font-size: clamp(0.95rem, 2vh, 1.15rem);
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
}

.btn-continue-correct {
  border: none;
  color: #1B242C;
  background-color: #93D333;
  box-shadow: 0 6px 0 #79B933;
}

.btn-continue-correct:hover {
  background-color: #A2E838;
  box-shadow: 0 6px 0 #85CC38;
}

.btn-continue-correct:active {
  background-color: #93D333;
  box-shadow: 0 2px 0 #79B933;
  transform: translateY(4px);
}

.btn-continue-wrong {
  border: none;
  color: #202F36;
  background-color: #EE5555;
  box-shadow: 0 6px 0 #D84848;
}

.btn-continue-wrong:hover {
  background-color: #FF5E5E;
  box-shadow: 0 6px 0 #D84848;
}

.btn-continue-wrong:active {
  background-color: #FF5E5E;
  box-shadow: none;
  transform: translateY(6px);
}

/* Bottom Action Footer */
.quiz-footer {
  position: relative;
  width: 100%;
  background-color: #131F24;
  z-index: 200;
  box-sizing: border-box;
  padding: clamp(10px, 1.8vh, 18px) 0;
  flex-shrink: 0;
  border-top: 2px solid #37464f;
}

.footer-inner-content {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 40px);
  box-sizing: border-box;
}

.footer-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 2vw, 16px);
  width: 100%;
}

@keyframes slideUpBounce {
  0% { transform: translateY(100%); opacity: 0; }
  75% { transform: translateY(-4px); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

.quiz-footer.feedback-active {
  animation: slideUpBounce 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.quiz-footer.correct-active {
  background-color: #18262D;
}

.quiz-footer.wrong-active {
  background-color: #18262D;
}

.feedback-content {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vh, 12px);
  width: 100%;
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feedback-title {
  font-size: clamp(1.15rem, 2.4vh, 1.45rem);
  font-weight: 800;
}

.feedback-title.correct { color: #58CC02; }
.feedback-title.wrong { color: #EE5555; }

.feedback-detail {
  font-size: clamp(0.9rem, 1.8vh, 1.1rem);
  font-weight: 700;
  color: #EE5555;
  margin-top: -2px;
}

.feedback-tools {
  display: flex;
  gap: 16px;
  color: #94A3B8;
  font-size: 1.3rem;
}

.feedback-icon {
  cursor: pointer;
  transition: color 0.15s;
}

.feedback-icon:hover { color: #FFFFFF; }

/* =========================================================================
   SCREEN 4: LESSON COMPLETION SUMMARY
   ========================================================================= */

#view-completion {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  width: 100%;
  padding: clamp(16px, 3vh, 32px) clamp(16px, 3vw, 28px);
  overflow: hidden;
  box-sizing: border-box;
}

#view-completion.active {
  display: flex;
}

.completion-card {
  background-color: #15202B;
  border: 2px solid #243342;
  border-radius: clamp(16px, 3vw, 24px);
  padding: clamp(20px, 4vh, 36px) clamp(18px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(12px, 2.2vh, 22px);
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.completion-icon {
  font-size: clamp(2.6rem, 6.5vh, 3.8rem);
  animation: bounce 1s infinite alternate ease-in-out;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.completion-title {
  font-size: clamp(1.35rem, 3.2vh, 1.9rem);
  font-weight: 800;
  color: #FFC700;
}

.completion-subtitle {
  font-size: clamp(0.9rem, 1.9vh, 1.1rem);
  color: #CBD5E1;
  line-height: 1.5;
  max-width: 440px;
}

.completion-actions-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 4px;
}

/* =========================================================================
   RESET PROGRESS CONFIRMATION MODAL
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.18s ease-out;
}

.modal-card {
  background-color: #15202B;
  border: 2px solid #243342;
  border-radius: clamp(16px, 3vw, 24px);
  padding: clamp(20px, 3.5vh, 32px) clamp(18px, 3vw, 28px);
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
  animation: phaseSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon {
  font-size: clamp(2rem, 5vh, 2.8rem);
  margin-bottom: 8px;
}

.modal-title {
  font-size: clamp(1.2rem, 2.6vh, 1.5rem);
  font-weight: 800;
  color: #FFFFFF;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: clamp(0.88rem, 1.8vh, 1rem);
  color: #94A3B8;
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.btn-modal-cancel {
  flex: 1;
  height: 44px;
  background-color: #1A2733;
  border: 2px solid #37464F;
  color: #CBD5E1;
  border-radius: 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 3px 0 #243342;
  transition: all 0.12s ease;
  outline: none;
}

.btn-modal-cancel:hover {
  background-color: #243342;
  color: #FFFFFF;
}

.btn-modal-cancel:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-modal-danger {
  flex: 1;
  height: 44px;
  background-color: #EE5555;
  border: none;
  color: #FFFFFF;
  border-radius: 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 0 #D84848;
  transition: all 0.12s ease;
  outline: none;
}

.btn-modal-danger:hover {
  background-color: #FF5E5E;
}

.btn-modal-danger:active {
  transform: translateY(3px);
  box-shadow: none;
}

/* =========================================================================
   RESPONSIVE LAYOUT MEDIA QUERIES
   ========================================================================= */

@media (max-width: 767px) {
  .btn-check-main {
    flex: 1;
  }

  .btn-skip-secondary {
    display: inline-flex;
    min-width: 80px;
    padding: 0 12px;
  }

  .question-text {
    font-size: clamp(1rem, 2.2vh, 1.35rem);
  }

  .worded-content {
    text-align: center;
  }

  .choice-badge {
    display: none;
  }

  .worded-card-base {
    justify-content: center;
  }

  .btn-reset-progress span {
    display: inline;
  }
}
