/* ============================================
   Arabic Tajweed Learning App - Main Styles
   Islamic-inspired design with warm gold & emerald
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Noto+Nastaliq+Urdu&family=Inter:wght@300;400;500;600;700&family=Scheherazade+New:wght@400;700&display=swap');

/* ======= CSS Variables ======= */
:root {
  --gold: #C9A84C;
  --gold-light: #E8C97A;
  --gold-dark: #9B7A2E;
  --emerald: #1B6B3A;
  --emerald-light: #2E9958;
  --emerald-pale: #EAF5EE;
  --deep-teal: #0D3B2E;
  --parchment: #FDF6E3;
  --parchment-dark: #F5E9C5;
  --ink: #1A1209;
  --ink-light: #4A3728;
  --ruby: #8B1A1A;
  --ruby-light: #C0392B;
  --lapis: #1A3A6B;
  --lapis-light: #2E6DA4;
  --white: #FFFFFF;
  --shadow-sm: 0 2px 8px rgba(26, 18, 9, 0.10);
  --shadow-md: 0 4px 16px rgba(26, 18, 9, 0.15);
  --shadow-lg: 0 8px 32px rgba(26, 18, 9, 0.20);
  --border-radius: 12px;
  --border-radius-lg: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======= Dark mode: re-maps the palette so the whole UI follows ======= */
[data-theme="dark"] {
  --parchment: #1A1A2E;
  --parchment-dark: #2A2A45;
  --ink: #ECECF0;
  --ink-light: #B0B0C0;
  --white: #24243A;
  --emerald-pale: #1E3A2C;
  --gold-light: #E8C97A;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] body { background: #14141F; }

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--parchment);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ======= Arabic Text ======= */
.arabic {
  font-family: 'Scheherazade New', 'Amiri', serif;
  direction: rtl;
  unicode-bidi: embed;
}

.arabic-large {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.8;
  letter-spacing: 0.05em;
}

.arabic-medium {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  line-height: 1.8;
}

.arabic-small {
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  line-height: 1.8;
}

/* ======= Header / Navigation ======= */
#app-header {
  background: linear-gradient(135deg, var(--deep-teal) 0%, var(--emerald) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  border-bottom: 3px solid var(--gold);
}

.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  gap: 0.75rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-bismillah {
  font-family: 'Scheherazade New', serif;
  font-size: 1.8rem;
  color: var(--gold-light);
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.logo-text {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.logo-subtitle {
  font-size: 0.7rem;
  color: var(--gold-light);
  letter-spacing: 0.3px;
}

/* ======= Navigation Tabs ======= */
#nav-hamburger {
  display: none; /* hidden on desktop; shown via media query on tablet/mobile */
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(201,168,76,0.4);
  color: var(--white);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
#nav-hamburger .hamburger-icon { font-size: 1.1rem; line-height: 1; }
#nav-hamburger:active { background: rgba(255,255,255,0.2); }

#main-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex: 1;
  justify-content: center;
  align-items: center;
  scroll-padding-inline: 1rem;
}

#main-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0.5rem 0.85rem;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  border-radius: 8px;
  transition: var(--transition);
  white-space: nowrap;
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  gap: 0.4rem;
  position: relative;
}

.nav-tab .tab-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.nav-tab .tab-arabic {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  color: rgba(255,255,255,0.92);
  opacity: 1;
}

.nav-tab:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

.nav-tab.active {
  background: var(--gold);
  color: var(--deep-teal);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.4);
}

.nav-tab.active .tab-arabic {
  color: var(--deep-teal);
  opacity: 1;
}

/* ======= Nav Dropdown Menus (grouping basics & tajweed tabs) ======= */
.nav-dropdown {
  position: relative;
  flex-shrink: 0;
}

.nav-dropdown-trigger {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
}

.nav-dropdown-trigger .tab-arabic {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
}

.nav-dropdown-caret {
  font-size: 0.6rem;
  color: var(--gold-light);
  transition: transform 0.2s ease;
}

.nav-dropdown.open .nav-dropdown-caret {
  transform: rotate(180deg);
}

.nav-dropdown.open .nav-dropdown-trigger {
  background: rgba(255,255,255,0.12);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--deep-teal);
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  min-width: 190px;
  z-index: 200;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
  animation: fadeIn 0.18s ease;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: start;
  width: 100%;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.nav-dropdown-item .tab-icon { font-size: 1.05rem; line-height: 1; flex-shrink: 0; }

.nav-dropdown-item .tab-arabic {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: inherit;
  opacity: 1;
}

.nav-dropdown-item:hover {
  background: rgba(201,168,76,0.2);
}

.nav-dropdown-item.active {
  background: var(--gold);
  color: var(--deep-teal);
}

@media (max-width: 480px) {
  .nav-dropdown-menu { min-width: 150px; }
  .nav-dropdown-item { font-size: 0.78rem; padding: 0.45rem 0.6rem; }
}

/* ======= Progress Bar ======= */
#progress-bar-container {
  background: rgba(0,0,0,0.2);
  height: 4px;
}

#progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  width: 0%;
  transition: width 0.6s ease;
  box-shadow: 0 0 8px var(--gold);
}

/* ======= Main Container ======= */
#app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ======= Section Pages ======= */
.section-page {
  display: none;
  animation: fadeIn 0.4s ease;
}

.section-page.active {
  display: block;
}

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

/* ======= Section Hero ======= */
.section-hero {
  background: linear-gradient(135deg, var(--deep-teal) 0%, var(--emerald) 60%, var(--emerald-light) 100%);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  color: var(--white);
  position: relative;
  overflow: hidden;
  border: 2px solid var(--gold);
}

.section-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(201,168,76,0.08) 0%, transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.05) 0%, transparent 40%);
}

