:root {
  color-scheme: light dark;
  --rhythm-page: #fafaf8;
  --rhythm-ink: #1d211e;
  --rhythm-muted: #505950;
  --rhythm-line: #d9ddd6;
  --rhythm-board: #000;
  --rhythm-board-frame: #3b3b3b;
  --rhythm-card: #171717;
  --rhythm-board-line: #757575;
  --rhythm-result: #fff;
  --rhythm-white: #fafaf8;
  --rhythm-soft: #cecece;
  --rhythm-disabled: #aaa;
  --rhythm-accent: #d5ff65;
  --rhythm-focus: #4d692b;
  background: var(--rhythm-page);
  color: var(--rhythm-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-underline-offset: .14em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--rhythm-focus); outline-offset: 4px; }

.rhythm-width { width: min(100% - 2.5rem, 63rem); margin-inline: auto; }
.rhythm-header {
  min-height: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--rhythm-line);
}
.rhythm-brand, .rhythm-journal, .rhythm-language { display: inline-flex; gap: .5rem; align-items: center; min-height: 44px; }
.rhythm-brand { font-size: .95rem; font-weight: 680; text-decoration: none; }
.rhythm-brand img { display: block; flex: none; }
.rhythm-header-links { display: flex; align-items: center; gap: .5rem; }
.rhythm-journal { font-size: .9375rem; }
.rhythm-language { min-width: 44px; justify-content: center; font-size: .875rem; color: var(--rhythm-muted); }
.rhythm-intro { padding-block: clamp(1.35rem, 5vw, 3.5rem) clamp(1.15rem, 3vw, 2rem); }
.rhythm-intro h1 { margin: 0; font-size: clamp(2.15rem, 7.8vw, 4.65rem); line-height: 1.04; letter-spacing: -.055em; }
.rhythm-intro p { max-width: 36rem; margin: .85rem 0 0; color: var(--rhythm-muted); font-size: clamp(1rem, 2vw, 1.25rem); }

