#app[data-play="rhythm"] :is(.race-top, .keyboard-guide, .touch-actions, .joystick, .ability-status) { display: none; }

.rhythm-launch-card { background: #fff1dfef; border-color: #9f739079; }
.rhythm-launch-card:hover { background: #fde9da; border-color: #805876; }
.rhythm-ticket { display: flex; justify-content: center; align-items: center; gap: 5px; background: radial-gradient(ellipse at center,#a26979,#443758 80%); }
.rhythm-ticket i { width: 8px; height: 15px; border-radius: 2px; background: #fac580; box-shadow: inset 0 -3px #aa7875; }
.rhythm-ticket i:nth-child(2) { height: 26px; background: #8de5d4; box-shadow: inset 0 -3px #5d948d; }
.rhythm-ticket i:nth-child(3) { height: 20px; background: #e2a6e2; box-shadow: inset 0 -3px #a684b4; }

#rhythm-stage {
  --warm: #fac580;
  --seafoam: #8de5d4;
  --orchid: #e2a6e2;
  --accent: #ffe3a7;
  --panel: #162a32eb;
  --line: #afdfd278;
  position: absolute;
  inset: 0;
  color: #fff6e4;
  font-variant-numeric: tabular-nums;
}

#rhythm-stage[data-track="thunder-step"] {
  --accent: #dbbcfe;
  --panel: #272241f0;
  --line: #d8cbfb80;
}

#rhythm-stage[data-track="windmill-waltz"] {
  --accent: #ffe1a0;
  --panel: #163e41ef;
  --line: #a7dccc89;
}

.rhythm-top {
  position: absolute;
  top: var(--top);
  left: max(12px,var(--safe-left));
  right: max(12px,var(--safe-right));
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
}

.rhythm-title, .rhythm-score, .rhythm-combo, .rhythm-tip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
}

.rhythm-title, .rhythm-score {
  min-height: 44px;
  display: grid;
  justify-content: start;
  align-content: center;
  gap: 1px;
  padding: 4px 10px;
}

.rhythm-title > span, .rhythm-score > span { color: var(--accent); font-size: 11px; font-weight: 800; }
.rhythm-title > strong { font-size: clamp(16px,2.1vw,24px); line-height: 1.1; }
.rhythm-top-right { display: flex; align-items: stretch; gap: 6px; }
.rhythm-score { justify-content: end; min-width: 82px; text-align: right; }
.rhythm-score strong { font-size: clamp(16px,2.6vw,23px); line-height: 1; }
.rhythm-pause { min-width: 44px; min-height: 44px; color: #fff6e4; border-color: var(--line); background: var(--panel); }
.rhythm-pause:hover { color: #302541; border-color: var(--accent); background: var(--accent); }

.rhythm-progress {
  position: absolute;
  top: calc(var(--top) + 53px);
  left: 50%;
  width: min(27vw,258px);
  height: 4px;
  overflow: hidden;
  transform: translateX(-50%);
  border-radius: 4px;
  background: #172834c5;
}

.rhythm-progress i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.rhythm-combo { position: absolute; right: max(12px,var(--safe-right)); top: calc(var(--top) + 58px); display: flex; align-items: baseline; gap: 6px; padding: 4px 8px; }
.rhythm-combo strong { color: var(--accent); font-size: 20px; }
.rhythm-combo span { color: #fff6e4; font-size: 11px; font-weight: 850; }

.rhythm-field {
  position: absolute;
  top: calc(var(--top) + 61px);
  bottom: calc(var(--bottom) + 5px);
  left: 50%;
  width: min(50vw,392px);
  transform: translateX(-50%);
  display: grid;
  grid-template-rows: minmax(0,1fr) minmax(58px,8dvh);
  gap: 9px;
}

.rhythm-lanes {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 12px 12px 5px 5px;
  background:
    linear-gradient(to bottom,#16242e38 0%,#142530aa 42%,#142230ed 100%),
    linear-gradient(to right,transparent 33%,#d9efe446 33%,#d9efe446 33.5%,transparent 33.5%,transparent 66.45%,#d9efe446 66.45%,#d9efe446 66.9%,transparent 66.9%);
  box-shadow: 0 6px 16px #0f152d4d, inset 0 -4px 0 #090f2864;
}

#rhythm-chart { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.rhythm-strike { position: absolute; bottom: 15px; inset-inline: 0; display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.rhythm-strike i { height: 3px; margin-inline: 7px; background: var(--lane); border-radius: 1px; box-shadow: 0 0 8px var(--lane); opacity: .88; }
.rhythm-strike i:nth-child(1), .rhythm-pads button:nth-child(1) { --lane: var(--warm); --wash: #734926; }
.rhythm-strike i:nth-child(2), .rhythm-pads button:nth-child(2) { --lane: var(--seafoam); --wash: #285d5c; }
.rhythm-strike i:nth-child(3), .rhythm-pads button:nth-child(3) { --lane: var(--orchid); --wash: #62426f; }

.rhythm-feedback {
  position: absolute;
  top: calc(var(--top) + 7px);
  left: 50%;
  width: max-content;
  max-width: 42vw;
  min-height: 25px;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 7px;
  background: #161c2ed9;
  color: var(--accent);
  font-weight: 950;
  font-size: clamp(16px,2.1vw,25px);
  line-height: 1.16;
  text-shadow: 0 2px 0 #291d35;
  text-align: center;
}

.rhythm-feedback:empty { display: none; }
.rhythm-feedback[data-kind="miss"] { color: #ffd4cb; }
.rhythm-feedback[data-kind="good"], .rhythm-feedback[data-kind="hold"] { color: #a8f6e3; }
.rhythm-feedback[data-kind="count"] { font-size: clamp(18px,3vw,31px); }

.rhythm-pads { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.rhythm-pads button {
  min-height: 46px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 4px;
  border: 1px solid var(--lane);
  border-radius: 9px;
  background: linear-gradient(155deg,var(--wash),#1c2338);
  color: #fff8ea;
  box-shadow: inset 0 -4px 0 #120d2d7d, 0 2px 0 #121729b0;
  font-size: clamp(12px,1.55vw,16px);
  font-weight: 850;
  touch-action: none;
  user-select: none;
}

.rhythm-pads button i { width: 14px; height: 14px; flex: none; background: var(--lane); }
.rhythm-pads button:nth-child(2) i { transform: rotate(45deg) scale(.85); }
.rhythm-pads button:nth-child(3) i { clip-path: polygon(35% 0,65% 0,65% 35%,100% 35%,100% 65%,65% 65%,65% 100%,35% 100%,35% 65%,0 65%,0 35%,35% 35%); }
.rhythm-pads button kbd { margin-left: 1px; min-width: 18px; border: 1px solid #faecd678; border-radius: 4px; background: #1a1d35b3; color: #fff6de; text-align: center; }
.rhythm-pads button[data-live], .rhythm-pads button:active { color: #212437; background: var(--lane); box-shadow: inset 0 -2px 0 #120d2d43, 0 0 13px var(--lane); }
.rhythm-pads button[data-live] i, .rhythm-pads button:active i { background: #282641; }
.rhythm-pads button:focus-visible { outline-color: #fff8df; outline-offset: 2px; }

.rhythm-tip {
  position: absolute;
  left: max(12px,var(--safe-left));
  bottom: calc(var(--bottom) + 7px);
  max-width: min(20vw,202px);
  margin: 0;
  padding: 6px 8px;
  color: #fff6e8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

#dialog[data-kind="rhythm-picker"] { width: min(91vw,656px,calc(100% - var(--phone-left,0px) - var(--phone-right,0px))); }
.rhythm-song-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.rhythm-song {
  min-width: 0;
  padding: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid #8e664e;
  border-radius: 11px;
  background: #ffefdc;
  color: #39303e;
  text-align: left;
  box-shadow: 0 3px 0 #dcc8b9;
}

.rhythm-song[data-track="thunder-step"] { border-color: #816da1; background: #f1eafd; box-shadow: 0 3px 0 #dfd1ea; }
.rhythm-song[data-track="windmill-waltz"] { border-color: #608c82; background: #e9f3e9; box-shadow: 0 3px 0 #c8dcd1; }
.rhythm-song:focus-visible { outline-offset: 2px; }
.rhythm-song-art {
  display: flex;
  height: clamp(45px,11dvh,91px);
  align-items: end;
  justify-content: center;
  gap: 7px;
  padding: 9px 10px;
  background: radial-gradient(ellipse at 50% 80%,#a9755f,#302a44 70%);
}
.rhythm-song[data-track="thunder-step"] .rhythm-song-art { background: radial-gradient(ellipse at 50% 80%,#615ba5,#242143 72%); }
.rhythm-song[data-track="windmill-waltz"] .rhythm-song-art {
  align-items: center;
  background: radial-gradient(ellipse at 50% 74%, #6f9a82, #264b51 72%);
}
.rhythm-windrose {
  width: min(48px, 90%);
  height: 100%;
  max-height: 48px;
  aspect-ratio: 1;
  background: conic-gradient(from 16deg, #fae5ae 0 41deg, transparent 41deg 90deg, #f1b585 90deg 131deg,
    transparent 131deg 180deg, #fae5ae 180deg 221deg, transparent 221deg 270deg, #f1b585 270deg 311deg, transparent 311deg);
  clip-path: polygon(50% 0, 83% 5%, 66% 39%, 100% 50%, 95% 83%, 60% 67%, 50% 100%,
    17% 95%, 34% 61%, 0 50%, 5% 17%, 40% 33%);
}
.rhythm-song-art i { width: 6%; height: var(--bar); background: var(--art); border-radius: 3px 3px 1px 1px; box-shadow: 0 0 12px #fff2c845, inset -2px 0 #34335447; }
.rhythm-song-text { display: grid; align-content: start; gap: 4px; padding: 8px 10px 10px; }
.rhythm-song-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 3px; }
.rhythm-song-title strong { font-size: clamp(16px,2.6vw,23px); font-weight: 950; }
.rhythm-song-title b, .rhythm-song-record { color: #5e4061; font-size: 11px; font-weight: 850; }
.rhythm-song-desc { color: #4c3d52; font-size: 12px; font-weight: 650; line-height: 1.35; }
.rhythm-result-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin-block: 10px; }
.rhythm-result-stats div { padding: 7px; border: 1px solid #8e719a5e; border-radius: 8px; background: #f5ebf7; }
.rhythm-result-stats dd { margin: 0; color: #473154; font-size: clamp(16px,3vw,23px); font-weight: 900; }
.rhythm-result-stats dt { margin-bottom: 3px; color: #614764; font-size: 11px; }
.rhythm-result-breakdown { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0; color: #614764; font-size: 12px; font-weight: 760; }
.rhythm-result-grade { font-size: 35px; }

#dialog:has(.rhythm-review) {
  width: min(94vw, 690px, calc(100% - var(--phone-left, 0px) - var(--phone-right, 0px)));
}
#dialog:has(.rhythm-review) .result-summary h2 { margin-right: 0; }
.rhythm-review {
  margin-block: 11px 5px; padding: 10px 12px 8px;
  border: 1px solid #9a9b92; border-radius: 9px; background: #eeeede;
  color: #31444a; font-variant-numeric: tabular-nums;
}
.rhythm-review > header, .rhythm-review-caption {
  display: flex; align-items: baseline; justify-content: space-between; gap: 5px 12px;
}
.rhythm-review h3 { margin: 0; color: #33484b; font-size: 15px; line-height: 1.3; }
.rhythm-phrase-score { color: #53645f; font-size: 11px; font-weight: 690; white-space: nowrap; }
.rhythm-phrase-score b { color: #325d54; font-weight: 850; }
.rhythm-phrase {
  --roll-height: 55px;
  display: grid; grid-template-columns: 26px minmax(0, 1fr); grid-template-rows: 15px var(--roll-height);
  position: relative; margin: 5px 0; padding: 3px 10px 3px 5px;
  background: linear-gradient(112deg, #233846, #293444 75%, #343645);
  color: #eaf1dd; border: 1px solid #253744; border-radius: 5px; overflow: hidden;
}
.rhythm-phrase-ruler { position: relative; grid-area: 1 / 2; margin-inline: 6px; }
.rhythm-phrase-ruler span {
  position: absolute; top: 1px; color: #b9c9c6; font: 650 9px/1.2 system-ui,sans-serif;
  white-space: nowrap;
}
.rhythm-phrase-ruler span.is-downbeat { color: #ffe5ad; font-weight: 850; }
.rhythm-phrase-ruler em { font-style: normal; }
.rhythm-phrase-keys { display: grid; grid-area: 2 / 1; grid-template-rows: repeat(3,1fr); align-items: center; }
.rhythm-phrase-keys span { font: 730 10px/1.1 system-ui,sans-serif; color: #f6e8cf; }
.rhythm-phrase-staff {
  grid-area: 2 / 2; position: relative; margin-inline: 6px; border-block: 1px solid #5e6e70;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(33.333% - 1px), #63747875 calc(33.333% - 1px) 33.333%);
}
.rhythm-beat { position: absolute; inset-block: 0; width: 1px; background: #7e8f8e55; }
.rhythm-beat.is-downbeat { background: #b6b49499; }
.rhythm-phrase-chord { position: absolute; width: 2px; transform: translateX(-1px); background: #f6cf84; }
.rhythm-phrase [data-lane="0"] { --ink: #fac580; }
.rhythm-phrase [data-lane="1"] { --ink: #8de5d4; }
.rhythm-phrase [data-lane="2"] { --ink: #e2a6e2; }
.rhythm-phrase-tail {
  position: absolute; height: 4px; transform: translateY(-50%); background: var(--ink);
  border-right: 2px solid #fff6de; border-radius: 0 1px 1px 0;
}
.rhythm-phrase-head {
  display: grid; place-items: center; position: absolute; transform: translate(-50%,-50%); width: 12px; height: 12px;
}
.rhythm-phrase-head b { width: 7px; height: 7px; background: var(--ink); }
.rhythm-phrase-head[data-lane="1"] b { width: 6px; height: 6px; transform: rotate(45deg); }
.rhythm-phrase-head[data-lane="2"] b {
  width: 9px; height: 9px; clip-path: polygon(33% 0,67% 0,67% 33%,100% 33%,100% 67%,67% 67%,67% 100%,33% 100%,33% 67%,0 67%,0 33%,33% 33%);
}
.rhythm-phrase-head[data-verdict="miss"] { border: 1.5px solid #ffaaa0; border-radius: 50%; background: #293343; }
.rhythm-phrase-head[data-verdict="miss"] b { width: 5px; height: 5px; }
.rhythm-phrase-head[data-verdict="miss"][data-lane="2"] b { width: 7px; height: 7px; }
.dialog-content .rhythm-review-caption p { margin: 0; font-size: 12px; line-height: 1.4; color: #465854; }
.rhythm-review-caption > span { display: inline-flex; align-items: center; gap: 4px; flex: none; color: #775451; font-size: 10px; }
.rhythm-review-caption > span i { width: 9px; height: 9px; border: 1.5px solid #ac5e56; border-radius: 50%; }
#dialog:has(.rhythm-review) .dialog-actions button { min-height: 44px; }
@media (orientation: portrait) and (max-width: 450px) {
  .rhythm-review { padding: 7px 8px; }
  .rhythm-review > header { flex-wrap: wrap; gap: 2px 7px; }
  .rhythm-phrase { padding-right: 4px; grid-template-columns: 24px minmax(0,1fr); }
  .rhythm-phrase-ruler span { font-size: 8px; }
  .rhythm-phrase-ruler em { display: none; }
  .rhythm-review-caption { gap: 6px; }
  #dialog:has(.rhythm-review) .dialog-actions button { flex-basis: 42%; }
}
@media (orientation: landscape) and (max-height: 430px) {
  #dialog:has(.rhythm-review) .dialog-content { padding: 8px 13px 10px; }
  #dialog:has(.rhythm-review) .result-summary { align-items: center; }
  #dialog:has(.rhythm-review) .result-summary h2 { margin: 0; font-size: 23px; }
  #dialog:has(.rhythm-review) .result-summary p { margin: 0; font-size: 11px; line-height: 1.25; }
  #dialog:has(.rhythm-review) .result-medal { width: 35px; height: 35px; font-size: 24px; border-radius: 9px; }
  #dialog:has(.rhythm-review) .rhythm-result-stats { margin-block: 4px; }
  #dialog:has(.rhythm-review) .rhythm-result-stats > div { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; padding: 3px 6px; }
  #dialog:has(.rhythm-review) .rhythm-result-stats dt { margin: 0; }
  #dialog:has(.rhythm-review) .rhythm-result-stats dd { font-size: 16px; }
  #dialog:has(.rhythm-review) .result-reward { margin: 2px 0 0 !important; }
  .rhythm-review { margin: 4px 0; padding: 4px 8px; }
  .rhythm-review h3 { font-size: 13px; }
  .rhythm-phrase { --roll-height: 40px; grid-template-rows: 12px var(--roll-height); margin-block: 3px; padding-block: 1px 2px; }
  .dialog-content .rhythm-review-caption p { font-size: 11px; }
  #dialog:has(.rhythm-review) .dialog-actions { margin-top: 5px; gap: 5px; }
  #dialog:has(.rhythm-review) .dialog-actions button { padding-inline: 7px; }
}

@media (any-pointer: coarse) { .rhythm-pads kbd { display: none; } }
.touch-hud .rhythm-pads kbd { display: none; }

@media (orientation: landscape) and (max-height: 430px) {
  .rhythm-top, .rhythm-tip { left: var(--phone-left,12px); }
  .rhythm-top, .rhythm-combo { right: var(--phone-right,12px); }
  .rhythm-field { width: min(46vw,290px); grid-template-rows: minmax(0,1fr) 48px; gap: 6px; }
  .rhythm-pads button { gap: 4px; }
  .rhythm-title, .rhythm-score { min-height: 44px; }
  .rhythm-song-art { height: clamp(38px,14dvh,58px); }
}

@media (orientation: landscape) and (min-aspect-ratio: 2/1) and (max-height: 430px) {
  #rhythm-stage { --rhythm-chart-width: min(46vw, 290px); }
  .rhythm-field { width: var(--rhythm-chart-width); }
  .rhythm-feedback:not([data-kind="count"]) {
    top: auto;
    bottom: calc(var(--bottom) + 76px);
    left: calc(50% + var(--rhythm-chart-width) / 2 + 8px);
    max-width: calc(50% - var(--rhythm-chart-width) / 2 - var(--phone-right, 12px) - 8px);
    transform: translateY(50%);
    padding: 4px 7px;
    font-size: clamp(14px, 1.9vw, 17px);
    pointer-events: none;
  }
}

@media (orientation: portrait) and (max-width: 580px) {
  .rhythm-combo { top: calc(var(--top) + 54px); }
  .rhythm-progress { top: calc(var(--top) + 50px); left: max(12px,var(--safe-left)); width: min(43vw,180px); transform: none; }
  .rhythm-feedback { top: calc(var(--top) + 56px); font-size: 15px; }
  .rhythm-field { top: calc(var(--top) + 113px); width: min(86vw,350px); grid-template-rows: minmax(0,1fr) clamp(54px,8dvh,71px); }
  .rhythm-tip { top: calc(var(--top) + 83px); bottom: auto; left: 50%; width: max-content; max-width: 86vw; transform: translateX(-50%); font-size: 11px; text-align: center; }
  .rhythm-song-text { padding-inline: 8px; }
  .rhythm-song-title { display: grid; }
  .rhythm-song-grid { grid-template-columns: 1fr; }
  .rhythm-song { grid-template: auto / 22% 1fr; }
  .rhythm-song-art { align-self: stretch; height: auto; min-height: 64px; gap: 3px; }
}
