@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* HSL Color System */
  --bg-primary: hsl(222, 47%, 7%);
  --bg-secondary: hsl(222, 40%, 12%);
  --bg-tertiary: hsl(222, 35%, 18%);
  
  --glass-bg: rgba(10, 17, 34, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-glow: rgba(0, 242, 254, 0.15);
  
  --primary-accent: hsl(180, 100%, 50%);
  --primary-accent-rgb: 0, 242, 254;
  --secondary-accent: hsl(267, 100%, 65%);
  --secondary-accent-rgb: 168, 85, 247;
  
  --correct: hsl(150, 84%, 44%);
  --correct-rgb: 16, 185, 129;
  --incorrect: hsl(350, 89%, 60%);
  --incorrect-rgb: 239, 68, 68;
  
  --text-primary: hsl(0, 0%, 95%);
  --text-secondary: hsl(220, 14%, 65%);
  --text-muted: hsl(220, 12%, 40%);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 30px;
  
  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 48px -4px rgba(0, 0, 0, 0.7);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(168, 85, 247, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 242, 254, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-primary);
  
  &:hover {
    background: var(--text-muted);
  }
}

/* Typography & Layout utility */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Header & Navigation layout */
header {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  background-color: rgba(6, 11, 19, 0.8);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  aria-expanded: false;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.45rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  
  svg {
    stroke: url(#logo-grad);
  }
}

/* Navigation Tabs */
.main-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  padding: 0.2rem;
  border-radius: var(--radius-md);
}

.tab-btn {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.55rem 1.1rem;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition-fast);
  
  &:hover {
    color: var(--text-primary);
  }
  
  &.active {
    background: var(--bg-tertiary);
    color: var(--primary-accent);
    box-shadow: var(--shadow-sm);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
  }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* US/DE Layout toggles */
.layout-toggle-group {
  display: flex;
  background: rgba(0,0,0,0.3);
  padding: 2px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.layout-btn {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: calc(var(--radius-sm) - 1px);
  cursor: pointer;
  transition: var(--transition-fast);
  
  &.active {
    background: var(--bg-tertiary);
    color: var(--primary-accent);
  }
}

/* Glassmorphism Button */
.btn {
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  
  &:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  
  &:active {
    transform: translateY(0);
  }
  
  &.btn-primary {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.15), rgba(168, 85, 247, 0.15));
    border-color: var(--primary-accent);
    color: var(--primary-accent);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.1);
    
    &:hover {
      background: linear-gradient(135deg, rgba(0, 242, 254, 0.25), rgba(168, 85, 247, 0.25));
      border-color: var(--primary-accent);
      color: var(--text-primary);
      box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
    }
  }
  
  &.btn-icon {
    padding: 0.6rem;
    border-radius: 50%;
  }
}

/* Main Container layout */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: tab-fade-in 0.3s ease-out forwards;
  
  &.active {
    display: block;
  }
}

@keyframes tab-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* SECTION 1: ACADEMY VIEW ROADMAP GRID */
.academy-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  align-items: start;
}

.roadmap-container {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.roadmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 1.5rem;
  
  h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
  }
  
  p {
    font-size: 0.85rem;
    color: var(--text-secondary);
  }
}

/* Roadmap learning track selectors */
.track-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  padding: 0.2rem;
  border-radius: var(--radius-md);
}

.track-btn {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.45rem 0.9rem;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: var(--transition-fast);
  
  &:hover {
    color: var(--text-primary);
  }
  
  &.active {
    background: var(--bg-tertiary);
    color: var(--primary-accent);
    box-shadow: var(--shadow-sm);
  }
}

/* Winding timeline track drawing */
.roadmap-winding-path {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  padding: 2.5rem 0;
  max-width: 580px;
  margin: 0 auto;
  width: 100%;
  
  /* Dashed Center Timeline connecting path */
  &::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    border-left: 2.5px dashed rgba(0, 242, 254, 0.18);
    transform: translateX(-50%);
    z-index: 1;
  }
}

