:root {
  color-scheme: light;
  --paper: #edede8;
  --page-background: var(--paper);
  --panel: #dddfd3;
  --cell: #f4f4f0;
  --track: #d1d4c4;
  --ink: #252626;
  --yellow: #fab633;
}

* { box-sizing: border-box; }
html {
  min-width: 280px;
  min-height: 100%;
  background: var(--paper);
}
html, body, body * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body {
  margin: 0;
  min-width: 280px;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (hover: none) and (pointer: coarse) {
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: none; }
  .metronome { touch-action: pan-y pinch-zoom; }
  .metronome .character { touch-action: pan-y pinch-zoom; }
}
button, input, output { font: inherit; }
button {
  border: 0;
  color: inherit;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:active { opacity: .7; }
button:disabled { opacity: .3; cursor: default; }
/* Keep focus styling centralized: controls must not add focus outline boxes. */
:focus, :focus-visible { outline: none; }
img, canvas {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-drag: none;
}

.metronome {
  position: relative;
  width: min(100%, 402px);
  height: clamp(540px, 100svh, 1000px);
  margin: 0 auto;
  padding: max(44px, env(safe-area-inset-top)) 20px max(4px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 72px 28px minmax(0, 1fr) 40px 60px 48px 16px;
  row-gap: clamp(10px, 2.3svh, 24px);
  overflow: hidden;
}

.tempo-overview {
  position: relative;
  z-index: 2;
  grid-row: 1;
  justify-self: center;
  width: min(340px, 100%);
  height: 72px;
  display: flex;
  gap: 8px;
}
#edit-tempo {
  width: 100px;
  height: 72px;
  flex: 0 0 100px;
  border-radius: 16px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
#bpm {
  font-size: 34px;
  font-weight: 600;
  line-height: 40px;
  pointer-events: none;
}
#edit-tempo.decimal #bpm { font-size: 30px; }
#edit-tempo span {
  color: #a2a693;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}
.beat-panel {
  min-width: 0;
  flex: 1;
  height: 72px;
  padding: 8px;
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
}
.beat-pattern {
  --columns: 4;
  --column-gap: 8px;
  width: 100%;
  height: 56px;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-auto-rows: 56px;
  column-gap: var(--column-gap);
  row-gap: 4px;
  align-content: center;
  justify-content: stretch;
}
.beat-pattern[data-count="1"] { --columns: 1; grid-template-columns: 42px; justify-content: center; }
.beat-pattern[data-count="2"] { --columns: 2; grid-template-columns: repeat(2, 42px); justify-content: center; }
.beat-pattern[data-count="3"] { --columns: 3; grid-template-columns: repeat(3, 42px); justify-content: center; }
.beat-pattern[data-count="4"] { --columns: 4; --column-gap: clamp(6px, 4vw, 16px); }
.beat-pattern[data-count="5"] { --columns: 5; --column-gap: 8px; }
.beat-pattern[data-count="6"] { --columns: 6; --column-gap: 6px; }
.beat-pattern[data-count="7"], .beat-pattern[data-count="8"] { --columns: 4; --column-gap: 8px; grid-auto-rows: 26px; }
.beat-pattern[data-count="9"] { --columns: 5; --column-gap: 8px; grid-auto-rows: 26px; }
.beat-pattern[data-count="12"] { --columns: 6; --column-gap: 6px; grid-auto-rows: 26px; }
.beat-cell {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border: 1.5px solid var(--cell);
  border-radius: 12px;
  background: var(--cell);
}
.beat-pattern[data-count="6"] .beat-cell,
.beat-pattern[data-count="7"] .beat-cell,
.beat-pattern[data-count="8"] .beat-cell,
.beat-pattern[data-count="9"] .beat-cell,
.beat-pattern[data-count="12"] .beat-cell { border-radius: 8px; }
.beat-cell.accent { background: var(--ink); }
.beat-cell.normal::after {
  content: "";
  position: absolute;
  left: -1.5px;
  right: -1.5px;
  bottom: -1.5px;
  height: calc(50% + 1.5px);
  background: var(--ink);
}
.beat-cell.mute { background: var(--cell); }
.beat-cell.current.accent { background: var(--yellow); }
.beat-cell.current.normal::after { background: var(--yellow); }

.tempo-controls {
  position: relative;
  z-index: 2;
  grid-row: 2;
  justify-self: center;
  width: min(340px, 100%);
  height: 28px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.step { width: 28px; height: 28px; flex: 0 0 28px; }
#quick-speed {
  position: relative;
  min-width: 0;
  flex: 1;
  height: 28px;
  cursor: ew-resize;
  touch-action: none;
  --position: 37.93%;
}
.quick-track {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 13px;
  height: 2px;
  border-radius: 7px;
  background: var(--track);
  overflow: hidden;
}
.quick-track i {
  display: block;
  width: var(--position);
  height: 100%;
  background: var(--ink);
}
#quick-speed > img {
  position: absolute;
  top: 4px;
  left: calc(var(--thumb-x, 106.62px) - 12px);
  width: 24px;
  height: 20px;
  pointer-events: none;
}

