/* ============================================================
   TeclaRápida — Design System & Core Styles
   Version: 1.0.0
   ============================================================
   Table of Contents:
   1. Custom Properties (Design Tokens)
   2. Reset & Normalize
   3. Typography Scale
   4. Layout System
   5. Screen System
   6. Navigation
   7. Components
      7a. Buttons
      7b. Cards
      7c. Modals
      7d. Badges
      7e. Progress Bars
      7f. Toasts
      7g. Tooltips
      7h. Toggle Switches
      7i. Select Dropdowns
   8. Home Screen
   9. Settings Screen
   10. Ad Slots
   11. Scrollbar Styling
   12. Selection & Focus
   13. Responsive Breakpoints
   14. Utility Classes
   ============================================================ */

/* ============================================================
   1. CUSTOM PROPERTIES (DESIGN TOKENS)
   ============================================================ */
:root {
  /* — Colors — */
  --color-bg:             #0a0e1a;
  --color-bg-elevated:    #141829;
  --color-surface:        rgba(20, 24, 41, 0.88);
  --color-surface-hover:  rgba(26, 31, 52, 0.95);
  --color-surface-solid:  #1e2340;

  /* — Monkeytype Typing Colors — */
  --color-char-pending:   #4a4d56;
  --color-char-correct:   #e2e8f0;
  --color-char-error:     #e85d6a;
  --color-kbd-key-bg:     #1e2236;
  --color-kbd-key-text:   #ffffff;
  --color-kbd-glow:       #22d3ee;

  --color-primary:        #6366f1;
  --color-primary-light:  #818cf8;
  --color-primary-dark:   #4f46e5;
  --color-secondary:      #a78bfa;

  --color-success:        #10b981;
  --color-success-light:  #34d399;
  --color-error:          #e85d6a;
  --color-error-light:    #fb7185;
  --color-warning:        #f59e0b;
  --color-warning-light:  #fbbf24;
  --color-info:           #22d3ee;

  --color-xp:             #fbbf24;
  --color-gold:           #fbbf24;

  --color-text:           #e8ecf4;
  --color-text-secondary: #a8b2d1;
  --color-text-muted:     #5a6180;
  --color-text-inverse:   #0a0e1a;

  --color-border:         rgba(99, 102, 241, 0.12);
  --color-border-hover:   rgba(99, 102, 241, 0.28);
  --color-border-focus:   rgba(99, 102, 241, 0.50);

  /* — Gradients — */
  --gradient-primary:     linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --gradient-primary-h:   linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c4b5fd 100%);
  --gradient-success:     linear-gradient(135deg, #059669, #10b981, #34d399);
  --gradient-error:       linear-gradient(135deg, #dc2626, #ef4444, #fb7185);
  --gradient-gold:        linear-gradient(135deg, #d97706, #f59e0b, #fbbf24);
  --gradient-bg-radial:   radial-gradient(ellipse at 50% -20%, rgba(99, 102, 241, 0.18) 0%, transparent 55%),
                          radial-gradient(ellipse at 80% 50%, rgba(139, 92, 246, 0.06) 0%, transparent 40%),
                          radial-gradient(ellipse at 20% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 40%);

  /* — Finger Colors — */
  --finger-left-pinky:    #ef4444;
  --finger-left-ring:     #f97316;
  --finger-left-middle:   #eab308;
  --finger-left-index:    #22c55e;
  --finger-right-index:   #06b6d4;
  --finger-right-middle:  #3b82f6;
  --finger-right-ring:    #8b5cf6;
  --finger-right-pinky:   #ec4899;
  --finger-thumb:         #94a3b8;

  /* — Typography — */
  --font-ui:              'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:            'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  --text-xs:    0.75rem;    /* 12px */
  --text-sm:    0.875rem;   /* 14px */
  --text-base:  1rem;       /* 16px */
  --text-lg:    1.125rem;   /* 18px */
  --text-xl:    1.25rem;    /* 20px */
  --text-2xl:   1.5rem;     /* 24px */
  --text-3xl:   1.875rem;   /* 30px */
  --text-4xl:   2.25rem;    /* 36px */
  --text-5xl:   3rem;       /* 48px */

  --leading-tight:   1.25;
  --leading-normal:  1.5;
  --leading-relaxed: 1.625;

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;
  --weight-black:    900;

  /* — Spacing — */
  --space-1:   0.25rem;   /* 4px */
  --space-2:   0.5rem;    /* 8px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-20:  5rem;      /* 80px */

  /* — Border Radius — */
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    18px;
  --radius-2xl:   24px;
  --radius-full:  9999px;

  /* — Shadows — */
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md:    0 4px 8px -1px rgba(0, 0, 0, 0.45), 0 2px 4px -2px rgba(0, 0, 0, 0.35);
  --shadow-lg:    0 12px 24px -4px rgba(0, 0, 0, 0.55), 0 4px 8px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl:    0 24px 48px -8px rgba(0, 0, 0, 0.6), 0 8px 16px -6px rgba(0, 0, 0, 0.45);
  --shadow-glow:  0 0 24px rgba(99, 102, 241, 0.35), 0 0 8px rgba(99, 102, 241, 0.15);
  --shadow-glow-success: 0 0 24px rgba(16, 185, 129, 0.35), 0 0 8px rgba(16, 185, 129, 0.15);
  --shadow-glow-error:   0 0 24px rgba(239, 68, 68, 0.35), 0 0 8px rgba(239, 68, 68, 0.15);
  --shadow-glow-gold:    0 0 24px rgba(245, 158, 11, 0.35), 0 0 8px rgba(245, 158, 11, 0.15);

  /* — Glassmorphism — */
  --glass-bg:       rgba(12, 17, 32, 0.75);
  --glass-blur:     blur(12px);
  --glass-border:   1px solid rgba(99, 102, 241, 0.12);
  --glass-bg-light: rgba(25, 32, 56, 0.55);

  /* — Transitions — */
  --ease-out:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:    cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:  150ms;
  --duration-normal:300ms;
  --duration-slow:  500ms;
  --transition-fast:  150ms;
  --transition-normal:300ms;
  --transition-slow:  500ms;

  /* — Z-Index Scale — */
  --z-base:       1;
  --z-dropdown:   100;
  --z-sticky:     200;
  --z-overlay:    300;
  --z-modal:      400;
  --z-toast:      500;
  --z-tooltip:    600;

  /* — Layout — */
  --nav-height:     64px;
  --nav-width:      72px;
  --content-max:    1200px;
  --content-narrow: 720px;
}


/* ============================================================
   2. RESET & NORMALIZE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  font-size: 16px;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Ambient background glow — multi-layer aurora */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--gradient-bg-radial);
  pointer-events: none;
  z-index: 0;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-primary-light);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
}
a:hover {
  color: var(--color-primary);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  outline: none;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

p {
  color: var(--color-text-secondary);
}

::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}