/* Individual node levels alignment maps */
.roadmap-node-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  z-index: 2;
  
  /* Zigzag alignment offsets */
  &.align-left { justify-content: flex-start; padding-left: 10%; }
  &.align-center { justify-content: center; }
  &.align-right { justify-content: flex-end; padding-right: 10%; }
}

.roadmap-node {
  background: var(--bg-secondary);
  border: 2px solid var(--glass-border);
  color: var(--text-secondary);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  box-shadow: var(--shadow-md);
  
  &::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
  }
  
  &:hover {
    transform: scale(1.1);
    color: var(--text-primary);
  }
  
  &.locked {
    opacity: 0.55;
    background: rgba(10, 17, 34, 0.4);
    border-color: rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    
    &:hover {
      transform: none;
    }
  }
  
  &.active-node {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    border-color: var(--primary-accent);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
    
    &::before {
      border-color: var(--primary-accent);
      animation: node-pulse-ring 2s infinite ease-out;
    }
    
    &:hover {
      box-shadow: 0 0 25px rgba(0, 242, 254, 0.6);
    }
  }
  
  &.completed {
    border-color: var(--correct);
    background: rgba(16, 185, 129, 0.15);
    color: var(--correct);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
    
    &:hover {
      border-color: var(--correct);
      box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
    }
  }
}

@keyframes node-pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* Roadmap node level number overlay label tooltip */
.node-tooltip {
  position: absolute;
  top: 50%;
  left: 80px;
  transform: translateY(-50%);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  z-index: 10;
  
  .roadmap-node-wrapper.align-right & {
    left: auto;
    right: 80px;
  }
}

.roadmap-node:hover .node-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(5px);
  
  .roadmap-node-wrapper.align-right & {
    transform: translateY(-50%) translateX(-5px);
  }
}

/* Sidebar Academy Panels */
.academy-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Speeches Mascot Box card */
.mascot-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.mascot-svg-box {
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inline SVG Mascot animation classes */
.cyber-owl {
  width: 100%;
  height: 100%;
  animation: owl-float 3s infinite alternate ease-in-out;
  
  .eye-glow {
    animation: owl-eye-glow 2s infinite alternate;
  }
  
  .pupil {
    animation: pupil-blink 4s infinite steps(2, start);
    transform-origin: 50% 40%;
  }
}

@keyframes owl-float {
  0% { transform: translateY(0); }
  100% { transform: translateY(-7px); }
}

@keyframes owl-eye-glow {
  0% { stroke-width: 1.5; opacity: 0.7; }
  100% { stroke-width: 3.5; opacity: 1; filter: drop-shadow(0 0 3px var(--primary-accent)); }
}

@keyframes pupil-blink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.mascot-speech-bubble {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  position: relative;
  width: 100%;
  text-align: center;
  
  /* Speech bubble glassy top arrow point */
  &::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-bottom-color: var(--glass-border);
  }
  
  &::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(10, 17, 34, 0.9);
  }
  
  strong {
    color: var(--primary-accent);
  }
}

/* Competitive weekly league card */
.league-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.league-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.75rem;
  
  .league-timer {
    font-size: 0.75rem;
    color: var(--text-muted);
  }
}

/* Glowing gold league badge */
.league-badge {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid hsl(45, 93%, 47%);
  color: hsl(45, 93%, 55%);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.15);
}

