/* ==========================================================================
   SOS Solfege v2.0 — Dark Theme Design System
   Inspired by Yousician, Simply Piano, Duolingo Music
   (c) 2026 Emmanuel Klein
   ========================================================================== */

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

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: rgba(255,255,255,0.08);
  --bg-card-hover: rgba(255,255,255,0.12);
  --bg-card-active: rgba(255,255,255,0.16);
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-dark: #5b21b6;
  --success: #06d6a0;
  --success-dark: #059669;
  --streak: #ff6b35;
  --streak-light: #ff9a76;
  --warning: #fbbf24;
  --danger: #ef4444;
  --info: #38bdf8;
  --text-primary: #f8f9fa;
  --text-secondary: rgba(248,249,250,0.7);
  --text-muted: rgba(248,249,250,0.4);
  --border: rgba(255,255,255,0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(124,58,237,0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --tab-height: 70px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: linear-gradient(160deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 10px);
}

body.no-scroll {
  overflow: hidden;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--accent); }

img { max-width: 100%; display: block; }

/* ---------- Utility Classes ---------- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ==========================================================================
   TOP HEADER / NAV BAR
   ========================================================================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26,26,46,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-header .logo {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--streak));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.top-header .header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

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

/* ==========================================================================
   TAB BAR (bottom navigation)
   ========================================================================== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(22,33,62,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--tab-height);
  padding-bottom: var(--safe-bottom);
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-width: 56px;
}

.tab-item .tab-icon {
  font-size: 1.5rem;
  transition: var(--transition);
}

.tab-item .tab-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.tab-item.active .tab-icon {
  transform: scale(1.15);
}

.tab-item.active .tab-label {
  color: var(--accent-light);
  font-weight: 600;
}

.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 4px 4px;
}

.tab-item:active {
  transform: scale(0.92);
}

/* ==========================================================================
   TAB CONTENT (screens)
   ========================================================================== */
.tab-content {
  display: none;
  animation: fadeIn 0.35s ease;
  padding-top: 12px;
  padding-bottom: 16px;
}

.tab-content.active {
  display: block;
}

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

/* ==========================================================================
   CARDS
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

.card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card:active {
  transform: translateY(0) scale(0.98);
  background: var(--bg-card-active);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.card-row .card {
  flex: 1;
  text-align: center;
  cursor: pointer;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

/* ==========================================================================
   STREAK
   ========================================================================== */
.streak-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(255,107,53,0.15), rgba(255,154,118,0.08));
  border: 1px solid rgba(255,107,53,0.25);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.streak-flame {
  font-size: 2.4rem;
  animation: flamePulse 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(255,107,53,0.5));
}

@keyframes flamePulse {
  0%, 100% { transform: scale(1) rotate(-3deg); }
  50% { transform: scale(1.12) rotate(3deg); }
}

.streak-info {
  flex: 1;
}

.streak-count {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--streak);
}

.streak-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.streak-days {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.streak-day {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
}

.streak-day.done {
  background: var(--streak);
  border-color: var(--streak);
  color: white;
}

.streak-day.today {
  border-color: var(--streak);
  box-shadow: 0 0 8px rgba(255,107,53,0.4);
}

/* ==========================================================================
   XP BAR & LEVEL
   ========================================================================== */
.xp-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.xp-level-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 0 16px rgba(124,58,237,0.4);
  flex-shrink: 0;
}

.xp-info {
  flex: 1;
}

.xp-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.xp-level-name {
  font-weight: 600;
  color: var(--accent-light);
}

.xp-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: rgba(255,255,255,0.2);
  border-radius: 5px 5px 0 0;
}

.xp-bar-fill.animate {
  animation: xpShine 1s ease forwards;
}

@keyframes xpShine {
  0% { box-shadow: 0 0 0 rgba(124,58,237,0); }
  50% { box-shadow: 0 0 20px rgba(124,58,237,0.6); }
  100% { box-shadow: 0 0 0 rgba(124,58,237,0); }
}

/* ==========================================================================
   CONTINUE LESSON CARD
   ========================================================================== */
.continue-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(124,58,237,0.05));
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
}

.continue-card:hover {
  background: linear-gradient(135deg, rgba(124,58,237,0.3), rgba(124,58,237,0.1));
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.continue-card:active {
  transform: scale(0.98);
}

.continue-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(124,58,237,0.4);
}

.continue-info {
  flex: 1;
}

