/* ═══════════════════════════════════════════
   KASZËBSCZI — Design System
   Kashubian Language Learning App
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Outfit:wght@400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Kashubian Heritage Colors */
  --primary: #1B4B8A;
  --primary-light: #2D6BC4;
  --primary-dark: #0F2D54;
  --accent: #D4A843;
  --accent-light: #F0CC6B;
  --accent-dark: #A87E2A;
  
  /* Traditional Embroidery Colors */
  --kasz-blue-light: #60A5FA;
  --kasz-blue-mid: #3B82F6;
  --kasz-blue-dark: #1E3A8A;
  --kasz-yellow: #FBBF24;
  --kasz-red: #EF4444;
  --kasz-green: #22C55E;

  /* Semantic Colors */
  --success: #22C55E;
  --success-bg: rgba(34,197,94,0.12);
  --error: #EF4444;
  --error-bg: rgba(239,68,68,0.12);
  --warning: #F59E0B;
  --info: #3B82F6;
  --xp-color: #A855F7;

  /* Dark Theme (default) */
  --bg-primary: #0A0F1C;
  --bg-secondary: #111827;
  --bg-card: #1A2235;
  --bg-card-hover: #1F2A40;
  --bg-glass: rgba(26,34,53,0.75);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', -apple-system, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(27,75,138,0.3);
  --shadow-accent: 0 0 20px rgba(212,168,67,0.2);

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

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated gradient background */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(27,75,138,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(212,168,67,0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Duże, dedykowane motywy kaszubskie dla poszczególnych podstron */
.view::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-repeat: repeat;
  background-position: center;
  background-size: 400px;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.5s var(--ease-out);
}

/* Nauka: Motyw żółto-niebieski */
#view-learn::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cpath d='M50 90 Q70 50 50 10 Q30 50 50 90' fill='%23FBBF24' /%3E%3Cpath d='M50 90 Q85 60 95 30 Q65 40 50 90' fill='%2360A5FA' /%3E%3Cpath d='M50 90 Q15 60 5 30 Q35 40 50 90' fill='%2360A5FA' /%3E%3C/svg%3E");
}

/* Gramatyka: Motyw czerwono-zielony */
#view-grammar::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='15' fill='%23EF4444' /%3E%3Cpath d='M50 50 Q75 25 100 50 Q75 75 50 50' fill='%2322C55E' /%3E%3Cpath d='M50 50 Q25 25 0 50 Q25 75 50 50' fill='%2322C55E' /%3E%3Cpath d='M50 50 Q75 75 50 100 Q25 75 50 50' fill='%231E3A8A' /%3E%3Cpath d='M50 50 Q75 25 50 0 Q25 25 50 50' fill='%231E3A8A' /%3E%3C/svg%3E");
}

/* Słownik: Motyw klasycznej niebieskiej róży */
#view-dictionary::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cpath d='M50 80 Q60 50 50 30 Q40 50 50 80' fill='%233B82F6' /%3E%3Cpath d='M50 80 Q75 60 85 40 Q65 45 50 80' fill='%231E3A8A' /%3E%3Cpath d='M50 80 Q25 60 15 40 Q35 45 50 80' fill='%231E3A8A' /%3E%3Ccircle cx='50' cy='80' r='6' fill='%2322C55E' /%3E%3C/svg%3E");
}

/* Fiszki: Motyw palmetki wielokolorowej */
#view-flashcards::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 100 100'%3E%3Cpath d='M50 70 Q70 40 50 20 Q30 40 50 70' fill='%23EF4444' /%3E%3Cpath d='M50 70 Q80 50 90 25 Q65 35 50 70' fill='%23FBBF24' /%3E%3Cpath d='M50 70 Q20 50 10 25 Q35 35 50 70' fill='%23FBBF24' /%3E%3C/svg%3E");
}

/* Remus: Motyw morski (bałtycki) */
#view-reader::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cpath d='M0 50 Q25 20 50 50 T100 50 Q75 80 50 50 T0 50' fill='none' stroke='%233B82F6' stroke-width='4' /%3E%3Ccircle cx='50' cy='50' r='8' fill='%23D4A843' /%3E%3C/svg%3E");
}

