:root {
  --paper: #f3f5f2;
  --paper-2: #e4e8e4;
  --ink: #14171d;
  --ink-2: #4a505c;
  --rule: rgba(20, 23, 29, .18);
  --pencil: #cf2f2a;   /* red pencil: what's happening now */
  --blue: #2546b0;     /* blue pencil: directions, links, things to do */
  --turf: #10271a;
  --chalk: #f0ece1;
  --serif: "Old Standard TT", "Iowan Old Style", Georgia, serif;
  --mono: "Martian Mono", ui-monospace, monospace;
  --music: "Noto Music", "Bravura Text", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  position: relative;
  margin: 0;
  background-color: var(--paper);
  /* manuscript paper: faint five-line staves under everything */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='112'%3E%3Cg stroke='%23526a8c' stroke-opacity='.13'%3E%3Cpath d='M0 40.5H8'/%3E%3Cpath d='M0 48.5H8'/%3E%3Cpath d='M0 56.5H8'/%3E%3Cpath d='M0 64.5H8'/%3E%3Cpath d='M0 72.5H8'/%3E%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 .28 0 0 0 0 .33 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font: 400 1.125rem/1.6 var(--serif);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* ---------- the stage: one SVG over the whole page ---------- */
#stage { position: absolute; z-index: 1; top: 0; left: 0; width: 100%; pointer-events: none; overflow: visible; }
#stage text { font-family: var(--mono); font-stretch: 80%; }
#stage text.serif { font-family: var(--serif); font-stretch: normal; }
#stage text.music { font-family: var(--music); font-stretch: normal; }

#tag {
  position: fixed; z-index: 4; pointer-events: none;
  font: 500 11px/1 var(--mono); font-stretch: 80%; letter-spacing: .04em;
  color: var(--paper); background: var(--ink);
  padding: 5px 7px 4px; transform: translate(-50%, calc(-100% - 12px));
  opacity: 0; transition: opacity .12s;
  white-space: nowrap;
}
#tag.on { opacity: 1; }
#tag.follow { background: var(--pencil); }

.dyn {
  position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, 6px);
  font: 400 2.4rem/1 var(--music); color: var(--ink); opacity: 0;
}
.dyn.go { animation: dyn .9s ease-out forwards; }
@keyframes dyn {
  0% { opacity: 1; transform: translate(-50%, 6px) scale(1.25); }
  25% { transform: translate(-50%, 6px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -4px) scale(1); }
}