.league-title {
  font-size: 0.95rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.league-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.league-row {
  display: grid;
  grid-template-columns: 24px 1fr 60px 16px;
  align-items: center;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: var(--transition-fast);
  
  .rank {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.75rem;
  }
  
  .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 0.5rem;
  }
  
  .xp {
    font-family: var(--font-mono);
    text-align: right;
    font-weight: 700;
    color: var(--text-primary);
  }
  
  .trend-arrow {
    font-size: 0.65rem;
    text-align: right;
    
    &.up { color: var(--correct); }
    &.down { color: var(--incorrect); }
    &.same { color: var(--text-muted); }
  }
  
  /* Standings rank icons */
  &:nth-child(1) .rank { color: hsl(45, 93%, 55%); font-size: 1rem; } /* Gold */
  &:nth-child(2) .rank { color: hsl(200, 10%, 70%); font-size: 0.9rem; } /* Silver */
  &:nth-child(3) .rank { color: hsl(30, 40%, 40%); font-size: 0.85rem; } /* Bronze */
  
  &.current-user {
    background: rgba(0, 242, 254, 0.06);
    border-color: rgba(0, 242, 254, 0.25);
    color: var(--primary-accent);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.05);
    
    .rank { color: var(--primary-accent); }
    .xp { color: var(--primary-accent); }
  }
  
  /* Promotion Zone dashed markers */
  &.promo-demarcation {
    border-bottom: 1.5px dashed rgba(16, 185, 129, 0.3);
    margin-bottom: 0.25rem;
    padding-bottom: 0.65rem;
  }
}

/* SECTION 2: LESSON WORKSPACE ACTIVE HEADER BANNER */
.active-lesson-bar {
  background: rgba(10, 17, 34, 0.95);
  border: 1px solid rgba(0, 242, 254, 0.3);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  backdrop-filter: blur(12px);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  
  .lesson-meta-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    
    .l-track-title {
      font-size: 0.75rem;
      text-transform: uppercase;
      font-weight: 700;
      color: var(--secondary-accent);
      letter-spacing: 0.05em;
    }
    
    .l-level-title {
      font-size: 1rem;
      font-weight: 700;
      color: var(--text-primary);
    }
  }
}

.lesson-progress-container {
  flex: 1;
  max-width: 260px;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
  
  .lesson-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-accent), var(--correct));
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Visual hands optimal position guide section */
.hand-guide-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 2rem;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
}

.hand-guide-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  
  span {
    color: var(--primary-accent);
    font-weight: 700;
  }
}

.hands-svg-container {
  max-width: 480px;
  width: 100%;
  
  .cyber-hands {
    display: block;
    width: 100%;
    height: auto;
    
    line {
      transition: stroke 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
      opacity: 0.25;
    }
    
    /* Neon glowing active finger posture triggers */
    .active-finger {
      stroke: var(--primary-accent) !important;
      opacity: 1 !important;
      filter: drop-shadow(0 0 5px rgba(0, 242, 254, 0.7));
    }
    
    .active-finger-secondary {
      stroke: var(--secondary-accent) !important;
      opacity: 1 !important;
      filter: drop-shadow(0 0 5px rgba(168, 85, 247, 0.7));
    }
  }
}

/* STATS GRID & STAT CARDS ROW */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-accent), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
  }
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--glass-border-glow);
    
    &::before {
      transform: translateX(100%);
    }
  }
  
  .stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
  }
  
  .stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    
    span {
      font-size: 1rem;
      font-weight: 500;
      color: var(--text-secondary);
    }
  }
  
  .stat-trend {
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: auto;
    
    &.positive {
      color: var(--correct);
    }
    
    &.negative {
      color: var(--incorrect);
    }
  }
}

/* Category & Mode Selector Card */
.control-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.selector-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  
  .selector-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
}

.pills-container {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.pill-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: var(--transition-fast);
  
  &:hover {
    color: var(--text-primary);
  }
  
  &.active {
    background: var(--bg-tertiary);
    color: var(--primary-accent);
    box-shadow: var(--shadow-sm);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
  }
}

/* Game Status Alert */
.vault-alert-banner {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(0, 242, 254, 0.15));
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(6px);
  animation: pulse-glow 3s infinite alternate;
  
  .alert-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    
    strong {
      color: var(--primary-accent);
    }
  }
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
  }
  100% {
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
    border-color: rgba(0, 242, 254, 0.4);
  }
}