.continue-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.continue-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.continue-progress {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.continue-progress-fill {
  height: 100%;
  background: var(--accent-light);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.continue-arrow {
  font-size: 1.5rem;
  color: var(--accent-light);
  flex-shrink: 0;
}

/* ==========================================================================
   DAILY CHALLENGE
   ========================================================================== */
.challenge-card {
  background: linear-gradient(135deg, rgba(6,214,160,0.15), rgba(6,214,160,0.05));
  border: 1px solid rgba(6,214,160,0.25);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
}

.challenge-card:hover {
  background: linear-gradient(135deg, rgba(6,214,160,0.25), rgba(6,214,160,0.1));
  transform: translateY(-2px);
}

.challenge-card:active {
  transform: scale(0.98);
}

.challenge-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.challenge-badge {
  background: var(--success);
  color: var(--bg-primary);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.challenge-reward {
  font-size: 0.75rem;
  color: var(--warning);
  font-weight: 600;
  margin-left: auto;
}

.challenge-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.challenge-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ==========================================================================
   PRACTICE BUTTONS
   ========================================================================== */
.practice-section-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 12px;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.practice-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: var(--text-primary);
}

.practice-btn:hover {
  background: var(--bg-card-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.practice-btn:active {
  transform: scale(0.95);
}

.practice-btn .p-icon {
  font-size: 2rem;
}

.practice-btn .p-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   LESSON PATH (Duolingo-style vertical path)
   ========================================================================== */
.lesson-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 20px 0;
  position: relative;
}

.lesson-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  z-index: 2;
  margin-bottom: 12px;
  -webkit-tap-highlight-color: transparent;
}

.lesson-node:hover .node-circle {
  transform: scale(1.1);
}

.lesson-node:active .node-circle {
  transform: scale(0.95);
}

.lesson-node.locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.lesson-node.locked .node-circle {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.node-connector {
  width: 3px;
  height: 28px;
  background: rgba(255,255,255,0.1);
  z-index: 1;
  margin: 0 auto;
}

.node-connector.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-light));
}

.node-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: 3px solid var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
  position: relative;
}

.node-circle.completed {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  border-color: var(--success);
  box-shadow: 0 4px 16px rgba(6,214,160,0.3);
}

.node-circle.current {
  animation: currentPulse 2s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(124,58,237,0.5);
}

@keyframes currentPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(124,58,237,0.4); }
  50% { box-shadow: 0 0 32px rgba(124,58,237,0.7); }
}

.node-stars {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}

.node-stars .star {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.node-stars .star.earned {
  color: var(--warning);
  filter: drop-shadow(0 0 4px rgba(251,191,36,0.5));
}

.node-name {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
  max-width: 100px;
  text-align: center;
  line-height: 1.2;
}

/* Zigzag path offset */
.lesson-node:nth-child(4n+1) { align-self: center; }
.lesson-node:nth-child(4n+2) { align-self: flex-end; margin-right: 20%; }
.lesson-node:nth-child(4n+3) { align-self: center; }
.lesson-node:nth-child(4n+4) { align-self: flex-start; margin-left: 20%; }

.node-connector:nth-child(4n+1) { margin-left: auto; margin-right: auto; }
.node-connector:nth-child(4n+2) { margin-right: 25%; margin-left: auto; }
.node-connector:nth-child(4n+3) { margin-left: auto; margin-right: auto; }
.node-connector:nth-child(4n+4) { margin-left: 25%; margin-right: auto; }

/* ==========================================================================
   PIANO
   ========================================================================== */
.piano-container {
  padding: 16px 0;
}

.piano-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.piano-control-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.piano-control-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.piano-control-btn:active {
  transform: scale(0.95);
}

.piano-wrapper {
  position: relative;
  margin: 0 auto;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 4px 0;
}

.piano-keys {
  display: flex;
  position: relative;
  height: 220px;
  min-width: 700px;
  user-select: none;
  -webkit-user-select: none;
}

.white-key {
  flex: 1;
  height: 100%;
  background: linear-gradient(180deg, #fafafa 0%, #e8e8e8 100%);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 0 0 8px 8px;
  margin: 0 1px;
  position: relative;
  cursor: pointer;
  transition: background 0.08s ease, transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15), inset 0 -2px 4px rgba(0,0,0,0.05);
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 12px;
}

.white-key:active,
.white-key.pressed {
  background: linear-gradient(180deg, #e0e0e0 0%, #d4d4d4 100%);
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.white-key.glow {
  box-shadow: 0 4px 8px rgba(0,0,0,0.15), 0 0 20px rgba(124,58,237,0.5);
}

.white-key .key-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(0,0,0,0.35);
  pointer-events: none;
  transition: opacity 0.2s;
}

.white-key .key-label.hidden { opacity: 0; }

.black-key {
  position: absolute;
  top: 0;
  width: 9%;
  max-width: 36px;
  height: 60%;
  background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 85%, #2a2a2a 100%);
  border-radius: 0 0 5px 5px;
  z-index: 3;
  cursor: pointer;
  transition: background 0.08s ease, transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), inset 0 -3px 6px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
}

.black-key:active,
.black-key.pressed {
  background: linear-gradient(180deg, #2a2a2a 0%, #111 100%);
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  height: 58%;
}

.black-key.glow {
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 16px rgba(124,58,237,0.6);
}

.black-key .key-label {
  font-size: 0.5rem;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  pointer-events: none;
  transition: opacity 0.2s;
}

.black-key .key-label.hidden { opacity: 0; }

.piano-note-display {
  text-align: center;
  margin-top: 12px;
  min-height: 40px;
}

.piano-note-name {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--streak));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: noteAppear 0.3s ease;
}

