/* ============================================================
   CajonDrum — style.css  (Design System & Responsive Global)
   ============================================================ */

:root {
  --bg-primary: #0b0b14;
  --bg-secondary: #141426;
  --bg-card: #181832;
  --bg-card2: #1e1e3f;
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.35);
  --accent2: #533483;
  --text-primary: #ffffff;
  --text-secondary: #a8a8c4;
  --text-muted: #6c6c8c;
  --success: #00d4aa;
  --warning: #ffd166;
  --danger: #ef233c;
  --bass-color: #e94560;
  --tone-color: #ffd166;
  --slap-color: #00d4aa;
  --border-radius: 18px;
  --border-radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --app-max-width: 480px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #06060c;
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Fond général Desktop / Tablette */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 20%, #1a152e 0%, #080811 80%);
}

/* Conteneur App Universel */
#app, #onboarding-screen {
  width: 100%;
  max-width: var(--app-max-width);
  height: 100%;
  height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 1px rgba(255, 255, 255, 0.1);
}

@media (min-width: 600px) {
  #app, #onboarding-screen {
    border-radius: 24px;
    height: min(920px, 96dvh);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
}

/* ============================================================
   EN-TÊTE PRINCIPAL (Header)
   ============================================================ */

#app-header {
  height: 56px;
  background: var(--bg-secondary);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  z-index: 10;
}

.app-logo {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 2px;
}

.logo-dot {
  color: var(--accent);
}

#xp-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.level-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--warning);
}

.xp-bar-container {
  width: 50px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
}

.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width 0.4s ease;
}

.streak-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: #ff9f1c;
}

#install-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ============================================================
   CONTENEUR DES SECTIONS & DÉFILEMENT
   ============================================================ */

#sections {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 74px;
  -webkit-overflow-scrolling: touch;
}

.section {
  display: none;
  padding: 16px;
  animation: fadeIn 0.25s ease-out;
}

.section.active {
  display: block;
}

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

/* ============================================================
   CARTES ET ÉLÉMENTS COMMUNS
   ============================================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: var(--transition);
}

.card-title {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Section titres */
.section h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 14px;
  color: #fff;
}

/* ============================================================
   ACCUEIL (Home Section)
   ============================================================ */

.home-greeting {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 2px;
}

.motivational-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Carte « Continuer » */
.continue-card {
  background: linear-gradient(135deg, #2a153a 0%, #44172f 50%, #681729 100%);
  border: 1px solid rgba(233, 69, 96, 0.3);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.continue-card:hover {
  transform: translateY(-2px);
  border-color: rgba(233, 69, 96, 0.6);
  box-shadow: 0 6px 25px rgba(233, 69, 96, 0.25);
}

.continue-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 14px;
}

.continue-card .rhythm-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.continue-card .stars {
  color: var(--warning);
  letter-spacing: 2px;
  font-size: 0.95rem;
}

.continue-card .bpm {
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.continue-card .btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--accent-glow);
  transition: var(--transition);
}

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

/* Grille de stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  padding: 12px 6px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-number {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Parcours / Niveaux */
.levels-section h2 {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.level-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border-left: 4px solid var(--accent);
}

.level-item.locked {
  border-left-color: rgba(255, 255, 255, 0.1);
  opacity: 0.55;
}

.level-num {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
  min-width: 24px;
}

.level-item.locked .level-num {
  color: var(--text-muted);
}

.level-details {
  flex: 1;
}

.level-details h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.level-details p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.level-status {
  font-size: 1.1rem;
}

/* ============================================================
   SECTION RYTHMES (Rhythms)
   ============================================================ */

.level-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.filter-btn.active, .filter-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.rhythm-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition);
  cursor: pointer;
}

.rhythm-card.unlocked:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.rhythm-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.rhythm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.rhythm-name {
  font-size: 1.05rem;
  font-weight: 800;
}

.rhythm-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.level-badge-sm, .bpm-badge-sm {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
}