.character {
  position: relative;
  grid-row: 3;
  justify-self: center;
  align-self: stretch;
  width: min(301px, 80%, 40svh);
  height: 100%;
  mix-blend-mode: multiply;
  pointer-events: auto;
  touch-action: pan-y;
  cursor: grab;
}
.character:active { cursor: grabbing; }
.character [hidden] { display: none !important; }
.sprite {
  position: absolute;
  width: 125%;
  height: auto;
  left: -12.5%;
  aspect-ratio: 1;
  top: 50%;
  transform: translateY(-50%) scale(.9);
}
.bird-sprite {
  position: absolute;
  width: 125%;
  height: auto;
  left: -12.5%;
  aspect-ratio: 16 / 9;
  top: 50%;
  transform: translateY(-50%) scale(var(--animal-scale, .9));
  pointer-events: none;
}
.bird-sprite[data-clip="halloweenBeat"] { --animal-x: 0px; }
.animal-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
  font-size: 16px;
  line-height: 20px;
}
.animal-loading[hidden] { display: none; }
.loading-frames { position: relative; width: 100px; height: 100px; }
.loading-frames img {
  position: absolute;
  inset: 0;
  width: 100px;
  height: 100px;
  image-rendering: pixelated;
  animation: loading-frame 600ms steps(1, end) infinite;
}
.loading-frames img + img { animation-delay: -300ms; }
@keyframes loading-frame { 0% { visibility: visible; } 50%, 100% { visibility: hidden; } }

#practice-time {
  position: relative;
  grid-row: 4;
  justify-self: center;
  align-self: center;
  width: 132px;
  height: 40px;
}
#practice-time[hidden] { display: none; }
#practice-value {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border-radius: 12px;
  background: #fff;
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
#cancel-timer { position: absolute; left: 140px; top: 0; width: 40px; height: 40px; display: grid; place-items: center; }
#cancel-timer img { width: 20px; height: 20px; }
#toggle, .confirm {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  height: 60px;
  border-radius: 20px;
  background: var(--ink);
  color: #fff;
  font-size: 32px;
  font-weight: 400;
  line-height: 32px;
}
#toggle {
  position: relative;
  grid-row: 5;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
#toggle img { width: 36px; height: 36px; object-fit: contain; }
#toggle .pause-icon { display: none; }
#toggle[aria-pressed="true"] .play-icon { display: none; }
#toggle[aria-pressed="true"] .pause-icon { display: block; }

footer {
  position: relative;
  grid-row: 6;
  justify-self: center;
  width: min(269px, 100%);
  height: 48px;
  display: grid;
  grid-template-columns: 48px repeat(3, 44px);
  justify-content: space-between;
  align-items: center;
}
footer button { width: 44px; height: 44px; display: grid; place-items: center; }
footer .signature {
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22.8px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
footer .signature.long { font-size: 18px; }
footer .note img, footer .sound img { width: 25.6px; height: 25.6px; margin: auto; }
footer .note img { filter: grayscale(1) brightness(.25); }
footer .alarm img { width: 20px; height: 20px; margin: 2.8px auto; }
footer .alarm.active { position: relative; }
footer .alarm.active img { visibility: hidden; }
footer .alarm.active::after {
  content: "";
  position: absolute;
  inset: 2.8px;
  background: var(--yellow);
  mask: url("assets/ui/alarm.svg") center / contain no-repeat;
  -webkit-mask: url("assets/ui/alarm.svg") center / contain no-repeat;
}
#message {
  position: relative;
  grid-row: 7;
  align-self: center;
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: #726c67;
}
#message span { opacity: 0; }

/* Dialogs follow the 362 × 540 Figma UI3 panel. */
.sheet {
  --option-bg: rgba(255, 255, 255, .8);
  position: fixed;
  inset: auto 0 max(30px, env(safe-area-inset-bottom));
  width: min(362px, calc(100vw - 40px));
  height: min(540px, calc(100dvh - 24px));
  max-width: none;
  max-height: calc(100svh - 40px);
  margin: 0 auto;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-radius: 30px;
  background: rgba(255, 255, 255, .6);
  box-shadow: inset 0 0 0 1px #fff;
  color: var(--ink);
  font-family: "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: contain;
}
.sheet::backdrop {
  background: transparent;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.sheet .close { position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; }
.sheet .close img { width: 40px; height: 40px; }
.sheet-title { position: absolute; left: 31px; top: 31px; margin: 0; font-size: 16px; font-weight: 500; line-height: 22px; }
.sheet .confirm {
  position: absolute;
  left: 50%;
  top: 456px;
  transform: translateX(-50%);
  width: calc(100% - 62px);
  min-width: 0;
  max-width: 300px;
  height: 60px;
  border-radius: 20px;
  font-size: 20px;
  font-weight: 500;
  line-height: 28px;
}

.meter-grid {
  position: absolute;
  top: 77px;
  left: 31px;
  right: 31px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.meter-grid button, .keypad button {
  min-width: 0;
  border: 0;
  background: var(--option-bg);
  font-weight: 400;
  line-height: 34px;
}
.meter-grid button { height: 72px; border-radius: 16px; font-size: 24px; }
.keypad button { height: 60px; border-radius: 15px; font-size: 24px; }
.meter-grid button.long { font-size: 24px; }
.meter-grid button[aria-pressed="true"] { color: var(--ink); background: var(--yellow); }

#rhythm-beats {
  position: absolute;
  left: 50%;
  top: 152px;
  transform: translateX(-50%);
  width: min(232px, calc(100% - 72px));
}
#rhythm-beats[data-count="4"] { grid-template-columns: repeat(4, 42px); --column-gap: 0px; justify-content: space-between; }
#rhythm-beats:not([data-count="4"]) { justify-content: center; }
.rhythm-divider, .timer-divider {
  position: absolute;
  left: 37px;
  right: 37px;
  height: 1px;
  background: rgba(0, 0, 0, .1);
}
.rhythm-divider { top: 323px; }
.sub-grid {
  position: absolute;
  top: 348px;
  left: 31px;
  right: 31px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 60px));
  gap: clamp(4px, 3vw, 20px);
  justify-content: space-between;
}
.sub-grid button {
  position: relative;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 0;
  border-radius: 15px;
  background: var(--option-bg);
}
.sub-grid img { width: 32px; height: 32px; }
.sub-grid button[aria-pressed="true"] { background: var(--yellow); }