@keyframes noteAppear {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   LEADERBOARD
   ========================================================================== */
.leaderboard-header {
  text-align: center;
  padding: 20px 0;
}

.leaderboard-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.leaderboard-period {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin: 20px 0 24px;
  padding: 0 10px;
}

.podium-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.podium-item:nth-child(1) { order: 2; }
.podium-item:nth-child(2) { order: 1; }
.podium-item:nth-child(3) { order: 3; }

.podium-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 3px solid;
  position: relative;
}

.podium-item:nth-child(1) .podium-avatar {
  width: 64px;
  height: 64px;
  font-size: 1.8rem;
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.podium-item:nth-child(2) .podium-avatar {
  border-color: #c0c0c0;
}

.podium-item:nth-child(3) .podium-avatar {
  border-color: #cd7f32;
}

.podium-medal {
  position: absolute;
  bottom: -6px;
  right: -6px;
  font-size: 1.2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.podium-name {
  font-size: 0.7rem;
  font-weight: 600;
  max-width: 80px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-xp {
  font-size: 0.65rem;
  color: var(--accent-light);
  font-weight: 600;
}

.podium-bar {
  width: 80px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  font-size: 1.5rem;
  font-weight: 800;
  color: rgba(255,255,255,0.3);
}

.podium-item:nth-child(1) .podium-bar {
  height: 100px;
  background: linear-gradient(180deg, rgba(255,215,0,0.3), rgba(255,215,0,0.05));
}
.podium-item:nth-child(2) .podium-bar {
  height: 75px;
  background: linear-gradient(180deg, rgba(192,192,192,0.2), rgba(192,192,192,0.05));
}
.podium-item:nth-child(3) .podium-bar {
  height: 55px;
  background: linear-gradient(180deg, rgba(205,127,50,0.2), rgba(205,127,50,0.05));
}

.leaderboard-list {
  list-style: none;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

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

.lb-row.is-user {
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-sm);
  margin: 4px 0;
}

.lb-rank {
  width: 28px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}

.lb-xp {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-light);
}

/* ==========================================================================
   PROFILE
   ========================================================================== */
.profile-header {
  text-align: center;
  padding: 24px 0;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 0 24px rgba(124,58,237,0.4);
}

.profile-level-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--warning);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  border: 3px solid var(--bg-primary);
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 12px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 20px 0;
}

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

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.badges-section {
  margin: 20px 0;
}

.badges-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.badge-item.locked {
  opacity: 0.3;
  filter: grayscale(1);
}

.badge-item.unlocked {
  border-color: rgba(124,58,237,0.3);
}

.badge-icon {
  font-size: 1.8rem;
}

.badge-name {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

.badge-item.just-unlocked {
  animation: badgeUnlock 0.6s ease;
}

@keyframes badgeUnlock {
  0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ==========================================================================
   SETTINGS
   ========================================================================== */
.settings-group {
  margin: 20px 0;
}

.settings-group h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.setting-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.setting-toggle {
  position: relative;
  width: 48px;
  height: 28px;
  cursor: pointer;
}

.setting-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 14px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.setting-toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.setting-toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ==========================================================================
   EXERCISE PAGES
   ========================================================================== */
.exercise-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  padding: 0;
}

.exercise-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(26,26,46,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.exercise-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-primary);
  transition: var(--transition);
  text-decoration: none;
}

.exercise-back:hover { background: var(--bg-card-hover); }

.exercise-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.exercise-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.exercise-score {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-light);
  min-width: 40px;
  text-align: right;
}

.exercise-body {
  padding: 24px 16px;
  max-width: 480px;
  margin: 0 auto;
}

.exercise-question {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.4;
}