/* ============================================================
   3. TYPOGRAPHY SCALE
   ============================================================ */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }
.text-4xl   { font-size: var(--text-4xl); }
.text-5xl   { font-size: var(--text-5xl); }

.font-mono  { font-family: var(--font-mono); }
.font-ui    { font-family: var(--font-ui); }

.font-normal   { font-weight: var(--weight-normal); }
.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }
.font-black    { font-weight: var(--weight-black); }

.text-primary   { color: var(--color-primary-light); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted     { color: var(--color-text-muted); }
.text-success   { color: var(--color-success); }
.text-error     { color: var(--color-error); }
.text-warning   { color: var(--color-warning); }
.text-gold      { color: var(--color-gold); }

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }
.uppercase   { text-transform: uppercase; letter-spacing: 0.05em; }


/* ============================================================
   4. LAYOUT SYSTEM
   ============================================================ */
.app-container {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: var(--z-base);
}

.content-wrapper {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--nav-height) + var(--space-6));
}

.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-inline: var(--space-4);
}

.container--narrow {
  max-width: var(--content-narrow);
}

/* Flex utilities */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.flex-row       { flex-direction: row; }
.flex-wrap      { flex-wrap: wrap; }
.flex-1         { flex: 1; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.items-end      { align-items: flex-end; }
.items-stretch  { align-items: stretch; }
.justify-center { justify-content: center; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.justify-start  { justify-content: flex-start; }

.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-5  { gap: var(--space-5); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }

/* Grid utilities */
.grid           { display: grid; }
.grid-cols-1    { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2    { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3    { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4    { grid-template-columns: repeat(4, 1fr); }

/* Spacing utilities */
.m-0   { margin: 0; }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }

.p-2  { padding: var(--space-2); }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }
.px-4 { padding-inline: var(--space-4); }
.py-2 { padding-block: var(--space-2); }
.py-4 { padding-block: var(--space-4); }

.w-full { width: 100%; }
.h-full { height: 100%; }


/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity var(--duration-slow) ease;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  text-align: center;
}

.loading-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
}

.loading-icon {
  font-size: var(--text-4xl);
  animation: breathe 2s ease-in-out infinite;
}

.loading-title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  margin: 0;
}