.rhythm-panel {
  display: grid;
  grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
  row-gap: clamp(.95rem, 2vw, 1.5rem);
  column-gap: clamp(1.5rem, 5vw, 3.25rem);
  padding: clamp(1.125rem, 4vw, 2.5rem);
  border: 1px solid var(--rhythm-board-frame);
  border-radius: 1.2rem;
  color-scheme: dark;
  background: var(--rhythm-board);
  color: var(--rhythm-white);
}
.rhythm-panel :focus-visible { outline-color: var(--rhythm-accent); }
.rhythm-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-column: 1 / -1;
  width: min(100%, 19rem);
  gap: .4rem;
}
.rhythm-tempo { min-width: 0; border: 0; margin: 0; padding: 0; }
.rhythm-tempo legend { padding: 0; color: var(--rhythm-soft); font-size: .9375rem; }
.rhythm-bpm { margin: .25rem 0 .35rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rhythm-bpm output { font-size: clamp(2.4rem, 7vw, 4.5rem); font-weight: 680; line-height: 1; letter-spacing: -.07em; }
.rhythm-bpm span { color: var(--rhythm-soft); font-size: .875rem; }
#tempo { display: block; width: 100%; min-height: 44px; margin: 0; accent-color: var(--rhythm-accent); }
.rhythm-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.rhythm-mode, .rhythm-preset, .rhythm-run, .rhythm-meter select {
  min-height: 44px;
  padding: .35rem .5rem;
  border: 1px solid var(--rhythm-board-line);
  border-radius: .6rem;
  background: var(--rhythm-card);
  color: var(--rhythm-white);
  cursor: pointer;
}
.rhythm-mode { font-size: .9375rem; font-weight: 560; }
.rhythm-mode[aria-pressed="true"] { border-color: var(--rhythm-accent); color: var(--rhythm-accent); font-weight: 710; }
.rhythm-preset { font-size: .9375rem; font-variant-numeric: tabular-nums; }
.rhythm-preset[aria-pressed="true"] { border-color: var(--rhythm-accent); color: var(--rhythm-accent); }
.rhythm-mode:disabled, .rhythm-preset:disabled, .rhythm-meter select:disabled, #tempo:disabled { cursor: default; }
#tempo:disabled { opacity: .7; }
.rhythm-preset:disabled:not([aria-pressed="true"]) { color: var(--rhythm-disabled); }
.rhythm-meter {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  grid-column: 1 / -1;
  gap: .75rem;
  margin-top: .7rem;
  color: var(--rhythm-soft);
  font-size: .9375rem;
}
.rhythm-meter select {
  appearance: none;
  min-width: 5rem;
  padding-inline: .65rem 1.75rem;
}
.rhythm-meter::after {
  position: absolute;
  top: calc(50% - .3rem);
  right: .8rem;
  width: .45rem;
  height: .45rem;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  pointer-events: none;
  content: "";
}

.rhythm-play { display: grid; gap: .875rem; min-width: 0; }
.rhythm-round {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .85rem;
}
.rhythm-round p { margin: 0; color: var(--rhythm-soft); font-size: .9375rem; font-variant-numeric: tabular-nums; }
.rhythm-round-steps { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: .25rem; }
.rhythm-round-steps span { height: .375rem; border-radius: 1rem; background: var(--rhythm-board-line); }
.rhythm-round-steps [data-complete] { background: var(--rhythm-soft); }
.rhythm-round-steps [data-current] { background: var(--rhythm-accent); }
.rhythm-status { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: .65rem 1.125rem; }
.rhythm-phase h2 { min-height: 1.25em; margin: 0; font-size: clamp(1.2rem, 4vw, 1.8rem); line-height: 1.25; letter-spacing: -.025em; }
.rhythm-phase p { min-height: 1.5em; margin: .25rem 0 0; color: var(--rhythm-soft); font-size: .9375rem; }
.rhythm-beats { display: grid; grid-template-columns: repeat(4, 2rem); gap: .3rem; font-variant-numeric: tabular-nums; }
.rhythm-beats span {
  display: grid;
  place-items: center;
  min-height: 2rem;
  border: 1px solid var(--rhythm-board-line);
  border-radius: .4rem;
  color: var(--rhythm-soft);
  font-size: .875rem;
}
.rhythm-beats [data-active] { border-color: var(--rhythm-accent); background: var(--rhythm-accent); color: var(--rhythm-board); font-weight: 750; }
[data-phase="silent"] .rhythm-beats, [data-phase="return"] .rhythm-beats { visibility: hidden; }

.rhythm-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(7.5rem, 9rem); align-items: stretch; gap: .65rem; }
.rhythm-pad {
  display: grid;
  place-content: center;
  gap: .05rem;
  min-height: clamp(5.75rem, 14vw, 9.5rem);
  padding: .65rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  background: var(--rhythm-accent);
  color: var(--rhythm-board);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
.rhythm-pad strong { font-size: clamp(1.5rem, 7vw, 2.5rem); line-height: 1.2; letter-spacing: -.045em; }
.rhythm-pad span { font-size: .875rem; }
.rhythm-pad:disabled { border-color: var(--rhythm-board-line); background: var(--rhythm-card); color: var(--rhythm-disabled); cursor: default; }
.rhythm-pad[data-pressed] { background: var(--rhythm-white); }
.rhythm-run { min-height: 48px; font-weight: 690; }
[data-phase="idle"] .rhythm-run:not(:disabled), [data-phase="finished"] .rhythm-run, [data-phase="error"] .rhythm-run {
  border-color: var(--rhythm-accent);
  background: var(--rhythm-accent);
  color: var(--rhythm-board);
}

.rhythm-panel[data-mode="free"] .rhythm-round { display: none; }
.rhythm-panel[data-mode="free"] .rhythm-beats {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 2rem;
}
.rhythm-panel[data-mode="free"] .rhythm-actions { grid-template-columns: minmax(0, 1fr); justify-items: start; }
.rhythm-panel[data-mode="free"] .rhythm-run { min-width: min(100%, 8rem); max-width: none; }

.rhythm-result {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1.2rem clamp(1.125rem, 4vw, 2.5rem);
  border: 1px solid var(--rhythm-line);
  border-radius: 1rem;
  background: var(--rhythm-result);
}
.rhythm-result h2 { margin: 0; color: var(--rhythm-muted); font-size: 1rem; font-weight: 620; }
.rhythm-score { margin: .15rem 0; font-size: clamp(1.55rem, 5vw, 2.2rem); font-weight: 720; letter-spacing: -.035em; }
#result-detail { margin: .3rem 0 0; color: var(--rhythm-muted); }
.rhythm-result-rounds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .5rem; }
.rhythm-result-rounds details { min-width: 0; border: 1px solid var(--rhythm-line); border-radius: .6rem; }
.rhythm-result-rounds summary { min-height: 44px; padding: .65rem .7rem; cursor: pointer; font-size: .9375rem; }
.rhythm-result-rounds summary > span { display: inline-flex; justify-content: space-between; width: calc(100% - 1.25rem); gap: .35rem; }
.rhythm-result-rounds summary strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rhythm-result-beats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; padding: 0; margin: 0; list-style: none; }
.rhythm-result-rounds .rhythm-result-beats { margin: 0 .65rem .65rem; }
.rhythm-result-beats li { display: grid; align-content: center; justify-items: center; min-height: 3.5rem; padding: .35rem .1rem; border: 1px solid var(--rhythm-line); border-radius: .5rem; text-align: center; }
.rhythm-result-beats li[data-hit] { border-color: var(--rhythm-focus); }
.rhythm-result-beats span { font-size: .875rem; color: var(--rhythm-muted); }
.rhythm-result-beats strong { font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.rhythm-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem 1rem; padding: .85rem 0 1.75rem; font-size: .9375rem; }
.rhythm-footer a { display: inline-flex; min-height: 44px; align-items: center; }
.rhythm-footer p, .rhythm-noscript { color: var(--rhythm-muted); margin: 0; }
.rhythm-noscript { margin-top: 1rem; }

