.rhythm-stage {
  --ink: #fff8eb;
  --pulse: #ffca86;
  color: var(--ink);
  text-align: left;
}
.rhythm-stage *,
.rhythm-stage *::before,
.rhythm-stage *::after {
  box-sizing: border-box;
}
.rhythm-stage [hidden] {
  display: none;
}
.rh-head,
.rh-actions,
.rh-song-select {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.rh-head {
  justify-content: space-between;
  margin: 0.45rem 0 0.75rem;
}
.rh-head h2 {
  margin: 0;
  font-size: clamp(1.3rem, 3.6vw, 2rem);
  line-height: 1.16;
}
.rh-head .rh-world {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: #bed4ca;
}
.rhythm-stage button,
.rhythm-stage select {
  font: inherit;
  touch-action: manipulation;
  cursor: pointer;
}
.rhythm-stage :focus-visible {
  outline: 3px solid #fff5c1;
  outline-offset: 3px;
}
.rh-sound,
.rh-action,
.rh-repeat,
.rh-song-select select {
  border-radius: 8px;
  border: 1px solid #637a78;
  padding: 0.56rem 0.85rem;
  background: #253d40;
  color: var(--ink);
  font-weight: 650;
}
.rh-sound {
  flex: none;
  font-size: 0.86rem !important;
}
.rh-sound[aria-pressed='true'] {
  border-color: #bed893;
  color: #e0f0b2;
}
.rh-backdrop {
  height: clamp(160px, 28vh, 250px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #769387;
  border-radius: 12px 12px 0 0;
  background: #293f46;
}
.rh-backdrop::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(0deg, #111e27 0%, transparent 60%, #15232b4a), var(--panorama);
  background-size:
    100% 100%,
    100% var(--sheet-height);
  background-position:
    center,
    center var(--panel-row);
}
.rh-backdrop::after {
  content: '';
  position: absolute;
  inset: 80% 0 0;
  border-top: 2px solid #cfaa88;
  background:
    repeating-linear-gradient(87deg, transparent 0 39px, #4d3146 40px 42px),
    linear-gradient(#a9806b, #674a55 82%, #422f43 84%);
}
.rh-score {
  position: absolute;
  top: 9px;
  right: 10px;
  z-index: 2;
  padding: 0.28rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 5px;
  background: #132629ec;
}
.rh-lamps {
  display: flex;
  justify-content: space-around;
  position: absolute;
  inset: 0 7%;
}
.rh-lamps i {
  position: relative;
  width: 16px;
  height: 6px;
  border-radius: 0 0 5px 5px;
  background: #fff0b1;
  box-shadow: 0 0 10px 2px #ffe8a2;
}
.rh-lamps i::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  width: clamp(82px, 23vw, 180px);
  height: clamp(145px, 25vh, 230px);
  transform: translateX(-50%) rotate(9deg);
  transform-origin: top;
  clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%);
  background: linear-gradient(#ffeab680, transparent 93%);
}
.rh-lamps i:last-child::after {
  transform: translateX(-50%) rotate(-11deg);
}
.rh-strum .rh-lamps i {
  background: var(--pulse);
}
.rh-strum .rh-lamps i::after {
  background: linear-gradient(var(--pulse), transparent 94%);
  opacity: 0.6;
}
.rh-band {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  z-index: 1;
}
.rh-panel {
  border: 1px solid #526a6b;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  padding: clamp(0.75rem, 2.5vw, 1.25rem);
  background: linear-gradient(145deg, #253b41, #243037);
}
.rh-song-select {
  flex-wrap: wrap;
  font-weight: 650;
}
.rh-song-select select {
  max-width: 100%;
  background: #17292e;
}
.rh-cue {
  min-height: 1.35em;
  margin: 0.55rem 0;
  line-height: 1.35;
  font-weight: 650;
}
.rh-sequence {
  position: relative;
  height: 29px;
  margin: 0.45rem 0.5rem 0.15rem;
}
.rh-sequence::before {
  content: '';
  position: absolute;
  top: 50%;
  width: 100%;
  border-top: 2px dashed #839195;
}
.rh-sequence span {
  position: absolute;
  left: var(--at);
  top: 50%;
  transform: translate(-25%, -50%);
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  font-size: 0.89rem;
  line-height: 1;
  background: #233037;
  border-radius: 50%;
  border: 1px solid var(--note);
  color: var(--note);
}
.rh-sequence .rh-next,
.rh-sequence .rh-now {
  color: #17292e;
  background: var(--note);
  outline: 2px solid #fff6db;
  outline-offset: 1px;
}
.rh-sequence .rh-done {
  background: var(--note);
  color: #18312f;
}
.rh-beat {
  height: 3px;
  margin: 0 0.4rem 0.75rem;
  background: #46555a;
}
.rh-beat span {
  display: block;
  height: 100%;
  transform-origin: left;
  background: #f9dfac;
}
.rh-pads {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.3rem, 1vw, 0.65rem);
}
.rh-pads button {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 54px;
  padding: 0.3rem;
  color: var(--note);
  border: 1px solid var(--note);
  border-bottom: 4px solid var(--note);
  border-radius: 8px;
  background: #202d39;
  touch-action: manipulation;
  opacity: 1;
}
.rh-pads button i {
  font-style: normal;
  font-size: 1.2em;
}
.rh-pads kbd {
  font:
    0.7em ui-monospace,
    monospace;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0.05rem 0.2rem;
}
.rh-pads button.rh-lit,
.rh-pads button:enabled:active {
  background: var(--note);
  color: #233037;
  transform: translateY(2px);
  border-bottom-width: 2px;
}
.rh-actions {
  margin-top: 0.7rem;
}
.rh-action {
  background: #f4d38e;
  border-color: #ffe8af;
  color: #302719;
}
.rhythm-stage[data-phase='listen'] .rh-actions {
  display: none;
}
@media (max-width: 540px) {
  .rh-head h2 {
    font-size: 1.2rem;
  }
  .rh-head .rh-world {
    font-size: 0.79rem;
  }
  .rh-head {
    gap: 0.35rem;
  }
  .rh-sound {
    max-width: 102px;
    padding: 0.42rem 0.55rem;
  }
  .rh-pads kbd {
    display: none;
  }
  .rh-pads button {
    min-height: 49px;
  }
}
/* Phone held sideways: the stage on the left, the guitar pads on the right. */
@media (orientation: landscape) and (max-height: 540px) {
  .rhythm-stage {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-areas: 'head head' 'stage panel';
  }
  .rh-head {
    grid-area: head;
    margin: 0 0 0.4rem;
  }
  .rh-head h2 {
    font-size: 1rem;
  }
  .rh-head .rh-world {
    display: none;
  }
  .rh-sound {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
  .rh-backdrop {
    grid-area: stage;
    height: auto;
    min-height: 0;
    border-radius: 12px 0 0 12px;
  }
  .rh-panel {
    grid-area: panel;
    border-top: 1px solid #526a6b;
    border-left: 0;
    border-radius: 0 12px 12px 0;
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  .rh-song-select {
    gap: 0.4rem;
    flex-wrap: nowrap;
  }
  .rh-song-select select {
    min-width: 0;
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
  }
  .rh-cue {
    margin: 0.3rem 0;
    font-size: 0.8rem;
  }
  .rh-pads {
    margin: 0.35rem 0;
    gap: 0.3rem;
  }
  .rh-pads button {
    min-height: 0;
    padding: 0.35rem 0.2rem;
  }
  .rh-pads kbd {
    display: none;
  }
  .rh-actions {
    gap: 0.4rem;
  }
  .rh-action,
  .rh-repeat {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
  }
}
