:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f8f5ee;
  color: #1f3048;
  font-synthesis: none;
  --navy: #1f3048;
  --teal: #1e727d;
  --paper: #f8f5ee;
  --card: #fffefa;
  --muted: #657181;
  --line: #dce1df;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(circle at 85% 4%, rgba(30, 114, 125, 0.09), transparent 28rem),
    var(--paper);
}

button, input { font: inherit; }

button { touch-action: manipulation; }

.app-shell {
  width: min(100%, 660px);
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px max(32px, env(safe-area-inset-bottom));
}

.app-header { margin-bottom: 28px; }

.brand {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(2rem, 8vw, 2.65rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.control-group {
  margin: 0 0 26px;
  padding: 0;
  border: 0;
}

.control-group legend {
  margin-bottom: 13px;
  font-size: 0.96rem;
  font-weight: 750;
}

.choice-grid { display: grid; gap: 11px; }
.clef-grid { grid-template-columns: repeat(2, 1fr); }
.count-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.accidental-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }

.choice-card,
.number-choice,
.accidental-choice {
  min-width: 0;
  border: 1px solid rgba(31, 48, 72, 0.08);
  border-radius: 17px;
  background: var(--card);
  color: var(--navy);
  box-shadow: 0 8px 24px rgba(31, 48, 72, 0.055);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.choice-card:active,
.number-choice:active,
.accidental-choice:active,
.primary-button:active,
.rating-buttons button:active { transform: scale(0.97); }

.choice-card {
  display: flex;
  min-height: 126px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.clef-symbol {
  height: 62px;
  font-family: "Apple Symbols", "Noto Music", serif;
  font-size: 3.8rem;
  font-weight: 400;
  line-height: 1;
}

.clef-symbol.bass { font-size: 3.35rem; }

.number-choice {
  height: 54px;
  font-size: 1.18rem;
  font-weight: 800;
}

.accidental-choice {
  display: flex;
  min-width: 0;
  min-height: 76px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 3px;
  font-size: clamp(0.68rem, 2.7vw, 0.78rem);
  font-weight: 750;
}

.accidental-symbol {
  height: 29px;
  font-family: "Apple Symbols", "Noto Music", serif;
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1;
}

.field-note {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.choice-card.selected,
.number-choice.selected,
.accidental-choice.selected {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.privacy-note {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 0 21px;
  border: 0;
  border-radius: 16px;
  background: var(--navy);
  color: white;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(31, 48, 72, 0.15);
}

.practice-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.clef-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.text-button {
  padding: 8px 0 8px 12px;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 0.87rem;
  font-weight: 700;
  cursor: pointer;
}

.staff-card {
  overflow: hidden;
  border: 1px solid rgba(31, 48, 72, 0.07);
  border-radius: 21px;
  background: var(--card);
  box-shadow: 0 14px 36px rgba(31, 48, 72, 0.075);
}

#staff {
  display: block;
  width: 100%;
  height: auto;
  min-height: 246px;
}

.instruction {
  margin: 18px 2px;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.rating-card {
  margin-top: 18px;
  padding: 19px;
  border: 1px solid rgba(31, 48, 72, 0.07);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 12px 30px rgba(31, 48, 72, 0.065);
}

.rating-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.rating-card h2 {
  margin: 0;
  font-size: 1.08rem;
}

.rating-heading strong {
  color: var(--teal);
  font-size: 1.55rem;
}

.rating-card p {
  margin: 10px 0 17px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-buttons button {
  height: 52px;
  border: 0;
  border-radius: 13px;
  background: var(--teal);
  color: white;
  font-size: 1.12rem;
  font-weight: 800;
  cursor: pointer;
}

.rating-scale {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(0.56rem, 2.35vw, 0.67rem);
  font-weight: 650;
}

.hidden { display: none !important; }

button:focus-visible {
  outline: 3px solid rgba(30, 114, 125, 0.35);
  outline-offset: 3px;
}

@media (max-width: 380px) {
  .app-shell { padding-inline: 16px; }
  .choice-card { min-height: 116px; }
  .rating-card { padding: 15px; }
  .rating-buttons { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