/* The Core Typing Interface Workspace */
.arena-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Text Wrapper styling */
.typing-viewport {
  position: relative;
  font-family: var(--font-mono);
  font-size: 1.45rem;
  line-height: 1.8;
  color: var(--text-muted);
  word-break: break-word;
  white-space: pre-wrap;
  user-select: none;
  min-height: 130px;
  cursor: text;
  outline: none;
}

/* Hidden input element that captures typed keystrokes */
.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* Individual letter tokens */
.char {
  position: relative;
  transition: color 0.1s ease;
  
  &.char-correct {
    color: var(--correct);
    text-shadow: 0 0 8px var(--correct-glow);
  }
  
  &.char-incorrect {
    color: var(--incorrect);
    background-color: rgba(239, 68, 68, 0.15);
    text-decoration: underline wavy var(--incorrect);
    text-shadow: 0 0 8px var(--incorrect-glow);
  }
  
  &.char-untyped {
    color: var(--text-muted);
  }
  
  &.char-active {
    color: var(--text-primary);
  }
}

/* Sliding Fluid Caret */
.caret {
  position: absolute;
  width: 2px;
  height: 1.55em;
  background-color: var(--primary-accent);
  box-shadow: 0 0 10px var(--primary-accent-glow), 0 0 20px var(--primary-accent-glow);
  border-radius: 2px;
  z-index: 5;
  pointer-events: none;
  animation: caret-blink 1s infinite steps(2, start);
  
  /* Use transform for hardware-accelerated fluid motion */
  will-change: transform, width, height;
  transition: transform 0.08s cubic-bezier(0.19, 1, 0.22, 1), width 0.08s ease, height 0.08s ease;
  
  &.typing {
    animation: none;
    opacity: 1;
  }
}

@keyframes caret-blink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* Action controls beneath Arena */
.arena-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--glass-border);
  padding-top: 1.5rem;
  
  .hint-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    
    kbd {
      background: var(--bg-tertiary);
      border: 1px solid var(--glass-border);
      border-radius: var(--radius-sm);
      padding: 0.1rem 0.4rem;
      font-family: var(--font-sans);
      font-size: 0.75rem;
      color: var(--text-secondary);
    }
  }
}

/* Interactive Virtual Keyboard section */
.keyboard-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.keyboard-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
}

.keycap {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  height: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  user-select: none;
  cursor: default;
  position: relative;
  overflow: hidden;
  
  /* Flex weights for specific layout keys */
  &.key-backspace { min-width: 90px; }
  &.key-tab { min-width: 75px; }
  &.key-caps { min-width: 85px; }
  &.key-enter { min-width: 90px; }
  &.key-shift-l { min-width: 110px; }
  &.key-shift-r { min-width: 110px; }
  &.key-ctrl, &.key-alt, &.key-cmd { min-width: 60px; }
  &.key-space { flex-grow: 1; max-width: 400px; }
  
  &.active {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: var(--bg-primary);
    border-color: var(--primary-accent);
    transform: scale(0.92);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
    font-weight: 700;
  }
}

/* Heatmap Red Glowing Error Overlays */
.keycap[data-errors] {
  &::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--incorrect);
    box-shadow: 0 0 6px var(--incorrect);
  }
}

/* Visual heat intensities */
.keycap[data-intensity="1"] {
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: inset 0 0 6px rgba(239, 68, 68, 0.1);
}
.keycap[data-intensity="2"] {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: inset 0 0 12px rgba(239, 68, 68, 0.25);
  color: hsl(350, 100%, 80%);
}
.keycap[data-intensity="3"] {
  border-color: var(--incorrect);
  background: rgba(239, 68, 68, 0.15);
  box-shadow: inset 0 0 16px rgba(239, 68, 68, 0.4), 0 0 10px rgba(239, 68, 68, 0.1);
  color: hsl(350, 100%, 75%);
  font-weight: 700;
}

