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

body {
  font-family: 'Courier New', monospace;
  background: #0a0a0a;
  color: #eee;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 20px;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
}

#song-title {
  font-size: 1.8em;
  padding: 10px;
  width: 600px;
  background: #222;
  border: 2px solid #555;
  color: #eee;
  text-align: center;
  border-radius: 8px;
}

.controls {
  text-align: center;
  margin: 20px 0;
  padding: 15px;
  background: #1a1a1a;
  border-radius: 12px;
}

.controls button {
  padding: 10px 20px;
  margin: 0 10px;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

.main {
  display: grid;
  grid-template-columns: 220px 1fr 180px;
  gap: 24px;
}

.chord-palette {
  background: #222;
  padding: 20px;
  border-radius: 12px;
}

.chord-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.chord-btn {
  padding: 18px;
  background: #444;
  text-align: center;
  border-radius: 8px;
  font-weight: bold;
  cursor: move;
  user-select: none;
  transition: 0.2s;
}

.chord-btn:hover {
  background: #555;
  transform: translateY(-3px);
}

#lead-sheet {
  display: grid;
  gap: 16px;
  padding: 30px;
  background: #111;
  border-radius: 16px;
  border: 4px solid #333;
  min-height: 600px;
}

.measure {
  background: #1e1e1e;
  border: 2px solid #444;
  border-radius: 10px;
  min-height: 100px;
  padding: 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  overflow: hidden;
}

.measure.empty {
  border-style: dashed;
  background: transparent;
}

/* Adatta box accordo alla cella — riempie senza padding extra */
.chord-box {
  background: #3498db;
  color: white;
  padding: 4px 6px;
  /* Ridotto da 12px 8px — più compatto */
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  font-size: 1.4em;
  cursor: move;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  flex: 1;
  min-width: 0;
  position: relative;
  height: 100%;
  /* Riempie la cella verticalmente */
  display: flex;
  /* Centra testo */
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}


.chord-box:hover {
  background: #5ab3f0;
  transform: translateY(-1px);
  /* Leggero hover per feedback */
}

.chord-box .remove {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 16px;
  opacity: 0.7;
  cursor: pointer;
}

.player-controls button {
  width: 100%;
  padding: 20px;
  margin: 10px 0;
  font-size: 1.5em;
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
}

#play {
  background: #3498db;
}

#stop {
  background: #3498db;
}

 
#save-song {
  background: #3498db;
}

.select-wrapper {
  position: relative;
  display: inline-block;
}

.select-wrapper::after {
  content: '▼';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #aaa;
  font-size: 0.8em;
}

#song-list {
  padding: 12px 36px 12px 16px;
  background: #222;
  border: 2px solid #444;
  border-radius: 10px;
  color: #eee;
  font-size: 1em;
  min-width: 220px;
  appearance: none;
  cursor: pointer;
  outline: none;
}

#song-list:hover {
  border-color: #666;
}

#song-list:focus {
  border-color: #3498db;
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.4);
}

.danger {
  background: #e74c3c !important;
}

.danger:hover {
  background: #c0392b !important;
}

#grid-setup-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: #1a1a1a;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  border: 3px solid #333;
  min-width: 360px;
}

.modal-content h2 {
  margin-bottom: 20px;
  font-size: 2em;
}

.grid-inputs {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 30px 0;
}

.grid-inputs label {
  font-size: 1.2em;
}

.grid-inputs input[type="number"] {
  width: 80px;
  padding: 10px;
  font-size: 1.4em;
  text-align: center;
  background: #333;
  border: 2px solid #555;
  border-radius: 8px;
  color: #eee;
}

#create-grid {
  padding: 14px 40px;
  font-size: 1.3em;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 20px;
}

#new-song {
  background: #3498db !important;
}

#new-song:hover {
  background: #2980b9 !important;
}

/* SPINNER DURANTE CARICAMENTO AUDIO */
.audio-spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  color: white;
  font-size: 1.6em;
}

.audio-spinner.hidden {
  display: none;
}