.loading-bar {
  width: 240px;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.loading-bar-fill {
  height: 100%;
  width: 0;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  animation: loadingProgress 1.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.loading-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  animation: pulseOpacity 1.5s ease-in-out infinite;
}

@keyframes loadingProgress {
  0% { width: 0%; }
  100% { width: 100%; }
}

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


/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  height: 64px;
  background: rgba(12, 16, 29, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: var(--z-sticky);
  transition: margin-left var(--duration-normal) var(--ease-out);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--color-text);
}

.brand-icon {
  font-size: var(--text-xl);
}

.streak-badge, .xp-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-1) var(--space-3);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  transition: all var(--duration-fast) ease;
}

.streak-badge {
  color: var(--color-gold);
}

.xp-badge {
  color: var(--color-primary-light);
}

.header-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--color-text-secondary);
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  transform: translateY(-1px);
}


/* ============================================================
   5. SCREEN SYSTEM
   ============================================================ */
.screen {
  display: none;
  opacity: 0;
  min-height: 100vh;
  width: 100%;
  flex-direction: column;
}

.screen.active {
  display: flex;
  opacity: 1;
  animation: fadeIn var(--duration-normal) var(--ease-out) forwards;
}

/* Screen header common style */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-6);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: linear-gradient(180deg, var(--color-bg) 60%, transparent 100%);
}

.screen-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.screen-header__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  transition: all var(--duration-fast) ease;
}
.screen-header__back:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

.screen-body {
  flex: 1;
  padding: 0 var(--space-4) var(--space-8);
}


/* ============================================================
   6. NAVIGATION
   ============================================================ */

/* Bottom nav — mobile default */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(8, 11, 22, 0.88);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-top: 1px solid rgba(99, 102, 241, 0.08);
  z-index: var(--z-sticky);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Subtle top shine on nav */
.nav-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.2), transparent);
  pointer-events: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  transition: all var(--duration-fast) ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  min-width: 48px;
  cursor: pointer;
}

.nav-item__icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.nav-item__label {
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-item:hover {
  color: var(--color-text-secondary);
}

.nav-item.active {
  color: var(--color-primary-light);
}

.nav-item.active .nav-item__icon {
  transform: scale(1.15);
}

/* Active indicator dot */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.85), 0 0 18px rgba(99, 102, 241, 0.45);
}

/* Notification badge on nav items */
.nav-item .nav-badge {
  position: absolute;
  top: 2px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-error);
  color: white;
  font-size: 0.6rem;
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}


/* ============================================================
   7. COMPONENTS
   ============================================================ */

/* ---- 7a. Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  line-height: 1.2;
}

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

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}
.btn:active::after {
  opacity: 1;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md), 0 0 24px rgba(99, 102, 241, 0.2);
  position: relative;
}
.btn-primary:hover {
  background: var(--gradient-primary-h);
  box-shadow: var(--shadow-lg), 0 0 36px rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--color-surface);
  backdrop-filter: var(--glass-blur);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow-success);
}

.btn-danger {
  background: var(--gradient-error);
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow-error);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}


/* ---- 7b. Cards ---- */
.card {
  background: var(--color-surface-solid);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-6);
  transition: all var(--duration-normal) ease;
}

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