/* WPM Canvas Graph Area */
.graph-section {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  
  .graph-title {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 180px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.03);
  overflow: hidden;
  
  canvas {
    display: block;
    width: 100%;
    height: 100%;
  }
}

/* Top-layer Drawer and Modal using <dialog> */

/* Settings Dialog modal (centered) */
dialog.modal-dialog {
  margin: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  color: var(--text-primary);
  outline: none;
  
  /* Animating display/overlay */
  opacity: 0;
  transform: scale(0.92);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.25s;
  transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
  transition-behavior: allow-discrete;
  
  &[open] {
    opacity: 1;
    transform: scale(1);
    
    @starting-style {
      opacity: 0;
      transform: scale(0.92);
    }
  }
  
  &::backdrop {
    background-color: rgba(4, 7, 13, 0);
    transition: display 0.25s allow-discrete, overlay 0.25s allow-discrete, background-color 0.25s ease-out;
  }
  
  &[open]::backdrop {
    background-color: rgba(4, 7, 13, 0.75);
    backdrop-filter: blur(4px);
    
    @starting-style {
      background-color: rgba(4, 7, 13, 0);
    }
  }
}

/* Mistake Vault Side-drawer */
dialog.drawer-dialog {
  margin: 0 0 0 auto; /* Align right */
  height: 100vh;
  max-height: 100vh;
  width: 95%;
  max-width: 440px;
  background: rgba(10, 17, 34, 0.9);
  border: none;
  border-left: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  color: var(--text-primary);
  outline: none;
  padding: 2rem;
  
  /* Animating sliding drawer from right */
  opacity: 0;
  transform: translateX(100%);
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.3s;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
  
  &[open] {
    opacity: 1;
    transform: translateX(0);
    
    @starting-style {
      opacity: 0;
      transform: translateX(100%);
    }
  }
  
  &::backdrop {
    background-color: rgba(4, 7, 13, 0);
    transition: display 0.3s allow-discrete, overlay 0.3s allow-discrete, background-color 0.3s ease-out;
  }
  
  &[open]::backdrop {
    background-color: rgba(4, 7, 13, 0.75);
    backdrop-filter: blur(4px);
    
    @starting-style {
      background-color: rgba(4, 7, 13, 0);
    }
  }
}

/* Dynamic Lesson Node preview box style inside dialog */
.lesson-preview-box {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  
  .l-preview-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }
  
  .l-preview-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    line-height: 1.5;
  }
  
  .l-preview-code {
    display: block;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--primary-accent);
    margin-top: 0.4rem;
    overflow-x: auto;
  }
}

/* RESULTS PAGE OVERLAY SCREEN */
.results-stats-container {
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.res-stat-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  
  .res-lbl {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }
  
  .res-val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    
    span {
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--text-secondary);
    }
  }
}

.results-tips-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid var(--incorrect);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  text-align: left;
}

/* Drawer / Dialog Layout elements */
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  
  h2 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    
    svg {
      color: var(--primary-accent);
    }
  }
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: calc(100% - 70px);
  overflow-y: auto;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  
  .settings-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    
    label {
      font-weight: 600;
      font-size: 1rem;
    }
    
    span {
      font-size: 0.8rem;
      color: var(--text-secondary);
    }
  }
}

/* Switch Toggle Styling */
.switch-control {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  
  input {
    opacity: 0;
    width: 0;
    height: 0;
    
    &:checked + .switch-slider {
      background-color: var(--primary-accent);
      
      &::before {
        transform: translateX(24px);
        background-color: var(--bg-primary);
      }
    }
    
    &:focus-visible + .switch-slider {
      box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
    }
  }
  
  .switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    transition: .3s;
    border-radius: 34px;
    
    &::before {
      position: absolute;
      content: "";
      height: 18px;
      width: 18px;
      left: 3px;
      bottom: 3px;
      background-color: var(--text-secondary);
      transition: .3s;
      border-radius: 50%;
    }
  }
}

