/* ===== RESET & BASE ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #d4af37;
  --primary-dark: #b39226;
  --secondary: #0f172a;
  --accent: #ff00c1;
  --success: #10b981;
  --error: #ef4444;
  --text-dark: #1e293b;
  --text-light: #64748b;
  --bg-light: #f8fafc;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: 'Inter', -apple-system, system-ui, sans-serif;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text-dark);
  line-height: 1.6;
  overflow-x: hidden;
  background: var(--white);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== NAVIGATION ===== */

.navbar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

.navbar.scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.logo a {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.6rem;
  color: var(--secondary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-menu {
  display: flex;
  gap: 2rem;
  list-style: none;
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: var(--text-dark);
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
  transition: color 0.3s;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.3s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
}

.nav-link:hover::after {
  width: 100%;
}

.hamburger {
  display: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  width: 24px;
  height: 2px;
  background: var(--text-dark);
  transition: 0.3s;
  border-radius: 2px;
}

/* ===== HERO SECTION ===== */

.hero {
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
  overflow: hidden;
  padding: 8rem 1.5rem 4rem;
  text-align: center;
  color: var(--white);
}

.hero-content {
  z-index: 2;
  max-width: 900px;
}

.hero-badge {
  display: inline-block;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--primary);
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 1.5rem;
  animation: fadeInDown 0.6s ease;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 900;
  line-height: 1;
  margin-bottom: 1rem;
  text-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: fadeInUp 0.8s ease 0.2s backwards;
}

.hero-tagline {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 6px;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
  animation: fadeInUp 0.8s ease 0.4s backwards;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  color: #cbd5e1;
  margin-bottom: 3rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
  animation: fadeInUp 0.8s ease 0.6s backwards;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem 1rem;
  border-radius: 16px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  animation: fadeInUp 0.8s ease 0.8s backwards;
  flex: 1;
  max-width: 200px;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-mono);
  line-height: 1.2;
  margin-bottom: 0.5rem;
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

#user-trophy {
  font-size: 1.2rem !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: 0.85rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.25rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeInUp 0.8s ease 1s backwards;
}

/* Floating decorations */

.hero-decoration {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

.decoration-circle {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--primary), transparent);
  opacity: 0.08;
  filter: blur(60px);
  animation: float 15s infinite ease-in-out;
}

.decoration-circle:nth-child(1) {
  width: 400px;
  height: 400px;
  top: -100px;
  left: -100px;
}

.decoration-circle:nth-child(2) {
  width: 300px;
  height: 300px;
  bottom: -50px;
  right: -50px;
  animation-delay: 5s;
}

.decoration-circle:nth-child(3) {
  width: 250px;
  height: 250px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: 10s;
}

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2rem;
  border-radius: 50px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  border: 2px solid transparent;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
}

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

.btn-primary:hover {
  background: var(--white);
  color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(212, 175, 55, 0.4);
}

.btn-glow {
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

.btn-amazon {
  background: #ff9900;
  color: var(--white);
  font-weight: 700;
}

.btn-amazon:hover {
  background: #e68a00;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(255, 153, 0, 0.4);
}

.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: var(--secondary);
}

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

/* ===== HOW IT WORKS ===== */

.how-it-works {
  padding: 5rem 0;
  background: var(--white);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.step-card {
  background: var(--bg-light);
  padding: 2.5rem 2rem;
  border-radius: 20px;
  text-align: center;
  transition: var(--transition);
  border: 2px solid transparent;
}

.step-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.step-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.step-card h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--secondary);
}

.step-card p {
  color: var(--text-light);
  line-height: 1.6;
}

/* ===== BLOG MODAL STYLES ===== */

dialog.blog-modal {
  /* Fix for top-chopping: Reset top/left/transform to use native dialog auto-margin centering */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  margin: auto;
  
  width: 95%;
  max-width: 800px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f172a;
  color: #cbd5e1;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 0;
  overflow: hidden;
}

.blog-modal::backdrop {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(5px);
}

.blog-content {
  max-height: 85vh;
  overflow-y: auto;
}

.blog-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  padding: 3rem 2rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.blog-tag {
  display: inline-block;
  background: rgba(255, 0, 193, 0.1);
  color: #ff00c1;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.blog-header h2 {
  font-family: var(--font-heading);
  color: #fff;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.blog-body {
  padding: 2.5rem 2rem;
  font-size: 1.1rem;
  line-height: 1.8;
}