.section-hero::after {
  content: attr(data-pattern);
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Scheherazade New', serif;
  font-size: 8rem;
  color: rgba(201,168,76,0.08);
  line-height: 1;
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  background: var(--gold);
  color: var(--deep-teal);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.hero-title-arabic {
  font-family: 'Scheherazade New', serif;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  color: var(--gold-light);
  line-height: 1.3;
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.hero-title-en {
  font-size: 1.1rem;
  font-weight: 300;
  color: rgba(255,255,255,0.8);
  margin-bottom: 1rem;
  letter-spacing: 1px;
}

.hero-desc {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.75);
  max-width: 500px;
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero-stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
}

.hero-stat-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ======= Tab Content within sections ======= */
.section-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--parchment-dark);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-tab-btn {
  padding: 0.6rem 1.2rem;
  border: none;
  background: none;
  color: var(--ink-light);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-tab-btn:hover {
  color: var(--emerald);
}

.section-tab-btn.active {
  color: var(--emerald);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

.section-content {
  display: none;
}

.section-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ======= Rule Cards ======= */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.rule-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--gold);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.rule-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0) 100%);
  transition: var(--transition);
}

.rule-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.rule-symbol {
  font-family: 'Scheherazade New', serif;
  font-size: 2.5rem;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  display: block;
}

.rule-name-ar {
  font-family: 'Scheherazade New', serif;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.15rem;
  direction: rtl;
}

.rule-name-en {
  font-size: 0.75rem;
  color: var(--ink-light);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.rule-sound {
  display: inline-block;
  background: var(--parchment);
  color: var(--emerald);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.rule-example {
  font-family: 'Scheherazade New', serif;
  font-size: 1.5rem;
  color: var(--ink);
  direction: rtl;
  margin-bottom: 0.2rem;
}

.rule-example-en {
  font-size: 0.75rem;
  color: var(--ink-light);
  font-style: italic;
}

/* ======= Word Practice Grid ======= */
.practice-area {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.practice-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  border: 2px solid var(--parchment-dark);
  background: none;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  color: var(--ink-light);
  font-weight: 500;
}

.filter-pill.active, .filter-pill:hover {
  background: var(--emerald);
  color: var(--white);
  border-color: var(--emerald);
}

.words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.word-card {
  background: var(--parchment);
  border-radius: var(--border-radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  position: relative;
}

.word-card:hover {
  border-color: var(--gold);
  background: var(--parchment-dark);
  transform: scale(1.02);
}

.word-card.mastered {
  border-color: var(--emerald);
  background: var(--emerald-pale);
}

.word-card .word-arabic {
  font-family: 'Scheherazade New', serif;
  font-size: 1.8rem;
  color: var(--ink);
  line-height: 1.6;
  direction: rtl;
  display: block;
}

.word-card .word-trans {
  font-size: 0.7rem;
  color: var(--emerald);
  font-style: italic;
  margin: 0.2rem 0;
}

.word-card .word-meaning {
  font-size: 0.7rem;
  color: var(--ink-light);
  font-weight: 500;
}

.word-card .word-type-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.word-card.mastered .word-type-badge {
  background: var(--emerald);
}

/* ======= Quran Verse Display ======= */
.quran-box {
  background: linear-gradient(135deg, var(--deep-teal), #0F4A37);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  margin-bottom: 1rem;
  color: var(--white);
  border: 2px solid var(--gold-dark);
  position: relative;
  overflow: hidden;
}

.quran-box::before {
  content: '﴿';
  position: absolute;
  left: 10px;
  top: 10px;
  font-family: 'Scheherazade New', serif;
  font-size: 5rem;
  color: rgba(201,168,76,0.1);
  line-height: 1;
}

.quran-box::after {
  content: '﴾';
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-family: 'Scheherazade New', serif;
  font-size: 5rem;
  color: rgba(201,168,76,0.1);
  line-height: 1;
}

.quran-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.7rem;
  color: var(--gold-light);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.quran-label::before {
  content: '🌙';
  font-size: 0.9rem;
}

.quran-arabic-text {
  font-family: 'Scheherazade New', serif;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  color: var(--gold-light);
  direction: rtl;
  text-align: center;
  line-height: 2;
  margin-bottom: 1rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.quran-transliteration {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  text-align: center;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.quran-translation {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.9);
  text-align: center;
  font-weight: 500;
}

.quran-surah {
  display: inline-block;
  background: var(--gold);
  color: var(--deep-teal);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  margin-top: 0.75rem;
}

.quran-highlight-box {
  background: rgba(201,168,76,0.15);
  border-left: 3px solid var(--gold);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.8rem;
  color: var(--gold-light);
}

/* ======= Quiz Section ======= */
.quiz-container {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--parchment-dark);
}

.quiz-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.quiz-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--parchment-dark);
  border-radius: 4px;
  margin: 0 1rem;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald), var(--emerald-light));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.quiz-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-light);
  white-space: nowrap;
}

.quiz-question-card {
  background: var(--parchment);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.quiz-question-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 0;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 500px) {
  .quiz-options {
    grid-template-columns: 1fr;
  }
}

.quiz-option {
  padding: 0.85rem 1rem;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--border-radius);
  background: var(--white);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  font-weight: 500;
  line-height: 1.4;
}

.quiz-option:hover {
  border-color: var(--gold);
  background: var(--parchment);
}

.quiz-option.correct {
  border-color: var(--emerald);
  background: var(--emerald-pale);
  color: var(--emerald);
}

.quiz-option.incorrect {
  border-color: var(--ruby-light);
  background: #FEE;
  color: var(--ruby-light);
}

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

.quiz-feedback {
  background: var(--parchment);
  border-radius: var(--border-radius);
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  border-left: 4px solid var(--gold);
  display: none;
}

.quiz-feedback.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

.quiz-feedback.correct-fb {
  border-left-color: var(--emerald);
  color: var(--emerald);
  background: var(--emerald-pale);
}

.quiz-feedback.wrong-fb {
  border-left-color: var(--ruby-light);
  color: var(--ruby-light);
  background: #FEF2F2;
}

.quiz-nav-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ======= Score Display ======= */
.score-display {
  text-align: center;
  padding: 2rem;
  animation: fadeIn 0.5s ease;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  border: 6px solid var(--gold);
  background: var(--parchment);
  box-shadow: 0 0 0 12px var(--parchment-dark);
}

.score-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--emerald);
  line-height: 1;
}

.score-total {
  font-size: 0.8rem;
  color: var(--ink-light);
}

