:root {
  --bg-color: #1a1a1a;
  --panel-bg: #2d2d2d;
  --accent: #3498db;
  --text: #f5f5f5;
  --wood: #3e2723;
  --fret-wire: #bdc3c7;
  --string-color: #ecf0f1;
  --highlight: #e74c3c;
  --box-highlight: rgba(52, 152, 219, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text);
  padding: 20px;
}

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

header h1 {
  color: var(--accent);
  margin-bottom: 5px;
}

.main-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  max-width: 1600px;
  margin: 0 auto;
}

.controls-panel {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 8px;
  min-width: 320px;
  flex: 1;
  max-width: 500px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.tabs {
  display: flex;
  margin-bottom: 15px;
  border-bottom: 2px solid #555;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: #aaa;
  padding: 10px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s, border-bottom 0.3s;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  margin-bottom: -2px; 
}

.tab-content { display: none; }
.tab-content.active { display: block; }
.form-group { margin-bottom: 15px; }

.form-group-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

select, input[type="range"] {
  width: 100%;
  padding: 8px;
  border-radius: 5px;
  background: #404040;
  color: #fff;
  border: 1px solid #555;
  font-size: 0.9rem;
  cursor: pointer;
}

select[multiple] {
  height: 75px; 
  padding: 4px;
}
select[multiple] option {
  padding: 2px 4px;
  margin-bottom: 2px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 1rem;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.play-btn {
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.play-btn:hover { background: #2ecc71; }
.arpeggio-btn { background: #8e44ad; }
.arpeggio-btn:hover { background: #9b59b6; }
.arpeggiator-btn { background: #e67e22; }
.arpeggiator-btn:hover { background: #f39c12; }
.stop-btn { background: #c0392b !important; }
.stop-btn:hover { background: #e74c3c !important; }
.pause-btn { background: #f39c12; display: none; }
.pause-btn:hover { background: #e67e22; }

.clear-btn {
  padding: 6px 12px;
  background: #c0392b;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}
.clear-btn:hover { background: #e74c3c; }

.chord-info {
  margin-top: 20px;
  background: #222;
  padding: 12px;
  border-radius: 6px;
}

.chord-info p {
  margin-bottom: 10px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.equiv-list {
  color: #f1c40f;
  font-size: 0.9rem;
  margin-left: 10px;
  display: block;
}

.tooltip-container {
  position: relative;
  display: inline-block;
  cursor: help;
  border-bottom: 1px dotted var(--accent);
  color: var(--accent);
}

.tooltip-container .tooltip-text {
  visibility: hidden;
  width: 250px;
  background-color: #555;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 10px;
  position: absolute;
  z-index: 10;
  bottom: 125%; 
  left: 50%;
  margin-left: -125px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.85rem;
  font-weight: normal;
  box-shadow: 0px 4px 8px rgba(0,0,0,0.4);
  line-height: 1.4;
}

.tooltip-container .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; }

.fretboard-container {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 8px;
  flex: 3;
  min-width: 800px;
  overflow-x: auto;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.fretboard-wrapper {
  position: relative;
  background: var(--wood);
  border-radius: 4px;
  padding: 10px 0;
  user-select: none;
}

.fretboard {
  display: grid;
  grid-template-columns: 50px repeat(18, 1fr);
  position: relative;
}

.position-highlight {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--box-highlight);
  border: 2px dashed var(--accent);
  pointer-events: none;
  z-index: 1;
  transition: grid-column 0.3s ease;
}

.fret-number-row {
  display: grid;
  grid-template-columns: 50px repeat(18, 1fr);
  margin-bottom: 8px;
  text-align: center;
  font-weight: bold;
  color: #aaa;
  font-size: 0.85rem;
}

.fret-cell {
  position: relative;
  height: 40px;
  border-right: 3px solid var(--fret-wire);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fret-cell:nth-child(19n + 1) {
  border-right: 6px solid #f39c12; 
  background: rgba(0, 0, 0, 0.2);
}

.string-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  background: var(--string-color);
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
}

.note-btn {
  position: relative;
  z-index: 2;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #555;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid #333;
  transition: all 0.15s ease;
  opacity: 0.3;
}

/* ========================================== */
/* MOBILE RESPONSIVE ADJUSTMENTS              */
/* ========================================== */

/* Tablets and smaller desktop windows */
@media (max-width: 1100px) {
  .main-container {
    flex-direction: column; /* Stacks the panel and fretboard vertically */
    align-items: center;
  }

  .controls-panel {
    min-width: 100%;
    max-width: 100%;
  }

  .fretboard-container {
    min-width: 100%;
    width: 100%;
    /* Ensures the user can swipe left/right to see the rest of the frets */
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS devices */
  }
}

/* Mobile Phones */
@media (max-width: 600px) {
  body {
    padding: 10px; /* Less padding on small screens to maximize space */
  }

  header h1 {
    font-size: 1.5rem; /* Slightly smaller header */
  }

  /* Stack the form rows so dropdowns are full-width and easy to tap */
  .form-group-row {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }

  /* Move the tooltip to avoid clipping off the screen */
  .tooltip-container .tooltip-text {
    left: 0;
    margin-left: 0;
    width: 100%;
  }

  .tooltip-container .tooltip-text::after {
    left: 10%; /* Move the little triangle pointer to align correctly */
  }
}

.note-btn:hover { transform: scale(1.15); background: #777; opacity: 1; }
.note-btn.active-root { background: var(--highlight); border: 2px solid #fff; opacity: 1; }
.note-btn.active-note { background: var(--accent); border: 2px solid #fff; opacity: 1; }
.note-btn.playable-voicing { box-shadow: 0 0 10px 4px rgba(255, 255, 255, 0.6); transform: scale(1.1); }