/* ==========================================================================
   Dragon Masters Reading & Audiobook Tracker
   Child-friendly, accessible, clean, responsive styling
   ========================================================================== */

:root {
  /* Core Fantasy Palette */
  --color-brand-primary: #ff6b35;
  --color-brand-secondary: #2ec4b6;
  --color-brand-accent: #ffbf69;
  
  --color-bg: #f8fafc;
  --color-bg-alt: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-hover: #f8fafc;
  
  --color-text-main: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  
  /* Feature specific */
  --color-read: #10b981;
  --color-read-light: #d1fae5;
  --color-read-dark: #047857;
  
  --color-listened: #8b5cf6;
  --color-listened-light: #ede9fe;
  --color-listened-dark: #6d28d9;
  
  --color-gold: #f59e0b;
  --color-gold-light: #fef3c7;
  --color-gold-glow: rgba(245, 158, 11, 0.4);

  --font-heading: 'Fredoka', 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 16px 36px rgba(0, 0, 0, 0.12);
  
  --transition-fast: 0.15s ease;
  --transition-bounce: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Parchment / Castle Theme Option */
[data-theme="parchment"] {
  --color-bg: #faf6ee;
  --color-bg-alt: #f3ecd8;
  --color-surface: #fffdf9;
  --color-surface-hover: #fdf8eb;
  --color-text-main: #3d2f1f;
  --color-text-muted: #79664f;
  --color-border: #e5d8be;
}

/* Bedtime / Dark Mode Option */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-alt: #1e293b;
  --color-surface: #1e293b;
  --color-surface-hover: #334155;
  --color-text-main: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
}

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

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

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* Utility layout */
.app-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  flex: 1;
}

/* ==========================================================================
   Header & Hero Section
   ========================================================================== */

.site-header {
  position: relative;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

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

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  color: #9a3412;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid #fbd38d;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-main);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all var(--transition-bounce);
}

.icon-btn:hover {
  transform: scale(1.1);
  border-color: var(--color-brand-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Account Switcher Bar & Profile Chips
   ========================================================================== */

.account-switch-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.08), rgba(46, 196, 182, 0.08));
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.85rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

[data-theme="dark"] .account-switch-bar {
  background: rgba(30, 41, 59, 0.7);
  border-color: #475569;
}

.account-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-text-main);
  user-select: none;
}

.account-dragon-icon {
  font-size: 1.25rem;
  animation: gentle-pulse 2.5s infinite;
}

.account-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem 0.3rem 0.35rem;
  border-radius: var(--radius-full);
  border: 2.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-main);
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  transition: all var(--transition-bounce);
  user-select: none;
  position: relative;
}

.account-chip:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: var(--color-brand-primary);
  box-shadow: var(--shadow-sm);
}

.account-chip.active {
  border-color: #ff6b35;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  box-shadow: 0 4px 14px rgba(255, 107, 53, 0.25);
  transform: scale(1.05);
  color: #9a3412;
}

[data-theme="dark"] .account-chip.active {
  background: linear-gradient(135deg, #431407, #7c2d12);
  color: #ffedd5;
  border-color: #ea580c;
}

.account-chip-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid #2e7d32;
}

.account-chip.active .account-chip-avatar {
  border-color: #ea580c;
  box-shadow: 0 0 8px rgba(234, 88, 12, 0.5);
}

.account-chip-name {
  font-weight: 800;
}

.account-chip-rank {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  font-weight: 700;
}

.account-chip.active .account-chip-rank {
  background: #ea580c;
  color: white;
}

.account-chip.add-chip {
  border-style: dashed;
  color: var(--color-brand-primary);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  background: transparent;
}

.account-chip.add-chip:hover {
  background: var(--color-surface);
  border-color: var(--color-brand-primary);
}

/* Avatar edit button on hero avatar */
.avatar-change-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-bounce);
  z-index: 2;
}

.avatar-change-btn:hover {
  transform: scale(1.2) rotate(15deg);
  border-color: var(--color-brand-primary);
  box-shadow: var(--shadow-md);
}

.hero-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.user-avatar {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  border: 4px solid #48bb78;
  object-fit: cover;
  box-shadow: 0 0 20px rgba(72, 187, 120, 0.35);
  animation: gentle-pulse 3s infinite ease-in-out;
}

