:root {
  --accent: #22c55e;
  --fret-min-width: clamp(12px, calc(2.1vw + 6px), 37px);
}

.dia-app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 12px 24px;
}

.control-panel {
  display: grid;
  gap: 12px;
  background: #f8fafc;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  grid-template-columns: 1fr;
  align-items: start;
}

.control-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.control-label {
  font-weight: 600;
  font-size: 0.92rem;
  color: #0f172a;
  min-width: 120px;
}

.pill-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  flex: 1 1 75%;
  max-width: 75%;
}

.pill-button {
  background: #e2e8f0;
  color: #0f172a;
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pill-button:hover {
  background: #cbd5e1;
}

.pill-button.selected {
  background: var(--accent);
  color: #fff;
}

.note-row {
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: stretch;
}

.pill-button.natural {
  min-width: 52px;
}

.accidental-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radio-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 0;
  max-width: 100%;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 0.9rem;
}

.radio-pill input {
  margin: 0;
}

.display-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 75%;
  max-width: 75%;
}

#scale-select {
  width: 75%;
  min-width: 160px;
  flex: 0 0 75%;
  max-width: 75%;
}

@media (max-width: 720px) {
  .control-group {
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .control-label {
    min-width: 0;
  }
  .pill-buttons,
  .radio-row,
  .display-buttons {
    flex: 1 1 100%;
    max-width: 100%;
  }
  #scale-select {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }
}

.range-group .range-inputs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.range-group input {
  width: 80px;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.status-row {
  margin-top: 12px;
  margin-bottom: 12px;
}

.status {
  padding: 10px 12px;
  border-radius: 12px;
  background: #ecfdf3;
  color: #14532d;
  font-weight: 600;
}

@media (min-width: 900px) {
  .control-panel {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
  .control-panel .control-group {
    grid-column: 1 / -1;
  }
  .control-panel .control-group:nth-of-type(3) {
    grid-column: 1;
  }
  .control-panel .control-group:nth-of-type(4) {
    grid-column: 2;
  }
}

.diatonic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}

.degree-card {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 12px 12px 16px;
  flex: 0 0 auto;
}

.degree-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.degree-roman {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  color: #0f172a;
}

.degree-chord {
  font-weight: 700;
  color: #334155;
}

.board-wrapper {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  padding: 10px 10px 14px;
  overflow-x: auto;
  width: auto;
  max-width: 1200px;
  margin: 0 auto;
}

.fret-numbers,
.string-row {
  display: grid;
  grid-template-columns: repeat(20, minmax(var(--fret-min-width), 1fr));
  column-gap: 0;
  align-items: center;
}

.fret-numbers {
  margin-bottom: 0;
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
}

.fret-number {
  font-variant-numeric: tabular-nums;
  padding: 10px 0;
  border-left: none;
  text-align: center;
}

.string-row {
  position: relative;
  padding: 0;
}

.string-row::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #000;
  pointer-events: none;
  z-index: 2;
}

.fret {
  position: relative;
  min-height: clamp(20px, 3.2vw, 26px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-left: 1px solid #d5d9e8;
  font-weight: 600;
  font-size: clamp(0.62rem, 1.4vw, 0.8rem);
  color: #111827;
}

.fret:last-child {
  border-right: 1px solid #d5d9e8;
}

.fret[data-fret="0"] {
  border-right: 2px solid #111827;
}

.fret-overlay {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.fret-overlay::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(14px, 3vw, 22px);
  height: clamp(14px, 3vw, 22px);
  border-radius: 50%;
  background: #111827;
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  z-index: 4;
}

.fret-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  font-size: clamp(0.6rem, 1.3vw, 0.78rem);
  letter-spacing: 0.01em;
  line-height: 1.15;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  z-index: 5;
}

.fret.has-label .fret-label {
  opacity: 1;
}

.fret.active .fret-overlay::before {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.fret.active .fret-label {
  background: transparent;
  box-shadow: none;
  color: #fff;
}

.fret.active.root-emphasis .fret-overlay::before {
  background: #22c55e;
}

.fret.active.root-emphasis .fret-label {
  color: #fff;
}