/* Vault list rendering drawer inside */
.vault-summary-panel {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  text-align: center;
  
  .summary-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    
    .lbl {
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-secondary);
    }
    
    .val {
      font-size: 1.25rem;
      font-weight: 700;
      color: var(--text-primary);
    }
  }
}

.vault-scroll-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
}

.vault-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-fast);
  
  &:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(0, 242, 254, 0.25);
  }
  
  .word-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    
    .word-text {
      font-family: var(--font-mono);
      font-size: 1.05rem;
      font-weight: 600;
      color: var(--primary-accent);
    }
    
    .word-meta {
      font-size: 0.75rem;
      color: var(--text-muted);
    }
  }
  
  .word-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
  
  /* Streak Lights (3 Lock Indicators) */
  .streak-lights {
    display: flex;
    gap: 0.25rem;
  }
  
  .streak-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
    
    &.filled {
      background: var(--correct);
      box-shadow: 0 0 8px var(--correct);
      border-color: var(--correct);
    }
  }
}

/* Mastered badge visual */
.mastered-badge {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--correct);
  color: var(--correct);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.15);
}

.empty-vault-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  
  svg {
    opacity: 0.3;
    color: var(--text-secondary);
  }
  
  p {
    font-size: 0.95rem;
    line-height: 1.5;
  }
}

/* Global Footer styling */
footer {
  margin-top: auto;
  border-top: 1px solid var(--glass-border);
  padding: 1.5rem 0;
  background-color: rgba(6, 11, 19, 0.4);
  
  .footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    
    a {
      color: var(--text-secondary);
      text-decoration: none;
      transition: var(--transition-fast);
      
      &:hover {
        color: var(--primary-accent);
      }
    }
  }
}

/* Responsive Overrides */
@media (max-width: 992px) {
  .academy-grid {
    grid-template-columns: 1fr;
  }
  
  .main-tabs {
    margin: 0.5rem auto 0;
  }
  
  .header-container {
    flex-direction: column;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  main {
    padding: 1rem;
    gap: 1rem;
  }
  
  .control-panel {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }
  
  .arena-card {
    padding: 1.5rem;
  }
  
  .typing-viewport {
    font-size: 1.2rem;
    min-height: 110px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .keyboard-section {
    display: none; /* Hide virtual keyboard on smaller touch layouts */
  }
  
  .hand-guide-section {
    display: none; /* Hide hand guides on smaller mobile screens */
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .caret {
    animation: caret-blink 1.5s infinite steps(2, start) !important;
    transition: none !important;
  }
  
  dialog {
    transform: none !important;
    transition-duration: 0.1s !important;
  }
  
  @starting-style {
    dialog[open], dialog.drawer-dialog[open] {
      transform: none !important;
    }
  }
}

/* Premium Mascot & Rewards Arena Styling */
.arena-mascot-widget {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--primary-accent);
  animation: tab-fade-in 0.4s ease-out forwards;
}

.arena-mascot-avatar-container {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arena-mascot-speech {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
  font-weight: 500;
  
  strong {
    color: var(--primary-accent);
  }
}

/* Inline reward alert */
.inline-reward-banner {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent);
  border-left: 4px solid var(--correct);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  animation: slide-reward 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slide-reward {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.reward-sparkle {
  font-size: 1.2rem;
  animation: sparkle-glow 1.5s infinite alternate;
}

@keyframes sparkle-glow {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px var(--correct)); }
  100% { transform: scale(1.2); filter: drop-shadow(0 0 8px var(--correct)); }
}

.reward-message {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--correct);
  letter-spacing: 0.02em;
}

/* Dev menu console log styling */
.dev-log-box {
  border: 1px solid rgba(168, 85, 247, 0.25) !important;
  background: #04060b !important;
  font-family: var(--font-mono);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