.level-badge-sm {
  background: var(--bg-card2);
  color: var(--text-secondary);
}

.bpm-badge-sm {
  background: rgba(255, 209, 102, 0.15);
  color: var(--warning);
}

.status-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
}

.unlocked-badge {
  background: rgba(0, 212, 170, 0.15);
  color: var(--success);
}

.mastered-badge {
  background: rgba(255, 209, 102, 0.2);
  color: var(--warning);
}

.locked-badge {
  background: rgba(239, 35, 60, 0.15);
  color: var(--danger);
}

.rhythm-stars {
  color: var(--warning);
  font-size: 0.95rem;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.rhythm-difficulty {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.diff-label {
  font-weight: 700;
}

.rhythm-score {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 700;
  margin-bottom: 6px;
}

.rhythm-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.35;
}

.play-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: var(--transition);
}

.play-btn:active {
  transform: scale(0.98);
}

.play-btn.locked-btn, .play-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ============================================================
   SECTION PROGRESSION
   ============================================================ */

.level-card .level-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

.xp-progress {
  margin-top: 10px;
}

.xp-progress .xp-bar-container {
  width: 100%;
  height: 10px;
  border-radius: 6px;
}

.xp-numbers {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 6px;
}

.streak-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.streak-icon {
  font-size: 2.2rem;
}

.streak-count {
  font-size: 1.6rem;
  font-weight: 900;
  color: #ff9f1c;
}

.streak-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
}

.progress-rhythm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.progress-rhythm-row.locked {
  opacity: 0.45;
}

.pr-name {
  font-weight: 700;
  flex: 1;
}

.pr-stars {
  color: var(--warning);
  letter-spacing: 1px;
  margin: 0 10px;
}

.pr-score {
  font-weight: 800;
  color: var(--success);
  min-width: 40px;
  text-align: right;
}

/* ============================================================
   SECTION PARAMÈTRES (Settings)
   ============================================================ */

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.setting-row span {
  font-size: 0.9rem;
  font-weight: 600;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 26px;
  transition: var(--transition);
}

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

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

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