.glass-card {
  background: linear-gradient(135deg, rgba(14, 20, 38, 0.82) 0%, rgba(10, 14, 26, 0.78) 100%);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(99, 102, 241, 0.10);
  padding: var(--space-6);
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 40%, rgba(99, 102, 241, 0.02) 100%);
  pointer-events: none;
}

/* Shimmer highlight on top edge */
.glass-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
}

.glass-card:hover {
  border-color: rgba(99, 102, 241, 0.22);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.06);
  transform: translateY(-2px);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}


/* ---- 7c. Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) ease;
  padding: var(--space-4);
}

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

.modal {
  background: var(--color-bg-elevated);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--duration-normal) var(--ease-spring);
  position: relative;
}

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

.modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: all var(--duration-fast) ease;
}
.modal__close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
}

.modal__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
}

.modal__body {
  margin-top: var(--space-4);
  color: var(--color-text-secondary);
}

.modal__actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  justify-content: flex-end;
}


/* ---- 7d. Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  line-height: 1.2;
  white-space: nowrap;
}

.badge--primary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--color-primary-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge--success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge--error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error-light);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge--warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning-light);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge--gold {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge--level {
  background: var(--gradient-primary);
  color: white;
  padding: var(--space-1) var(--space-4);
  font-weight: var(--weight-bold);
  box-shadow: var(--shadow-glow);
}


/* ---- 7e. Progress Bars ---- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: inherit;
  transition: width var(--duration-slow) var(--ease-out);
  position: relative;
}

/* Shine animation on fill */
.progress-bar__fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.progress-bar--success .progress-bar__fill {
  background: var(--gradient-success);
}

.progress-bar--gold .progress-bar__fill {
  background: var(--gradient-gold);
}

.progress-bar--lg {
  height: 12px;
}

.progress-bar--sm {
  height: 4px;
}

/* Circular progress */
.progress-circle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-circle svg {
  transform: rotate(-90deg);
}

.progress-circle__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
}

.progress-circle__fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-linecap: round;
  transition: stroke-dashoffset var(--duration-slow) var(--ease-out);
}

.progress-circle__label {
  position: absolute;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}


/* ---- 7f. Toasts ---- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-elevated);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  animation: bounceIn var(--duration-normal) var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.toast--success::before { background: var(--color-success); }
.toast--error::before   { background: var(--color-error); }
.toast--warning::before { background: var(--color-warning); }
.toast--info::before    { background: var(--color-info); }

.toast__icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
}
.toast--success .toast__icon { color: var(--color-success); }
.toast--error .toast__icon   { color: var(--color-error); }
.toast--warning .toast__icon { color: var(--color-warning); }
.toast--info .toast__icon    { color: var(--color-info); }

.toast__content {
  flex: 1;
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.toast__message {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.toast__close {
  padding: var(--space-1);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.toast__close:hover {
  color: var(--color-text);
}

/* Auto-dismiss progress */
.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--color-primary);
  animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}


/* ---- 7g. Tooltips ---- */
.tooltip {
  position: relative;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-solid);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-fast) ease;
  z-index: var(--z-tooltip);
  pointer-events: none;
}

.tooltip::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--color-surface-solid);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-fast) ease;
  z-index: var(--z-tooltip);
  pointer-events: none;
}

.tooltip:hover::before,
.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.tooltip:hover::after {
  transform: translateX(-50%);
}


/* ---- 7h. Toggle Switches ---- */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  cursor: pointer;
}

.toggle__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.toggle__description {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.toggle__switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle__track {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all var(--duration-fast) ease;
  cursor: pointer;
}

.toggle__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-text-muted);
  transition: all var(--duration-fast) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}

