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

:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #111111;
  --bg-card-hover: #1a1a1a;
  --bg-input: #0d0d0d;
  --text-primary: #f0f0f0;
  --text-secondary: #888888;
  --text-muted: #555555;
  --accent: #dc2f2f;
  --accent-hover: #b71c1c;
  --accent-dim: rgba(220, 47, 47, 0.12);
  --accent-glow: rgba(220, 47, 47, 0.25);
  --danger: #dc2f2f;
  --danger-hover: #b71c1c;
  --success: #1db954;
  --success-dim: rgba(29, 185, 84, 0.12);
  --warning: #f57c00;
  --info: #3366ff;
  --border: #1a1a1a;
  --border-light: #2a2a2a;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes glow-pulse {
  0%, 100% { text-shadow: 0 0 8px rgba(220, 47, 47, 0.3), 0 0 20px rgba(220, 47, 47, 0.1); }
  50% { text-shadow: 0 0 16px rgba(220, 47, 47, 0.6), 0 0 40px rgba(220, 47, 47, 0.2), 0 0 60px rgba(220, 47, 47, 0.1); }
}

@keyframes glow-box {
  0%, 100% { box-shadow: 0 0 8px rgba(220, 47, 47, 0.15), inset 0 0 8px rgba(220, 47, 47, 0.05); }
  50% { box-shadow: 0 0 25px rgba(220, 47, 47, 0.3), inset 0 0 15px rgba(220, 47, 47, 0.1); }
}

.text-glow {
  animation: glow-pulse 2.5s ease-in-out infinite;
}

.box-glow {
  animation: glow-box 3s ease-in-out infinite;
  border-color: var(--accent-dim) !important;
}

.emoji {
  opacity: 0.7;
  filter: grayscale(1) brightness(1.3);
  transition: all 0.2s;
  display: inline-block;
}

:hover > .emoji,
a:hover .emoji,
.btn:hover .emoji { opacity: 1; filter: grayscale(0.6) brightness(1.5); }

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-dim), var(--accent), var(--accent-dim), transparent);
  opacity: 0.6;
}

.header-left { display: flex; align-items: center; gap: 2.5rem; }

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  position: relative;
}

.logo span { color: var(--text-primary); }
.by { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 0.25rem; }

.nav-links a {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}

.nav-links a:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-links a.nav-upgrade {
  background: linear-gradient(135deg,#dc2f2f,#ff6b35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

.nav-links a.nav-upgrade:hover {
  background: linear-gradient(135deg,#ff4444,#ff7a45);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-color: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
}

.nav-links a.nav-admin:hover {
  color: var(--accent) !important;
  background: rgba(220,47,47,0.08);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.header-right { display: flex; align-items: center; gap: 1rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

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

.btn-danger:hover { background: var(--danger-hover); }

.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }

.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }

/* ===== PROFILE DROPDOWN ===== */
.profile-dropdown { position: relative; }

.profile-trigger {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  overflow: hidden;
  background: var(--bg-card);
}

.profile-trigger:hover { border-color: var(--accent); }

.profile-trigger img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition);
  z-index: 1001;
  overflow: hidden;
}

.dropdown-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dropdown-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dropdown-user-info h4 { font-size: 0.875rem; font-weight: 600; }
.dropdown-user-info span { font-size: 0.75rem; color: var(--text-muted); }
.dropdown-body { padding: 0.5rem; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.dropdown-item i { width: 18px; text-align: center; font-size: 0.875rem; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--accent-dim); }

.auth-buttons { display: flex; gap: 0.5rem; }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; padding-top: 64px; }

.page-hero {
  padding: 4rem 2rem 3rem;
  text-align: center;
  background: linear-gradient(180deg, #0a0a0a 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
  pointer-events: none;
}

.page-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 0.75rem;
  position: relative;
}

.page-hero h1 span { color: var(--accent); }

.page-hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