.flowchart-container {
  background: #1e293b;
  padding: 2rem;
  border-radius: 16px;
  margin: 2rem 0;
  display: flex;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cta-box {
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid var(--primary);
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  margin-top: 3rem;
}

/* ===== BLOG MODAL CONTENT ELEMENTS ===== */

.author-line {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.blog-body h3 {
  font-family: var(--font-heading);
  color: #e2e8f0;
  font-size: 1.4rem;
  margin: 2rem 0 0.75rem;
}

.blog-body ul {
  padding-left: 1.5rem;
  margin: 0.75rem 0 1.5rem;
}

.blog-body li {
  margin-bottom: 0.85rem;
  color: #cbd5e1;
  line-height: 1.7;
}

/* ===== BOOKS SECTION ===== */

.books-section {
  padding: 6rem 0;
  background: var(--bg-light);
}

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  text-align: center;
  margin-bottom: 0.75rem;
  color: var(--secondary);
}

.section-subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 4rem;
  font-size: 1.1rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 2.5rem;
}

.book-card {
  background: var(--white);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 2px solid rgba(0,0,0,0.05);
  position: relative;
}

.book-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.book-card.solved {
  border-color: var(--success);
}

.book-image {
  position: relative;
  height: 400px;
  overflow: hidden;
  background: #e2e8f0;
}

.book-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s;
}

.book-card:hover .book-image img {
  transform: scale(1.08) rotate(1deg);
}