#tempo-draft {
  position: absolute;
  left: 40px;
  right: 40px;
  top: 12px;
  display: block;
  text-align: center;
  font-size: 70px;
  font-weight: 500;
  line-height: 98px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#tempo-draft.decimal { font-size: 54px; }
.tempo-divider { position: absolute; top: 120px; left: 31px; right: 31px; height: 1px; background: rgba(0, 0, 0, .1); }
.keypad {
  position: absolute;
  left: 40px;
  right: 110px;
  top: 145px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.keypad button:nth-child(n+10) { background: rgba(255, 255, 255, .7); }
.slider-wrap { position: absolute; right: 44px; top: 145px; width: 37px; height: 288px; --value: 37.93%; }
.slider-track { position: absolute; left: 8px; top: 0; width: 21px; height: 288px; border-radius: 7px; background: rgba(0, 0, 0, .2); overflow: hidden; }
#slider-fill { position: absolute; bottom: 0; width: 100%; height: var(--value); border-radius: 7px; background: var(--ink); }
#slider-thumb { position: absolute; left: 0; bottom: calc(var(--value) - 9px); width: 37px; height: 18px; pointer-events: none; }
/* The invisible native thumb is 61 × 44; the visible icon stays 37 × 18.
   Extend each end by half its height to keep thumb centers on the 288px track. */
#tempo-slider { position: absolute; left: -12px; top: -22px; width: 61px; height: 332px; margin: 0; padding: 0; border: 0; opacity: 0; appearance: none; -webkit-appearance: none; writing-mode: vertical-lr; direction: rtl; cursor: ns-resize; touch-action: none; }
#tempo-slider::-webkit-slider-runnable-track { width: 61px; height: 100%; border: 0; background: transparent; }
#tempo-slider::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 61px; height: 44px; margin: 0; border: 0; background: transparent; }
#tempo-slider::-moz-range-track { width: 61px; height: 100%; border: 0; background: transparent; }
#tempo-slider::-moz-range-thumb { width: 61px; height: 44px; border: 0; border-radius: 0; background: transparent; }
#tempo-error { position: absolute; top: 102px; left: 20px; right: 20px; min-height: 18px; margin: 0; text-align: center; color: #a3452a; font-size: 12px; line-height: 18px; }

/* Sound selection: Hits, Loops and Voice. */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#sound-dialog { overflow: hidden; }
#sound-dialog .confirm { top: auto; bottom: 24px; }
.sound-tabs { position: absolute; left: 32px; right: 52px; top: 25px; display: flex; align-items: flex-start; gap: 24px; }
.sound-tabs button { position: relative; min-width: 0; padding: 0 0 8px; white-space: nowrap; color: #979797; font-size: 16px; font-weight: 500; line-height: 22px; }
.sound-tabs button[aria-selected="true"] { color: var(--ink); }
.sound-tabs button[aria-selected="true"]::after { content: ""; position: absolute; bottom: 0; left: calc(50% - 8px); width: 16px; height: 2px; border-radius: 1px; background: #1d1d1f; }
.sound-panel { position: absolute; left: 32px; right: 30px; top: 73px; bottom: 104px; }
.sound-panel[hidden], #backing-empty[hidden], #backing-status[hidden] { display: none; }
.sound-options { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none; }
.sound-options::-webkit-scrollbar, .key-filters::-webkit-scrollbar, #backing-options::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sound-card { position: relative; display: flex; flex: 0 0 52px; align-items: center; min-width: 0; height: 52px; padding-right: 12px; border-radius: 15px; background: var(--option-bg); overflow: hidden; }
.sound-card:has(.basic-select[aria-pressed="true"]), .sound-card.selected { background: var(--yellow); }
.basic-select { position: relative; display: flex; flex: 1; align-items: center; gap: 10px; height: 52px; min-width: 0; padding: 0 8px 0 12px; border-radius: 15px; text-align: left; }
.sound-card .record-icon { width: 28px; height: 28px; flex: 0 0 28px; }
.sound-name { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 14px; font-weight: 400; line-height: 20px; color: var(--ink); white-space: nowrap; }
.count-sound-card .sound-info { gap: 0; }
.count-sound-meta { display: block; overflow: hidden; text-overflow: ellipsis; color: #666; font-size: 10px; line-height: 14px; white-space: nowrap; }
.count-sound-meta[data-out-of-range="true"] { color: #c14343; }
html[data-theme="dark"] .count-sound-meta { color: #c9c9c5; }
html[data-theme="dark"] .count-sound-meta[data-out-of-range="true"] { color: #f96e6e; }
.sound-action { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 4px; }
.sound-loading { display: flex; align-items: center; justify-content: flex-end; color: var(--ink); font-size: 12px; font-weight: 400; line-height: 17px; }
.sound-loading[hidden], .sound-name[hidden] { display: none; }
.sound-progress-value { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.preview-button { position: relative; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 8px; }
.preview-button img { width: 32px; height: 32px; pointer-events: none; }
.sound-action .preview-button:disabled { opacity: 1; cursor: default; }
.preview-button .preview-download, .preview-button .preview-pause { display: none; }
.sound-card[data-download-state="unloaded"] .preview-play,
.sound-card[data-download-state="loading"] .preview-play,
.sound-card[data-download-state="error"] .preview-play,
.backing-row[data-download-state="unloaded"] .preview-play,
.backing-row[data-download-state="loading"] .preview-play,
.backing-row[data-download-state="error"] .preview-play { display: none; }
.sound-card[data-download-state="unloaded"] .preview-download,
.sound-card[data-download-state="loading"] .preview-download,
.sound-card[data-download-state="error"] .preview-download,
.backing-row[data-download-state="unloaded"] .preview-download,
.backing-row[data-download-state="loading"] .preview-download,
.backing-row[data-download-state="error"] .preview-download { display: block; }
.previewing .preview-button .preview-play, .preview-button[aria-pressed="true"] .preview-play { display: none; }
.previewing .preview-button .preview-pause, .preview-button[aria-pressed="true"] .preview-pause { display: block; }
.previewing .preview-button .preview-download, .preview-button[aria-pressed="true"] .preview-download { display: none; }
.sound-card.previewing .record-icon, .backing-row.previewing .record-icon { animation: record-spin var(--preview-spin-duration, 2s) linear infinite; }
@keyframes record-spin { to { transform: rotate(360deg); } }
#backing-tracks-panel { display: flex; flex-direction: column; gap: 12px; }
#backing-tracks-panel[hidden] { display: none; }
.key-filters { display: flex; gap: 8px; flex: 0 0 34px; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x; scroll-snap-type: x proximity; }
.key-filters button { flex: 0 0 64px; height: 34px; border-radius: 38px; background: rgba(255,255,255,.6); font-size: 12px; font-weight: 400; line-height: 17px; white-space: nowrap; scroll-snap-align: start; }
.key-filters button[data-key="none"] { flex-basis: 88px; }
.key-filters button[aria-pressed="true"] { background: var(--yellow); }
#backing-options { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 12px; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; touch-action: pan-y; }
.backing-row { display: flex; flex: 0 0 62px; align-items: center; min-width: 0; height: 62px; padding-right: 12px; border-radius: 15px; background: var(--option-bg); }
.backing-row[hidden], #backing-options[hidden] { display: none; }
.backing-row.selected, .backing-row[aria-selected="true"], .backing-row:has(.backing-select[aria-pressed="true"]) { background: var(--yellow); }
.backing-select { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; height: 100%; padding: 12px 8px 12px 12px; text-align: left; border-radius: 15px; }
.backing-select .record-icon, #backing-status .record-icon { width: 28px; height: 28px; flex: 0 0 28px; }
.sound-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.backing-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 400; line-height: 20px; }
.badges { display: flex; align-items: center; gap: 2px; min-width: 0; }
.sound-key, .sound-range { padding: 0 4px; border-radius: 5px; background: rgba(0,0,0,.05); color: #666; font-size: 12px; font-weight: 400; line-height: 17px; white-space: nowrap; }
.backing-empty { margin: auto 0; padding: 24px 12px; color: #666; text-align: center; font-size: 14px; line-height: 20px; }
#sound-load-status { position: absolute; bottom: 86px; left: 31px; right: 31px; margin: 0; color: var(--ink); text-align: center; font-size: 12px; line-height: 17px; }
#backing-status { position: absolute; z-index: 2; top: calc(max(44px, env(safe-area-inset-top)) + 100px + clamp(10px, 2.3svh, 24px) + 24px); left: max(20px, calc((100% - 340px) / 2)); display: flex; align-items: center; gap: 4px; min-width: 167px; height: 28px; padding-right: 6px; border-radius: 14px 10px 10px 14px; background: #fff; }
#backing-status .status-backplate { position: absolute; inset: 0; width: 167px; height: 28px; z-index: -1; }
#backing-status .sound-key, #backing-status .sound-range { background: var(--cell); }
#backing-status .sound-range.out-of-range, #backing-status .sound-range[data-out-of-range="true"] { color: #f96e6e; }

#timer-dialog h2 { position: absolute; left: 0; right: 0; margin: 0; text-align: center; font-size: 16px; font-weight: 500; line-height: 22px; }
.stopwatch-title { top: 40px; }
.countdown-title { top: 295px; }
#stopwatch-preview { position: absolute; top: 83px; left: 0; right: 0; text-align: center; font-size: 50px; font-weight: 400; line-height: 70px; font-variant-numeric: tabular-nums; }
#timer-dialog #start-stopwatch { top: 178px; }
.timer-divider { top: 270px; }
#countdown-presets { position: absolute; top: 343px; left: 31px; right: 31px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
#countdown-presets::-webkit-scrollbar { display: none; }
#countdown-presets button { width: 60px; height: 60px; flex-shrink: 0; border: 0; border-radius: 15px; background: var(--option-bg); scroll-snap-align: start; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0; }
#countdown-presets span { display: block; font-size: 24px; line-height: 34px; transform: translateY(6px); }
#countdown-presets small { display: block; font-size: 14px; line-height: 20px; }
#countdown-presets button[aria-pressed="true"] { color: var(--ink); background: var(--yellow); }

@media (orientation: landscape) {
  .sheet { --option-bg: rgba(255, 255, 255, .6); inset: 50% auto auto 50%; transform: translate(-50%, -50%); }
}

@media (max-width: 370px) {
  .metronome { padding-left: 14px; padding-right: 14px; }
  .tempo-overview, .tempo-controls { width: 100%; }
  .tempo-overview { gap: 6px; }
  #edit-tempo { width: 92px; flex-basis: 92px; }
  .beat-panel { padding-left: 5px; padding-right: 5px; }
  .keypad { left: 24px; right: 88px; gap: 12px; }
  .slider-wrap { right: 26px; }
  .sub-grid { left: 24px; right: 24px; }
}

@media (max-height: 650px) and (orientation: portrait) {
  .character { width: min(80%, 33svh); }
}

@media (min-width: 600px) and (max-width: 1023px), (min-width: 600px) and (orientation: portrait) {
  body { display: grid; place-items: center; }
  .metronome {
    width: min(560px, calc(100vw - 48px));
    height: clamp(680px, calc(100svh - 32px), 960px);
    padding-left: 32px;
    padding-right: 32px;
  }
  .tempo-overview, .tempo-controls { width: min(460px, 100%); }
  #edit-tempo { width: 112px; flex-basis: 112px; }
  .character { width: min(340px, 72%, 38svh); }
  footer { width: 300px; }
  .sheet {
    inset: 50% auto auto 50%;
    width: min(362px, calc(100vw - 40px));
    height: min(540px, calc(100dvh - 64px));
    transform: translate(-50%, -50%);
  }
}

/* Desktop canvas follows the 1120 × 630 Figma panel. */
.brand { display: none; }
.animal-switcher { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 7.5px; white-space: nowrap; color: rgba(0,0,0,.3); font-size: 16px; font-weight: 500; line-height: 22px; }
.animal-switcher button { width: 32px; height: 32px; display: grid; place-items: center; }
.animal-switcher button:disabled { opacity: .5; cursor: default; }
.animal-switcher button img { display: block; width: 7px; height: 10px; }
#animal-next img { transform: rotate(180deg); }
.animal-caption { position: relative; min-width: 82px; text-align: center; }
.character[data-preview-loading="true"] .animal-caption::after { content: "loading…"; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 400; line-height: 16px; pointer-events: none; }
footer .alarm.active::after { inset: auto; width: 20px; height: 20px; }
@media (min-width: 1024px) and (orientation: landscape), (orientation: landscape) and (min-width: 700px) and (max-height: 700px) {
  :root, body { --page-background: #fff; background: #fff; }
  body { display: grid; place-items: center; }
  .metronome {
    --controls-left: calc(50% + 79px);
    --overview-height: 72px;
    --overview-gap: 40px;
    --control-row-height: 60px;
    --control-edge-min: 84px;
    --control-fixed-height: calc(var(--overview-height) + var(--overview-gap) + 28px + var(--control-row-height));
    /* Shrink the middle gap first, then reduce both outer spaces equally. */
    --control-edge: clamp(var(--control-edge-min), calc((100% - var(--control-fixed-height) - 24px) / 2), 154.8px);
    width: min(1120px, calc(100vw - 80px));
    height: min(630px, calc(100svh - 64px));
    min-height: calc(var(--control-edge-min) + var(--control-edge-min) + var(--control-fixed-height) + 12px);
    padding: 0;
    display: block;
    border-radius: 40px;
    background: var(--paper);
    margin: 32px auto;
  }
  .brand { display: block; position: absolute; left: 40px; top: 40px; height: 24px; color: var(--ink); font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif; font-size: 26px; font-weight: 800; line-height: 1; white-space: nowrap; }
  .tempo-overview, .tempo-controls { position: absolute; left: var(--controls-left); width: 348px; }
  .tempo-overview { top: var(--control-edge); }
  #edit-tempo { width: 100px; flex-basis: 100px; }
  .tempo-controls { top: calc(var(--control-edge) + var(--overview-height) + var(--overview-gap)); }
  .character { position: absolute; left: calc(24.15% - 192px); top: 114px; width: 384px; height: 424px; }
  .character canvas { top: 47.4%; transform: translate(var(--animal-x, 12px), -50%) scale(var(--animal-scale, .9)); }
  .animal-switcher { bottom: -5px; }
  .animal-loading { left: 24.15%; top: 50%; }
  #toggle { position: absolute; top: auto; bottom: var(--control-edge); left: calc(var(--controls-left) + 99px); }
  footer { display: contents; }
  footer button, footer .alarm.active { position: absolute; }
  footer .signature, footer .note { top: auto; bottom: var(--control-edge); width: 60px; height: 60px; border-radius: 16px; background: var(--panel); }
  footer .signature { left: var(--controls-left); font-size: 20px; }
  footer .signature.long { font-size: 20px; }
  footer .note { left: calc(var(--controls-left) + 288px); }
  footer .sound { right: 93.6px; bottom: 28px; }
  footer .alarm { right: 28px; bottom: 28px; }
  #practice-time { position: absolute; right: var(--utility-right); bottom: var(--utility-bottom); width: var(--timer-width); height: 36px; padding: 0 10px; display: flex; align-items: center; gap: 10px; background: white; border-radius: 12px; }
  #practice-time[hidden] { display: none; }
  #practice-value { flex: 1; min-width: 0; height: 36px; background: none; }
  #cancel-timer { position: static; width: 20px; height: 20px; flex: 0 0 20px; }
  #message { position: absolute; left: var(--controls-left); bottom: 100px; width: 348px; }
  .sheet { inset: 50% auto auto 50%; width: min(362px, calc(100vw - 40px)); height: min(540px, calc(100dvh - 32px)); transform: translate(-50%, -50%); }
  #rhythm-beats { width: 232px; }
}
@media (orientation: landscape) and (min-width: 700px) and (max-width: 1100px) {
  .metronome { --controls-left: calc(100% - 380px); width: calc(100vw - 32px); }
  .character { left: calc((100% - 380px) / 2 - 160px); width: 320px; }
}
@media (orientation: landscape) and (min-width: 700px) and (max-height: 700px) {
  .metronome { height: min(630px, calc(100svh - 32px)); margin: 16px auto; }
  .brand { top: 24px; left: 24px; }
  .character { top: 70px; height: calc(100% - 110px); width: min(320px, 54svh); left: calc((100% - 380px) / 2 - min(160px, 27svh)); }
  footer .sound, footer .alarm { bottom: 28px; }
}
/* Balance the two main columns on compact tablet landscape screens. */
@media (orientation: landscape) and (min-width: 960px) and (max-width: 1100px) and (min-height: 521px) {
  .metronome { --controls-left: calc(73% - 174px); }
  .character { left: calc(27% - min(160px, 27svh)); }
  .animal-loading { left: 27%; }
}
/* Keep the desktop two-column UI on phones rotated to landscape. */
@media (orientation: landscape) and (min-width: 480px) and (max-height: 520px) {
  :root, body { --page-background: #fff; background: #fff; }
  body { display: grid; place-items: center; }
  .metronome {
    --controls-left: max(40%, calc(100% - 380px));
    --controls-width: min(348px, calc(100% - var(--controls-left) - 16px));
    --overview-height: 72px;
    --overview-gap: 20px;
    --control-row-height: 60px;
    --control-edge-min: 72px;
    --control-fixed-height: calc(var(--overview-height) + var(--overview-gap) + 28px + var(--control-row-height));
    --control-edge: clamp(var(--control-edge-min), calc((100% - var(--control-fixed-height) - 24px) / 2), 154.8px);
    display: block;
    width: min(1120px, calc(100vw - 16px));
    height: calc(100svh - 16px);
    min-height: calc(var(--control-edge-min) + var(--control-edge-min) + var(--control-fixed-height) + 12px);
    margin: 8px auto;
    padding: 0;
    border-radius: 24px;
    background: var(--paper);
  }
  .brand { display: block; position: absolute; left: 20px; top: 16px; height: 24px; color: var(--ink); font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif; font-size: 26px; font-weight: 800; line-height: 1; white-space: nowrap; }
  .tempo-overview, .tempo-controls { position: absolute; left: var(--controls-left); width: var(--controls-width); }
  .tempo-overview { top: var(--control-edge); }
  #edit-tempo { width: 100px; flex-basis: 100px; }
  .tempo-controls { top: calc(var(--control-edge) + var(--overview-height) + var(--overview-gap)); }
  .character { position: absolute; top: clamp(52px, 18%, 70px); left: calc(50% - 190px); width: min(320px, 54svh); height: calc(100% - 112px); transform: translateX(-50%); }
  .character canvas { top: 47.4%; transform: translate(var(--animal-x, 12px), -50%) scale(var(--animal-scale, .9)); }
  .animal-switcher { bottom: -5px; }
  .animal-loading { left: calc(50% - 190px); top: 50%; }
  #toggle { position: absolute; left: calc(var(--controls-left) + 99px); top: auto; bottom: var(--control-edge); }
  footer { display: contents; }
  footer button, footer .alarm.active { position: absolute; }
  footer .signature, footer .note { top: auto; bottom: var(--control-edge); width: 60px; height: 60px; border-radius: 16px; background: var(--panel); }
  footer .signature { left: var(--controls-left); font-size: 20px; }
  footer .signature.long { font-size: 20px; }
  footer .note { left: auto; right: max(16px, calc(100% - var(--controls-left) - 348px)); }
  footer .sound { right: 93.6px; bottom: 28px; }
  footer .alarm { right: 28px; bottom: 28px; }
  #practice-time { position: absolute; right: var(--utility-right); bottom: var(--utility-bottom); width: var(--timer-width); height: 36px; padding: 0 10px; display: flex; align-items: center; gap: 10px; background: white; border-radius: 12px; }
  #practice-time[hidden] { display: none; }
  #practice-value { flex: 1; min-width: 0; height: 36px; background: none; }
  #cancel-timer { position: static; width: 20px; height: 20px; flex: 0 0 20px; }
  #message { position: absolute; left: 10px; bottom: 8px; width: calc(var(--controls-left) - 20px); font-size: 11px; line-height: 15px; }
  .sheet { inset: 50% auto auto 50%; width: min(362px, calc(100vw - 24px)); height: min(540px, calc(100dvh - 16px)); max-height: calc(100dvh - 16px); transform: translate(-50%, -50%); }
  #rhythm-beats { width: 232px; }
}
@media (orientation: landscape) and (min-width: 560px) and (max-width: 650px) and (max-height: 520px) {
  .character, .animal-loading { left: 20%; }
  #toggle { left: calc(var(--controls-left) + 82px); }
}
@media (orientation: landscape) and (min-width: 480px) and (max-width: 559px) and (max-height: 520px) {
  .metronome { --overview-height: 60px; --overview-gap: 14px; --control-row-height: 52px; }
  .brand { height: 20px; font-size: 21px; }
  .tempo-overview, .beat-panel, #edit-tempo { height: 60px; }
  #edit-tempo { width: 80px; flex-basis: 80px; }
  #bpm { font-size: 28px; line-height: 32px; }
  #edit-tempo span { font-size: 11px; }
  .beat-panel { padding: 6px; }
  #beats { height: 48px; grid-auto-rows: 48px; }
  #beats[data-count="7"], #beats[data-count="8"], #beats[data-count="9"], #beats[data-count="12"] { grid-auto-rows: 22px; }
  .character { left: 20%; width: min(145px, 46svh); height: calc(100% - 124px); }
  .animal-loading { left: 20%; }
  #toggle { left: calc(var(--controls-left) + 66px); width: 130px; min-width: 130px; max-width: 130px; height: 52px; }
  footer .signature, footer .note { width: 48px; height: 52px; }
  footer .note { right: 16px; }
}
@media (orientation: landscape) and (min-width: 480px) and (max-height: 340px) {
  .metronome { --control-edge-min: 52px; }
  footer .sound, footer .alarm { bottom: 12px; width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* Paint the dimmed color on the real page surface so Safari can extend it
   beneath its toolbars. Dim the content separately, exactly once. */
html:has(.sheet[open]), html:has(.sheet[open]) body {
  background-color: color-mix(in srgb, var(--page-background) 50%, #4d4d4d);
}
html:has(.sheet[open]) .metronome {
  isolation: isolate;
  background: var(--paper);
}
html:has(.sheet[open]) .metronome::after,
html:has(.sheet[open]) .theme-switcher::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: rgba(77, 77, 77, .5);
}

/* Theme variants are scoped to the home page; dialogs retain light tokens. */
.theme-dark-asset,
.metronome .theme-dark-asset,
.theme-switcher .theme-dark-asset { display: none; }
.theme-switcher { display: none; position: fixed; right: 20px; top: 20px; width: 100px; height: 36px; overflow: hidden; border-radius: 10px; background: #e2e2da; }
.theme-switcher[hidden] { display: none; }
.theme-switcher button { display: grid; place-items: center; width: 50px; height: 36px; }
.theme-switcher button[data-theme="light"] { background: #edede8; }
.theme-switcher img { width: 20px; height: 20px; }
.theme-switcher button[data-theme="dark"] img { width: 18px; height: 18px; }
@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  .theme-switcher:not([hidden]) { display: flex; }
}
.brand-image { position: absolute; inset: 0; overflow: hidden; }
.brand .theme-light-asset img { position: absolute; width: 121.33%; height: 975.24%; left: -10.61%; top: -664.04%; }
.brand .theme-dark-asset img { position: absolute; width: 100%; height: 616.87%; left: 0; top: -239.76%; }
.metronome .brand { width: 160.762px; height: 20px; }
html[data-theme="dark"], html[data-theme="dark"] body { --page-background: #212224; background-color: #212224; }
html[data-theme="dark"] .metronome { --paper: #494e50; --panel: #85878e; --track: rgba(255, 255, 255, .2); background: var(--paper); }
html[data-theme="dark"] .metronome .theme-light-asset,
html[data-theme="dark"] .theme-switcher .theme-light-asset { display: none; }
html[data-theme="dark"] .metronome .theme-dark-asset,
html[data-theme="dark"] .theme-switcher .theme-dark-asset { display: block; }
html[data-theme="dark"] .theme-switcher { background: #45494c; }
html[data-theme="dark"] .theme-switcher button[data-theme="light"] { background: #2e3133; }
html[data-theme="dark"] .metronome .brand { width: 160.386px; height: 26px; opacity: .8; }
html[data-theme="dark"] #bpm,
html[data-theme="dark"] #edit-tempo span,
html[data-theme="dark"] footer .signature { color: #f4f4f0; }
html[data-theme="dark"] #current-note { display: none; }
html[data-theme="dark"] footer .note::after { content: ""; width: 25.6px; height: 25.6px; background: #f4f4f0; mask: var(--note-icon) center / contain no-repeat; -webkit-mask: var(--note-icon) center / contain no-repeat; }
html[data-theme="dark"] .quick-track i { background: #fff; }
.dark-quick-thumb { position: absolute; top: 4px; left: calc(var(--thumb-x, 106.62px) - 12px); width: 24px; height: 20px; pointer-events: none; }
.dark-quick-thumb > img { position: absolute; left: 0; top: 0; width: 24px; height: 20px; }
.dark-quick-thumb > .dark-quick-bars { left: 7px; top: 6px; width: 10px; height: 8px; }
html[data-theme="dark"] .character { mix-blend-mode: normal; }
html[data-theme="dark"] .animal-switcher,
html[data-theme="dark"] #message,
html[data-theme="dark"] .animal-loading { color: #e5e5e5; }
html[data-theme="dark"] .animal-switcher button { justify-items: center; }
html[data-theme="dark"] .animal-switcher .theme-dark-asset { width: 6.13544px; height: 7.74058px; }
html[data-theme="dark"] footer .sound .theme-dark-asset { width: 24.32px; height: 24.32px; }
footer .alarm:not(.active) .theme-alarm-active { display: none; }
html[data-theme="dark"] footer .alarm:not(.active) .theme-alarm-default { filter: brightness(0) invert(1); }
html[data-theme="dark"] footer .alarm.active .theme-alarm-default,
html[data-theme="dark"] footer .alarm.active::after { display: none; }
html[data-theme="dark"] footer .alarm.active .theme-alarm-active { visibility: visible; }

/* Keep the backing status below the slider in portrait and beside the timer in landscape. */
@media (max-width: 370px) {
  .sound-tabs { left: 24px; }
  .sound-panel { left: 24px; right: 24px; }
  .sound-options { gap: 12px; }
  .backing-row { padding-right: 8px; }
  .backing-select { gap: 8px; padding: 8px; }
  .backing-select .record-icon { width: 24px; height: 24px; flex-basis: 24px; }
  .backing-row .preview-button { width: 32px; height: 32px; flex-basis: 32px; }
  .backing-row .preview-button img { width: 32px; height: 32px; }
  .backing-row .sound-key, .backing-row .sound-range { font-size: 10px; padding: 0 3px; }
  .backing-row[data-download-state="loading"] .backing-select { padding: 6px 8px; }
  .backing-row[data-download-state="loading"] .backing-name { font-size: 12px; line-height: 16px; }
  .backing-row[data-download-state="loading"] .badges { flex-wrap: wrap; }
  .backing-row[data-download-state="loading"] .sound-key,
  .backing-row[data-download-state="loading"] .sound-range { line-height: 14px; }
  #backing-status { left: 14px; }
}
@media (min-width: 600px) and (max-width: 1023px), (min-width: 600px) and (orientation: portrait) {
  #backing-status { left: max(32px, calc((100% - 460px) / 2)); }
}
@media (min-width: 1024px) and (orientation: landscape), (orientation: landscape) and (min-width: 700px) and (max-height: 700px), (orientation: landscape) and (min-width: 480px) and (max-height: 520px) {
  .metronome { --utility-right: 171px; --utility-bottom: 32px; --timer-width: 161px; --status-gap: 12px; }
  #backing-status { left: auto; top: auto; right: calc(var(--utility-right) + var(--timer-width) + var(--status-gap)); bottom: var(--utility-bottom); height: 36px; padding: 4px 6px 4px 4px; border-radius: 12px; translate: 0 var(--utility-shift, 0px); }
  #backing-status .status-backplate { display: none; }
}
/* Desktop Figma utilities share one slot when timing is off. */
@media (min-width: 1024px) and (orientation: landscape) and (hover: hover) and (pointer: fine),
       (min-width: 700px) and (max-height: 700px) and (orientation: landscape) and (hover: hover) and (pointer: fine) {
  .metronome { --utility-right: 172px; --utility-bottom: 40px; --timer-width: 140px; --status-gap: 16px; }
  .metronome:has(> #practice-time[hidden]) #backing-status { right: var(--utility-right); }
  #practice-value { font-size: 16px; font-weight: 400; line-height: 22px; }
  #backing-status { min-width: 168px; padding: 0 8px 0 0; gap: 6px; border-radius: 18px 10px 10px 18px; }
  #backing-status .record-icon { width: 36px; height: 36px; flex-basis: 36px; }
  #backing-status .sound-key, #backing-status .sound-range { font-size: 14px; line-height: 20px; }
  footer .sound, footer .alarm { bottom: calc(var(--utility-bottom) - 4px); width: 44px; height: 44px; }
}
@media (orientation: landscape) and (min-width: 480px) and (max-width: 559px) and (max-height: 520px) {
  .metronome { --timer-width: 136px; --status-gap: 8px; }
  #practice-value { font-size: 16px; }
  #backing-status { min-width: 0; padding-left: 0; }
  #backing-status .badges { flex-direction: column; align-items: flex-start; gap: 2px; }
  #backing-status .sound-key, #backing-status .sound-range { line-height: 13px; }
}
@media (orientation: landscape) and (min-width: 480px) and (max-height: 340px) {
  .metronome { --utility-bottom: 12px; }
}
@media (max-height: 575px) {
  #sound-dialog .sound-panel { bottom: 100px; }
  #sound-dialog .confirm { bottom: 20px; }
}
html[data-theme="dark"] #backing-status { background: #85878e; }
html[data-theme="dark"] #backing-status .status-backplate { opacity: 0; }
html[data-theme="dark"] #backing-status .sound-key,
html[data-theme="dark"] #backing-status .sound-range { background: #6c6e74; color: #fff; }
html[data-theme="dark"] #backing-status .sound-range.out-of-range,
html[data-theme="dark"] #backing-status .sound-range[data-out-of-range="true"] { color: #f96e6e; }
html[data-theme="dark"] #practice-time { background: #85878e; border-radius: 12px; }
html[data-theme="dark"] #practice-value { background: transparent; color: #fff; }
html[data-theme="dark"] #cancel-timer img { content: url("assets/ui/dark-timer-close.svg"); }

/* Move the mobile lower section together without replacing sprite transforms. */
@media (max-width: 699px), (hover: none) and (pointer: coarse) {
  .metronome { --utility-shift: 20px; }
  .bird-sprite[data-clip="halloweenBeat"] { --animal-scale: 1.035; }
  .metronome > .character,
  .metronome > .animal-loading,
  .metronome > #practice-time,
  .metronome > #toggle,
  .metronome > footer > button,
  .metronome > #message {
    translate: 0 20px;
  }
}
/* Short landscape panels need room for the shifted bottom controls. */
@media (orientation: landscape) and (max-height: 340px) and (max-width: 699px),
       (orientation: landscape) and (max-height: 340px) and (hover: none) and (pointer: coarse) {
  .metronome { overflow: visible; }
}

/* Keep the player in its original first-screen layout; help follows below. */
.practice-stage { display: flow-root; width: 100%; min-height: 100svh; }
.practice-help-link { display: none; color: #726c67; font-size: 12px; line-height: 18px; text-decoration: underline; text-underline-offset: 3px; }
.practice-guide { width: min(100% - 40px, 760px); margin: 0 auto; padding: 40px 0 64px; font-size: 16px; line-height: 1.75; scroll-margin-top: 24px; }
.practice-guide, .practice-guide * { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.practice-guide h1 { margin: 0 0 16px; font-size: clamp(25px, 4vw, 34px); line-height: 1.25; letter-spacing: -.02em; }
.practice-guide h2 { margin: 32px 0 10px; font-size: 21px; line-height: 1.4; }
.practice-guide p { margin: 0 0 16px; }
.practice-guide ol { margin: 0; padding-left: 24px; }
.practice-guide li { padding-left: 4px; margin: 0 0 12px; }
.practice-guide details { padding: 14px 0; border-bottom: 1px solid color-mix(in srgb, currentColor 20%, transparent); }
.practice-guide summary { cursor: pointer; font-weight: 600; }
.practice-guide details p { margin: 12px 0 0; }
.practice-guide .practice-guide-zh { margin-top: 32px; font-size: 14px; }
.practice-return { display: inline-block; margin-top: 12px; color: inherit; text-underline-offset: 4px; }
.practice-guide a:focus-visible, .practice-guide summary:focus-visible, .practice-help-link:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
html[data-theme="dark"] .practice-guide { color: #f4f4f0; }
@media (min-width: 1024px) and (orientation: landscape), (orientation: landscape) and (min-width: 700px) and (max-height: 700px) {
  .practice-stage { min-height: 100dvh; display: grid; place-items: center; }
}
@media (max-width: 699px), (hover: none) and (pointer: coarse) {
  .metronome > #message { translate: none; }
}

/* Keep audio status in its own text node. */
#message .playback-message { opacity: 1; }


/* Center the desktop guide link 32px below the player card. */
@media (min-width: 1024px) and (orientation: landscape) and (hover: hover) and (pointer: fine),
       (orientation: landscape) and (min-width: 700px) and (max-height: 700px) and (hover: hover) and (pointer: fine) {
  .practice-stage { grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; justify-items: center; }
  .practice-stage > .metronome { grid-row: 2; }
  .practice-help-link { display: block; grid-row: 3; align-self: start; justify-self: center; }
}
html[data-theme="dark"] .practice-help-link { color: #e5e5e5; }
@media (max-width: 699px), (hover: none) and (pointer: coarse) {
  .practice-help-link { display: none; }
  .practice-guide { padding-top: 60px; }
  .practice-guide h1 {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.25em, #000 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 1.25em, #000 100%);
  }
}