@keyframes gentle-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.avatar-rank-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #f59e0b;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.hero-text {
  flex: 1;
  min-width: 250px;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--color-text-main);
  line-height: 1.2;
}

.name-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-brand-primary);
  font-size: 1.1rem;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  transition: transform var(--transition-bounce);
}

.name-edit-btn:hover {
  transform: scale(1.2) rotate(10deg);
}

.hero-tagline {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  margin-top: 0.25rem;
}

.hero-banner-image {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-top: 1.25rem;
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Progress & Stats Dashboard
   ========================================================================== */

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

.stat-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform var(--transition-bounce), box-shadow var(--transition-fast);
}

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

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

.stat-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-count {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.stat-card.read-stat {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #f0fdf4 0%, var(--color-surface) 60%);
}
.stat-card.read-stat .stat-count {
  color: var(--color-read-dark);
}

.stat-card.listen-stat {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #f5f3ff 0%, var(--color-surface) 60%);
}
.stat-card.listen-stat .stat-count {
  color: var(--color-listened-dark);
}

.stat-card.rank-stat {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, var(--color-surface) 65%);
  position: relative;
  overflow: hidden;
}

.stat-card.rank-stat::after {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
  border-radius: var(--radius-full);
  pointer-events: none;
}

.rank-tier-pill {
  font-size: 0.76rem;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.rank-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.rank-badge-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rank-badge-icon {
  font-size: 2.35rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.3));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: gentle-bob 3s ease-in-out infinite;
}

@keyframes gentle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px) scale(1.05); }
}

.rank-info-text {
  flex: 1;
  min-width: 0;
}

.stat-card.rank-stat .stat-count {
  color: #b45309;
  font-size: 1.25rem;
  line-height: 1.2;
  word-break: break-word;
}

.rank-points-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: #b45309;
  opacity: 0.9;
  margin-top: 0.15rem;
}

.rank-next-progress {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: rgba(254, 243, 199, 0.5);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(253, 230, 138, 0.7);
}

.rank-next-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #78350f;
  font-weight: 600;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rank-needed-badge {
  background: #f59e0b;
  color: white;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.rank-roadmap-link-btn {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-bounce);
  white-space: nowrap;
}

.rank-roadmap-link-btn:hover {
  background: #f59e0b;
  color: white;
  transform: scale(1.05);
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-bar-fill.fill-read {
  background: linear-gradient(90deg, #34d399, #10b981);
}

.progress-bar-fill.fill-listen {
  background: linear-gradient(90deg, #a78bfa, #8b5cf6);
}

.progress-bar-fill.fill-rank {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.stat-footnote {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Milestone banner / Quick highlight */
.quest-status-banner {
  background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
  border: 2px solid #fdba74;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.quest-banner-text {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  color: #9a3412;
  font-size: 0.95rem;
  flex: 1;
  min-width: 260px;
}

.quest-banner-headline {
  font-weight: 600;
  line-height: 1.35;
}

.quest-rank-hint {
  font-size: 0.85rem;
  margin-top: 0.3rem;
  color: #9a3412;
  background: rgba(255, 255, 255, 0.55);
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(253, 186, 116, 0.7);
}

.quest-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quest-banner-icon {
  font-size: 1.75rem;
  line-height: 1;
  margin-top: 0.1rem;
}

.quest-banner-btn {
  background: #ea580c;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(234, 88, 12, 0.3);
  transition: transform var(--transition-bounce), background-color var(--transition-fast);
}

.quest-banner-btn:hover {
  background: #c2410c;
  transform: scale(1.05);
}

.quest-banner-btn.rank-cta-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
}

.quest-banner-btn.rank-cta-btn:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.quest-banner-btn.secondary-btn {
  background: rgba(255, 255, 255, 0.85);
  color: #9a3412;
  border: 1.5px solid #fdba74;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.quest-banner-btn.secondary-btn:hover {
  background: #ffffff;
  color: #7c2d12;
}

/* ==========================================================================
   Navigation Tabs & Controls Bar
   ========================================================================== */

.tabs-and-controls {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.main-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--color-surface);
  padding: 0.4rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab-btn {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-bounce);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--color-brand-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.tab-btn:not(.active):hover {
  color: var(--color-text-main);
  background: var(--color-bg-alt);
}

.search-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.search-box-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}

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

.search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.75rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-main);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.15);
}