.book-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.difficulty-badge {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: var(--white);
  padding: 0.4rem 0.9rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.difficulty-easy { border: 2px solid var(--success); }
.difficulty-medium { border: 2px solid #f59e0b; }
.difficulty-hard { border: 2px solid var(--error); }

.points-badge {
  background: var(--primary);
  color: var(--secondary);
  padding: 0.4rem 0.9rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.solved-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--success);
  color: var(--white);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.book-info {
  padding: 2rem;
  text-align: center;
}

.book-info h3 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
  color: var(--secondary);
}

.book-description {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.book-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ===== LEADERBOARD SECTION ===== */

.leaderboard-section {
  padding: 6rem 0;
  background: var(--white);
}

.leaderboard-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.leaderboard-table {
  background: var(--white);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid #e2e8f0;
}

.leaderboard-header {
  display: grid;
  grid-template-columns: 80px 1fr 120px 100px 120px;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--secondary);
  color: var(--white);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 80px 1fr 120px 100px 120px;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  align-items: center;
  transition: background 0.2s;
}

.leaderboard-row:hover {
  background: var(--bg-light);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.rank {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
}

.username {
  font-weight: 600;
  color: var(--text-dark);
}

.leaderboard-row div:nth-child(3) {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 2px;
}

/* Trophy Colors */

.trophy-human { color: #10b981; }
.trophy-cyborg { color: #ff00c1; }

/* ===== RIDDLE MODAL ===== */

dialog {
  border: none;
  border-radius: 20px;
  padding: 0;
  width: 90%;
  max-width: 550px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  overflow: hidden;
  background: var(--white);

  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-height: 90vh;
  overflow-y: auto;
}


dialog::backdrop {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
}

.modal-wrapper {
  position: relative;
}

.close-modal {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(15, 23, 42, 0.7); /* Translucent background to pop against scrollbars/content */
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 2rem;
  cursor: pointer;
  color: var(--white);
  transition: 0.2s;
  z-index: 9999; /* Force it to stay above all scroll contexts */
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.close-modal:hover {
  color: var(--primary);
  background: rgba(15, 23, 42, 0.95);
  transform: scale(1.05);
}

.modal-header {
  background: linear-gradient(135deg, var(--secondary), #1e293b);
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  color: var(--white);
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.modal-book-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
}

.modal-difficulty {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}

.modal-body {
  padding: 2rem;
}

.riddle-hint-box {
  background: var(--bg-light);
  padding: 1.5rem;
  border-radius: 12px;
  border-left: 4px solid var(--primary);
  margin-bottom: 1.5rem;
}

.riddle-hint-box strong {
  color: var(--primary);
  display: block;
  margin-bottom: 0.5rem;
}

.modal-hint {
  color: var(--text-dark);
  line-height: 1.6;
  font-size: 0.95rem;
}

.input-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.input-group input {
  flex: 1;
  padding: 1rem 1.25rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 1rem;
  outline: none;
  transition: 0.2s;
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.input-group input:disabled {
  background: var(--bg-light);
  cursor: not-allowed;
  opacity: 0.6;
}

.riddle-result {
  margin-top: 1.5rem;
  font-weight: 600;
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.result-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 2px solid var(--success);
}

.result-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 2px solid var(--error);
}

.riddle-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: var(--text-light);
}

/* ===== ACHIEVEMENT TOAST ===== */

.achievement-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--white);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border-radius: 16px;
  padding: 1.5rem;
  min-width: 320px;
  z-index: 9999;
  transform: translateY(150%);
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 2px solid var(--primary);
}

.achievement-toast.show {
  transform: translateY(0);
}

.toast-content {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toast-icon {
  font-size: 2.5rem;
}

.toast-text strong {
  display: block;
  color: var(--secondary);
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.toast-text p {
  color: var(--text-light);
  font-size: 0.9rem;
}

.toast-share {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: var(--secondary);
  border: none;
  border-radius: 50px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
}

.toast-share:hover {
  background: var(--primary-dark);
  transform: scale(1.02);
}

/* ===== ABOUT SECTION (iOS SAFARI FIXED) ===== */

.about-section {
  padding: 6rem 0;
  background: var(--bg-light);
}

.persona-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 4rem;
  align-items: center;
}

.persona-visual {
  position: relative;
  display: block;
  width: 100%;
}

.persona-avatar-wrapper {
  position: relative;
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.persona-avatar {
  display: block;
  width: 100%;
  height: auto;
  max-width: 400px;
  aspect-ratio: 1 / 1; /* iOS Safari fix */
  border-radius: 20px;
  box-shadow: 20px 20px 0 var(--primary);
  transition: transform 0.3s;
  object-fit: cover;
  background: #e2e8f0; /* Fallback while loading */
}

.persona-avatar-wrapper:hover .persona-avatar {
  transform: translateY(-10px);
}

.persona-badge {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  background: rgba(239, 68, 68, 0.95); /* Removed backdrop-filter for iOS */
  color: var(--white);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  z-index: 2;
  animation: slideInLeft 0.6s ease;
}

.persona-label {
  font-size: 0.85rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.persona-name {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  margin: 0.5rem 0 1.5rem;
  color: var(--secondary);
}

.persona-bio {
  margin-bottom: 2rem;
}

.persona-bio p {
  margin-bottom: 1rem;
  color: var(--text-dark);
  line-height: 1.7;
}

.text-highlight {
  color: var(--primary);
  font-weight: 600;
}

.persona-social {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.social-link {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: var(--secondary);
  text-decoration: none;
  border-radius: 50px;
  font-weight: 600;
  transition: var(--transition);
}

.social-link:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

/* ===== NEWSLETTER SECTION (iOS SAFARI FIXED) ===== */

.newsletter-section {
  padding: 6rem 0;
  background: var(--white);
}

.newsletter-card {
  background: var(--bg-light);
  border-radius: 20px;
  padding: 3rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  border: 2px solid rgba(212, 175, 55, 0.2);
}

.newsletter-card h3 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  margin-bottom: 1rem;
  color: var(--secondary);
}

.newsletter-card p {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.newsletter-section form {
  width: 100%;
}

.newsletter-section .form-group {
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.newsletter-section .form-group input {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: 0.2s;
  -webkit-appearance: none; /* iOS Safari fix */
  appearance: none;
  background-color: var(--white); /* Explicit background for iOS */
}

.newsletter-section .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.newsletter-section button[type="submit"] {
  width: 100%;
  max-width: 400px;
  -webkit-appearance: none; /* iOS Safari fix */
  appearance: none;
}

/* ===== FOOTER ===== */

.footer {
  background: var(--secondary);
  color: var(--white);
  text-align: center;
  padding: 2rem 0;
}

/* ===== ANIMATIONS ===== */

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

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

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

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake { animation: shake 0.5s; }
.animate-in { animation: fadeInUp 0.6s ease; }

/* ===== SCROLL ENTRANCE ANIMATIONS ===== */

/* Initial hidden state — set on elements before they're observed */
.book-card,
.stat-box {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Triggered by IntersectionObserver in script.js */
.book-card.animate-visible,
.stat-box.animate-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger each book card slightly by its DOM position */
.book-card:nth-child(1) { transition-delay: 0.05s; }
.book-card:nth-child(2) { transition-delay: 0.12s; }
.book-card:nth-child(3) { transition-delay: 0.19s; }
.book-card:nth-child(4) { transition-delay: 0.26s; }
.book-card:nth-child(5) { transition-delay: 0.33s; }
.book-card:nth-child(6) { transition-delay: 0.40s; }


/* ===== LEADERBOARD — CURRENT USER HIGHLIGHT ===== */
.leaderboard-row.user-row {
  background: rgba(212, 175, 55, 0.08);
  border-left: 4px solid var(--primary);
  font-weight: 700;
}

.leaderboard-row.user-row:hover {
  background: rgba(212, 175, 55, 0.14);
}

/* ===== GLITCH TEXT EFFECTS ===== */

/* Hero title glitch (used on .glitch-text elements) */
.glitch-text {
  position: relative;
  display: inline-block;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch-text::before {
  color: var(--accent);
  animation: glitch-before 3s infinite linear;
  clip-path: polygon(0 30%, 100% 30%, 100% 50%, 0 50%);
  opacity: 0;
}

.glitch-text::after {
  color: var(--primary);
  animation: glitch-after 3s infinite linear;
  clip-path: polygon(0 60%, 100% 60%, 100% 75%, 0 75%);
  opacity: 0;
}

.glitch-text:hover::before,
.glitch-text:hover::after {
  opacity: 1;
}

@keyframes glitch-before {
  0%   { transform: translate(0, 0);   }
  20%  { transform: translate(-2px, 1px); }
  40%  { transform: translate(2px, -1px); }
  60%  { transform: translate(-1px, 2px); }
  80%  { transform: translate(1px, -2px); }
  100% { transform: translate(0, 0);   }
}

@keyframes glitch-after {
  0%   { transform: translate(0, 0);   }
  25%  { transform: translate(2px, -1px); }
  50%  { transform: translate(-2px, 1px); }
  75%  { transform: translate(1px, 2px);  }
  100% { transform: translate(0, 0);   }
}

/* Section heading glitch (used on .glitch elements with data-text) */
.glitch {
  position: relative;
  display: inline-block;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  color: var(--primary);
  animation: glitch-before 4s infinite linear;
  clip-path: polygon(0 20%, 100% 20%, 100% 40%, 0 40%);
  opacity: 0;
}

.glitch::after {
  color: var(--accent);
  animation: glitch-after 4s infinite linear;
  clip-path: polygon(0 65%, 100% 65%, 100% 80%, 0 80%);
  opacity: 0;
}

.glitch:hover::before,
.glitch:hover::after {
  opacity: 1;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 1024px) {
  .persona-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2rem;
  }
  .persona-visual {
    max-width: 400px;
    margin: 0 auto;
  }
  .persona-avatar {
    box-shadow: 15px 15px 0 var(--primary);
  }
}

@media (max-width: 768px) {
  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 75%;
    height: 100vh;
    background: var(--white);
    flex-direction: column;
    padding: 5rem 2rem;
    box-shadow: -10px 0 30px rgba(0,0,0,0.2);
    transition: 0.3s;
    z-index: 999;
  }
  .nav-menu.active { right: 0; }
  .hamburger { display: flex; z-index: 1001; }
  .hero { padding: 6rem 1.5rem 3rem; }
  .hero-title { font-size: 2.5rem; }
  .hero-tagline { font-size: 1.25rem; letter-spacing: 3px; }
  .hero-stats { flex-direction: column; gap: 1rem; }
  .stat-box { width: 100%; max-width: 100%; }
  .persona-visual {
    max-width: 280px;
  }
  .persona-avatar {
    box-shadow: 15px 15px 0 var(--primary);
  }
  .persona-badge {
    bottom: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }
  .persona-social {
    justify-content: center;
    flex-wrap: wrap;
  }
  .newsletter-card {
    padding: 2rem;
    margin: 0 1rem;
  }
  .newsletter-card h3 {
    font-size: 1.8rem;
  }
  .leaderboard-controls {
    flex-direction: column;
  }
  .leaderboard-header,
  .leaderboard-row {
    grid-template-columns: 60px 1fr 80px 80px;
    font-size: 0.85rem;
  }
  .leaderboard-row div:nth-child(5),
  .leaderboard-header div:nth-child(5) {
    display: none;
  }
  .decoration-circle {
    display: none;
  }
  .hero-buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
}

.hero-buttons .btn {
    width: 100%;
    justify-content: center;
}
dialog {
  width: 95%;
  max-height: 88vh;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

dialog.blog-modal {
  /* Prevent mobile screens from overriding the native centering fix */
  top: 0;
  left: 0;
  transform: none;
  margin: auto;
}

.modal-body {
  padding: 1.25rem;
}

.modal-header {
  padding: 1.75rem 1.25rem 1.5rem;
}

.input-group {
  flex-direction: column;
}

.input-group input,
.input-group button {
  width: 100%;
}
}

/* ===== iOS SAFARI SPECIFIC FIXES ===== */

@supports (-webkit-touch-callout: none) {
  /* iOS Safari only */
  .persona-avatar {
    -webkit-transform: translateZ(0); /* Force GPU acceleration */
    transform: translateZ(0);
  }
  .newsletter-card {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  input,
  button,
  select,
  textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 12px; /* Ensure border-radius works */
  }
}

/* Additional mobile fixes */
@media (max-width: 768px) {
  .persona-avatar-wrapper {
    max-width: 300px;
  }
  .persona-avatar {
    box-shadow: 12px 12px 0 var(--primary);
  }
  .persona-badge {
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    padding: 0.5rem;
  }
  .newsletter-card {
    padding: 2rem 1.5rem;
    margin: 0 1rem;
  }
  .newsletter-card h3 {
    font-size: 1.8rem;
  }
}