.spinner {
  width: 70px;
  height: 70px;
  border: 8px solid #333;
  border-top: 8px solid #27ae60;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}

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

/* EVIDENZIAZIONE DEL CHORD IN RIPRODUZIONE – ORA SI VEDE DAVVERO */
.chord-box.playing {
  background: #ffff00 !important;
  /* Giallo fluo */
  color: #000 !important;
  font-weight: 900 !important;
  font-size: 2em !important;
  transform: scale(1.4) !important;
  border: 6px solid #ff0000 !important;
  box-shadow:
    0 0 40px #ffff00,
    0 0 80px #ff0000,
    inset 0 0 30px #ffffff !important;
  z-index: 9999 !important;
  animation: flash 0.5s infinite alternate !important;
  border-radius: 16px !important;
}

@keyframes flash {
  from {
    box-shadow: 0 0 40px #ffff00, 0 0 80px #ff0000, inset 0 0 30px #fff;
  }

  to {
    box-shadow: 0 0 70px #ffff00, 0 0 120px #ff0000, inset 0 0 50px #fff;
  }
}

.extension-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.extension-btn {
  padding: 14px 8px;
  background: #2c3e50;
  color: #ecf0f1;
  text-align: center;
  border-radius: 8px;
  font-weight: bold;
  font-size: 1.1em;
  cursor: move;
  user-select: none;
  transition: 0.2s;
  border: 1px solid #444;
}

.extension-btn:hover {
  background: #34495e;
  transform: translateY(-3px);
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

* {
  cursor: default !important;
}

body[data-copy-mode] {
  cursor: copy !important;
}

button:disabled,
input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

#bpm-slider:disabled {
  background: #444;
}

.created-by {
  font-size: 0.9em;
  color: #888;
  margin-top: 5px;
  text-align: center;
  font-style: italic;
}

/* Sub-grid per 3-4 accordi */
.sub-chord-box {
  background: #1e1e1e;
  border: 1px solid #444;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 2px;
}

.chord-box,
.sub-chord-box .chord-box {

  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  transition: font-size 0.2s ease;
  padding: 2px 4px;
  font-weight: bold;
}

/* Visual feedback durante drag & drop */
.measure.drag-over {
  border-color: #27ae60 !important;
  background: rgba(39, 174, 96, 0.1) !important;
  transform: scale(1.02);
}

.chord-box.drag-over {
  border: 2px dashed #27ae60 !important;
  background: rgba(39, 174, 96, 0.2) !important;
}

/* Icona manina con Ctrl premuto */
body.ctrl-drag {
  cursor: copy !important;
  /* manina per copy */
}

.sub-chord-box {
  font-size: 1.05em !important;
  padding: 2px 4px;
}

/* Feedback drag feedback */
.measure.drag-over,
.chord-box.drag-over {
  outline: 3px solid #27ae60;
  background: rgba(39, 174, 96, 0.2) !important;
}

/* Ctrl = manina */
body.ctrl-active * {
  cursor: copy !important;
}

/* FIX FINALE: box nella sub-griglia identici a quelli normali */
.sub-chord-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 30, 0.8);
  border-radius: 6px;
  overflow: hidden;
  padding: 2px;
  /* importante per dare respiro */
}

.sub-chord-box,
.chord-box {
  width: 100%;
  height: 100%;
  min-height: 44px;
  /* stessa altezza minima dei box normali */
  display: flex;
  background: #1a1a1a;
  align-items: center;
  justify-content: center;
  border: 1px solid #444;
  border-radius: 5px;
  font-weight: bold;
  font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
  font-size: xx-large;
  color: #fff;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
  cursor: move;
}

.sub-chord-box {
  font-size: 1.05em !important;
  /* piccolo ma leggibile */
  line-height: 1.1;
}