.search-clear-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  display: none;
}

.search-clear-btn.visible {
  display: block;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.filter-chip {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-bounce);
}

.filter-chip .chip-count {
  font-size: 0.75rem;
  background: var(--color-bg-alt);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.filter-chip.active {
  background: var(--color-text-main);
  color: var(--color-surface);
  border-color: var(--color-text-main);
}

.filter-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: var(--color-surface);
}

.filter-chip:not(.active):hover {
  border-color: var(--color-brand-primary);
  color: var(--color-brand-primary);
}

/* ==========================================================================
   Book Cards Grid
   ========================================================================== */

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

/* Container query container for book cards */
.book-card-container {
  container-type: inline-size;
}

.book-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform var(--transition-bounce), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.book-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

@container (min-width: 380px) {
  .book-card-actions {
    gap: 0.85rem;
  }
  .track-toggle-btn {
    font-size: 1rem;
    padding: 0.75rem 0.75rem;
  }
  .dragon-visual-panel {
    padding: 1rem 1.15rem;
  }
}

/* Card States */
.book-card.is-both {
  border-color: #f59e0b;
  box-shadow: 0 8px 24px var(--color-gold-glow);
}

.book-card.is-both::before {
  content: "🌟 DRAGON MASTERED";
  position: absolute;
  top: 10px;
  right: -32px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.25rem 2.2rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

.book-card-header {
  padding: 1.1rem 1.1rem 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.book-number-badge {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  color: var(--color-text-main);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
}

.book-card.is-read .book-number-badge {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
  border-color: #6ee7b7;
}

.book-card-header-info {
  flex: 1;
}

.book-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--color-text-main);
  margin-bottom: 0.25rem;
}

.dragon-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.element-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-bg-alt);
  color: var(--color-text-main);
}

/* Card Visual Crest & Dragon info */
.dragon-visual-panel {
  margin: 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.dragon-visual-panel:hover {
  transform: scale(1.02);
}

.dragon-crest-icon {
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.dragon-details-brief {
  flex: 1;
}

.dragon-name-label {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dragon-power-brief {
  font-size: 0.78rem;
  color: #4b5563;
  line-height: 1.3;
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

/* Interactive Toggles Container */
.book-card-actions {
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: auto;
}

.track-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-bounce);
  user-select: none;
}

/* Read button styling */
.track-toggle-btn.btn-read {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.track-toggle-btn.btn-read:hover {
  border-color: var(--color-read);
  color: var(--color-read-dark);
}

.track-toggle-btn.btn-read.active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border-color: #047857;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

/* Listened button styling */
.track-toggle-btn.btn-listen {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.track-toggle-btn.btn-listen:hover {
  border-color: var(--color-listened);
  color: var(--color-listened-dark);
}

.track-toggle-btn.btn-listen.active {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  border-color: #6d28d9;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.track-toggle-btn:active {
  transform: scale(0.94);
}

/* Card footer: Rating & Favorite */
.book-card-footer {
  padding: 0 1rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--color-border);
  padding-top: 0.65rem;
  margin-top: 0.25rem;
}

/* Smiley rating component */
.smiley-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-bg-alt);
  padding: 0.15rem 0.35rem;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
}

.smiley-btn {
  background: transparent;
  border: 1.5px solid transparent;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 9999px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), 
              background-color 0.2s ease, 
              border-color 0.2s ease, 
              box-shadow 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.smiley-btn:focus-visible {
  outline: 2px solid var(--color-primary, #3b82f6);
  outline-offset: 2px;
}

.smiley-btn .smiley-emoji {
  font-size: 1.25rem;
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease, opacity 0.2s ease;
  filter: grayscale(85%);
  opacity: 0.38;
}

.smiley-btn:hover {
  transform: scale(1.18);
}

.smiley-btn:hover .smiley-emoji {
  filter: grayscale(15%);
  opacity: 0.9;
  transform: scale(1.1);
}

.smiley-btn:active {
  transform: scale(0.92);
}

.smiley-btn.selected {
  transform: scale(1.12);
}

.smiley-btn.selected .smiley-emoji {
  filter: none;
  opacity: 1;
  transform: scale(1.15);
}

/* Individual accent styling when selected */
.smiley-btn.rating-1.selected {
  background: #fee2e2;
  border-color: #fca5a5;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}

.smiley-btn.rating-2.selected {
  background: #fef9c3;
  border-color: #fde047;
  box-shadow: 0 2px 6px rgba(234, 179, 8, 0.25);
}

.smiley-btn.rating-3.selected {
  background: #ffedd5;
  border-color: #fdba74;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
  animation: smiley-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes smiley-pop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1.12); }
}

[data-theme="dark"] .smiley-btn.rating-1.selected {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .smiley-btn.rating-2.selected {
  background: rgba(234, 179, 8, 0.25);
  border-color: rgba(234, 179, 8, 0.5);
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
}

[data-theme="dark"] .smiley-btn.rating-3.selected {
  background: rgba(249, 115, 22, 0.3);
  border-color: rgba(249, 115, 22, 0.55);
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.4);
}

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: #cbd5e1;
  padding: 0.2rem;
  transition: transform var(--transition-bounce), color var(--transition-fast);
}