/* ===== CATEGORIES ===== */
.container { max-width: 1280px; margin: 0 auto; padding: 0 2rem; }
.categories-section { padding: 3rem 0; }

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

.section-header h2 { font-size: 1.25rem; font-weight: 700; }

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

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

.category-card[open] { border-color: var(--accent); }

.category-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  cursor: pointer;
  list-style: none;
  transition: var(--transition);
}

.category-summary::-webkit-details-marker { display: none; }
.category-summary::marker { display: none; content: ''; }

.category-summary:hover { background: var(--bg-card-hover); }

.category-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.category-card h3 { font-size: 1.05rem; font-weight: 700; }

.category-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.2rem 0 0.3rem;
}

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

.category-stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.category-stats span { display: flex; align-items: center; gap: 0.35rem; }

/* ===== ROOMS LIST IN CATEGORY ===== */
.category-rooms { display: none; margin-bottom: 2rem; }
.category-rooms.open { display: block; }

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

.rooms-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rooms-header .back-btn {
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
  background: none;
  border: none;
  font-family: inherit;
}

.rooms-header .back-btn:hover { color: var(--accent); }

.room-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.625rem;
  cursor: pointer;
  transition: var(--transition);
}

.room-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateX(4px);
}

.room-status-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.room-status-icon.completed { background: var(--success-dim); color: var(--success); }
.room-status-icon.not-completed { background: var(--accent-dim); color: var(--accent); }

.room-info { flex: 1; min-width: 0; }
.room-info h4 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.15rem; }
.room-info p { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }

.room-difficulty {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
}

.difficulty-facile { background: rgba(255,255,255,0.06); color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.08); }
.difficulty-moyen { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(220,47,47,0.15); }
.difficulty-difficile { background: rgba(220,47,47,0.15); color: var(--accent); border: 1px solid rgba(220,47,47,0.3); }

.room-points { font-size: 0.875rem; font-weight: 700; color: var(--accent); }

/* ===== ROOM DETAIL PAGE ===== */
.room-detail { padding: 2rem; max-width: 900px; margin: 0 auto; }
.room-detail-header { margin-bottom: 2rem; }

.room-detail-header .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  transition: var(--transition);
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.room-detail-header .back-link:hover { color: var(--accent); }
.room-detail-header h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 0.5rem; }
.room-detail-meta { display: flex; gap: 1rem; flex-wrap: wrap; }

.room-detail-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.room-detail-body h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.room-detail-body p { color: var(--text-secondary); line-height: 1.8; margin-bottom: 1rem; }
.room-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }

.flag-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.flag-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.flag-input-group { display: flex; gap: 0.75rem; }

.flag-input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'Courier New', monospace;
  outline: none;
  transition: var(--transition);
}

.flag-input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.flag-result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
}

.flag-result.success { display: block; background: var(--success-dim); color: var(--success); border: 1px solid rgba(29,185,84,0.2); }
.flag-result.error { display: block; background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(220,47,47,0.2); }
.flag-result.already { display: block; background: rgba(51,102,255,0.1); color: var(--info); border: 1px solid rgba(51,102,255,0.2); }

/* ===== FOOTER ===== */
.footer {
  background: #050505;
  border-top: 1px solid var(--border);
  padding: 3rem 2rem 1.5rem;
  margin-top: auto;
}

.footer-grid {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2rem;
}

.footer-brand h3 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-brand p { color: var(--text-secondary); font-size: 0.85rem; line-height: 1.7; max-width: 300px; }

.footer-col h4 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.footer-col a {
  display: block;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.3rem 0;
  transition: var(--transition);
}

.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  max-width: 1280px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-socials { display: flex; gap: 1rem; }

.footer-socials a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