.setting-row select {
  background: var(--bg-card2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
}

.btn-danger {
  width: 100%;
  padding: 14px;
  background: rgba(239, 35, 60, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  font-weight: 800;
  margin-top: 16px;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ============================================================
   ÉCRAN DE JEU INTERACTIF (Game Screen)
   ============================================================ */

#game-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--bg-primary);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#game-screen.active {
  transform: translateX(0);
}

/* En-tête de jeu */
.game-header {
  height: 52px;
  background: var(--bg-secondary);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.btn-back {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.game-rhythm-name {
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  flex: 1;
  margin: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bpm-badge {
  background: rgba(255, 209, 102, 0.2);
  color: var(--warning);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Onglets de modes de jeu */
.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.mode-tab {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* Sélecteur de mesures (mode Jouer) */
.measures-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  margin: 4px 12px;
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.measures-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.measures-btns {
  display: flex;
  gap: 4px;
}

.measure-btn {
  background: var(--bg-card2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.measure-btn.active, .measure-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.measure-counter {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--warning);
  background: rgba(255, 209, 102, 0.12);
  padding: 4px 10px;
  border-radius: 12px;
}
#hint-card {
  margin: 6px 12px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: 52px;
}

.hint-hand {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.hint-letter {
  font-size: 1.6rem;
  font-weight: 900;
}

.hint-letter.hand-r { color: var(--accent); }
.hint-letter.hand-l { color: var(--accent2); }

.hint-sound {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.hint-sound.sound-bass { color: var(--bass-color); }
.hint-sound.sound-tone { color: var(--tone-color); }
.hint-sound.sound-slap { color: var(--slap-color); }

.hint-beat {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-secondary);
}

/* Timeline musicale */
#timeline {
  margin: 4px 12px;
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
  position: relative;
  flex-shrink: 0;
}

.beat-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.beat-label {
  flex: 1;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.beat-label.active {
  color: var(--warning);
  font-weight: 900;
}

.hit-markers {
  display: flex;
  gap: 2px;
  height: 20px;
  position: relative;
}

.hit-marker {
  flex: 1;
  height: 100%;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 800;
  color: transparent;
  transition: background 0.15s;
}

.hit-marker.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.hit-marker.sound-bass { background: rgba(233, 69, 96, 0.35); color: var(--bass-color); }
.hit-marker.sound-tone { background: rgba(255, 209, 102, 0.35); color: var(--tone-color); }
.hit-marker.sound-slap { background: rgba(0, 212, 170, 0.35); color: var(--slap-color); }

.hit-marker.status-perfect { background: var(--success) !important; color: #000 !important; }
.hit-marker.status-good    { background: var(--warning) !important; color: #000 !important; }
.hit-marker.status-miss    { background: var(--danger) !important; color: #fff !important; }
.hit-marker.status-late    { background: #ff9f1c !important; color: #000 !important; }

.timeline-cursor {
  position: absolute;
  bottom: 6px;
  left: 0;
  width: 2px;
  height: 22px;
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  pointer-events: none;
  transition: left 0.04s linear;
}

/* Zone Cajon Virtuel */
#cajon-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  position: relative;
  min-height: 180px;
  touch-action: manipulation;
}

.cajon-wrapper {
  width: 100%;
  max-width: 280px;
  height: 100%;
  max-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cajon-body {
  width: 100%;
  height: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(165deg, #7a4b2b 0%, #4a2c0a 45%, #5d3517 100%);
  border-radius: 16px;
  border: 3px solid #361c0c;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), inset 0 0 25px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
}

.cajon-sound-hole {
  position: absolute;
  width: 80px;
  height: 80px;
  background: #0d0806;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 6px 15px rgba(0, 0, 0, 0.9), 0 0 2px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.cajon-zone {
  position: absolute;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
  transition: background-color 0.1s ease;
}

.zone-slap-left {
  top: 0;
  left: 0;
  width: 32%;
  height: 25%;
  border-bottom-right-radius: 16px;
  background: rgba(0, 212, 170, 0.05);
}

.zone-slap-right {
  top: 0;
  right: 0;
  width: 32%;
  height: 25%;
  border-bottom-left-radius: 16px;
  background: rgba(0, 212, 170, 0.05);
}

.zone-tone {
  top: 0;
  left: 32%;
  width: 36%;
  height: 28%;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  background: rgba(255, 209, 102, 0.05);
}

.zone-bass {
  bottom: 0;
  left: 0;
  width: 100%;
  height: 72%;
  background: rgba(233, 69, 96, 0.05);
}

.zone-label {
  font-size: 0.85rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.5px;
  pointer-events: none;
  transition: transform 0.3s ease;
}

/* Animations de flash sur frappe */
@keyframes flashExpected {
  0%   { background-color: rgba(255, 209, 102, 0); }
  50%  { background-color: rgba(255, 209, 102, 0.45); }
  100% { background-color: rgba(255, 209, 102, 0); }
}

@keyframes flashHit {
  0%   { background-color: rgba(0, 212, 170, 0.6); }
  100% { background-color: rgba(0, 212, 170, 0); }
}

@keyframes flashMiss {
  0%   { background-color: rgba(239, 35, 60, 0.6); }
  100% { background-color: rgba(239, 35, 60, 0); }
}

.highlight-expected { animation: flashExpected 0.35s ease-out; }
.highlight-hit      { animation: flashHit 0.25s ease-out; }
.highlight-miss     { animation: flashMiss 0.25s ease-out; }

/* Bouton Rotation */
#rotate-btn {
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: var(--transition);
}

#rotate-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Popup de feedback flottant */
.feedback-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  pointer-events: none;
  animation: floatFeedback 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  z-index: 50;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.feedback-perfect { color: var(--success); }
.feedback-good    { color: var(--warning); }
.feedback-late    { color: #ff9f1c; }
.feedback-miss    { color: var(--danger); }

@keyframes floatFeedback {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.85); }
  100% { opacity: 0; transform: translate(-50%, -100%) scale(1.15); }
}

/* Contrôles BPM */
#bpm-controls {
  padding: 4px 16px;
  flex-shrink: 0;
}

.bpm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 6px;
}

.btn-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.bpm-display {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  min-width: 50px;
  text-align: center;
}

.bpm-presets {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn.active, .preset-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#bpm-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

/* Boutons de contrôle (Play / Stop / Restart) */
#game-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 16px 12px;
  flex-shrink: 0;
}

#play-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: var(--transition);
}

#play-btn:active {
  transform: scale(0.92);
}

.btn-circle-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

/* ============================================================
   ÉCRAN DE SCORE FINAL (Score Overlay)
   ============================================================ */

#score-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 20, 0.96);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.score-title {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.score-stars {
  font-size: 1.8rem;
  color: var(--warning);
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.score-total {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 16px;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 14px;
}

.score-stat {
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  padding: 10px 4px;
  font-size: 0.95rem;
  font-weight: 800;
}

.score-stat span {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.score-feedback {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  max-width: 280px;
}

.xp-badge {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.score-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.btn-outline {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

.btn-primary.continue-btn {
  flex: 1;
  padding: 12px;
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

/* ============================================================
   NAVIGATION DU BAS (Bottom Nav)
   ============================================================ */

#bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 10;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 12px;
  transition: var(--transition);
}

.nav-item.active, .nav-item:hover {
  color: var(--accent);
}

.nav-icon {
  font-size: 1.25rem;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ============================================================
   ONBOARDING
   ============================================================ */

#onboarding-screen {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.onboarding-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.onboarding-emoji {
  font-size: 4rem;
  margin-bottom: 8px;
}

.onboarding-slide h2 {
  font-size: 1.6rem;
  font-weight: 900;
}

.onboarding-slide p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 260px;
  line-height: 1.4;
}

.slide-dots {
  display: flex;
  gap: 8px;
  margin: 24px 0 20px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: var(--transition);
}

.dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

.onboarding-btn {
  width: 100%;
  max-width: 280px;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* ============================================================
   NOTIFICATIONS TOAST
   ============================================================ */

#toast-container {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}

.toast {
  background: var(--bg-card2);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.toast-success {
  background: rgba(0, 212, 170, 0.9);
  color: #000;
}

.toast.toast-error {
  background: rgba(239, 35, 60, 0.9);
  color: #fff;
}

.hidden {
  display: none !important;
}

/* ============================================================
   RESPONSIVE : SMARTPHONE / TABLETTE EN PAYSAGE (Landscape)
   ============================================================ */

@media (orientation: landscape) and (max-height: 520px) {
  :root {
    --app-max-width: 860px;
  }

  #game-screen {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .game-header {
    width: 100%;
    height: 42px;
  }

  /* Colonne gauche : infos, timeline, contrôles */
  .mode-tabs, #hint-card, #timeline, #bpm-controls, #game-controls {
    width: 48%;
  }

  #hint-card {
    min-height: 42px;
    padding: 4px 12px;
    margin: 4px 8px;
  }

  #timeline {
    margin: 4px 8px;
    padding: 4px;
  }

  #bpm-controls {
    padding: 2px 12px;
  }

  .bpm-row {
    margin-bottom: 2px;
  }

  .bpm-display {
    font-size: 1.2rem;
  }

  .bpm-presets {
    display: none;
  }

  #game-controls {
    padding: 2px 12px 6px;
  }

  #play-btn {
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
  }

  /* Colonne droite : Cajon géant */
  #cajon-container {
    width: 52%;
    height: calc(100% - 42px);
    position: absolute;
    right: 0;
    top: 42px;
    padding: 6px;
  }

  .cajon-wrapper {
    max-width: 240px;
    max-height: 240px;
  }
}