.toggle__switch input:checked + .toggle__track {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.toggle__switch input:checked + .toggle__track::after {
  transform: translateX(20px);
  background: white;
}

.toggle__switch input:focus-visible + .toggle__track {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}


/* ---- 7i. Select Dropdowns ---- */
.select-wrapper {
  position: relative;
  width: 100%;
}

.select {
  width: 100%;
  padding: var(--space-3) var(--space-10) var(--space-3) var(--space-4);
  background: var(--color-surface);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.select:hover {
  border-color: var(--color-border-hover);
}

.select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.select option {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  padding: var(--space-2);
}

.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  font-size: var(--text-sm);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: all var(--duration-fast) ease;
}

.input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}


/* ============================================================
   8. HOME SCREEN
   ============================================================ */
#home-screen .screen-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Hero Section */
.hero {
  text-align: center;
  padding: var(--space-8) 0 var(--space-4);
  position: relative;
}

.hero__logo {
  font-size: var(--text-4xl);
  font-weight: var(--weight-black);
  margin-bottom: var(--space-2);
  position: relative;
  display: inline-block;
}

.hero__logo .text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__tagline {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

/* Streak Counter */
.streak-counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-gold);
}

.streak-counter__icon {
  font-size: var(--text-lg);
  animation: streakFire 1.5s ease-in-out infinite;
}

.streak-counter__days {
  font-weight: var(--weight-bold);
}

/* Stats Summary Row */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
}

.stat-item__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  font-family: var(--font-mono);
  color: var(--color-text);
}

.stat-item__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Quick Action Buttons */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-normal) ease;
}

.quick-action:hover {
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.quick-action__icon {
  font-size: var(--text-3xl);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow);
}

.quick-action--practice .quick-action__icon {
  background: var(--gradient-primary);
}
.quick-action--survival .quick-action__icon {
  background: var(--gradient-error);
  box-shadow: var(--shadow-glow-error);
}
.quick-action--lessons .quick-action__icon {
  background: var(--gradient-success);
  box-shadow: var(--shadow-glow-success);
}
.quick-action--stats .quick-action__icon {
  background: var(--gradient-gold);
  box-shadow: var(--shadow-glow-gold);
}

.quick-action__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.quick-action__sublabel {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: calc(-1 * var(--space-2));
}

/* Daily Challenge Card */
.daily-challenge {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  overflow: hidden;
}

.daily-challenge::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.daily-challenge__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  position: relative;
  z-index: 1;
}

.daily-challenge__badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.daily-challenge__timer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.daily-challenge__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
  position: relative;
  z-index: 1;
}

.daily-challenge__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 1;
}

.daily-challenge__reward {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-gold);
  position: relative;
  z-index: 1;
}


/* ============================================================
   9. SETTINGS SCREEN
   ============================================================ */
.settings-section {
  margin-bottom: var(--space-6);
}

.settings-section__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  padding-left: var(--space-1);
}

.settings-group {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--duration-fast) ease;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.settings-item__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.settings-item__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.settings-item__desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.settings-item .select {
  max-width: 180px;
  flex-shrink: 0;
}

/* Keyboard layout selector */
.keyboard-layout-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
}

.keyboard-layout-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.keyboard-layout-option:hover {
  border-color: var(--color-border-hover);
  background: rgba(255, 255, 255, 0.05);
}

.keyboard-layout-option.active {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.keyboard-layout-option__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.keyboard-layout-option__desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}


/* ============================================================
   10. AD SLOTS
   ============================================================ */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  min-height: 50px;
}

/* Empty state label (hidden when ad loads) */
.ad-slot:empty::after {
  content: '';
  /* No visible placeholder — keep layout space */
}

.ad-banner-top {
  width: 100%;
  min-height: 50px;
  max-height: 90px;
  margin-bottom: var(--space-4);
}

.ad-banner-bottom {
  width: 100%;
  min-height: 50px;
  max-height: 90px;
  margin-top: var(--space-4);
  margin-bottom: calc(var(--nav-height) + var(--space-2));
}

.ad-sidebar {
  display: none; /* Hidden on mobile, shown on desktop */
  width: 160px;
  min-height: 600px;
  flex-shrink: 0;
}