.score-message {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.score-arabic-msg {
  font-family: 'Scheherazade New', serif;
  font-size: 1.8rem;
  color: var(--gold-dark);
  direction: rtl;
  margin-bottom: 1.5rem;
}

/* ======= Buttons ======= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--emerald);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--emerald-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(27,107,58,0.3);
}

.btn-gold {
  background: var(--gold);
  color: var(--deep-teal);
}

.btn-gold:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(201,168,76,0.4);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--parchment-dark);
  color: var(--ink-light);
}

.btn-outline:hover {
  border-color: var(--emerald);
  color: var(--emerald);
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ======= Audio Button ======= */
.audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: var(--deep-teal);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.audio-btn:hover {
  background: var(--gold-light);
  transform: scale(1.1);
}

/* ======= Accordion for Tajweed Rules ======= */
.accordion-item {
  background: var(--white);
  border-radius: var(--border-radius);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--parchment-dark);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  background: var(--white);
  border: none;
  width: 100%;
  text-align: left;
  font-family: 'Inter', sans-serif;
}

.accordion-header:hover {
  background: var(--parchment);
}

.accordion-header.open {
  background: var(--deep-teal);
  color: var(--white);
}

.accordion-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.accordion-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--deep-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.accordion-header.open .accordion-number {
  background: var(--gold-light);
}

.accordion-title-ar {
  font-family: 'Scheherazade New', serif;
  font-size: 1.2rem;
  direction: rtl;
  color: var(--ink);
}

.accordion-header.open .accordion-title-ar {
  color: var(--gold-light);
}

.accordion-title-en {
  font-size: 0.8rem;
  color: var(--ink-light);
}

.accordion-header.open .accordion-title-en {
  color: rgba(255,255,255,0.7);
}

.accordion-arrow {
  font-size: 0.9rem;
  transition: transform 0.3s ease;
  color: var(--gold-dark);
}

.accordion-header.open .accordion-arrow {
  transform: rotate(180deg);
  color: var(--gold-light);
}

.accordion-body {
  display: none;
  padding: 1.25rem;
  border-top: 1px solid var(--parchment-dark);
  animation: fadeIn 0.3s ease;
}

.accordion-body.open {
  display: block;
}

/* ======= Rule Explanation ======= */
.rule-explanation {
  font-size: 0.9rem;
  color: var(--ink-light);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.examples-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.example-chip {
  background: var(--parchment);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--parchment-dark);
}

.example-chip .chip-arabic {
  font-family: 'Scheherazade New', serif;
  font-size: 1.4rem;
  direction: rtl;
  color: var(--ink);
}

.example-chip .chip-trans {
  font-size: 0.65rem;
  color: var(--emerald);
  font-style: italic;
}

.example-chip .chip-meaning {
  font-size: 0.65rem;
  color: var(--ink-light);
}

/* ======= Flashcard Mode ======= */
.flashcard-container {
  perspective: 1000px;
  margin: 0 auto;
  max-width: 400px;
}

.flashcard {
  width: 100%;
  min-height: 200px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

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

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--gold);
  min-height: 200px;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--deep-teal);
  color: var(--white);
}

.flashcard-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.flashcard-count {
  font-size: 0.85rem;
  color: var(--ink-light);
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

/* ======= Matching Game ======= */
.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.match-col { display: flex; flex-direction: column; gap: 0.5rem; }

.match-item {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--parchment-dark);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  background: var(--white);
  text-align: center;
  font-weight: 500;
}

.match-item.arabic-item {
  font-family: 'Scheherazade New', serif;
  font-size: 1.6rem;
  direction: rtl;
  line-height: 1.6;
}

.match-item:hover { border-color: var(--gold); background: var(--parchment); }
.match-item.selected { border-color: var(--lapis-light); background: #EFF6FF; }
.match-item.matched { border-color: var(--emerald); background: var(--emerald-pale); cursor: default; }
.match-item.wrong { border-color: var(--ruby-light); background: #FEF2F2; animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ======= Home Page ======= */
#home-page {
  display: block;
}

.home-hero {
  background: linear-gradient(160deg, var(--deep-teal) 0%, #0D3B2E 40%, #1A5C42 100%);
  border-radius: var(--border-radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--white);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--gold-dark);
}

.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23C9A84C' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.home-bismillah {
  font-family: 'Scheherazade New', serif;
  font-size: clamp(2.5rem, 6vw, 5rem);
  color: var(--gold-light);
  line-height: 1.6;
  margin-bottom: 1rem;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  position: relative;
}

.home-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--white);
  margin-bottom: 0.5rem;
  position: relative;
}

.home-subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 2rem;
  position: relative;
}

.home-cta-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.module-card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border-bottom: 4px solid var(--gold);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-bottom-color: var(--emerald);
}

.module-icon {
  font-size: 2rem;
  line-height: 1;
}

.module-title-ar {
  font-family: 'Scheherazade New', serif;
  font-size: 1.5rem;
  color: var(--gold-dark);
  direction: rtl;
}

.module-title-en {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.module-desc {
  font-size: 0.8rem;
  color: var(--ink-light);
  line-height: 1.5;
}

.module-stats {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--parchment-dark);
}

.module-stat {
  font-size: 0.7rem;
  color: var(--ink-light);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.module-stat strong {
  color: var(--emerald);
  font-size: 0.8rem;
}

/* ======= Final Exam ======= */
.exam-hero {
  background: linear-gradient(135deg, var(--ruby) 0%, #A93226 100%);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  text-align: center;
  color: var(--white);
  margin-bottom: 2rem;
  border: 2px solid var(--gold-dark);
}

.exam-hero-arabic {
  font-family: 'Scheherazade New', serif;
  font-size: 2.5rem;
  color: var(--gold-light);
  margin-bottom: 0.5rem;
}

/* ======= Word Modal ======= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  border-top: 6px solid var(--gold);
  animation: slideUp 0.3s ease;
  position: relative;
}

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

.modal-close {
  position: sticky;
  float: right;
  top: -0.5rem;
  margin: -0.5rem -0.5rem 0 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--parchment-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--ink-light);
  transition: var(--transition);
  z-index: 2;
}

.modal-close:hover {
  background: var(--ruby-light);
  color: var(--white);
}

.modal-word-arabic {
  font-family: 'Scheherazade New', serif;
  font-size: 3.5rem;
  color: var(--ink);
  direction: rtl;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.modal-word-trans {
  text-align: center;
  font-size: 0.85rem;
  color: var(--emerald);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.modal-word-meaning {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal-focus {
  background: var(--parchment);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-light);
  border-left: 3px solid var(--gold);
  margin-bottom: 1.25rem;
}

.modal-mark-btn {
  width: 100%;
}

/* ======= Tajweed Reference Diagram ======= */
.diagram-box {
  background: var(--parchment);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--parchment-dark);
  text-align: center;
}

.diagram-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

/* ======= Toast Notification ======= */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 1000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--emerald); }
.toast.error { background: var(--ruby-light); }
.toast.info { background: var(--lapis); }