.fav-btn.favorited {
  color: #ef4444;
}

.fav-btn:hover {
  transform: scale(1.2);
}

/* Empty state */
.empty-books-state {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--color-border);
}

.empty-dragon-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.empty-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.empty-desc {
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

/* ==========================================================================
   Achievements & Dragon Codex Sections
   ========================================================================== */

.section-container {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

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

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.achievement-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-bg-alt);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  opacity: 0.6;
  filter: grayscale(0.8);
  transition: all var(--transition-bounce);
}

.achievement-card.unlocked {
  opacity: 1;
  filter: none;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.2);
}

.achievement-card.unlocked:hover {
  transform: translateY(-3px) scale(1.02);
}

.achievement-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

.achievement-card.unlocked .achievement-icon-circle {
  border-color: #f59e0b;
}

.achievement-info h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.achievement-info p {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.unlocked-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  color: #b45309;
  background: #fde68a;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-top: 0.3rem;
}

/* ==========================================================================
   Modals & Dialogs (Accessible, Child-Friendly)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  transform: scale(0.9);
  transition: transform var(--transition-bounce);
  border: 3px solid var(--color-border);
}

.modal-backdrop.open .modal-box {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-bounce);
}

.modal-close-btn:hover {
  transform: scale(1.15) rotate(90deg);
  border-color: var(--color-brand-primary);
}

/* Certificate Modal Specifics */
.certificate-preview {
  border: 6px double #d97706;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  background: #fffdf5;
  color: #451a03;
  text-align: center;
  position: relative;
  box-shadow: inset 0 0 20px rgba(217, 119, 6, 0.1);
  margin-bottom: 1.25rem;
}

.cert-header-icon {
  font-size: 2.75rem;
  margin-bottom: 0.5rem;
}

.cert-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #b45309;
}

.cert-subtitle {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: #78350f;
}

.cert-awarded-to {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.cert-name {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: #92400e;
  border-bottom: 2px solid #b45309;
  display: inline-block;
  padding: 0 1rem 0.25rem;
  margin: 0.4rem 0 1rem;
}

.cert-stats-row {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1rem 0;
}

.cert-stat-badge {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.cert-signatures {
  display: flex;
  justify-content: space-around;
  margin-top: 1.5rem;
  font-size: 0.78rem;
  border-top: 1px solid #fed7aa;
  padding-top: 0.75rem;
}

.cert-sign-line {
  font-weight: 700;
  color: #9a3412;
}

/* ==========================================================================
   Account Switcher & Avatar Selection Modal Styles
   ========================================================================== */

.account-modal-box {
  max-width: 680px;
  padding: 2rem;
}

.account-modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.account-modal-icon {
  font-size: 2.5rem;
  margin-bottom: 0.35rem;
}

.account-modal-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text-main);
  margin-bottom: 0.3rem;
}

.account-modal-sub {
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.account-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.account-profile-card {
  border: 2.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: all var(--transition-bounce);
}

.account-profile-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.account-profile-card.active-card {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.45), rgba(254, 215, 170, 0.25));
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .account-profile-card.active-card {
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.4), rgba(67, 20, 7, 0.4));
  border-color: #f59e0b;
}