@media (max-width: 47rem) {
  .rhythm-width { width: min(100% - 1.5rem, 47rem); }
  .rhythm-header { min-height: 3.25rem; }
  .rhythm-panel { grid-template-columns: 1fr; gap: .95rem; }
  .rhythm-tempo { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .1rem .85rem; }
  .rhythm-tempo legend { position: absolute; top: 0; left: 0; }
  .rhythm-bpm { margin: 1.2rem 0 .1rem; }
  #tempo { align-self: end; }
  .rhythm-presets { grid-column: 1 / -1; }
  .rhythm-play { padding-top: .8rem; border-top: 1px solid var(--rhythm-board-frame); }
}

@media (max-width: 28rem) {
  .rhythm-panel { padding: .85rem; }
  .rhythm-status { grid-template-columns: 1fr; }
  .rhythm-beats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rhythm-beats span { min-height: 1.85rem; }
  .rhythm-actions { grid-template-columns: minmax(0, 1fr) minmax(5.6rem, auto); }
  .rhythm-run { max-width: 7.25rem; }
  .rhythm-panel[data-mode="free"] .rhythm-beats { grid-auto-columns: minmax(0, 1fr); }
  .rhythm-panel[data-mode="free"] .rhythm-actions { justify-items: stretch; }
  .rhythm-result-rounds { grid-template-columns: 1fr; }
}

@media (max-width: 28rem) and (max-height: 640px) {
  .rhythm-intro { padding-block: .85rem; }
  .rhythm-intro p { margin-top: .5rem; }
  .rhythm-play { gap: .65rem; }
  .rhythm-pad { min-height: 4.75rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --rhythm-page: #101010;
    --rhythm-ink: #fafaf8;
    --rhythm-muted: #c4c4c4;
    --rhythm-line: #4d4d4d;
    --rhythm-board-frame: #555;
    --rhythm-result: #181818;
    --rhythm-focus: #d5ff65;
  }
}

@media (forced-colors: active) {
  .rhythm-panel :focus-visible { outline-color: Highlight; }
  .rhythm-mode[aria-pressed="true"] { border: 2px solid Highlight; }
  .rhythm-round-steps [data-complete] { background: GrayText; }
  .rhythm-round-steps [data-current] { background: Highlight; }
  .rhythm-beats [data-active], .rhythm-pad[data-pressed], .rhythm-result-beats li[data-hit] { outline: 2px solid Highlight; outline-offset: -2px; }
}