/* ======= Responsive ======= */
/* ===== Tablet & narrow desktop: collapse the whole nav into ONE dropdown ===== */
@media (max-width: 900px) {
  #nav-hamburger { display: inline-flex; }

  /* The nav becomes a full vertical dropdown panel, hidden until opened */
  #main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0.15rem;
    overflow-x: visible;
    overflow-y: auto;
    max-height: calc(100vh - 70px);
    background: var(--deep-teal);
    border-top: 2px solid var(--gold);
    box-shadow: var(--shadow-lg);
    padding: 0.6rem;
    z-index: 300;
  }

  #main-nav.mobile-open { display: flex; }

  /* Make each top-level tab a full-width row inside the dropdown */
  #main-nav > .nav-tab,
  #main-nav > .nav-dropdown {
    width: 100%;
    flex-shrink: 0;
  }

  #main-nav > .nav-tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    min-width: 0;
  }
  #main-nav > .nav-tab .tab-arabic { font-size: 1rem; opacity: 1; }

  /* Sub-dropdowns (basics/tajweed/mushaf) expand inline, not as floating menus */
  #main-nav .nav-dropdown { position: static; }
  #main-nav .nav-dropdown-trigger {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
  }
  #main-nav .nav-dropdown-menu {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100%;
    min-width: 0;
    box-shadow: none;
    border: none;
    background: rgba(0,0,0,0.18);
    border-radius: 8px;
    margin: 0.15rem 0 0.3rem;
    padding: 0.25rem;
  }
  #main-nav .nav-dropdown-item {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
  #main-nav .nav-dropdown-caret { margin-right: auto; }

  /* App header needs relative positioning so the absolute nav anchors to it */
  #app-header { position: sticky; top: 0; }
  /* Single compact row: logo (left) · stats+toggles · hamburger (right).
     No wrapping, so the header stays short and doesn't eat the screen. */
  .header-inner {
    position: relative;
    flex-wrap: nowrap;
    gap: 0.4rem;
    min-height: 56px;
    padding: 0 0.75rem;
  }
  .header-inner .logo-area { order: 1; flex-shrink: 0; }
  #engagement-widget-slot {
    order: 2;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
    display: flex;
    align-items: center;
    min-width: 0;
  }
  #engagement-widget-slot::-webkit-scrollbar { display: none; }
  #nav-hamburger { order: 3; flex-shrink: 0; padding: 0.45rem 0.6rem; }
  #nav-hamburger .hamburger-label { display: none; } /* icon only on mobile to save space */
  #main-nav { order: 4; }
  /* Shrink the logo bismillah a touch on mobile */
  .logo-bismillah { font-size: 1.4rem; }
}

