/* Find our rhythm: tactile at the edges, completely still while estimating.
   Never use an animated beat, sweep, progress ring, or breathing hold state. */
.rhythm-game {
  --rhythm-ink: #34303d;
  --rhythm-muted: #665d6d;
  --rhythm-pink: #f9dce6;
  --rhythm-pink-ink: #71364e;
  --rhythm-lilac: #e8e0f5;
  --rhythm-lilac-ink: #584078;
  --rhythm-line: #d7cbd8;
  width: 100%;
  max-width: 560px;
  min-width: 0;
  margin: 0 auto;
  color: var(--rhythm-ink);
  text-align: center;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.rhythm-game *, .rhythm-game *::before, .rhythm-game *::after { box-sizing: border-box; }
.rhythm-game [hidden] { display: none !important; }
.game-content:has(.rhythm-game) { min-height: 0; padding: 22px 26px 24px; }
.game-shell:has(.rhythm-game) { min-height: 0; }
/* A phase may inherit the dialog's scroll position. Keep its way out visible. */
.game-dialog:has(.rhythm-game) .game-header { position: sticky; top: 0; z-index: 3; flex-shrink: 0; background: var(--bg, #f8f5ef); }
.rhythm-game h3 { margin: 10px 0; font: 800 28px/1.2 'Manrope', sans-serif; letter-spacing: -.7px; }
.rhythm-game p { margin: 10px auto; color: var(--rhythm-muted); font-size: 14px; line-height: 1.5; }
.rhythm-topline { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin: 0 0 12px; font-size: 12px; font-weight: 650; text-align: left; }
.rhythm-topline > * { min-width: 0; max-width: 100%; }
.rhythm-summary { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; color: var(--rhythm-muted); font-size: 12px; }
.rhythm-summary b, .rhythm-summary strong { color: var(--rhythm-ink); }
.rhythm-summary > span { max-width: 100%; }
.rhythm-target { position: relative; display: grid; justify-items: center; gap: 2px; padding: 12px 16px; margin: 10px auto; border: 1px solid var(--rhythm-line); border-radius: 18px; background: #fffaf5; }
.rhythm-target > small, .rhythm-target > span:first-child { color: var(--rhythm-muted); font-size: 12px; font-weight: 650; }
.rhythm-target-value { display: block; color: var(--rhythm-ink); font: 800 clamp(32px, 7vw, 42px)/1.15 'Manrope', sans-serif; letter-spacing: -1px; }
.rhythm-target-value small, .rhythm-target-value > span { font-size: .45em; letter-spacing: 0; }
.rhythm-status { min-height: 42px; display: grid; align-content: center; margin: 8px 0 12px; color: var(--rhythm-muted); font-size: 13px; line-height: 1.5; }
.rhythm-status strong { color: var(--rhythm-ink); }
.rhythm-countdown { display: grid; place-items: center; min-height: 84px; margin: 12px auto; color: var(--rhythm-lilac-ink); font: 800 52px/1.1 'Manrope', sans-serif; }
.rhythm-pads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; width: 100%; }
.rhythm-pad { display: flex; flex-direction: column; min-width: 0; }
.rhythm-hold {
  --pad-bg: var(--rhythm-pink);
  --pad-ink: var(--rhythm-pink-ink);
  --pad-edge: #b76f89;
  position: relative;
  isolation: isolate;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 196px;
  padding: 18px 12px;
  border: 2px solid var(--pad-edge);
  border-radius: 23px;
  background: var(--pad-bg);
  color: var(--pad-ink);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--pad-edge) 55%, #fffaf5), 0 9px 16px #4934500a;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: pointer;
  transition: background-color 100ms ease, box-shadow 100ms ease;
}
.rhythm-hold[data-slot="1"], .rhythm-pad[data-slot="1"] .rhythm-hold, .rhythm-hold.player-1 {
  --pad-bg: var(--rhythm-lilac);
  --pad-ink: var(--rhythm-lilac-ink);
  --pad-edge: #9277b5;
}
.rhythm-hold > * { min-width: 0; max-width: 100%; pointer-events: none; }
.rhythm-hold:not(:disabled):hover { filter: none; }
.rhythm-hold:not(:disabled):active { transform: none; }
.rhythm-hold.is-holding, .rhythm-pad.is-holding .rhythm-hold {
  border-width: 3px;
  padding: 17px 11px;
  box-shadow: inset 0 0 0 3px #fffaf570, 0 2px 0 var(--pad-edge);
}
.rhythm-hold.is-submitted, .rhythm-pad.is-submitted .rhythm-hold { border-style: dashed; box-shadow: none; }
.rhythm-hold:disabled { opacity: 1; cursor: default; }
.rhythm-hold:disabled:not(.is-submitted) { background: #eee8ed; color: #665d6d; border-color: #a499a7; box-shadow: none; }
.rhythm-pad-name { display: block; font-size: 13px; font-weight: 700; line-height: 1.35; }
.rhythm-pad-label { display: grid; place-items: center; min-height: 55px; font: 800 24px/1.15 'Manrope', sans-serif; letter-spacing: -.5px; }
.rhythm-readout { display: grid; place-items: center; min-height: 42px; color: inherit; font: 800 30px/1.2 'Manrope', sans-serif; letter-spacing: -.5px; }
.rhythm-hold[data-blind="true"] .rhythm-readout, .rhythm-hold.is-submitted .rhythm-readout { font-size: 14px; line-height: 1.45; letter-spacing: 0; }
.rhythm-pad-hint { display: block; font-size: 12px; font-weight: 500; line-height: 1.4; }
.rhythm-pad-hint kbd, .rhythm-game kbd { padding: 1px 5px; border: 1px solid currentColor; border-radius: 5px; font-family: inherit; font-size: 12px; font-weight: 650; line-height: 1.4; }
.rhythm-partner { padding: 10px 12px; margin: 10px auto; border: 1px dashed var(--rhythm-line); border-radius: 12px; color: var(--rhythm-muted); font-size: 13px; line-height: 1.45; background: #fffaf5; }
.rhythm-game[data-mode="remote"] .rhythm-pads { grid-template-columns: minmax(0, 1fr); max-width: 340px; margin-left: auto; margin-right: auto; }
.rhythm-pads > :only-child { grid-column: 1 / -1; }
.rhythm-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.rhythm-controls > *, .rhythm-mode { min-width: 0; max-width: 100%; }
.rhythm-controls button, button.rhythm-ready, button.rhythm-practice, button.rhythm-mode, .rhythm-mode button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--rhythm-line);
  border-radius: 12px;
  background: #fffaf5;
  color: var(--rhythm-ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  white-space: normal;
}
.rhythm-controls .primary, button.rhythm-ready, .rhythm-game button.primary { border-color: #584078; background: #584078; color: #fffaf5; }
.rhythm-mode { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px auto; }
.rhythm-mode button { flex: 1 1 125px; }
.rhythm-mode [aria-pressed="true"] { border-color: #584078; background: var(--rhythm-lilac); box-shadow: inset 0 0 0 1px #584078; color: #584078; }
label.rhythm-mode { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: start; gap: 9px; min-height: 44px; max-width: 380px; padding: 10px; border-radius: 10px; text-align: left; font-size: 13px; line-height: 1.45; cursor: pointer; }
label.rhythm-mode input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: #584078; }
.rhythm-game .rhythm-help { margin: 10px auto; font-size: 12px; line-height: 1.5; }
.rhythm-scoring { margin: 12px 0 0; border: 1px solid var(--rhythm-line); border-radius: 12px; background: #fffaf5; text-align: left; }
.rhythm-scoring > summary { min-height: 44px; padding: 11px 12px; color: var(--rhythm-muted); font-size: 12px; font-weight: 700; line-height: 20px; cursor: pointer; }
.rhythm-scoring > p { padding: 0 12px 12px; margin: 0; font-size: 12px; }
.rhythm-game button:focus-visible, .rhythm-game summary:focus-visible, .rhythm-game input:focus-visible { outline: 3px solid #584078; outline-offset: 4px; }
.rhythm-game button:disabled:not(.rhythm-hold) { opacity: 1; background: #eee8ed; color: #665d6d; border-color: #b4a7b6; cursor: default; }
.rhythm-result { margin: 12px 0; padding: 18px 16px; border: 1px solid var(--rhythm-line); border-radius: 20px; background: #fffaf5; }
.rhythm-result h3 { margin: 4px 0 8px; font-size: 25px; }
.rhythm-game .rhythm-star { color: #80621e; font-size: 15px; font-weight: 700; line-height: 1.4; }
.rhythm-game .rhythm-star.is-earned { color: #80621e; text-shadow: 0 2px 0 #f5d77580; }
/* Revealed values only. Player markers occupy separate lanes, including ties.
   Marker position is a bounded percentage, never live elapsed-time progress. */
.rhythm-marker-track { position: relative; isolation: isolate; height: 112px; margin: 14px 9px 8px; border-radius: 14px; background: linear-gradient(90deg, #f9dce64d, #e8e0f54d); }
.rhythm-marker-track::before { position: absolute; content: ''; top: 55px; right: 0; left: 0; height: 2px; background: #b4a7b6; }
.rhythm-marker { position: absolute; left: clamp(3%, var(--marker, 50%), 97%); top: 28px; z-index: 1; max-width: 48%; transform: translateX(-50%); color: var(--rhythm-pink-ink); font-size: 12px; font-weight: 700; white-space: nowrap; }
.rhythm-marker::before { content: ''; display: block; width: 14px; height: 14px; margin: 0 auto 4px; border: 2px solid var(--rhythm-pink-ink); border-radius: 50%; background: var(--rhythm-pink); }
.rhythm-marker.player-1 { top: 67px; color: var(--rhythm-lilac-ink); }
.rhythm-marker.player-1::before { width: 12px; height: 12px; border-color: var(--rhythm-lilac-ink); border-radius: 2px; background: var(--rhythm-lilac); transform: rotate(45deg); }
.rhythm-marker.is-target { top: 6px; bottom: 7px; left: 50%; z-index: 0; color: var(--rhythm-muted); font-size: 12px; }
.rhythm-marker.is-target::before { position: absolute; top: 19px; bottom: 0; left: 50%; width: 0; height: auto; margin: 0; border: 0; border-left: 2px dashed #8c8093; border-radius: 0; background: none; }
.rhythm-result-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0 0; }
.rhythm-result-row { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding: 12px 8px; border: 1px solid #dcb5c5; border-radius: 13px; background: var(--rhythm-pink); color: var(--rhythm-pink-ink); font-size: 12px; line-height: 1.4; }
.rhythm-result-row:nth-child(2), .rhythm-result-row.player-1 { border-color: #c6b5dc; background: var(--rhythm-lilac); color: var(--rhythm-lilac-ink); }
.rhythm-result-row strong { display: block; font: 800 26px/1.3 'Manrope', sans-serif; }
.rhythm-result-row small { font-size: 12px; }
.rhythm-round-history { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 12px 0; padding: 0; list-style: none; font-size: 12px; color: var(--rhythm-muted); }
.rhythm-round-history > * { display: grid; place-items: center; min-width: 28px; min-height: 28px; padding: 3px 6px; border: 1px solid var(--rhythm-line); border-radius: 9px; background: #fffaf5; }
.rhythm-round-history .is-earned { color: #725519; background: #f8e8af; border-color: #be9d4f; }
.rhythm-finish { padding: 16px 0; }
.rhythm-finish .rhythm-summary { margin: 14px 0; padding: 12px; border-radius: 14px; background: #f4eef8; }
/* A short one-off result arrival is never active during estimation. */
.rhythm-game[data-phase="reveal"] .rhythm-result, .rhythm-game[data-phase="finished"] .rhythm-finish { animation: rhythm-result-arrive 180ms ease-out both; }
@keyframes rhythm-result-arrive { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.rhythm-game[data-phase="play"],
.rhythm-game[data-phase="play"] *,
.rhythm-game[data-phase="play"] *::before,
.rhythm-game[data-phase="play"] *::after { animation: none !important; transition: none !important; }
/* Background artwork is visible through the modal backdrop. Freeze the whole
   page only for an open timing round so no decorative beat becomes a clock. */
body:has(dialog[open] .rhythm-game[data-phase="play"]),
body:has(dialog[open] .rhythm-game[data-phase="play"])::before,
body:has(dialog[open] .rhythm-game[data-phase="play"])::after,
body:has(dialog[open] .rhythm-game[data-phase="play"]) *,
body:has(dialog[open] .rhythm-game[data-phase="play"]) *::before,
body:has(dialog[open] .rhythm-game[data-phase="play"]) *::after,
body:has(dialog[open] .rhythm-game[data-phase="play"]) dialog::backdrop { animation: none !important; transition: none !important; }
.rhythm-game[data-phase="paused"] .rhythm-status { padding: 14px; border: 1px solid var(--rhythm-line); border-radius: 14px; background: #f4eef8; }
@media (max-width: 600px) {
  .game-content:has(.rhythm-game) { padding: 12px 14px 16px; }
  .game-shell:has(.rhythm-game) { min-height: 100dvh; }
  .game-shell:has(.rhythm-game) .game-header { padding: 10px 14px; gap: 8px; }
  .game-shell:has(.rhythm-game) .game-header h2 { margin: 2px 0; font-size: 18px; line-height: 1.3; }
  .game-shell:has(.rhythm-game) .game-header button { min-height: 44px; }
  .rhythm-topline { margin-bottom: 8px; gap: 6px 10px; }
  .rhythm-target { padding: 9px 12px; margin: 8px auto; border-radius: 15px; }
  .rhythm-target-value { font-size: 34px; }
  .rhythm-status { min-height: 40px; margin: 7px 0 9px; }
  .rhythm-pads { gap: 10px; margin: 9px 0 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rhythm-hold { min-height: 166px; padding: 14px 8px; gap: 7px; border-radius: 19px; }
  .rhythm-hold.is-holding, .rhythm-pad.is-holding .rhythm-hold { padding: 13px 7px; }
  .rhythm-pad-label { min-height: 51px; font-size: 22px; }
  .rhythm-readout { font-size: 27px; }
  .rhythm-controls { margin-top: 12px; }
  .rhythm-result { padding: 13px 10px; margin: 10px 0; border-radius: 16px; }
  .rhythm-result h3 { font-size: 23px; }
  .rhythm-result-row { padding: 10px 6px; }
  .rhythm-result-row strong { font-size: 23px; }
  .rhythm-finish { padding: 8px 0; }
}
@media (max-height: 650px) and (max-width: 600px) {
  .rhythm-game[data-phase="play"] .rhythm-hold { min-height: 146px; }
  .rhythm-game[data-phase="play"] .rhythm-target { padding-top: 6px; padding-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .rhythm-game, .rhythm-game *, .rhythm-game *::before, .rhythm-game *::after { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
html[data-motion="off"] .rhythm-game *, html.page-away .rhythm-game * { animation: none !important; transition: none !important; }
@media (forced-colors: active) {
  .rhythm-hold, .rhythm-result, .rhythm-target, .rhythm-result-row { border-color: CanvasText; background: Canvas; color: CanvasText; box-shadow: none; }
  .rhythm-hold.is-holding, .rhythm-pad.is-holding .rhythm-hold { border-color: Highlight; outline: 2px solid Highlight; outline-offset: -6px; }
  .rhythm-hold.is-submitted, .rhythm-pad.is-submitted .rhythm-hold { border-style: dashed; }
  .rhythm-game button:focus-visible, .rhythm-game summary:focus-visible, .rhythm-game input:focus-visible { outline-color: Highlight; }
  .rhythm-marker, .rhythm-star, .rhythm-result-row { color: CanvasText; }
  .rhythm-marker::before { border-color: CanvasText; background: Canvas; }
  .rhythm-marker-track::before { background: CanvasText; }
}