.active-crown-tag {
  position: absolute;
  top: -10px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.account-card-avatar {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
  border: 3.5px solid #2e7d32;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.account-card-name {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-text-main);
  margin-bottom: 0.25rem;
}

.account-card-rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.84rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--color-bg-alt);
  color: var(--color-text-main);
  margin-bottom: 0.85rem;
}

.account-card-stats {
  width: 100%;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.5rem;
  display: flex;
  justify-content: space-around;
  margin-bottom: 1rem;
}

.account-card-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.account-card-stat-val {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--color-text-main);
}

.account-card-stat-lbl {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.account-card-action-btn {
  width: 100%;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.95rem;
  transition: all var(--transition-bounce);
}

.btn-switch-account {
  background: linear-gradient(135deg, #ff6b35, #ea580c);
  color: white;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

.btn-switch-account:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.45);
}

.btn-active-account {
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #f59e0b;
  cursor: default;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

[data-theme="dark"] .btn-active-account {
  background: #78350f;
  color: #fef3c7;
}

/* Avatar Selection Section inside Modal */
.avatar-picker-section {
  margin-top: 1.5rem;
  border-top: 2px dashed var(--color-border);
  padding-top: 1.25rem;
}

.avatar-picker-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.85rem;
  text-align: center;
}

.avatar-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.avatar-option-card {
  border: 2.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.4rem;
  text-align: center;
  cursor: pointer;
  background: var(--color-surface);
  transition: all var(--transition-bounce);
}

.avatar-option-card:hover {
  transform: scale(1.06);
  border-color: var(--color-brand-primary);
}

.avatar-option-card.selected {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .avatar-option-card.selected {
  background: #451a03;
}

.avatar-preview-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin: 0 auto 0.4rem;
  display: block;
  border: 2px solid var(--color-border);
}

.avatar-option-name {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
}

.avatar-option-element {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.custom-avatar-row {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.custom-avatar-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 2px dashed var(--color-border);
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.custom-avatar-upload-btn:hover {
  border-color: var(--color-brand-primary);
  color: var(--color-brand-primary);
  background: var(--color-surface);
}

.account-modal-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
}

.add-account-action-btn {
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-full);
  border: 2px dashed var(--color-brand-primary);
  background: transparent;
  color: var(--color-brand-primary);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all var(--transition-bounce);
}

.add-account-action-btn:hover {
  background: var(--color-brand-primary);
  color: white;
  transform: scale(1.05);
}

/* ==========================================================================
   Confetti & Celebration Particle Effects
   ========================================================================== */

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* Toast message */
.toast-notice {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 5000;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

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

/* ==========================================================================
   Dragon Rank Journey Roadmap & Ladder Styles
   ========================================================================== */

.rank-hero-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 60%, #fed7aa 100%);
  border: 3px solid #f59e0b;
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.15);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .rank-hero-card {
  background: linear-gradient(135deg, #1e293b 0%, #292524 60%, #451a03 100%);
  border-color: #f59e0b;
}

.rank-hero-top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.rank-hero-crest {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 4px solid #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.4);
  animation: gentle-pulse 2.5s infinite ease-in-out;
  flex-shrink: 0;
}

.rank-hero-details {
  flex: 1;
  min-width: 250px;
}

.rank-hero-level-tag {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  border: 1.5px solid #fcd34d;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

[data-theme="dark"] .rank-hero-level-tag {
  background: #451a03;
  color: #fde68a;
  border-color: #b45309;
}

.rank-hero-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: #78350f;
  line-height: 1.2;
}

[data-theme="dark"] .rank-hero-title {
  color: #fef3c7;
}

.rank-hero-desc {
  font-size: 1rem;
  color: #92400e;
  margin-top: 0.25rem;
  font-weight: 600;
}

[data-theme="dark"] .rank-hero-desc {
  color: #fed7aa;
}

.rank-hero-points-total {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  color: #ea580c;
  margin-top: 0.35rem;
}

/* Rank Hero Next Progress Bar */
.rank-hero-progress-section {
  background: var(--color-surface);
  border: 2px solid #fcd34d;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.rank-hero-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rank-hero-progress-bar {
  height: 18px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
}

.rank-hero-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 50%, #f97316 100%);
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

.rank-hero-progress-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Points System Rules Card */
.rank-rules-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.rank-rule-chip {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.rank-rule-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.rank-rule-pts {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--color-brand-primary);
}

.rank-rule-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.2;
}

/* ==========================================================================
   Rank Ladder Roadmap (All 11 Tiers)
   ========================================================================== */

.rank-ladder-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rank-ladder-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: relative;
}