@media (max-width: 768px) {
  .header-inner { padding: 0 1rem; }
  #app-main { padding: 1rem; }
  .section-hero { padding: 1.5rem 1rem; }
  .rules-grid { grid-template-columns: 1fr 1fr; }
  .words-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .modules-grid { grid-template-columns: 1fr; }
  .quiz-options { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .logo-text { display: none; }
  .rules-grid { grid-template-columns: 1fr; }
  .nav-tab .tab-icon { font-size: 1rem; }
  .nav-tab { min-width: 52px; padding: 0.4rem 0.5rem; }
  .home-hero { padding: 2rem 1rem; }
}

/* ======= Utility ======= */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Highlight different types */
.hl-fatha { color: #E74C3C; font-weight: bold; }
.hl-kasra { color: #3498DB; font-weight: bold; }
.hl-damma { color: #27AE60; font-weight: bold; }
.hl-sukoon { color: #8E44AD; font-weight: bold; }
.hl-shadda { color: #C0392B; font-weight: bold; }
.hl-gold { color: var(--gold-dark); font-weight: bold; }

/* Stars rating */
.stars {
  color: var(--gold);
  font-size: 1.2rem;
  letter-spacing: 2px;
}

/* ======= Loading Spinner ======= */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--parchment-dark);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--parchment-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* Print */
@media print {
  #app-header { position: relative; }
  .no-print { display: none; }
}

/* ============================================
   WhatsApp Floating Enrollment Button
   ============================================ */
.whatsapp-float {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #25D366;
  color: white;
  padding: 0.8rem 1.2rem;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37,211,102,0.4), 0 2px 6px rgba(0,0,0,0.15);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
  animation: whatsappPulse 2.5s ease-in-out infinite;
  border: 2px solid rgba(255,255,255,0.3);
}

.whatsapp-float:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 8px 24px rgba(37,211,102,0.5);
  animation-play-state: paused;
}

.whatsapp-float .wa-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.whatsapp-float .wa-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.whatsapp-float .wa-text small {
  font-size: 0.65rem;
  opacity: 0.85;
  font-weight: 400;
}

@keyframes whatsappPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(37,211,102,0.4), 0 0 0 0 rgba(37,211,102,0.5); }
  50% { box-shadow: 0 4px 16px rgba(37,211,102,0.4), 0 0 0 10px rgba(37,211,102,0); }
}

@media (max-width: 600px) {
  .whatsapp-float { bottom: 1rem; left: 1rem; padding: 0.65rem 0.9rem; }
  .whatsapp-float .wa-text { display: none; }
}

/* Enrollment banner card (used on home page) */
.enroll-banner {
  background: linear-gradient(135deg, #1FA855 0%, #128C42 100%);
  border-radius: var(--border-radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
  border: 2px solid #0F7A3A;
  position: relative;
  overflow: hidden;
}

.enroll-banner::before {
  content: '💬';
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 6rem;
  opacity: 0.08;
  transform: rotate(15deg);
}

.enroll-banner-text h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.enroll-banner-text p {
  font-size: 0.82rem;
  opacity: 0.9;
  max-width: 420px;
}

.enroll-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  color: #128C42;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.enroll-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

.enroll-btn svg { width: 22px; height: 22px; }

/* ============================================
   Games Hub & Game Cards (ayakids-style playful UI)
   ============================================ */
.games-hero {
  background: linear-gradient(160deg, #FF6B9D 0%, #C44569 50%, #845EC2 100%);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  color: white;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  border: 3px solid #FFD93D;
}

.games-hero::before {
  content: '🎮 🎯 🌟 🎨 🎲';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  font-size: 2.5rem;
  opacity: 0.12;
  pointer-events: none;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.game-card {
  background: white;
  border-radius: 24px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.game-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.4), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.game-card:hover {
  transform: translateY(-8px) scale(1.03) rotate(-1deg);
  box-shadow: 0 16px 32px rgba(0,0,0,0.15);
}

.game-card:hover::after { opacity: 1; }

.game-card:nth-child(1) { border-color: #FF6B9D; }
.game-card:nth-child(2) { border-color: #4ECDC4; }
.game-card:nth-child(3) { border-color: #FFD93D; }
.game-card:nth-child(4) { border-color: #845EC2; }
.game-card:nth-child(5) { border-color: #FF9F43; }
.game-card:nth-child(6) { border-color: #54A0FF; }

.game-card-icon {
  font-size: 3rem;
  margin-bottom: 0.6rem;
  display: inline-block;
  animation: gameIconBounce 2s ease-in-out infinite;
}

@keyframes gameIconBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(5deg); }
}

.game-card-title-ar {
  font-family: 'Scheherazade New', serif;
  font-size: 1.3rem;
  color: var(--ink);
  direction: rtl;
  margin-bottom: 0.2rem;
}

.game-card-title-en {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-light);
  margin-bottom: 0.5rem;
}

.game-card-desc {
  font-size: 0.75rem;
  color: var(--ink-light);
  line-height: 1.5;
}

.game-card-play {
  display: inline-block;
  margin-top: 0.75rem;
  background: var(--gold);
  color: var(--deep-teal);
  padding: 0.4rem 1.1rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Game container (shown when a game is active) */
.game-stage {
  background: linear-gradient(160deg, #FFF8E7 0%, #FFFFFF 100%);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border: 3px solid var(--gold);
  position: relative;
  min-height: 400px;
}

.game-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.game-back-btn {
  background: var(--parchment-dark);
  border: none;
  border-radius: 50px;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  transition: var(--transition);
}

.game-back-btn:hover { background: var(--gold); color: white; }

.game-score-badge {
  background: var(--deep-teal);
  color: white;
  padding: 0.5rem 1.1rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Letter Catch Game (falling letters) */
.catch-game-zone {
  position: relative;
  height: 380px;
  background: linear-gradient(180deg, #E3F2FD 0%, #BBDEFB 100%);
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid #90CAF9;
}

.falling-letter {
  position: absolute;
  font-family: 'Scheherazade New', serif;
  font-size: 3.6rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.falling-letter:hover { transform: scale(1.2); }

.falling-letter.popped {
  animation: popOut 0.4s ease forwards;
  pointer-events: none;
}

@keyframes popOut {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.8; }
  100% { transform: scale(0); opacity: 0; }
}

.catch-target-banner {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 50px;
  padding: 0.5rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Spinning Wheel Game */
.wheel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.wheel-wrapper {
  position: relative;
  width: 280px;
  height: 280px;
}

.spin-wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 3s cubic-bezier(0.17, 0.67, 0.12, 0.99);
  box-shadow: 0 0 0 8px white, 0 0 0 12px var(--gold), 0 8px 24px rgba(0,0,0,0.25);
}

.wheel-pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 28px solid var(--ruby);
  z-index: 10;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

/* Memory Match Game */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  max-width: 460px;
  margin: 0 auto;
}

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

.memory-card {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-family: 'Scheherazade New', serif;
  color: white;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-style: preserve-3d;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  position: relative;
}

.memory-card.flipped {
  background: white;
  color: var(--ink);
  transform: rotateY(180deg);
  border: 2px solid var(--emerald);
}

.memory-card.matched {
  background: var(--emerald-pale);
  color: var(--emerald);
  border: 2px solid var(--emerald);
  cursor: default;
  animation: matchedPulse 0.5s ease;
}

@keyframes matchedPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.memory-card .card-inner {
  transform: rotateY(180deg);
}

.memory-card:not(.flipped):not(.matched) .card-inner { display: none; }
.memory-card:not(.flipped):not(.matched)::before { content: '❓'; }

/* Sound Bubble Pop Game */
.bubble-field {
  position: relative;
  height: 400px;
  background: linear-gradient(180deg, #B2EBF2 0%, #4DD0E1 100%);
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid #00ACC1;
}

.sound-bubble {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(255,255,255,0.2) 60%, rgba(255,255,255,0.05));
  border: 2px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Scheherazade New', serif;
  font-size: 2.4rem;
  color: var(--deep-teal);
  cursor: pointer;
  animation: bubbleFloat linear infinite;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1), inset 0 0 20px rgba(255,255,255,0.5);
}

@keyframes bubbleFloat {
  0% { transform: translateY(0) translateX(0); }
  25% { transform: translateY(-15px) translateX(8px); }
  50% { transform: translateY(-5px) translateX(-8px); }
  75% { transform: translateY(-20px) translateX(5px); }
  100% { transform: translateY(0) translateX(0); }
}

.sound-bubble.bubble-popped {
  animation: bubblePop 0.4s ease forwards !important;
  pointer-events: none;
}

@keyframes bubblePop {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Drag & Drop Sorting Game */
.sort-game-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sort-tray {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 70px;
  padding: 1rem;
  background: var(--parchment);
  border-radius: 12px;
  border: 2px dashed var(--parchment-dark);
}

.sort-item {
  background: white;
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-family: 'Scheherazade New', serif;
  font-size: 2.1rem;
  cursor: grab;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  user-select: none;
}

.sort-item:active { cursor: grabbing; }
.sort-item.dragging { opacity: 0.4; transform: scale(0.9); }

.sort-bins {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.sort-bin {
  min-height: 120px;
  background: white;
  border: 3px dashed var(--parchment-dark);
  border-radius: 16px;
  padding: 1rem;
  text-align: center;
  transition: var(--transition);
}

.sort-bin.drag-over {
  border-color: var(--emerald);
  background: var(--emerald-pale);
  transform: scale(1.02);
}

.sort-bin-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-bottom: 0.5rem;
}

.sort-bin-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

/* Confetti celebration */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -20px;
  z-index: 2000;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Game feedback popup */
.game-feedback-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: white;
  border-radius: 24px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  z-index: 1500;
  border: 4px solid var(--gold);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-feedback-popup.show {
  transform: translate(-50%, -50%) scale(1);
}

.game-feedback-popup .gf-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

.game-feedback-popup .gf-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

/* Animated mascot character */
.mascot {
  font-size: 3rem;
  display: inline-block;
  animation: mascotWiggle 3s ease-in-out infinite;
}

@keyframes mascotWiggle {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-8deg) translateY(-3px); }
  75% { transform: rotate(8deg) translateY(-3px); }
}

/* ============================================
   Engagement Widget (Streak / XP / Level) - header pills
   ============================================ */
/* Header right cluster: engagement pills + language + theme + install,
   all aligned in a single tidy row that never wraps. */
#engagement-widget-slot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.engagement-widget {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.eng-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 20px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: var(--transition);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.eng-pill:hover {
  background: rgba(255,255,255,0.18);
  transform: scale(1.05);
}

.eng-pill-icon { font-size: 0.9rem; line-height: 1; }

.streak-pill .eng-pill-value { color: #FF8A65; }
.xp-pill .eng-pill-value { color: var(--gold-light); }
.level-pill .eng-pill-value { color: #81C784; }

/* Combined compact stat box — three stats in one pill to save header space */
.eng-combined {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 20px;
  padding: 0.32rem 0.7rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}
.eng-combined:hover { background: rgba(255,255,255,0.18); }
.eng-combined-item { display: inline-flex; align-items: center; gap: 0.25rem; }
.eng-combined-sep { width: 1px; height: 14px; background: rgba(255,255,255,0.25); }
.eng-combined .streak-val { color: #FF8A65; }
.eng-combined .xp-val { color: var(--gold-light); }
.eng-combined .level-val { color: #81C784; }

/* Header settings dropdown (theme, language, install, shortcuts) */
.header-settings { position: relative; flex-shrink: 0; margin-left: 0.4rem; }
.header-settings-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(201,168,76,0.4);
  color: #fff; border-radius: 8px;
  padding: 0.4rem 0.6rem; cursor: pointer;
  font-size: 1rem; line-height: 1; flex-shrink: 0;
  transition: var(--transition);
}
.header-settings-btn:hover { background: rgba(255,255,255,0.22); }
.header-settings-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--white); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  border: 1px solid var(--parchment-dark);
  min-width: 200px; padding: 0.4rem;
  display: none; flex-direction: column; gap: 0.15rem;
  z-index: 1200;
}
.header-settings-menu.open { display: flex; }
.hs-item {
  display: flex; align-items: center; gap: 0.6rem;
  background: none; border: none; width: 100%;
  text-align: left; padding: 0.6rem 0.7rem;
  border-radius: 8px; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 0.85rem;
  font-weight: 600; color: var(--ink); transition: background 0.15s;
}
.hs-item:hover { background: var(--parchment); }
.hs-item span { font-size: 1.1rem; }

@media (max-width: 700px) {
  .eng-pill { padding: 0.25rem 0.5rem; font-size: 0.7rem; }
  .eng-pill-icon { font-size: 0.8rem; }
  .eng-combined { padding: 0.28rem 0.55rem; font-size: 0.7rem; gap: 0.4rem; }
}

@media (max-width: 480px) {
  .engagement-widget { gap: 0.25rem; }
  .eng-combined { gap: 0.32rem; padding: 0.25rem 0.5rem; }
  .eng-combined-sep { height: 12px; }
}

/* ============================================
   Spaced Repetition status indicators on word cards
   ============================================ */
.word-card .srs-indicator {
  position: absolute;
  bottom: 0.4rem;
  right: 0.4rem;
  font-size: 0.65rem;
  background: var(--white);
  border-radius: 8px;
  padding: 0.1rem 0.35rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.srs-new { color: var(--lapis); }
.srs-learning { color: var(--gold-dark); }
.srs-due { color: var(--ruby-light); }
.srs-mastered { color: var(--emerald); }

/* ============================================
   Tajweed Color-Coded Mushaf Legend & Highlighted Text
   ============================================ */
.mushaf-text {
  font-family: 'Scheherazade New', serif;
  direction: rtl;
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  line-height: 2.2;
  text-align: center;
}

.tw-ghunnah { color: #E74C3C; font-weight: bold; }
.tw-qalqala { color: #F39C12; font-weight: bold; }
.tw-madd { color: #3498DB; font-weight: bold; }
.tw-ikhfa { color: #9B59B6; font-weight: bold; }
.tw-idgham { color: #27AE60; font-weight: bold; }
.tw-iqlab { color: #E67E22; font-weight: bold; }
.tw-qalb { color: #1ABC9C; font-weight: bold; }
.tw-lam-shamsiya { color: #C0392B; text-decoration: line-through; opacity: 0.5; }

.mushaf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.mushaf-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--parchment);
  border-radius: 20px;
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.mushaf-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   Reduced Motion Support (Accessibility)
   ============================================ */
@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;
  }
  .mascot, .game-card-icon, .home-bismillah {
    animation: none !important;
  }
}

/* ============================================
   Button press feedback (micro-interaction)
   ============================================ */
.btn:active, .nav-tab:active, .game-card:active, .word-card:active {
  transform: scale(0.97);
}

.btn, .nav-tab, .filter-pill, .quiz-option {
  transition: transform 120ms ease-out, background-color 150ms ease-out, box-shadow 150ms ease-out, border-color 150ms ease-out;
}

/* Skeleton loading shimmer (for perceived performance) */
.skeleton {
  background: linear-gradient(90deg, var(--parchment) 25%, var(--parchment-dark) 50%, var(--parchment) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--parchment-dark); }
}

/* ============================================
   New Games (Part 10): Tracing / Fishing / Builder / Balloons
   ============================================ */
.builder-slot.drag-over {
  border-color: var(--emerald) !important;
  background: var(--emerald-pale) !important;
  transform: scale(1.08);
}

.builder-letter {
  transition: visibility 0s, transform 0.2s ease;
}

#trace-canvas {
  touch-action: none;
}

@keyframes balloonPopFx {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Make sure dynamically injected fish/balloons don't overflow game zones */
.bubble-field, .catch-game-zone {
  position: relative;
  overflow: hidden;
}

/* Tooltip entrance animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Whiteboard studio fullscreen: make tools compact and let the canvas fill */
#whiteboard-studio:fullscreen,
#whiteboard-studio:-webkit-full-screen {
  background: var(--white);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#whiteboard-studio:fullscreen #wb-toolbar,
#whiteboard-studio:-webkit-full-screen #wb-toolbar {
  flex-shrink: 0;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
}
#whiteboard-studio:fullscreen canvas,
#whiteboard-studio:-webkit-full-screen canvas {
  flex: 1;
  height: auto !important;
  min-height: 0;
}

/* ============================================
   Embedded interactive Tajweed lessons (iframe)
   ============================================ */
#tajweedlessons-page { padding: 0; }
.tajweed-lessons-frame-wrap { width: 100%; }
.tajweed-lessons-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 72px);
  height: calc(100dvh - 72px);
  min-height: 560px;
  border: 0;
  border-radius: 8px;
  background: #f6efe0;
}

/* ============================================
   Floating Streak/XP/Level panel — right side
   (widget moved out of the header)
   ============================================ */
.eng-float {
  position: fixed;
  right: 8px;
  top: 64%;
  transform: translateY(-50%);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}
.eng-float-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--deep-teal, #0D3B2E);
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  transition: transform 0.15s, opacity 0.2s;
  opacity: 0.65; /* subtle until needed */
}
.eng-float.open .eng-float-toggle,
.eng-float-toggle:hover,
.eng-float-toggle:focus-visible { opacity: 1; }
.eng-float-toggle:hover { transform: scale(1.08); }
.eng-float-panel { display: none; }
.eng-float.open .eng-float-panel {
  display: flex;
  background: var(--deep-teal, #0D3B2E);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 0.5rem 0.55rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: engFloatIn 0.18s ease;
}
@keyframes engFloatIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
/* Stack the three pills vertically inside the panel */
.eng-float .engagement-widget { flex-direction: column; align-items: stretch; }
.eng-float .eng-combined {
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.35rem 0.4rem;
}
.eng-float .eng-combined-sep { width: 100%; height: 1px; }
@media (max-width: 640px) {
  .eng-float { right: 6px; }
  .eng-float-toggle { width: 36px; height: 36px; font-size: 1rem; }
}
/* Keep it clear of modal overlays */
.modal-overlay, #book-reader-overlay { z-index: 2000; }

/* ============================================
   Whiteboard: compact toolbar + big canvas + slide-in Tools panel
   (layout modeled on Microsoft Whiteboard / ViewSonic: canvas fills
   the space, secondary tools live in a floating panel off the board)
   ============================================ */
#whiteboard-studio {
  position: relative;
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 0.6rem;
  box-shadow: var(--shadow-sm);
}
#wb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  background: var(--deep-teal, #0D3B2E);
  border-radius: 12px;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.5rem;
}
.wb-tb-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.35rem;
  border-inline-end: 1px solid rgba(255,255,255,0.15);
}
.wb-tb-group:last-child { border-inline-end: none; }
.wb-tb-group.wb-colors { gap: 0.25rem; flex-wrap: wrap; max-width: 240px; }
.wb-tb-right { margin-inline-start: auto; border-inline-end: none; }
.wb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.wb-icon-btn:hover { background: rgba(255,255,255,0.2); transform: translateY(-1px); }
.wb-icon-btn.active { background: var(--gold); border-color: var(--gold-light); }
.wb-icon-btn.wb-save { background: var(--gold); }
.wb-tools-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--gold);
  color: #1A1209;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.wb-tools-btn:hover { filter: brightness(1.05); }
#wb-toolbar select { background: rgba(255,255,255,0.95); }
#wb-toolbar input[type=range] { accent-color: var(--gold); }

/* Stage: the canvas fills nearly the whole viewport height */
#wb-stage {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid var(--gold);
  background: #fff;
  touch-action: none;
}
#wb-canvas {
  display: block;
  width: 100%;
  height: clamp(600px, 74vh, 940px);
  cursor: crosshair;
}
#wb-notes-layer { position: absolute; inset: 0; pointer-events: none; }
#wb-pending-hint {
  display: none;
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  background: var(--emerald);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  pointer-events: none;
  z-index: 5;
}
#wb-pending-hint.show { display: block; }

/* Slide-in Tools panel + backdrop */
#wb-tools-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 20;
  border-radius: var(--border-radius-lg);
}
#wb-tools-backdrop.open { display: block; }
#wb-tools-panel {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: min(340px, 88%);
  background: var(--parchment, #FBF6E9);
  box-shadow: -8px 0 24px rgba(0,0,0,0.18);
  border-inline-start: 2px solid var(--gold);
  border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
  transform: translateX(102%);
  transition: transform 0.22s ease;
  z-index: 21;
  display: flex;
  flex-direction: column;
}
#wb-tools-panel.open { transform: translateX(0); }
.wb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  background: var(--deep-teal, #0D3B2E);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 0 var(--border-radius-lg) 0 0;
}
.wb-panel-head .wb-icon-btn { width: 30px; height: 30px; font-size: 0.9rem; }
.wb-panel-body { padding: 0.7rem; overflow-y: auto; flex: 1; }
.wb-panel-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--white); border: 1px solid var(--parchment-dark);
  border-radius: 8px; padding: 0.4rem 0.7rem; font-size: 0.74rem; cursor: pointer;
}
.wb-panel-btn.active, .wb-icon-btn.active { background: var(--gold); }