.ad-interstitial {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 10);
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.ad-interstitial.active {
  display: flex;
}

.ad-interstitial__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  cursor: pointer;
  z-index: 1;
}


/* ============================================================
   11. SCROLLBAR STYLING
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}


/* ============================================================
   12. SELECTION & FOCUS
   ============================================================ */
::selection {
  background: rgba(99, 102, 241, 0.3);
  color: var(--color-text);
}

::-moz-selection {
  background: rgba(99, 102, 241, 0.3);
  color: var(--color-text);
}

/* Focus-visible for keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  z-index: 9999;
  font-weight: var(--weight-semibold);
  transition: top var(--duration-fast) ease;
}

.skip-link:focus {
  top: var(--space-4);
}


/* ============================================================
   13. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* --- Tablet (≥768px) --- */
@media (min-width: 768px) {
  .content-wrapper {
    padding: var(--space-6);
    padding-bottom: calc(var(--nav-height) + var(--space-8));
  }

  .hero__logo {
    font-size: var(--text-5xl);
  }

  .stats-summary {
    gap: var(--space-4);
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .grid-cols-2-tablet { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3-tablet { grid-template-columns: repeat(3, 1fr); }

  .keyboard-layout-selector {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal {
    max-width: 520px;
    padding: var(--space-10);
  }

  .toast-container {
    top: var(--space-6);
    right: var(--space-6);
  }
}

/* --- Desktop (≥1024px) --- */
@media (min-width: 1024px) {
  :root {
    --nav-height: 0px;
  }

  .app-container {
    flex-direction: column;
  }

  .content-wrapper {
    padding-bottom: var(--space-8);
    margin-left: var(--nav-width);
  }

  .app-header {
    margin-left: var(--nav-width);
  }

  /* Side navigation on desktop */
  .nav-bar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--nav-width);
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding: var(--space-6) var(--space-2);
    gap: var(--space-1);
    border-top: none;
    border-right: 1px solid var(--color-border);
  }

  .nav-item {
    width: 100%;
    padding: var(--space-3) var(--space-2);
    border-radius: var(--radius-md);
  }

  .nav-item.active::after {
    bottom: auto;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
  }

  /* Show sidebar ad */
  .ad-sidebar {
    display: flex;
  }

  .ad-banner-bottom {
    margin-bottom: 0;
  }

  .grid-cols-2-desktop { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3-desktop { grid-template-columns: repeat(3, 1fr); }
  .grid-cols-4-desktop { grid-template-columns: repeat(4, 1fr); }
}

/* --- Wide (≥1440px) --- */
@media (min-width: 1440px) {
  :root {
    --nav-width: 88px;
  }

  .content-wrapper {
    max-width: 1400px;
  }

  .hero__logo {
    font-size: 3.5rem;
  }
}


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

.hidden     { display: none !important; }
.invisible  { visibility: hidden; }
.visible    { visibility: visible; }

.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

.inset-0  { inset: 0; }
.z-10     { z-index: 10; }
.z-50     { z-index: 50; }

.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.no-select {
  user-select: none;
  -webkit-user-select: none;
}

.pointer-events-none { pointer-events: none; }

.opacity-0   { opacity: 0; }
.opacity-50  { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* Divider */
.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: var(--space-4) 0;
}

/* --- iPad & Tablet Specific Responsiveness --- */
@media (min-width: 768px) and (max-width: 1024px) {
  .game-container {
    max-width: 920px;
    margin: 0 auto;
    padding: var(--space-4);
  }
  .typing-area {
    font-size: 1.65rem;
    min-height: 130px;
    padding: var(--space-5);
  }
  .keyboard-container {
    max-width: 840px;
  }
  .key {
    touch-action: manipulation;
  }
}

/* --- PC Desktop Extra Large Responsiveness --- */
@media (min-width: 1025px) {
  .game-container {
    max-width: 1080px;
    margin: 0 auto;
  }
  .typing-area {
    font-size: 1.9rem;
    min-height: 145px;
    padding: var(--space-6);
  }
}