.rank-ladder-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: relative;
  transition: all var(--transition-bounce);
}

.rank-ladder-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

/* State: Unlocked / Passed */
.rank-ladder-card.is-unlocked {
  border-color: #a7f3d0;
  background: linear-gradient(90deg, #f0fdf4 0%, var(--color-surface) 35%);
}

[data-theme="dark"] .rank-ladder-card.is-unlocked {
  background: linear-gradient(90deg, #064e3b 0%, var(--color-surface) 35%);
  border-color: #059669;
}

/* State: Current Rank */
.rank-ladder-card.is-current {
  border-color: #f59e0b;
  border-width: 3px;
  background: linear-gradient(90deg, #fef3c7 0%, #fffbeb 40%, var(--color-surface) 100%);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.25);
  transform: scale(1.02);
}

[data-theme="dark"] .rank-ladder-card.is-current {
  background: linear-gradient(90deg, #451a03 0%, #78350f 40%, var(--color-surface) 100%);
  border-color: #f59e0b;
}

/* State: Next Rank */
.rank-ladder-card.is-next {
  border: 2px dashed #f59e0b;
  background: linear-gradient(90deg, #fffbeb 0%, var(--color-surface) 30%);
}

[data-theme="dark"] .rank-ladder-card.is-next {
  border-color: #f59e0b;
  background: linear-gradient(90deg, #292524 0%, var(--color-surface) 30%);
}

/* State: Locked */
.rank-ladder-card.is-locked {
  opacity: 0.65;
  background: var(--color-bg-alt);
}

.rank-step-number {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-text-muted);
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.rank-ladder-card.is-current .rank-step-number {
  color: #b45309;
}

.rank-step-crest {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-bounce);
}

.rank-ladder-card.is-unlocked .rank-step-crest {
  border-color: #10b981;
  background: #ecfdf5;
}

.rank-ladder-card.is-current .rank-step-crest {
  border-color: #f59e0b;
  border-width: 3px;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
  animation: gentle-bob 3s ease-in-out infinite;
}

.rank-step-content {
  flex: 1;
  min-width: 0;
}

.rank-step-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.rank-step-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text-main);
  line-height: 1.2;
}

.rank-step-dragon {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-brand-primary);
  background: var(--color-bg-alt);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full);
}

.rank-step-desc {
  font-size: 0.86rem;
  color: var(--color-text-muted);
  line-height: 1.35;
}

.rank-step-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.rank-step-pts-badge {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--color-text-main);
  background: var(--color-bg-alt);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.rank-ladder-card.is-current .rank-step-pts-badge {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

.rank-status-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.rank-status-tag.unlocked {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.rank-status-tag.current {
  background: #f59e0b;
  color: white;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
  animation: gentle-pulse 2s infinite ease-in-out;
}

.rank-status-tag.next {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.rank-status-tag.locked {
  background: #f1f5f9;
  color: #64748b;
}

[data-theme="dark"] .rank-status-tag.locked {
  background: #334155;
  color: #94a3b8;
}

/* ==========================================================================
   Rank Up Celebration Modal
   ========================================================================== */

.rank-up-modal-box {
  text-align: center;
  max-width: 480px;
  background: linear-gradient(180deg, #fffbeb 0%, var(--color-surface) 40%);
  border: 4px solid #f59e0b;
  box-shadow: 0 20px 50px rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .rank-up-modal-box {
  background: linear-gradient(180deg, #451a03 0%, var(--color-surface) 50%);
}

.rank-up-crest {
  font-size: 4.75rem;
  line-height: 1;
  margin: 0.5rem auto 1rem;
  animation: rank-crest-bounce 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 6px 16px rgba(245, 158, 11, 0.45));
}

@keyframes rank-crest-bounce {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(10deg); opacity: 1; }
  80% { transform: scale(0.95) rotate(-5deg); }
  100% { transform: scale(1) rotate(0); }
}

.rank-up-header-tag {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 800;
  color: #d97706;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.rank-up-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  color: #b45309;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

[data-theme="dark"] .rank-up-title {
  color: #fde68a;
}

.rank-up-tier-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  border: 1.5px solid #fcd34d;
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
}

.rank-up-lore-box {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  border: 2px solid #fdba74;
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

[data-theme="dark"] .rank-up-lore-box {
  background: #292524;
  border-color: #b45309;
}

.rank-up-lore-title {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 800;
  color: #9a3412;
  margin-bottom: 0.25rem;
}

[data-theme="dark"] .rank-up-lore-title {
  color: #fde68a;
}

.rank-up-lore-desc {
  font-size: 0.9rem;
  color: #78350f;
  line-height: 1.4;
}

[data-theme="dark"] .rank-up-lore-desc {
  color: #e2e8f0;
}

.rank-up-next-teaser {
  font-size: 0.86rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

.rank-up-celebrate-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: white;
  border: none;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0.75rem 2rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.4);
  transition: all var(--transition-bounce);
}

.rank-up-celebrate-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.5);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-top: auto;
}

.footer-dragon-quote {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-brand-primary);
  margin-bottom: 0.35rem;
}

/* ==========================================================================
   Cloud Sync Styles
   ========================================================================== */

.sync-btn {
  position: relative;
}

.sync-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #9ca3af;
  border: 1.5px solid var(--color-surface, #ffffff);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.sync-dot.online {
  background-color: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
}

.sync-dot.syncing {
  background-color: #f59e0b;
  animation: sync-dot-pulse 0.7s infinite alternate;
}

.sync-dot.offline {
  background-color: #94a3b8;
}

@keyframes sync-dot-pulse {
  from { transform: scale(0.9); opacity: 0.6; }
  to { transform: scale(1.3); opacity: 1; }
}

.sync-modal-box {
  max-width: 520px;
}

.sync-status-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1.5px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

[data-theme="dark"] .sync-status-card {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(59, 130, 246, 0.35);
}

.sync-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text-main);
}

