:root {
  color-scheme: light;
  --paper: #f6f3e9;
  --white: #fffdf7;
  --ink: #202b23;
  --muted: #4e5e53;
  --forest: #173e32;
  --green: #205f44;
  --leaf: #e4ecd9;
  --rule: #c8cec0;
  --red: #862d22;
  --display: Georgia, "Times New Roman", serif;
  --text: "Avenir Next", "Trebuchet MS", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--text);
}

button, select, input { font: inherit; }
button, select { color: inherit; }
button:not(:disabled), select, input { cursor: pointer; }
a { color: var(--green); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #8a5a08; outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--display); color: var(--forest); }
h1 { font-size: clamp(2.05rem, 5vw, 4.25rem); line-height: 1.01; letter-spacing: -.054em; text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.35rem); line-height: 1.13; letter-spacing: -.035em; }
.wrap { width: min(100% - 2.5rem, 70rem); margin-inline: auto; }
.skip-link { position: absolute; top: .5rem; left: .5rem; transform: translateY(-180%); z-index: 2; background: var(--white); padding: .5rem 1rem; }
.skip-link:focus { transform: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.site-header { border-bottom: 1px solid var(--rule); }
.header-inner, .footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem 1rem; }
.header-inner { min-height: 4rem; padding-block: .4rem; }
.wordmark { display: inline-flex; gap: .48rem; align-items: center; color: var(--forest); font: 700 1.38rem/1 var(--display); letter-spacing: -.045em; text-decoration: none; }
.wordmark span { margin-left: -.46rem; font-weight: 400; }
.header-inner nav, .footer-inner nav { display: flex; gap: clamp(.65rem, 2.7vw, 1.8rem); align-items: center; }
.header-inner nav a { padding-block: .52rem; }
.header-inner nav a, .footer-inner nav a { font-size: .88rem; font-weight: 600; text-decoration: none; }
.header-inner a[aria-current], .header-inner nav a:hover, .footer-inner nav a:hover { text-decoration: underline; }
.hero { padding-top: clamp(1.35rem, 3.8vw, 3.25rem); }
.lead { margin-top: .72rem; color: var(--muted); font-size: clamp(.95rem, 2vw, 1.2rem); }