.footer-socials a:hover { background: var(--accent); color: #fff; }

/* ===== LEADERBOARD ===== */
.leaderboard-section { padding: 3rem 0; }

.leaderboard-table {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.leaderboard-table table { width: 100%; border-collapse: collapse; }

.leaderboard-table th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: #080808;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table td { padding: 1rem 1.25rem; font-size: 0.875rem; border-bottom: 1px solid var(--border); }
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr:hover td { background: var(--bg-card-hover); }

.rank-number { font-weight: 700; font-size: 1rem; }
.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

.leaderboard-user { display: flex; align-items: center; gap: 0.75rem; }
.leaderboard-user img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.leaderboard-user span { font-weight: 600; }
.leaderboard-points { font-weight: 700; color: var(--accent); }

/* ===== AUTH PAGES ===== */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--bg-primary); }
.auth-container { width: 100%; max-width: 420px; }

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

.auth-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.auth-box .logo { justify-content: center; margin-bottom: 1.5rem; }
.auth-box h1 { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.auth-box .subtitle { text-align: center; color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 2rem; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-group .error-text { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; display: none; }
.form-group.error input { border-color: var(--danger); }
.form-group.error .error-text { display: block; }
.auth-box .btn { width: 100%; padding: 0.875rem; font-size: 1rem; margin-top: 0.5rem; }

.auth-footer-text { text-align: center; font-size: 0.85rem; color: var(--text-secondary); margin-top: 1.5rem; }
.auth-footer-text a { color: var(--accent); font-weight: 600; }
.auth-footer-text a:hover { text-decoration: underline; }

/* ===== PROFILE PAGE ===== */
.profile-page { padding: 3rem 2rem; max-width: 900px; margin: 0 auto; }

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.profile-avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent-dim);
  flex-shrink: 0;
}

.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.profile-info h2 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
.profile-info .username { color: var(--accent); font-weight: 500; }
.profile-info .member-since { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--accent); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ===== SETTINGS PAGE ===== */
.settings-page { padding: 3rem 2rem; max-width: 700px; margin: 0 auto; }
.settings-page h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.settings-page > p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 2rem; }

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.settings-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.avatar-upload { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 1.5rem; }

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--border-light);
  flex-shrink: 0;
}

.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload-btn { position: relative; }
.avatar-upload-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.success-message {
  padding: 0.75rem 1rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(220,47,47,0.2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
  margin-bottom: 1rem;
}

.success-message.show { display: block; }

/* ===== CONFIRM MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

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

.modal-box {
  background: #111;
  border: 1px solid #1a1a1a;
  border-radius: 12px;
  padding: 2rem 2.5rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 1rem;
}

.modal-box h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-box p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.modal-actions .btn {
  min-width: 100px;
  padding: 0.6rem 1.5rem;
}

/* ===== AUTH REQUIRED OVERLAY ===== */
.auth-required {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem;
}
.auth-required-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.auth-required-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1.25rem;
}
.auth-required-box h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.auth-required-box p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}
.auth-required-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-required-buttons .btn {
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
}

/* ===== FAQ ACCORDION ===== */
.faq-section { padding: 4rem 0; max-width: 760px; margin: 0 auto; }

.faq-section h2 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 2.5rem;
  letter-spacing: -0.5px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.faq-item:hover {
  border-color: var(--accent-dim);
  box-shadow: 0 2px 20px rgba(220,47,47,0.06);
}

.faq-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(220,47,47,0.03) 0%, transparent 50%);
  border: none;
  font-family: inherit;
  gap: 1rem;
  user-select: none;
  letter-spacing: -0.2px;
}

.faq-q:hover { color: var(--accent); }

.faq-q .faq-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
  flex-shrink: 0;
}

.faq-a {
  display: none;
  padding: 0 1.5rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.8;
}

.faq-a p { margin: 0 0 0.5rem; }
.faq-a p:last-child { margin-bottom: 0; }

.faq-a code {
  background: var(--bg-input);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.82rem;
  font-family: 'Courier New', monospace;
}

.faq-a strong { color: var(--text-primary); font-weight: 600; }