/* Collapsible tool groups inside the panel */
.wb-group {
  border: 1px solid var(--parchment-dark);
  border-radius: 10px;
  margin-bottom: 0.55rem;
  background: var(--white);
  overflow: hidden;
}
.wb-group > summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--deep-teal, #0D3B2E);
  padding: 0.55rem 0.7rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}
.wb-group > summary::-webkit-details-marker { display: none; }
.wb-group > summary::after {
  content: '▾';
  margin-inline-start: auto;
  color: var(--ink-light);
  transition: transform 0.15s;
}
.wb-group[open] > summary::after { transform: rotate(180deg); }
.wb-group .wb-group-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0 0.7rem 0.6rem;
}

/* Fullscreen: studio fills the screen, canvas grows, toolbar stays on top */
#whiteboard-studio:fullscreen,
#whiteboard-studio:-webkit-full-screen {
  overflow: hidden;
  background: var(--white, #fff);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
}
#whiteboard-studio:fullscreen #wb-stage,
#whiteboard-studio:-webkit-full-screen #wb-stage { flex: 1; }
#whiteboard-studio:fullscreen #wb-canvas,
#whiteboard-studio:-webkit-full-screen #wb-canvas { height: 100%; }
#whiteboard-studio:fullscreen > p,
#whiteboard-studio:-webkit-full-screen > p { display: none; }