/* Hover e feedback uguale a quello dei box normali */
.sub-chord-box:hover,
.chord-box:hover {
  background: #2a2a2a;
  border-color: #666;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Rimuovi × identico */
.sub-chord-box .remove,
.chord-box .remove {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.9em;
  color: #aaa;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.sub-chord-box:hover .remove,
.chord-box:hover .remove {
  opacity: 1;
}

.sub-chord-box .remove:hover,
.chord-box .remove:hover {
  color: #ff5b5b;
}

/* Assicura che tutte le celle abbiano la stessa altezza */
.measure {
  background: #1e1e1e;
  border: 2px solid #444;
  border-radius: 10px;
  min-height: 80px;
  /* Ridotto da 100px — celle più compatte */
  padding: 6px;
  /* Ridotto da 10px per più spazio interno */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  /* Ridotto da 6px per fit tighter */
  overflow: hidden;
}


/* Palette Sticky per Desktop */
.chord-palette {
  background: #222;
  padding: 20px;
  border-radius: 12px;
  position: sticky;
  /* Fissa in alto durante scroll verticale */
  top: 20px;
  /* Distanza dal top del viewport */
  height: fit-content;
  overflow-y: auto;
  /* Scroll interno se palette troppo alta */
  max-height: 80vh;
  /* Limita altezza per evitare overflow */
}

/* Mobile: Palette orizzontale in basso, si sposta su/giù con scroll */
@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
    /* Stack verticale su mobile */
    gap: 12px;
  }

  .chord-palette {
    position: fixed !important;
    /* Forza fixed su mobile */
    bottom: 0;
    left: 0;
    width: 100%;
    top: auto;
    border-radius: 12px 12px 0 0;
    /* Arrotonda solo in alto */
    padding: 15px;
    z-index: 100;
    /* Sopra tutto */
    transform: translateY(100%);
    /* Inizialmente nascosto sotto */
    transition: transform 0.3s ease;
    /* Animazione smooth */
    display: flex;
    /* Layout orizzontale */
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
  }

  .chord-palette.mobile-visible {
    transform: translateY(0);
    /* Visibile quando scroll */
  }

  .chord-list,
  .extension-list {
    display: flex !important;
    /* Forza orizzontale su mobile */
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .chord-btn,
  .extension-btn {
    padding: 10px 8px;
    /* Più piccolo su mobile */
    font-size: 1em;
    min-width: 35px;
  }

  #lead-sheet {
    margin-bottom: 120px;
    /* Spazio per palette in basso su mobile */
  }

  .player-controls {
    margin-top: 120px;
    /* Spazio per palette */
  }

  /* Smooth scrolling durante playback */
  html {
    scroll-behavior: smooth;
  }

  /* Previeni layout shift */
  body {
    overflow-x: hidden;
  }

}

/* Scrollbar personalizzata per palette su desktop */
.chord-palette::-webkit-scrollbar {
  width: 6px;
}

.chord-palette::-webkit-scrollbar-track {
  background: #333;
}

.chord-palette::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 3px;
}

.style-selector {
  display: flex;
  gap: 8px;
  margin-top: 5px;
}

.style-btn {
  padding: 8px 12px;
  border: 2px solid #444;
  background: #222;
  color: #ccc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.style-btn.active {
  background: #d4af37;
  color: black;
  border-color: #d4af37;
  font-weight: bold;
}

/* ───── YOUJAZZ MODERN MESSAGE BOX ───── */
.yj-message-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.yj-message-overlay.show {
  opacity: 1;
  visibility: visible;
}

.yj-message-box {
  background: #1a1a1a;
  border: 2px solid #d4af37;
  border-radius: 16px;
  padding: 30px 40px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(212, 175, 55, 0.2);
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.yj-message-overlay.show .yj-message-box {
  transform: scale(1);
}

.yj-message-icon {
  font-size: 4em;
  margin-bottom: 16px;
  color: #d4af37;
}

.yj-message-title {
  font-size: 1.8em;
  font-weight: bold;
  color: #d4af37;
  margin: 0 0 12px 0;
  font-family: 'Georgia', serif;
}

.yj-message-text {
  font-size: 1.2em;
  color: #eee;
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.yj-message-btn {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: black;
  border: none;
  padding: 14px 32px;
  font-size: 1.2em;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(212, 175, 55, 0.4);
  transition: all 0.2s;
}

.yj-message-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(212, 175, 55, 0.6);
}

.yj-message-btn:active {
  transform: translateY(0);
}

.yj-message-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.yj-btn-primary {
  background: linear-gradient(135deg, #d4af37, #b8860b);
  color: black;
}

.yj-btn-secondary {
  background: #444;
  color: #eee;
}

.yj-btn-danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
}

.yj-btn-primary:hover,
.yj-btn-danger:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.yj-input {
  width: 100%;
  padding: 12px 16px;
  background: #333;
  border: 2px solid #555;
  border-radius: 12px;
  color: #eee;
  font-size: 1.1em;
  text-align: center;
}

.yj-input:focus {
  outline: none;
  border-color: #d4af37;
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}



.like-btn {
  background: #1a1a1a;
  border: 2px solid #d4af37;
  color: #d4af37;
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 1.3em;
  cursor: pointer;
  margin-left: 12px;
  transition: all 0.3s;
}

.like-btn:hover {
  background: #3498db;
  color: #000;
}

.like-btn.liked {
  background: #3498db;
  border-color: #e74c3c;
  color: white;
}

.like-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#like-count {
  font-size: 0.9em;
  margin-left: 6px;
}


.measure.drag-over {
  outline: 4px solid #e91e63 !important;
  outline-offset: -4px;
  background: rgba(233, 30, 99, 0.15) !important;
}