/* Material Symbols Adjustments */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}
.material-symbols-rounded.icon-fill {
  font-variation-settings: 'FILL' 1;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

.font-display { font-family: var(--font-display); }
.text-gradient {
  background: linear-gradient(135deg, var(--accent-light), var(--accent), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Layout ── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ── Glass Card ── */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 8px 32px rgba(0,0,0,0.2);
  transition: all var(--duration-normal) var(--ease-out);
}

.glass-card:hover {
  border-color: var(--border-hover);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 12px 40px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

/* ── Header / Navbar ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: var(--space-md) 0;
  background: rgba(10,15,28,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  box-shadow: var(--shadow-glow);
}

.logo-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(212,168,67,0.3));
}

.logo-text {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-family: var(--font-display);
  background: linear-gradient(135deg, #fff, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-stats {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: rgba(26,34,53,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.stat-badge .icon { font-size: 1.1rem; }

.stat-badge.streak { color: #FB923C; }
.stat-badge.xp { color: var(--xp-color); }
.stat-badge.gems { color: #38BDF8; }

/* ── Main Navigation Tabs ── */
.nav-container {
  padding: var(--space-md) 0;
}

.main-nav {
  display: flex;
  gap: var(--space-xs);
  padding: 0;
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: auto;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}
.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.nav-tab .material-symbols-rounded {
  font-size: 1.6rem;
  transition: transform var(--duration-normal) var(--ease-spring);
}

.nav-tab:hover .material-symbols-rounded {
  transform: translateY(-2px);
  color: var(--primary-light);
}

.nav-tab:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

/* ── Lesson Tree / Season Grid ── */
.seasons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
}

.season-card {
  padding: var(--space-lg);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.season-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--primary-light), var(--accent));
  border-radius: 4px 0 0 4px;
}