/* Mobile: toolbar scrolls horizontally instead of stacking tall */
@media (max-width: 640px) {
  #wb-toolbar { flex-wrap: nowrap; overflow-x: auto; }
  .wb-tb-group.wb-colors { max-width: none; flex-wrap: nowrap; }
  #wb-canvas { height: clamp(440px, 62vh, 700px); }
  .wb-tools-btn span { display: none; }
}

/* ===== Navbar "Sections" menu — auto-collapse when links don't fit =====
   The horizontal nav was clipping its items at laptop widths (centered
   overflow with a hidden scrollbar). Instead of guessing a pixel width, a
   tiny script (in index.html) measures whether the links actually overflow
   and adds .nav-compact to .header-inner. When compact, the horizontal links
   are hidden and the الأقسام button reveals ALL sections as a clean drawer.
   The phone hamburger (<=900px) is untouched. */
#nav-more {
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(201,168,76,0.5);
  color: var(--white);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}
#nav-more .hamburger-icon { font-size: 1.05rem; line-height: 1; }
#nav-more:hover { background: rgba(255,255,255,0.22); }
#nav-more:active { transform: scale(0.97); }

/* Only above the phone breakpoint; <=900px keeps the existing hamburger. */
@media (min-width: 901px) {
  .header-inner { position: relative; }

  /* Compact mode: show الأقسام button, hide the horizontal strip. */
  .header-inner.nav-compact #nav-more { display: inline-flex; order: 3; }
  .header-inner.nav-compact #main-nav {
    order: 4;
    display: none;
    position: absolute;
    top: 100%;
    inset-inline: 0;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0.15rem;
    overflow-x: visible;
    overflow-y: auto;
    max-height: calc(100vh - 74px);
    background: var(--deep-teal);
    border-top: 2px solid var(--gold);
    box-shadow: var(--shadow-lg);
    padding: 0.6rem;
    z-index: 300;
  }
  .header-inner.nav-compact #main-nav.mobile-open { display: flex; }

  .header-inner.nav-compact #main-nav > .nav-tab,
  .header-inner.nav-compact #main-nav > .nav-dropdown { width: 100%; flex-shrink: 0; }
  .header-inner.nav-compact #main-nav > .nav-tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    min-width: 0;
  }
  .header-inner.nav-compact #main-nav > .nav-tab .tab-arabic { font-size: 1rem; opacity: 1; }

  .header-inner.nav-compact #main-nav .nav-dropdown { position: static; width: 100%; }
  .header-inner.nav-compact #main-nav .nav-dropdown-trigger {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
  }
  .header-inner.nav-compact #main-nav .nav-dropdown-menu {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100%;
    min-width: 0;
    box-shadow: none;
    border: none;
    background: rgba(0,0,0,0.18);
    border-radius: 8px;
    margin: 0.15rem 0 0.35rem;
    padding: 0.25rem;
  }
  .header-inner.nav-compact #main-nav .nav-dropdown-item { padding: 0.6rem 1.2rem; font-size: 0.9rem; }
  .header-inner.nav-compact #main-nav .nav-dropdown-caret { margin-inline-start: auto; }
}

/* ===== Header space reclaim (v100) =====
   The nav was borderline-fitting (~1040px needed vs ~1060px free), so it kept
   collapsing into the Menu button. Basmallah removed from the navbar markup and
   the logo/links tightened to free ~90px, so the full nav fits on laptops. */
.logo-area { gap: 0.5rem; }
.logo-mark { display: block; flex-shrink: 0; }
.logo-title { font-size: 1rem; letter-spacing: 0.2px; }

/* Slightly tighter nav items = more links fit before compact mode kicks in. */
#main-nav { gap: 0.3rem; }
#main-nav > .nav-tab,
#main-nav .nav-dropdown-trigger { padding-inline: 0.6rem; }
.nav-dropdown-caret { margin-inline-start: 0.15rem; }

/* Keep the header from spreading items apart; nav gets the space instead. */
.header-inner { justify-content: flex-start; padding: 0 1rem; gap: 0.6rem; }
.header-inner > .logo-area { margin-inline-end: 0.15rem; }

/* In compact mode push the Menu button to the far end. */
.header-inner.nav-compact #nav-more { margin-inline-start: auto; }