.sync-status-badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  display: inline-block;
}

.sync-status-badge-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.sync-status-badge-dot.syncing {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  animation: sync-dot-pulse 0.7s infinite alternate;
}

.sync-status-badge-dot.offline {
  background: #94a3b8;
}

.sync-time-tag {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.sync-status-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.4;
}

.sync-action-cards {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sync-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.sync-primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4);
}

.sync-primary-btn:active {
  transform: translateY(0);
}

.sync-spin-icon.spinning {
  display: inline-block;
  animation: sync-rotate 0.8s linear infinite;
}

@keyframes sync-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sync-pair-section {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
}

.sync-section-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--color-text-main);
}

.sync-section-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.4;
}

.sync-link-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sync-link-input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-family: monospace;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-main);
  outline: none;
}

.sync-copy-btn {
  background: var(--color-brand-primary);
  color: white;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sync-copy-btn:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.sync-qr-wrapper {
  text-align: center;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--color-border);
}

.sync-qr-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.65rem;
}

.sync-qr-img-box {
  display: inline-block;
  background: #ffffff;
  padding: 0.65rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--color-border);
}

.sync-qr-img-box img {
  width: 140px;
  height: 140px;
  display: block;
}

.sync-key-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.sync-key-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  justify-content: space-between;
}

.sync-key-code {
  font-family: monospace;
  font-weight: 700;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--color-brand-primary);
}

.sync-edit-key-btn {
  background: none;
  border: none;
  color: var(--color-brand-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}

.sync-edit-key-btn:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Print Stylesheet (For Certificates & Reading Logs)
   ========================================================================== */

@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .site-header,
  .tabs-and-controls,
  .site-footer,
  .modal-close-btn,
  .icon-btn,
  .quest-status-banner,
  .achievements-grid,
  .stats-grid,
  #confetti-canvas {
    display: none !important;
  }
  
  .modal-backdrop {
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 0 !important;
  }
  
  .modal-box {
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  
  .certificate-preview {
    border: 8px double #b45309 !important;
    padding: 3rem 2rem !important;
    page-break-inside: avoid;
  }
}