.season-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.season-number {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.season-title-csb {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.season-title-pl {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.season-meta {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.cefr-badge {
  padding: 2px 10px;
  background: rgba(27,75,138,0.2);
  color: var(--primary-light);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.lesson-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  margin-top: var(--space-md);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

/* ── Lesson View (Quiz) ── */
.lesson-screen {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-md);
}

.lesson-progress {
  display: flex;
  gap: 3px;
  margin-bottom: var(--space-2xl);
}

.lesson-progress-segment {
  flex: 1;
  height: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.lesson-progress-segment.completed {
  background: var(--success);
}

.lesson-progress-segment.current {
  background: linear-gradient(90deg, var(--success) 50%, var(--bg-card) 50%);
  animation: pulseProgress 2s ease infinite;
}

@keyframes pulseProgress {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.question-card {
  text-align: center;
  padding: var(--space-2xl);
}

.question-prompt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.question-word {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: var(--space-sm);
  font-family: var(--font-display);
}

.question-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: var(--space-2xl);
}

/* Answer options */
.answer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.answer-btn {
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.answer-btn:hover {
  border-color: var(--primary-light);
  background: var(--bg-card-hover);
  transform: scale(1.02);
}

.answer-btn.correct {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
  animation: correctPop 0.4s var(--ease-spring);
}

.answer-btn.incorrect {
  border-color: var(--error);
  background: var(--error-bg);
  color: var(--error);
  animation: shake 0.4s ease;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ── Dictionary ── */
.search-container {
  position: relative;
  margin-bottom: var(--space-lg);
}

.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  padding-left: 48px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  outline: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
}

.dict-entry {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  transition: background var(--duration-fast);
}

.dict-entry:hover {
  background: var(--bg-card-hover);
}

.dict-word-csb {
  font-weight: 700;
  font-size: 1.05rem;
}

.dict-word-pl {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.dict-pos {
  padding: 2px 8px;
  background: rgba(168,126,42,0.15);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.2), 0 4px 16px rgba(27,75,138,0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.3), 0 8px 24px rgba(27,75,138,0.6);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  background: rgba(26,34,53,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-full);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.btn-primary .material-symbols-rounded,
.btn-secondary .material-symbols-rounded {
  font-size: 1.35rem;
}

.btn-secondary:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(31,42,64,0.7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 4px 12px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}

/* ── XP Popup Animation ── */
.xp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 2rem;
  font-weight: 800;
  color: var(--xp-color);
  pointer-events: none;
  z-index: 200;
  text-shadow: 0 0 20px rgba(168,85,247,0.5);
}

.xp-popup.show {
  animation: xpBurst 1s var(--ease-spring) forwards;
}

@keyframes xpBurst {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50% { transform: translate(-50%, -80%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

/* ── Welcome / Hero ── */
.hero-section {
  text-align: center;
  padding: var(--space-3xl) var(--space-md);
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  margin-bottom: var(--space-md);
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto var(--space-2xl);
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Category Pills ── */
.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
}

.category-pill {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.category-pill:hover,
.category-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary-light);
}

/* ── Flashcard ── */
.flashcard {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 3/2;
  margin: var(--space-xl) auto;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s var(--ease-out);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
}

.flashcard-front {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow-lg);
}

.flashcard-back {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  transform: rotateY(180deg);
  color: var(--bg-primary);
}

.flashcard-word {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-display);
}

.flashcard-label {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Interactive Elements (No tap delay) ── */
a, button, .nav-tab, .season-card, .glass-card, .flashcard, .category-pill, .answer-btn, .quiz-option {
  touch-action: manipulation;
}

/* ── Responsive ── */

/* ── TABLET ── */
@media (max-width: 768px) {
  :root {
    --space-xl: 20px;
    --space-2xl: 32px;
    --space-3xl: 40px;
  }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.1rem; }

  .seasons-grid { grid-template-columns: 1fr; }
  .answer-options { grid-template-columns: 1fr; }

  /* Header — bardziej zwięzły */
  .app-header { padding: 8px 0; }
  .header-inner { padding: 0 var(--space-sm); }

  .logo-img { width: 32px; height: 32px; }
  .logo-text { font-size: 1.15rem; }

  .nav-stats { gap: 6px; }
  .stat-badge {
    padding: 3px 8px;
    font-size: 0.72rem;
    gap: 3px;
  }
  .stat-badge .icon { font-size: 0.85rem; }

  /* Dolny pasek nawigacji */
  .main-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: rgba(10, 15, 28, 0.97) !important;
    z-index: 2147483647 !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    padding: 4px 0 env(safe-area-inset-bottom, 4px) 0;
    justify-content: flex-start;
    border-top: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.6);
    margin: 0;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    gap: 0;
  }
  .main-nav::-webkit-scrollbar { display: none; }

  .nav-tab {
    flex-direction: column;
    gap: 1px;
    padding: 6px 10px;
    font-size: 0.65rem;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    min-width: 56px;
    flex-shrink: 0;
    text-align: center;
  }

  .nav-tab.active {
    background: transparent;
    color: var(--primary-light);
    box-shadow: none;
    border-bottom: 2px solid var(--primary-light);
    border-radius: 0;
  }

  .nav-tab .material-symbols-rounded {
    font-size: 1.3rem;
  }

  .nav-tab span:last-child {
    display: block;
    line-height: 1.1;
  }

  /* Treść strony — marginesy na górze i dole */
  body {
    padding-bottom: 72px !important;
  }

  /* Karty */
  .season-card { padding: var(--space-md); }
  .glass-card { padding: var(--space-md); }
  .season-title-csb { font-size: 1.15rem; }

  /* Fiszki */
  .flashcard { max-width: 320px; }
  .flashcard-word { font-size: 1.8rem; }

  /* Hero sekcja */
  .hero-section { padding: var(--space-xl) var(--space-sm); }
  .hero-title { font-size: 1.6rem; }
  .hero-subtitle { font-size: 0.95rem; }

  /* Quiz opcje */
  .quiz-option { padding: 12px; font-size: 0.9rem; }

  /* Widoki — padding bottom */
  .view { padding-bottom: 80px !important; }
}

/* ── MAŁE TELEFONY (do 480px) ── */
@media (max-width: 480px) {
  :root {
    --space-xl: 16px;
    --space-2xl: 24px;
    --space-3xl: 32px;
  }

  html { font-size: 14px; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }

  /* Header jeszcze kompaktniejszy */
  .app-header { padding: 6px 0; }
  .logo-img { width: 28px; height: 28px; }
  .logo-text { font-size: 1rem; }
  
  .stat-badge {
    padding: 2px 6px;
    font-size: 0.68rem;
  }
  .stat-badge .icon { display: none; }

  /* Nawigacja mobilna — jeszcze mniejsze ikony */
  .nav-tab {
    padding: 5px 8px;
    font-size: 0.58rem;
    min-width: 48px;
  }
  .nav-tab .material-symbols-rounded { font-size: 1.15rem; }

  /* Treść */
  .app-container { padding: 0 var(--space-sm); }

  .hero-section { padding: var(--space-lg) var(--space-xs); }
  .hero-title { font-size: 1.4rem; }
  .hero-subtitle { font-size: 0.85rem; }

  .season-number { width: 36px; height: 36px; font-size: 1rem; }
  .season-title-csb { font-size: 1rem; }
  .season-title-pl { font-size: 0.75rem; }

  .btn-primary, .btn-secondary {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .question-word { font-size: 1.8rem; }
  .answer-btn { padding: 12px; font-size: 0.9rem; }

  .flashcard { max-width: 280px; }
  .flashcard-word { font-size: 1.5rem; }

  /* Mała przerwa pod nawigacją */
  body { padding-bottom: 64px !important; }

  /* Sekcja Daily Challenge */
  #daily-challenge { margin-bottom: var(--space-sm); }

  /* Profil */
  #view-profile .glass-card { padding: var(--space-sm); }
}

/* ── BARDZO MAŁE TELEFONY (do 360px) ── */
@media (max-width: 360px) {
  html { font-size: 13px; }
  
  .nav-tab {
    padding: 4px 6px;
    font-size: 0.52rem;
    min-width: 42px;
  }
  .nav-tab .material-symbols-rounded { font-size: 1rem; }

  .logo-text { font-size: 0.9rem; }
  .stat-badge { padding: 2px 4px; font-size: 0.6rem; }
  
  .question-word { font-size: 1.5rem; }
}

/* ── Scroll animations ── */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--duration-slow) var(--ease-out);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── View switching ── */
.view { display: none; }
.view.active { display: block; }

/* ── Name Modal ── */
#name-modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease;
}

.name-modal {
  width: 90%;
  max-width: 420px;
  padding: var(--space-2xl);
  text-align: center;
  animation: modalSlideUp 0.5s var(--ease-spring);
}

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

/* ── Docs view code blocks ── */
#view-docs code {
  background: rgba(212,168,67,0.12);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
}

@keyframes pulseLoader {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; filter: drop-shadow(0 0 20px rgba(212,168,67,0.5)); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ── Quiz Styles ── */
.quiz-option {
  text-align: left;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  background: rgba(255,255,255,0.02);
  color: var(--text-primary);
  width: 100%;
}

.quiz-option:hover:not(.disabled) {
  background: rgba(255,255,255,0.08);
  transform: translateX(4px);
  border-color: rgba(255,255,255,0.2);
}

.quiz-option.disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.quiz-option.correct {
  border-color: var(--success) !important;
  color: var(--success) !important;
  background: rgba(34,197,94,0.1) !important;
}

.quiz-option.wrong {
  border-color: var(--error) !important;
  color: var(--error) !important;
  background: rgba(239,68,68,0.1) !important;
}

.quiz-feedback.correct {
  color: var(--success);
  background: rgba(34,197,94,0.1);
}

.quiz-feedback.wrong {
  color: var(--error);
  background: rgba(239,68,68,0.1);
}

/* ── Karaoke TTS Highlight ── */
.remus-word.karaoke-active {
  color: var(--accent-light) !important;
  background: rgba(212,168,67,0.2);
  border-bottom-color: var(--accent) !important;
  border-bottom-width: 2px;
  border-bottom-style: solid;
  border-radius: 3px;
  padding: 1px 4px;
  animation: karaokeGlow 0.6s ease-in-out infinite alternate;
  transition: all 0.15s ease-out;
}

@keyframes karaokeGlow {
  from {
    text-shadow: 0 0 4px rgba(212,168,67,0.3);
    box-shadow: 0 0 6px rgba(212,168,67,0.15);
  }
  to {
    text-shadow: 0 0 12px rgba(212,168,67,0.6);
    box-shadow: 0 0 16px rgba(212,168,67,0.3);
  }
}

/* ── TTS Speaker Button Active State ── */
.btn-tts-active {
  animation: ttsSpeak 0.4s ease-in-out infinite alternate;
}

@keyframes ttsSpeak {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

/* ── Name Modal (First Visit) ── */
#name-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,15,28,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeIn 0.4s ease;
}

#name-modal-overlay .name-modal {
  max-width: 420px;
  width: 90%;
  padding: var(--space-2xl);
  text-align: center;
  animation: modalSlideUp 0.5s var(--ease-spring);
}