.rhythm-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 28rem); }
.rhythm-panel[data-mode="live"] .rhythm-beats { display: none; }
.rhythm-panel[data-mode="live"] .rhythm-status,
.rhythm-panel[data-mode="live"] .rhythm-actions { grid-template-columns: minmax(0, 1fr); }
.rhythm-panel[data-mode="live"] .rhythm-run { width: 100%; max-width: none; }
.live-settings { display: grid; gap: .75rem; margin-block-start: 1rem; grid-column: 1 / -1; }
.live-setting { display: grid; gap: .28rem; }
.live-setting > span, .live-record-state, .live-loopline span { color: var(--rhythm-soft); font-size: .875rem; }
.live-choices, .live-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.live-choices button, .live-actions button, .live-pad {
  min-height: 44px; border: 1px solid var(--rhythm-board-line); border-radius: .5rem;
  background: var(--rhythm-card); color: var(--rhythm-white); font: inherit; cursor: pointer;
}
.live-choices button { flex: 1; padding: .25rem .4rem; font-size: .9rem; }
.live-choices [aria-pressed="true"], .live-actions [aria-pressed="true"], .live-actions [data-recording] {
  border-color: var(--rhythm-accent); color: var(--rhythm-accent);
}
.live-board { display: grid; min-width: 0; gap: .65rem; }
.live-readout { display: grid; gap: .15rem; font-variant-numeric: tabular-nums; color: var(--rhythm-soft); font-size: .875rem; }
#live-pending { color: var(--rhythm-accent); }
.live-pads { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .35rem; }
.live-pad { display: grid; gap: .1rem; min-width: 0; min-height: 60px; padding: .4rem .1rem; align-content: center; justify-items: center; touch-action: manipulation; user-select: none; }
.live-pad strong { line-height: 1.15; font-weight: 650; }
.live-pad kbd { color: var(--rhythm-soft); font-family: inherit; font-size: .71rem; }
.live-pad[data-loop-note] { border-color: var(--rhythm-accent); }
.live-pad[data-pressed] { background: var(--rhythm-accent); border-color: var(--rhythm-accent); color: var(--rhythm-board); }
.live-pad[data-pressed] kbd { color: inherit; }
.live-loopline { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.live-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; margin-block-start: -.38rem; }
.live-grid span { display: grid; min-width: 0; min-height: 1.9rem; place-items: center; border: 1px solid var(--rhythm-board-frame); border-radius: .2rem; color: var(--rhythm-soft); font-size: .78rem; }
.live-grid span[data-note] { color: var(--rhythm-white); }
.live-grid span[data-head] { box-shadow: inset 0 -3px var(--rhythm-accent); border-color: var(--rhythm-board-line); }
.live-actions button { padding: .3rem .6rem; font-size: .9rem; }
.live-actions button:disabled { border-color: var(--rhythm-board-frame); color: var(--rhythm-disabled); cursor: default; }
.live-record-state { margin: 0; }
@media (max-width: 47rem) {
  .live-settings { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: .6rem; margin-block-start: .45rem; }
}
@media (max-width: 28rem) {
  .rhythm-mode { padding-inline: .2rem; font-size: .86rem; }
  .live-pads { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .live-pad { min-height: 48px; }
  .live-actions { gap: .25rem; }
  .live-actions button { font-size: .81rem; padding-inline: .45rem; }
}
@media (forced-colors: active) {
  .live-choices [aria-pressed="true"], .live-pad[data-pressed], .live-grid span[data-head], .live-actions [data-recording] { outline: 2px solid Highlight; outline-offset: -2px; }
}

.live-channels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
.live-channel { display: grid; grid-template-rows: 1fr auto; min-width: 0; border: 1px solid var(--rhythm-board-line); border-radius: .5rem; }
.live-channel:has(.live-track[aria-pressed="true"]) { border-color: var(--rhythm-accent); }
.live-channel button { width: 100%; min-width: 0; margin: 0; border: none; background: none; color: var(--rhythm-white); font: inherit; cursor: pointer; touch-action: manipulation; }
.live-channel .live-track { display: grid; align-content: center; gap: .08rem; min-height: 46px; padding: .2rem .15rem; line-height: 1.15; }
.live-track strong { font-size: clamp(.72rem, 2.4vw, .92rem); overflow-wrap: anywhere; }
.live-track small { color: var(--rhythm-soft); font-size: .73rem; font-variant-numeric: tabular-nums; }
.live-track[aria-pressed="true"] strong { color: var(--rhythm-accent); }
.live-channel .live-mute { border-top: 1px solid var(--rhythm-board-frame); min-height: 30px; border-radius: 0 0 .45rem .45rem; color: var(--rhythm-soft); font-size: .76rem; }
.live-mute[aria-pressed="true"] { color: var(--rhythm-white); background: var(--rhythm-card); }
.live-channel button:disabled { cursor: default; }
.live-length { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.live-length > span { color: var(--rhythm-soft); font-size: .87rem; }
.live-length .live-choices { flex-wrap: nowrap; gap: .25rem; }
.live-length .live-choices button { min-width: 36px; min-height: 34px; }
.live-record-state { min-height: 2.8em; }
.live-saved { margin-block-start: -.4rem; color: var(--rhythm-soft); font-size: .75rem; }
.live-grid span { font-variant-numeric: tabular-nums; }
@media (max-width: 28rem) {
  .live-channel .live-mute { min-height: 34px; }
  .live-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.live-lesson { border-top: 1px solid var(--rhythm-board-frame); font-size: .9rem; }
.live-lesson summary { cursor: pointer; min-height: 44px; padding-block: .62rem; }
.live-lesson ol { margin: 0 0 .4rem; padding-inline-start: 1.35rem; color: var(--rhythm-soft); }
.live-lesson li + li { margin-block-start: .45rem; }

.live-board #live-game-announcement { width: fit-content; margin-block: .25rem; color: var(--rhythm-muted); font-size: .875rem; }
.rhythm-announcement { max-width: 46rem; margin-block: clamp(2.5rem,9vw,6.5rem); }
.rhythm-announcement h1 { margin: .25rem 0 1.6rem; font-size: clamp(3rem,9vw,5.5rem); line-height: 1; letter-spacing: -.06em; }
.rhythm-announcement p { max-width: 58ch; font-size: clamp(1.05rem,2vw,1.2rem); }
.rhythm-announcement .rhythm-announcement-kind { margin: 0; color: var(--rhythm-muted); font-size: .87rem; font-weight: 650; }
.rhythm-announcement nav { border-top: 1px solid var(--rhythm-line); display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; margin-top: 2rem; padding-top: 1rem; }