/* Evidenziazione cella durante riproduzione */
.measure.measure-playing {
  border: 4px solid #ffff00 !important;
  background: rgba(255, 255, 0, 0.15) !important;
  box-shadow:
    0 0 30px rgba(255, 255, 0, 0.6),
    inset 0 0 20px rgba(255, 255, 0, 0.2) !important;
  transform: scale(1.03);
  transition: all 0.2s ease;
  z-index: 100;
}

.measure.measure-playing.empty {
  background: rgba(255, 255, 0, 0.1) !important;
}

/* ========== MOBILE RESPONSIVE STYLES ========== */
/* Aggiungi questo alla fine del tuo styles.css */

@media (max-width: 768px) {

  /* Header ottimizzato */
  header h1 {
    font-size: 1.5em;
    margin-bottom: 8px;
  }

  html {
    scroll-behavior: smooth;
  }

  /* Previeni layout shift */
  body {
    overflow-x: hidden;
  }

    /* User info compatta */
  header>div[style*="position:absolute"] {
    position: static !important;
    text-align: center !important;
    margin-top: 10px;
  }
  #song-title {
    width: 90%;
    font-size: 1.2em;
    padding: 8px;
  }



  #user-name {
    font-size: 0.9em !important;
  }

  #user-pic {
    width: 30px !important;
    height: 30px !important;
    margin-top: 5px !important;
  }

  /* Controls responsive */
  .controls {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .controls button {
    width: 100%;
    padding: 12px;
    margin: 0;
    font-size: 1em;
  }

  .controls label {
    display: block;
    text-align: center;
    margin: 8px 0 4px 0;
  }

  #bpm-slider {
    width: 100%;
  }

  .select-wrapper {
    width: 100%;
  }

  #song-list {
    width: 100%;
    min-width: auto;
  }

  /* Layout principale mobile */
  .main {
    grid-template-columns: 1fr;
    gap: 0;
    position: relative;
  }

  /* Lead sheet ottimizzato */
  #lead-sheet {
    padding: 15px 10px;
    gap: 12px;
    min-height: auto;
    margin-bottom: 180px;
    /* Spazio per palette e controlli */
  }

  /* Misure più compatte */
  .measure {
    min-height: 70px;
    padding: 8px;
    gap: 4px;
  }

  /* Chord box mobile */
  .chord-box {
    font-size: 1.2em !important;
    padding: 6px 4px;
    min-height: 40px;
  }

  .sub-chord-box {
    font-size: 0.9em !important;
    min-height: 35px;
  }

  .chord-box .remove {
    font-size: 18px;
    top: 1px;
    right: 3px;
  }

  /* Player controls in basso fissi */
  .player-controls {
    position: fixed;
    bottom: 100px;
    /* Sopra la palette */
    left: 0;
    right: 0;
    background: #1a1a1a;
    padding: 10px;
    z-index: 99;
    display: flex;
    gap: 8px;
    border-top: 2px solid #333;
  }

  .player-controls button {
    flex: 1;
    padding: 14px 8px;
    margin: 0;
    font-size: 1.1em;
  }

  /* Palette mobile in basso */
  .chord-palette {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 100px;
    top: auto;
    border-radius: 12px 12px 0 0;
    padding: 12px 8px;
    z-index: 100;
    overflow-x: auto;
    overflow-y: hidden;
    transform: translateY(0);
    display: flex;
    flex-direction: row;
    gap: 8px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
  }

  .chord-palette h3 {
    display: none;
    /* Nascondi titoli su mobile */
  }

  .control-group {
    display: none;
    /* Nascondi style selector su mobile per risparmiare spazio */
  }

  /* Accordi in riga orizzontale */
  .chord-list {
    display: flex !important;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding: 0;
    flex-wrap: nowrap;
  }

  .chord-btn {
    min-width: 45px;
    padding: 12px 8px;
    font-size: 1.1em;
    flex-shrink: 0;
  }

  /* Estensioni in riga */
  .extension-list {
    display: flex !important;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding: 0;
    flex-wrap: nowrap;
  }

  .extension-btn {
    min-width: 40px;
    padding: 10px 6px;
    font-size: 1em;
    flex-shrink: 0;
  }

  /* Scrollbar orizzontale più visibile su mobile */
  .chord-list::-webkit-scrollbar,
  .extension-list::-webkit-scrollbar {
    height: 4px;
  }

  .chord-list::-webkit-scrollbar-thumb,
  .extension-list::-webkit-scrollbar-thumb {
    background: #d4af37;
    border-radius: 2px;
  }

  /* Modal responsive */
  .modal-content {
    width: 90%;
    min-width: auto;
    padding: 25px 20px;
  }

  .modal-content h2 {
    font-size: 1.5em;
  }

  .grid-inputs {
    flex-direction: column;
    gap: 15px;
  }

  .grid-inputs input[type="number"] {
    width: 100%;
    font-size: 1.2em;
  }

  #create-grid {
    width: 100%;
    font-size: 1.1em;
  }

  /* Spinner mobile */
  .audio-spinner {
    font-size: 1.2em;
  }

  .spinner {
    width: 50px;
    height: 50px;
  }

  /* Guest notice mobile */
  #guest-notice {
    top: 5px !important;
    right: 5px !important;
    left: 5px !important;
    padding: 8px !important;
    font-size: 0.8em !important;
    text-align: center;
  }

  /* Like button mobile */
  .like-btn {
    padding: 6px 10px;
    font-size: 1em;
    margin-left: 8px;
  }

  /* Created by text */
  .created-by {
    font-size: 0.8em;
  }

  /* Message box mobile */
  .yj-message-box {
    width: 90%;
    max-width: 90%;
    padding: 20px;
  }

  .yj-message-icon {
    font-size: 3em;
  }

  .yj-message-title {
    font-size: 1.4em;
  }

  .yj-message-text {
    font-size: 1em;
  }

  .yj-message-btn {
    padding: 12px 24px;
    font-size: 1em;
  }

  /* Grid columns adattive per mobile */
  #lead-sheet {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
  }

  /* Prevent zoom on input focus */
  input[type="text"],
  input[type="number"],
  select {
    font-size: 16px !important;
  }
}