.exercise-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.exercise-option {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font);
  color: var(--text-primary);
}

.exercise-option:hover {
  border-color: var(--accent);
  background: rgba(124,58,237,0.1);
}

.exercise-option:active {
  transform: scale(0.95);
}

.exercise-option.correct {
  border-color: var(--success);
  background: rgba(6,214,160,0.2);
  animation: correctPop 0.4s ease;
}

.exercise-option.wrong {
  border-color: var(--danger);
  background: rgba(239,68,68,0.15);
  animation: wrongShake 0.4s ease;
}

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

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

/* ==========================================================================
   RHYTHM EXERCISE
   ========================================================================== */
.rhythm-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  min-height: 100px;
  flex-wrap: wrap;
}

.rhythm-note {
  font-size: 2.2rem;
  transition: var(--transition);
  opacity: 0.4;
}

.rhythm-note.active {
  opacity: 1;
  transform: scale(1.3);
  color: var(--accent-light);
}

.rhythm-note.hit {
  color: var(--success);
  opacity: 1;
}

.rhythm-note.miss {
  color: var(--danger);
  opacity: 1;
}

.tap-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  margin: 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 8px 32px rgba(124,58,237,0.4);
  color: white;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.tap-button:active {
  transform: scale(0.92);
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}

.tap-ripple {
  position: absolute;
  border-radius: 50%;
  animation: rippleOut 0.6s ease-out forwards;
  pointer-events: none;
}

.tap-ripple.perfect { background: rgba(6,214,160,0.4); }
.tap-ripple.good { background: rgba(255,107,53,0.4); }
.tap-ripple.ok { background: rgba(251,191,36,0.4); }
.tap-ripple.miss { background: rgba(239,68,68,0.3); }

@keyframes rippleOut {
  from { width: 0; height: 0; opacity: 1; }
  to { width: 300px; height: 300px; opacity: 0; margin: -150px; }
}

.metronome-indicator {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 12px 0;
}

.bpm-display {
  font-weight: 700;
  color: var(--accent-light);
}

/* ==========================================================================
   RESULT SCREEN
   ========================================================================== */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,0.95);
  backdrop-filter: blur(20px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  max-width: 360px;
  width: 90%;
}

.result-emoji {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: resultBounce 0.6s ease;
}

@keyframes resultBounce {
  0% { transform: scale(0) rotate(-10deg); }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-score {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-light), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 12px 0;
}

.result-xp {
  font-size: 1rem;
  color: var(--warning);
  font-weight: 700;
  margin-bottom: 20px;
}

.result-stars {
  font-size: 2rem;
  margin-bottom: 20px;
  letter-spacing: 8px;
}

.result-btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 14px 40px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  margin: 6px;
}

.result-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124,58,237,0.4);
}

.result-btn:active {
  transform: scale(0.97);
}

.result-btn.secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  padding: 12px 24px;
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(124,58,237,0.4);
}

.btn-primary:active { transform: scale(0.97); }

.btn-success {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   XP POPUP ANIMATION
   ========================================================================== */
.xp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 900;
  color: var(--warning);
  pointer-events: none;
  z-index: 1000;
  animation: xpFly 1.2s ease forwards;
  text-shadow: 0 0 20px rgba(251,191,36,0.5);
}

@keyframes xpFly {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  30% { transform: translate(-50%, -70%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(0.8); opacity: 0; }
}

/* ==========================================================================
   CONFETTI
   ========================================================================== */
.confetti-piece {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (min-width: 768px) {
  .container {
    max-width: 540px;
  }

  .piano-keys {
    height: 260px;
  }

  .practice-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 380px) {
  .piano-keys {
    height: 180px;
  }

  .node-circle {
    width: 56px;
    height: 56px;
    font-size: 1.3rem;
  }

  .streak-days {
    gap: 2px;
  }

  .streak-day {
    width: 24px;
    height: 24px;
    font-size: 0.5rem;
  }

  .badges-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   DARK THEME OVERRIDES FOR SCROLLBAR / SELECTION
   ========================================================================== */
::selection {
  background: rgba(124,58,237,0.4);
  color: white;
}

/* PWA safe area */
@supports (padding: env(safe-area-inset-top)) {
  .top-header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .tab-bar {
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    height: calc(var(--tab-height) + env(safe-area-inset-bottom));
  }
}

/* ==========================================================================
   LOADING / SPLASH
   ========================================================================== */
.splash-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--bg-primary), var(--bg-secondary));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: splashPulse 1.5s ease-in-out infinite;
}

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

.splash-title {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--streak));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.splash-loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-top: 24px;
}

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