/* ---------- chrome ---------- */
.chrome {
  position: fixed; z-index: 3; top: 0; left: 0; right: 0; white-space: nowrap;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 22px; pointer-events: none;
}
.chrome > * { pointer-events: auto; }
.chrome::before {
  content: ""; position: absolute; z-index: -1; inset: 0 0 -28px; pointer-events: none;
  background: linear-gradient(var(--paper) 58%, rgba(243, 245, 242, 0));
}
.chrome.inv::before { background: linear-gradient(var(--turf) 58%, rgba(16, 39, 26, 0)); }
.tempo { display: inline-flex; align-items: baseline; gap: .3em; font-weight: 700; font-size: 1.05rem; }
.tempo .qn { width: .62em; height: 1.35em; fill: currentColor; align-self: center; transform: translateY(-.12em); }
.tempo em { font-weight: 700; margin-left: .6em; letter-spacing: .01em; }
.tempo.hit #bpm { color: var(--pencil); }
.tempo { border-bottom: 1.5px dashed transparent; }
.tempo:hover { border-bottom-color: currentColor; }
.tempo .yours { font: italic 700 .9rem var(--serif); color: var(--pencil); margin-left: .5em; }
.sound { display: inline-flex; align-items: baseline; gap: .5em; font-size: 1.05rem; padding: 2px 10px 1px; border: 1.5px solid currentColor; }
.sound .plain { font: 400 10px/1 var(--mono); font-stretch: 80%; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.sound[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.direction.tap-hint::before { content: none; }
.tap-hint {
  position: absolute; left: 24px; top: 56px; margin: 0;
  opacity: 0; transition: opacity .5s; pointer-events: none !important;
}
.tap-hint.on { opacity: 1; }

.letters {
  position: fixed; z-index: 3; right: 22px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px;
}
.letters a {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1.5px solid currentColor; text-decoration: none;
  font: 700 15px/1 var(--serif); position: relative;
}
.letters a.inv { color: var(--chalk); }
.letters a.on { color: var(--blue); }
.letters a.on::after {
  content: ""; position: absolute; inset: -7px -8px;
  border: 1.6px solid var(--blue); border-radius: 50%;
  transform: rotate(-8deg);
}

.measure {
  position: fixed; z-index: 3; left: 18px; bottom: 16px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font: 400 italic 1rem var(--serif);
}
.measure svg { width: 44px; height: 44px; overflow: visible; }
.measure path { fill: none; stroke: currentColor; stroke-width: 1; opacity: .35; }
.measure circle { fill: var(--pencil); }
.measure b { font-style: normal; font-variant-numeric: tabular-nums; }

.inv { color: var(--chalk); }
.inv .sound[aria-pressed="true"] { background: var(--chalk); color: var(--turf); }

/* ---------- sets: words on the left, a stage on the right ---------- */
main { position: relative; }
.set { position: relative; display: flex; align-items: flex-start; padding: 13vh 0 6vh; }
.text {
  position: relative; z-index: 2; flex: none;
  width: min(34rem, 38vw); margin-left: 8vw;
  text-shadow: 0 0 10px var(--paper), 0 0 3px var(--paper), 0 0 1px var(--paper);
}
.text.wide { width: min(62rem, 82vw); }
.text.center { margin: 0 auto; text-align: center; width: min(40rem, 86vw); }
.slot { flex: none; width: 42vw; height: 72vh; margin: -2vh calc(6vw + 24px) 0 auto; }

/* section heads are rehearsal marks: a big boxed letter and a printed section title */
h2 { font: italic 700 1.3rem/1.2 var(--serif); margin: 0 0 1.5rem; display: flex; align-items: center; gap: 1rem; }
.text.center h2 { justify-content: center; }
.rl { display: inline-grid; place-items: center; width: 3.4rem; height: 3.4rem; border: 3px solid currentColor; font: normal 700 2.3rem/1 var(--serif); }
.lede { font-size: clamp(2rem, 4.2vw, 3.6rem); line-height: 1.04; margin: 0 0 1.6rem; letter-spacing: -.025em; text-wrap: balance; }
.text p { margin: 0 0 1.1rem; }
/* performance directions, the way a score prints "a tempo" or "attacca" */
.direction { font: italic 700 1.05rem/1.35 var(--serif); color: var(--blue); letter-spacing: .01em; text-wrap: balance; }
.direction::before { content: "\2192\00a0"; font-style: normal; }

/* title page */
.set.title { display: flex; flex-direction: column; align-items: stretch; min-height: 100svh; padding: 0; }
.titleblock { position: relative; z-index: 2; width: min(60rem, 92vw); margin: 0 auto; padding-top: 12vh; text-align: center; }
.corners { display: flex; justify-content: space-between; font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; margin: 0 0 6vh; color: var(--ink-2); }
h1 { text-wrap: balance; margin: 0; font-weight: 400; line-height: .9; font-size: clamp(3.6rem, 13vw, 12rem); letter-spacing: -.035em; }
.sub { margin: 1.2rem 0 .2rem; font-size: clamp(1.2rem, 2.2vw, 1.7rem); }
.inst { text-wrap: balance; margin: 0; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.credits { display: flex; justify-content: space-between; margin: 4vh 0 0; font-size: 1rem; }
.credits span:last-child { font-variant: small-caps; letter-spacing: .06em; font-size: 1.6rem; line-height: 1; }
.slot.hero { position: relative; flex: 1 0 34vh; width: 100%; height: auto; margin: 0; }
.note-baton { position: absolute; z-index: 2; left: 9vw; bottom: 16vh; max-width: 15rem; margin: 0; opacity: 0; transition: opacity .6s; }
.note-baton.on { opacity: 1; }
#count {
  position: absolute; left: 50%; bottom: 54px; transform: translateX(-50%);
  font: 700 2.4rem/1 var(--serif); letter-spacing: .3em; color: var(--pencil); white-space: nowrap; pointer-events: none;
}

/* field: under the lights */
.field {
  background:
    radial-gradient(90% 55% at 70% 0%, rgba(255, 238, 196, .16), transparent 70%),
    var(--turf);
  color: var(--chalk);
  box-shadow: inset 0 4px 0 var(--chalk), inset 0 -4px 0 var(--chalk);
}
.field .text { text-shadow: 0 0 10px var(--turf), 0 0 3px var(--turf); }
.field .direction { color: #a9bfff; }
.letters a.on.inv { color: #a9bfff; }
.letters a.on.inv::after { border-color: #a9bfff; }

/* battery presets */
.presets { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; margin-top: 1.6rem !important; }
.presets button { font-style: italic; font-size: 1.1rem; border-bottom: 1.5px solid transparent; padding: 0 0 2px; }
.presets button[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); }

.tutti { margin-left: .4em; font: italic 700 1.05rem var(--serif); color: var(--blue); border-bottom: 1.5px solid currentColor; padding: 0 0 2px; }

/* program */
#E { padding-top: 12vh; min-height: 0; }
.program { list-style: none; padding: 0; margin: 0 0 4rem; }
.program li { display: flex; align-items: baseline; gap: .8rem; padding: .9rem 0; font-size: clamp(1.15rem, 2vw, 1.6rem); }
.program .num { width: 2.8rem; flex: none; text-align: right; font-weight: 700; }
.program .ttl { flex: 0 1 auto; min-width: 0; }
.program .ttl a { text-decoration-color: var(--blue); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.program .leader { flex: 1 0 3rem; height: 1px; align-self: baseline; }
.program .by { flex: none; font-style: italic; font-size: .72em; color: var(--ink-2); max-width: 26rem; text-align: right; }
.program .by i { color: var(--blue); }
.notes { max-width: 36rem; margin-left: 3.6rem; }
.notes h3 { font: italic 700 1.3rem/1.2 var(--serif); margin: 0 0 1rem; }

/* coda */
.coda { display: grid; place-items: center; padding-top: 14vh; }
.about { font-style: italic; color: var(--ink-2); margin-top: -.6rem !important; }
.mail { font-size: clamp(1.4rem, 3.4vw, 2.6rem); margin: clamp(6.5rem, 12vw, 9.5rem) 0 2rem !important; }
.mail a { text-decoration: none; border-bottom: 2px solid var(--blue); }
.fine { font: italic 700 clamp(3rem, 8vw, 6rem)/1 var(--serif); margin: 12vh 0 2rem !important; }
.foot { display: flex; justify-content: center; gap: 2rem; font-size: .85rem; color: var(--ink-2); letter-spacing: .06em; }
.foot a { font-style: italic; }

@media (min-width: 761px) {
  .measure { top: 12px; bottom: auto; left: auto; right: 168px; }
  .measure svg { width: 34px; height: 34px; }
}

/* ---------- phones: stage on top, words underneath ---------- */
@media (max-width: 760px) {
  body { font-size: 1.05rem; }
  .chrome { padding: 12px 16px; }
  .tempo { font-size: .95rem; }
  .tempo .yours { display: none; }
  .rl { width: 2.8rem; height: 2.8rem; font-size: 1.9rem; }
  .tap-hint { left: 16px; top: 48px; font-size: .95rem; }
  .letters {
    top: auto; bottom: 0; left: 0; right: 0; transform: none;
    flex-direction: row; justify-content: flex-end; gap: 7px;
    padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
    background: var(--paper); border-top: 1px solid var(--rule);
  }
  .letters.inv { background: var(--turf); border-color: rgba(240, 236, 225, .22); }
  .letters a { width: 25px; height: 25px; font-size: 12px; }
  .letters a.on::after { inset: -5px -6px; }
  .measure { z-index: 4; bottom: calc(6px + env(safe-area-inset-bottom)); left: 12px; }
  .measure svg { width: 32px; height: 32px; }
  .set { flex-direction: column; align-items: stretch; min-height: 0; padding: 8svh 0 6svh; }
  .set > .text:not(.wide):not(.center) { display: contents; }
  .set > .text > * { margin-left: 16px; margin-right: 16px; }
  .set > .text > h2 { order: 0; }
  .set > .text > .lede { order: 1; }
  .slot { order: 2; width: auto; height: 44svh; margin: 0 16px 2svh; }
  .set > .text > .direction, .set > .text > .presets { order: 3; margin-bottom: 1.4rem; }
  .set > .text > p { order: 4; }
  .text, .text.wide { width: auto; margin: 0 16px; }
  .lede { font-size: 2.1rem; }
  #A .slot { height: 34svh; }
  #C .slot { height: 30svh; }
  .titleblock { padding-top: 12svh; }
  .corners { margin-bottom: 5svh; font-size: .7rem; }
  .credits { flex-direction: column; gap: .2rem; align-items: center; }
  .note-baton { position: static; order: 0; margin: 3svh auto 0; max-width: 16rem; text-align: center; }
  .slot.hero { order: 1; flex: 1 0 34svh; margin: 0 0 56px; }
  #count { font-size: 2rem; bottom: 44px; }
  #E { padding-top: 6svh; }
  .program li { flex-wrap: wrap; gap: .2rem .6rem; }
  .program .num { width: auto; }
  .program .leader { flex-basis: 2.2rem; }
  .program .by { flex-basis: 100%; text-align: left; padding-left: 2.2rem; }
  .notes { margin-left: 0; }
  .coda { padding-top: 10svh; padding-bottom: 16svh; }
  .foot { flex-direction: column; gap: .4rem; }
}

/* keyboard players: real controls, visually hidden; focus shows as a ring on the stage */
.keys { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