/* Extra small phones (< 400px) */
@media (max-width: 400px) {
  header h1 {
    font-size: 1.2em;
  }

  #song-title {
    font-size: 1em;
  }

  .controls button {
    padding: 10px;
    font-size: 0.9em;
  }

  .chord-btn {
    min-width: 40px;
    padding: 10px 6px;
    font-size: 1em;
  }

  .extension-btn {
    min-width: 35px;
    padding: 8px 4px;
    font-size: 0.9em;
  }

  .player-controls button {
    padding: 12px 6px;
    font-size: 1em;
  }

  .measure {
    min-height: 60px;
  }

  .chord-box {
    font-size: 1em !important;
  }
}

/* Landscape mode per mobile */
@media (max-width: 768px) and (orientation: landscape) {
  header {
    margin-bottom: 10px;
  }

  html {
    scroll-behavior: smooth;
  }

  /* Previeni layout shift */
  body {
    overflow-x: hidden;
  }

  header h1 {
    font-size: 1.3em;
    margin-bottom: 5px;
  }

  .controls {
    padding: 8px;
  }

  .chord-palette {
    max-height: 80px;
  }

  .player-controls {
    bottom: 80px;
  }

  #lead-sheet {
    margin-bottom: 140px;
    padding: 10px;
  }
}

/* Migliora l'aspetto del dropdown utente */
#user-dropdown {
  animation: fadeIn 0.2s ease-out;
}

#user-dropdown div:hover {
  background: #333 !important;
}

/* Animazione apertura menu */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* User info posizionamento migliorato */
#user-info {
  position: absolute;
  top: 20px;
  right: 20px;
  cursor: pointer;
  z-index: 1000;
}

#user-pic {
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

#user-pic:hover {
  transform: scale(1.1);
}

#user-dropdown {
  display: none;
  position: absolute;
  top: 55px;
  right: 0;
  background: #1a1a1a;
  border: 2px solid #444;
  border-radius: 12px;
  min-width: 200px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.8);
  overflow: hidden;
}

.dropdown-header {
  padding: 16px;
  color: #eee;
  font-weight: bold;
  border-bottom: 1px solid #444;
  background: #222;
}

.dropdown-item {
  padding: 12px 16px;
  color: #ff6b6b;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: #333;
}

/* Public toggle nel controls */
#public-toggle-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #222;
  border-radius: 8px;
  margin: 0 10px;
}

#public-toggle-container label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 1em;
  color: #ddd;
  margin: 0;
}

#public-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #e91e63;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  #user-info {
    position: static;
    text-align: center;
    margin: 10px 0;
  }
  
  #user-dropdown {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
  }
  
  #public-toggle-container {
    width: 100%;
    justify-content: center;
    margin: 10px 0;
  }
}

#add-row {
  background: #3498db;
}

#add-row:hover:not(:disabled) {
  background: #3498db;
}