/* ===== TIER BADGES ===== */
.tier-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: middle; }
.tier-medium { background: rgba(100,181,246,0.15); color: #64b5f6; border: 1px solid rgba(100,181,246,0.25); }
.tier-ultra { background: rgba(255,215,0,0.15); color: #ffd700; border: 1px solid rgba(255,215,0,0.25); }
.room-tier-badge { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; vertical-align: middle; margin-left: 0.3rem; }
.room-item.room-locked { opacity: 0.5; cursor: not-allowed; }
.room-item.room-locked:hover { transform: none; background: var(--bg-card); border-color: var(--border); }
.room-status-icon.locked { background: rgba(255,255,255,0.04); color: var(--text-muted); }

/* ===== PROFILE CATEGORY STATS ===== */
.profile-category-stats { margin-top: 2rem; }

.profile-category-stats h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.cat-stat-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.cat-stat-name {
  font-size: 0.85rem;
  font-weight: 600;
  width: 130px;
  flex-shrink: 0;
}

.cat-stat-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cat-stat-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 0.6s ease;
}

.cat-stat-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.cat-stat-check {
  font-size: 0.85rem;
  color: var(--success);
  width: 30px;
  text-align: center;
  flex-shrink: 0;
}

/* ===== CURSOR GLOW ===== */
#cursorGlow {
  position: fixed;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(circle, rgba(220, 47, 47, 0.08) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  will-change: left, top;
}

/* ===== CART BADGE ===== */
.cart-icon-wrap, .mail-icon-wrap { position:relative; cursor:pointer; display:flex; align-items:center; }
.cart-badge { position:absolute; top:-6px; right:-6px; background:var(--accent); color:#fff; font-size:0.6rem; font-weight:700; min-width:16px; height:16px; border-radius:8px; display:flex; align-items:center; justify-content:center; padding:0 3px; line-height:1; }

/* ===== HOME PAGE SPECIFIC ===== */
.home-hero {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  position: relative;
  overflow: hidden;
}


.home-hero .home-logo {
  width: 140px;
  height: auto;
  margin-bottom: 1.5rem;
  position: relative;
  animation: logo-float 4s ease-in-out infinite, logo-glow 3s ease-in-out infinite;
}
@keyframes logo-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes logo-glow { 0%, 100% { filter: drop-shadow(0 0 40px rgba(220,47,47,0.25)); } 50% { filter: drop-shadow(0 0 80px rgba(220,47,47,0.5)); } }

.home-hero h1 {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: -1.5px;
  margin-bottom: 1rem;
  position: relative;
}

.home-hero h1 span { color: var(--accent); }

.home-hero p {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 2rem;
  line-height: 1.7;
  position: relative;
}

.home-hero .home-buttons {
  display: flex;
  gap: 1rem;
  position: relative;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .categories-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
  .header { padding: 0 1rem; }
  .nav-links { display: none; }
  .page-hero h1 { font-size: 1.75rem; }
  .page-hero { padding: 3rem 1rem 2rem; }
  .container { padding: 0 1rem; }
  .categories-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .profile-card { flex-direction: column; text-align: center; }
  .profile-stats { grid-template-columns: 1fr; }
  .flag-input-group { flex-direction: column; }
  .room-meta { gap: 0.5rem; }
  .room-difficulty { display: none; }
}

@media (max-width: 480px) {
  .auth-box { padding: 1.5rem; }
  .profile-avatar-large { width: 90px; height: 90px; }
  .settings-card { padding: 1.25rem; }
}

/* ===== VERIFICATION CODE INPUT ===== */
.v-code-input:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(220,47,47,0.15); }

/* ===== ROOM DETAIL MODAL ===== */
.room-detail-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.room-detail-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  position: relative;
  animation: modalFadeIn 0.25s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.room-detail-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.1rem; cursor: pointer; padding: 0.25rem;
  line-height: 1;
}
.room-detail-close:hover { color: var(--text-primary); }
.rd-header { padding: 1.5rem 1.5rem 0; }
.rd-header h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.75rem; }
.rd-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.rd-body { padding: 0 1.5rem; }
.rd-body h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-secondary); }
.rd-body p { font-size: 0.88rem; line-height: 1.6; color: var(--text-primary); margin-bottom: 1.25rem; }
.rd-tips { margin-bottom: 1.25rem; }
.rd-tips h3 { display: flex; align-items: center; gap: 0.75rem; }
.rd-tips ul { list-style: none; padding: 0.75rem 0 0; margin: 0; }
.rd-tips ul li { padding: 0.4rem 0; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.rd-tips ul li::before { content: '\f0eb'; font-family: 'Font Awesome 6 Free'; font-weight: 900; margin-right: 0.5rem; color: #ffd700; font-size: 0.75rem; }
.rd-footer { padding: 1rem 1.5rem 1.5rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.rd-footer .btn { flex: 1; text-align: center; }

/* ===== ADMIN PAGE ===== */
.admin-page { padding: 2rem 1rem; max-width: 1100px; margin: 0 auto; }
.admin-header { text-align: center; margin-bottom: 2rem; }
.admin-header h1 { font-size: 1.8rem; font-weight: 800; }
.admin-header p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.3rem; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.admin-stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; align-items: center; gap: 1rem; }
.admin-stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.admin-stat-info h3 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.admin-stat-info span { font-size: 0.78rem; color: var(--text-secondary); }
.admin-db-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 2rem; }
.admin-db-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.admin-db-header h2 { font-size: 1.1rem; font-weight: 700; }
.admin-db-table { overflow-x: auto; }
.admin-db-table table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.admin-db-table th { background: rgba(255,255,255,0.03); padding: 0.6rem 0.75rem; text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-db-table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
.admin-db-table tr:hover td { background: rgba(255,255,255,0.02); }
.db-password { cursor: pointer; color: var(--accent); font-family: monospace; font-weight: 600; }
.db-password:hover { text-decoration: underline; }
.admin-db-actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.admin-tier-select { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); border-radius: 4px; padding: 0.25rem 0.4rem; font-size: 0.78rem; cursor: pointer; }
.admin-tier-select:focus { outline: none; border-color: var(--accent); }
.admin-action-cell { white-space: nowrap; text-align: center; }
@media (max-width: 600px) { .admin-stats { grid-template-columns: 1fr 1fr; } }

/* ===== LEARNING PAGE ===== */
.learning-hero { text-align: center; padding: 3rem 1rem 1rem; }
.learning-hero h1 { font-size: 2rem; font-weight: 800; }
.learning-hero p { color: var(--text-secondary); margin-top: 0.3rem; }
.learning-placeholder { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.learning-placeholder i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.learning-placeholder p { font-size: 0.95rem; }
.active-cat { border-color: var(--accent) !important; box-shadow: 0 0 15px var(--accent-glow); }
.learning-modules { display: flex; flex-direction: column; gap: 0.75rem; padding: 0 1.5rem 1.5rem; }
.learning-module { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; cursor: pointer; transition: var(--transition); position: relative; overflow: hidden; }
.learning-module:hover:not(.locked) { border-color: var(--accent-dim); background: var(--bg-card-hover); }
.learning-module.locked { cursor: not-allowed; opacity: 0.5; }
.learning-module.locked:hover { border-color: var(--border); }
.learning-module-header h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.35rem; }
.learning-module-info p { font-size: 0.85rem; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.learning-module-meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.learning-duration { font-size: 0.78rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.25rem; }
.learning-module-lessons { padding: 0.6rem 1.5rem 0.75rem; font-size: 0.8rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 0.5rem; }
.learning-lock-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; gap: 0.6rem; color: var(--text-primary); font-weight: 600; font-size: 0.9rem; }
.learn-modal { max-width: 750px !important; }
.learn-modal-header { padding: 1.5rem 1.5rem 0; }
.learn-modal-header h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.learn-modal-body { padding: 1.5rem; max-height: 75vh; overflow-y: auto; }
.learn-step-counter { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.learn-intro { background: var(--bg-input); border-left: 3px solid var(--accent); padding: 0.75rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-bottom: 1.25rem; font-size: 0.88rem; line-height: 1.6; color: var(--text-secondary); display: flex; align-items: center; gap: 0.5rem; }
.learn-intro p { margin: 0; }
.learn-teach { font-size: 0.92rem; line-height: 1.8; color: var(--text-secondary); margin-bottom: 1rem; }
.learn-teach p { margin: 0 0 0.75rem; }
.learn-teach strong { color: var(--text-primary); }
.learn-teach code { background: var(--bg-input); color: var(--accent); padding: 1px 5px; border-radius: 3px; font-size: 0.82rem; font-family: 'Courier New', monospace; }
.learn-teach .code-block { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0.75rem 0; overflow-x: auto; font-size: 0.82rem; line-height: 1.6; font-family: 'Courier New', monospace; color: var(--text-primary); }
.learn-question { margin-bottom: 1rem; }
.learn-question p { font-size: 1rem; font-weight: 600; color: var(--text-primary); line-height: 1.5; }
.learn-interactive { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.learn-opt { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 1rem; cursor: pointer; font-size: 0.9rem; color: var(--text-primary); text-align: left; transition: var(--transition); font-family: inherit; }
.learn-opt:hover { border-color: var(--accent-dim); background: var(--bg-card-hover); }
.learn-opt.learn-correct { border-color: #00e676; background: rgba(0,230,118,0.1); color: #00e676; }
.learn-opt.learn-wrong { border-color: #dc2f2f; background: rgba(220,47,47,0.1); color: #dc2f2f; }
.learn-input-wrap { display: flex; gap: 0.5rem; }
.learn-input { flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 1rem; color: var(--text-primary); font-size: 0.9rem; font-family: 'Courier New', monospace; transition: var(--transition); }
.learn-input:focus { outline: none; border-color: var(--accent); }
.learn-input:disabled { opacity: 0.5; }
.learn-submit { white-space: nowrap; }
.learn-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.learn-feedback { margin: 0.75rem 0; }
.learn-fb { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.9rem; padding: 0.6rem 1rem; border-radius: var(--radius-sm); }
.learn-fb-correct { background: rgba(0,230,118,0.1); color: #00e676; border: 1px solid rgba(0,230,118,0.3); }
.learn-fb-wrong { background: rgba(220,47,47,0.1); color: #dc2f2f; border: 1px solid rgba(220,47,47,0.3); }
.learn-explain { margin-top: 0.5rem; font-size: 0.85rem; line-height: 1.6; color: var(--text-secondary); }
.learn-explain p { margin: 0.4rem 0; }
.learn-explain strong { color: var(--text-primary); }
.learn-explain code { background: var(--bg-input); color: var(--accent); padding: 1px 5px; border-radius: 3px; font-size: 0.8rem; font-family: 'Courier New', monospace; }
.learn-next { margin-top: 0.75rem; width: 100%; justify-content: center; }
.learn-lesson { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.learn-lesson:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.learn-lesson h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.learn-lesson-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-dim); color: var(--accent); font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.learn-lesson-content { font-size: 0.88rem; line-height: 1.7; color: var(--text-secondary); }
.learn-lesson-content p { margin-bottom: 0.75rem; }
.learn-lesson-content ul, .learn-lesson-content ol { margin: 0.5rem 0 0.75rem; padding-left: 1.25rem; }
.learn-lesson-content li { margin-bottom: 0.4rem; }
.learn-lesson-content strong { color: var(--text-primary); }
.learn-lesson-content code { background: var(--bg-input); color: var(--accent); padding: 1px 5px; border-radius: 3px; font-size: 0.8rem; font-family: 'Courier New', monospace; }
.learn-code-block { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0.75rem 0; overflow-x: auto; }
.learn-code-block pre { margin: 0; font-size: 0.78rem; line-height: 1.6; color: var(--text-primary); font-family: 'Courier New', monospace; }
