:root {
  --bg: #f4f0e8;
  --panel: #efe8dd;
  --ink: #111;
  --muted: #6b665f;
  --line: #15120f;
  --fret: #59524b;
  --dot-fill: #111;
  --dot-open: #f8f5ef;
  --shadow: rgba(0,0,0,0.12);
  --active: #d66b3d;
}

* { box-sizing: border-box; }

/* Keyboard focus — visible ring using the active accent colour */
:focus-visible {
  outline: 3px solid var(--active);
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.app {
  width: min(1180px, 100%);
  display: grid;
  gap: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 2px solid rgba(0,0,0,0.18);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 8px 20px var(--shadow);
}

.title {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.title h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.title p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.btn, .chip, select {
  border: 2px solid var(--ink);
  background: #faf7f1;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.95rem;
}

.btn {
  cursor: pointer;
  font-weight: 600;
  min-width: 90px;
}

.btn.play {
  min-width: 110px;
}

.chip {
  font-weight: 700;
  background: #111;
  color: #f8f5ef;
}

.board-wrap {
  background: var(--panel);
  border: 2px solid rgba(0,0,0,0.18);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 10px 24px var(--shadow);
}

.legend {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-select-item select {
  border: 1.5px solid var(--ink);
  background: #faf7f1;
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.88rem;
  cursor: pointer;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--dot-fill);
  display: inline-block;
}

.swatch.open {
  background: var(--dot-open);
}

.swatch.ghost {
  background: rgba(17,17,17,0.18);
  border-color: transparent;
}

svg {
  width: 100%;
  height: auto;
  display: block;
}

.nut {
  fill: var(--line);
}

.string {
  stroke: var(--line);
  stroke-linecap: round;
}

.string.s1 { stroke-width: 4; }
.string.s2 { stroke-width: 5; }
.string.s3 { stroke-width: 6; }
.string.s4 { stroke-width: 7; }

.fret {
  stroke: var(--fret);
  stroke-width: 10;
  opacity: 0.9;
}

.rail {
  stroke: var(--line);
  stroke-width: 8;
  stroke-linecap: round;
}

.note {
  fill: var(--dot-fill);
  stroke: var(--ink);
  stroke-width: 2.5;
  transition: fill 0.12s ease, transform 0.12s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.note.root {
  fill: var(--dot-open);
}

.note.ghost {
  fill: rgba(17,17,17,0.18);
  stroke: none;
}

.note.active {
  fill: var(--active);
  filter: drop-shadow(0 0 6px rgba(214,107,61,0.6));
  transform: scale(1.08);
}

.note.root.active {
  fill: #fff0e6;
}

.footer-note {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 12px;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .title {
    grid-column: 1 / -1;
  }
}

.pattern-toggle {
  display: flex;
  gap: 0;
}

.pattern-toggle .pattern-btn {
  border-radius: 0;
  border-right-width: 1px;
  min-width: 0;
  padding: 10px 12px;
}

.pattern-toggle .pattern-btn:first-child { border-radius: 999px 0 0 999px; }
.pattern-toggle .pattern-btn:last-child  { border-radius: 0 999px 999px 0; border-right-width: 2px; }
.pattern-toggle .pattern-btn.active      { background: var(--ink); color: var(--dot-open); }

@media (max-width: 900px) {
  .pattern-toggle { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  body { padding: 16px; }
  .board-wrap { padding: 14px; border-radius: 20px; }
  .btn, .chip { width: 100%; }
  .topbar { grid-template-columns: 1fr; }
  .pattern-toggle { width: 100%; }
  .pattern-toggle .pattern-btn { flex: 1; }
}