.game {
  display: grid;
  grid-template-columns: minmax(13.5rem, 1fr) 3fr;
  margin-top: clamp(1rem, 2.6vw, 1.9rem);
  border: 1px solid #a8b3a1;
  border-radius: 1rem;
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 8px 0 #dbe2d5;
}
.game-controls { padding: 1.6rem 1.35rem; background: var(--leaf); border-right: 1px solid var(--rule); }
.game-controls h2 { font-size: 1.6rem; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem; margin-top: .95rem; padding: .2rem; background: #d1ddc9; border-radius: .55rem; }
.mode-tabs button { min-height: 44px; padding: .25rem .3rem; border: 0; border-radius: .42rem; background: transparent; font-size: .88rem; font-weight: 700; }
.mode-tabs [aria-selected="true"] { background: var(--forest); color: var(--white); }
.settings { display: grid; gap: .75rem; margin-top: 1.3rem; }
.settings label { font-size: .85rem; font-weight: 700; }
.settings select { display: block; width: 100%; min-height: 44px; margin-top: .2rem; padding: .27rem .42rem; border: 1px solid #a7b7a5; border-radius: .4rem; background: var(--white); font-size: .9rem; }
.settings .timer-option { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-height: 44px; cursor: pointer; }
.timer-option input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--forest); }
.timer-option small { color: var(--muted); font-size: .72rem; font-weight: 500; }
.game-main { padding: 1.1rem clamp(.8rem, 3.3vw, 2.75rem) 1rem; min-width: 0; }
.stats, .results-stats { display: flex; justify-content: space-around; gap: .4rem; text-align: center; font-variant-numeric: tabular-nums; }
.stats { padding-bottom: .67rem; border-bottom: 1px solid var(--rule); }
.stats dt, .results-stats dt { color: var(--muted); font-size: .76rem; font-weight: 700; }
.stats dd, .results-stats dd { color: var(--forest); font-weight: 700; font-size: 1.2rem; line-height: 1.2; }
#time-left.urgent { color: var(--red); }
.prompt { display: grid; justify-items: center; align-content: center; height: 12.3rem; padding-top: .45rem; }
.prompt p { color: var(--muted); font-weight: 700; font-size: .85rem; }
#staff { display: block; width: min(100%, 24rem); }
.staff-lines { fill: none; stroke: #657268; stroke-width: 1.15; }
.clef-sign { color: var(--forest); fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 3.8; }
.note-stem { fill: none; stroke: var(--forest); stroke-width: 2.4; }
.note-head, #accidental { fill: var(--forest); }
#accidental { font: 26px var(--display); }
.audio-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: .48rem; margin: .9rem 0 .48rem; }
#audio-message { color: var(--muted); font-size: .85rem; text-align: center; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .38rem .9rem; border: 1px solid var(--forest); border-radius: .45rem; font-size: .9rem; font-weight: 700; text-decoration: none; }
.primary { background: var(--forest); color: var(--white); }
.primary:hover { background: var(--green); }
.secondary { background: var(--white); color: var(--forest); }
.secondary:hover { background: var(--leaf); }
.letters { display: grid; grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: clamp(3px, 1.35vw, .72rem); max-width: 30rem; margin-inline: auto; }
.letters button { min-height: 46px; border: 1px solid #a8b3a1; border-radius: .45rem; background: var(--paper); color: var(--forest); font: 700 1.36rem var(--display); }
.letters button:disabled { color: #626a60; border-color: var(--rule); }
.letters button:not(:disabled):hover { background: var(--leaf); }
.letters button.correct-key, .letters button.correct-key:hover { background: #d4ebd7; border-color: var(--green); color: var(--forest); }
.modifiers { border: 0; margin: -.1rem 0 .45rem; padding: 0; }
.modifier-options { display: flex; justify-content: center; gap: .32rem; }
.modifier-options button { min-height: 44px; border: 1px solid var(--rule); border-radius: .4rem; background: var(--white); padding: .2rem .45rem; font-size: .81rem; }
.modifier-options button[aria-pressed="true"] { background: var(--leaf); border-color: var(--green); font-weight: 700; }
.modifier-options span { opacity: .8; margin-left: .14rem; }
.feedback { margin-top: .62rem; min-height: 1.8rem; padding: .2rem .34rem; border-radius: .32rem; text-align: center; color: var(--muted); font-size: .85rem; }
.feedback.correct { background: #e2efdd; color: #184e2e; }
.feedback.incorrect { background: #f5e4da; color: var(--red); }
.results { display: grid; min-height: 17rem; justify-items: center; align-content: center; gap: .62rem; text-align: center; }
.results h3 { font-size: 1.3rem; }
.score { font: 700 3.4rem/.97 var(--display); color: var(--forest); }
.results-stats { width: min(100%, 24rem); margin: .35rem 0; }
#round:has(#modifiers:not([hidden])) .prompt { height: 10.05rem; }
#round:has(#modifiers:not([hidden])) #staff { width: min(100%, 20rem); }

.home-guide { margin-top: clamp(2rem, 5vw, 4rem); padding-bottom: 3rem; }
.guide-nav { display: flex; flex-wrap: wrap; gap: .4rem 1.15rem; border-block: 1px solid var(--rule); padding-block: .6rem; font-size: .92rem; font-weight: 600; }
.prose { max-width: 46rem; }
.prose section { margin-top: 2.35rem; scroll-margin-top: .85rem; }
.prose p, .prose ol, .prose ul { margin-top: .85rem; }
.prose li + li { margin-top: .52rem; }
.prose ol, .prose ul { padding-left: 1.5rem; }
.prose table { margin-top: 1rem; width: 100%; border-collapse: collapse; background: var(--white); text-align: left; }
.prose caption { padding: .55rem .65rem; background: var(--leaf); font-weight: 700; text-align: left; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: .45rem .65rem; }
.faq h2 { margin-bottom: .7rem; }
.faq details { border-top: 1px solid var(--rule); padding: .7rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--rule); }
.faq summary { color: var(--forest); font-weight: 700; cursor: pointer; }
.faq details p { margin-top: .5rem; }
.document { padding-block: 2.2rem 3.5rem; }
.document h1 { max-width: 15ch; }
.document .lead { max-width: 58ch; }
.breadcrumbs { display: flex; gap: .5rem; margin-bottom: .85rem; color: var(--muted); font-size: .86rem; }
.site-footer { border-top: 1px solid var(--rule); padding-block: 1.3rem; font-size: .85rem; color: var(--muted); }

@media (max-width: 700px) {
  .game { grid-template-columns: 1fr; }
  .game-controls { padding: .65rem .8rem .35rem; border-right: 0; border-bottom: 1px solid var(--rule); }
  .game-controls h2 { font-size: 1.25rem; }
  .mode-tabs { margin-top: .28rem; }
  .settings { grid-template-columns: .76fr 1.46fr .54fr; align-items: end; gap: .48rem; margin-top: .28rem; }
  .settings select { margin-top: 0; }
  .settings .timer-option { flex-wrap: nowrap; gap: .24rem; }
  .timer-option small { display: none; }
  .game-main { padding-top: .58rem; padding-bottom: .45rem; }
  .stats { padding-bottom: .36rem; }
  .prompt { height: 9.1rem; padding-top: .05rem; }
  #staff { width: min(100%, 18.75rem); }
  #round:has(#modifiers:not([hidden])) .prompt { height: 8.3rem; }
  #round:has(#modifiers:not([hidden])) #staff { width: min(100%, 17rem); }
  .feedback { margin-top: .35rem; }
}

@media (max-width: 390px) {
  .wrap { width: calc(100% - 1.2rem); }
  .wordmark { font-size: 1.25rem; }
  .wordmark svg { width: 27px; height: 27px; }
  .header-inner { min-height: 3.2rem; }
  .header-inner nav { gap: .55rem; }
  .header-inner nav a { font-size: .8rem; }
  .game-main { padding-inline: .42rem; }
  .game-controls { padding-inline: .55rem; }
  .letters { gap: 4px; }
}
@media (max-width: 359px) {
  .header-inner { column-gap: .3rem; }
  .hero { padding-top: .85rem; }
  .hero h1 { font-size: 1.73rem; }
  .hero .lead { margin-top: .35rem; font-size: .85rem; line-height: 1.35; }
  .game { margin-top: .75rem; }
  .game-controls { display: contents; }
  .game-controls h2 { padding: .48rem .65rem 0; }
  .mode-tabs { margin: .25rem .5rem 0; }
  .game-main { order: 1; }
  .settings { order: 2; padding: .32rem .5rem .48rem; border-top: 1px solid var(--rule); background: var(--leaf); }
  .prompt, #round:has(#modifiers:not([hidden])) .prompt { height: 6.6rem; }
  #staff, #round:has(#modifiers:not([hidden])) #staff { width: min(100%, 13rem); }
  .letters { grid-template-columns: repeat(4, minmax(44px, 1fr)); }
}
