:root {
  --bg: #121212;
  --bg-strong: #1a1a1a;
  --card: #1e1e1e;
  --ink: #e8e8e8;
  --muted: #888;
  --accent: #e76f51;
  --accent-strong: #c8553d;
  --good: #4ade80;
  --bad: #f87171;
  --staff: #888;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 16px;
  --transition: 200ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0 0 6px;
}

h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 0 0 6px;
}

.lead {
  max-width: 480px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-strong);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.meter {
  width: 140px;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-strong);
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 120ms ease;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 280px 200px;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
}

.staff-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.staff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card-label {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.6rem;
  color: var(--muted);
  margin: 0 0 6px;
}

.note-name {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin: 0;
}

.note-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.status {
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--bg-strong);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.65rem;
}

.staff-frame {
  background: var(--bg-strong);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
}

#staffSvg {
  width: 100%;
  height: auto;
  display: block;
}

.staff-lines line,
.ledger-lines line {
  stroke: var(--staff);
  stroke-width: 2;
  stroke-linecap: round;
}

.note-group {
  transition: transform var(--transition), opacity var(--transition);
}

.note-group .note-head {
  fill: var(--ink);
  stroke: var(--ink);
  stroke-width: 1.5;
  transform: rotate(-20deg);
  transform-box: fill-box;
  transform-origin: center;
}

.note-group .note-stem {
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.note-group .note-accidental {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 20px;
  fill: var(--ink);
}

#targetNote.is-correct .note-head,
#targetNote.is-correct .note-stem,
#targetNote.is-correct .note-accidental {
  fill: var(--good);
  stroke: var(--good);
}

#playedNote .note-head,
#playedNote .note-stem,
#playedNote .note-accidental {
  fill: var(--bad);
  stroke: var(--bad);
}

.note-group.is-hidden {
  opacity: 0;
}

.control-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.6rem;
  color: var(--muted);
}

.range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity var(--transition);
}

.primary:hover {
  opacity: 0.9;
}

.primary:active {
  opacity: 0.8;
}

.hint {
  color: var(--muted);
  font-size: 0.75rem;
  margin: 0;
}

.detected {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-strong);
  border-radius: 12px;
  padding: 12px;
}

.detected-note {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 1.6rem;
}

.detected-freq {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.6rem;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.75rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.dot.good {
  background: var(--good);
}

.dot.bad {
  background: var(--bad);
}

.sax-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sax-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sax-note {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 1.6rem;
}

.sax-range {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-strong);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.6rem;
  font-weight: 600;
}

.sax-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-strong);
  border: 1px solid var(--border);
  min-height: 180px;
}

.sax-diagram svg {
  width: 140px;
  height: auto;
  display: block;
}

.sax-key {
  fill: transparent !important;
  stroke: #666 !important;
  transition: fill var(--transition), stroke var(--transition);
}

.sax-key.is-pressed {
  fill: var(--accent) !important;
  stroke: var(--accent-strong) !important;
}

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr 240px;
  }

  .sax-card {
    grid-column: 1 / -1;
  }
}

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

  .hero-meta {
    align-items: flex-start;
  }

  .detected {
    flex-direction: column;
    align-items: flex-start;
  }
}
