:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0a060b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 240px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  background: #0a060b;
}

button,
input {
  font: inherit;
}

.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 941 / 1672));
  height: min(100dvh, calc(100vw * 1672 / 941));
  overflow: hidden;
  isolation: isolate;
  background: url("assets/Background_v1.png") center / 100% 100% no-repeat;
}

.transport {
  position: absolute;
  z-index: 2;
  top: clamp(12px, 3.6%, 36px);
  left: 50%;
  display: grid;
  grid-template-columns: 34px 78px 34px;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
}

.play-button,
.bpm-display,
.bpm-input,
.speed-button,
.metronome-button {
  border: 1px solid rgb(255 211 235 / 28%);
  color: #fff7fc;
  background: rgb(24 11 25 / 82%);
  box-shadow: 0 3px 12px rgb(4 0 6 / 24%);
}

.play-button,
.bpm-display,
.speed-button,
.metronome-button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.play-button:focus-visible,
.bpm-display:focus-visible,
.bpm-input:focus-visible,
.speed-button:focus-visible,
.metronome-button:focus-visible {
  outline: 2px solid #ffc0e8;
  outline-offset: 2px;
}

.play-button {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border-radius: 50%;
}

.play-button:disabled {
  cursor: wait;
  color: rgb(255 247 252 / 48%);
}

.play-icon {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.play-button.is-playing .play-icon {
  width: 8px;
  height: 10px;
  margin-left: 0;
  border: 0;
  background: linear-gradient(
    90deg,
    currentColor 0 3px,
    transparent 3px 5px,
    currentColor 5px 8px
  );
}

.bpm-control {
  width: 78px;
  height: 48px;
}

.bpm-display,
.bpm-input {
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

.bpm-display {
  display: grid;
  padding: 5px 8px 4px;
  line-height: 1;
  place-content: center;
  text-align: center;
}

.bpm-value {
  min-width: 3ch;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.bpm-label {
  margin-top: 3px;
  color: rgb(255 231 246 / 74%);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.bpm-input {
  padding: 0 5px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: center;
  appearance: textfield;
}

.bpm-input::-webkit-inner-spin-button,
.bpm-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

[hidden] {
  display: none !important;
}

.dance-speed-control {
  position: absolute;
  top: 50%;
  left: 128px;
  display: flex;
  gap: 4px;
  transform: translateY(-50%);
}

.speed-button {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border-radius: 8px;
  color: rgb(255 231 246 / 70%);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

.speed-button.is-selected {
  border-color: rgb(255 192 232 / 76%);
  color: #fff;
  background: rgb(171 68 135 / 68%);
  box-shadow:
    0 0 0 1px rgb(255 220 241 / 12%) inset,
    0 3px 12px rgb(4 0 6 / 24%);
}

.metronome-button {
  position: absolute;
  top: 50%;
  left: 192px;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border-radius: 8px;
  color: rgb(255 231 246 / 82%);
  background: rgb(62 28 55 / 84%);
  transform: translateY(-50%);
}

.metronome-button.is-muted {
  border-color: rgb(255 162 196 / 66%);
  color: #ffd3e4;
  background: rgb(112 39 66 / 78%);
}

.metronome-icon {
  width: 16px;
  height: 16px;
  overflow: visible;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metronome-icon .sound-wave,
.metronome-icon .mute-slash {
  fill: none;
}

.metronome-icon .mute-slash,
.metronome-button.is-muted .sound-wave {
  display: none;
}

.metronome-button.is-muted .mute-slash {
  display: inline;
}

.dancer {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: -2.2%;
  display: block;
  width: auto;
  height: 86%;
  aspect-ratio: 2 / 3;
  user-select: none;
  pointer-events: none;
  transform: translate3d(-50%, 0, 0);
  transform-origin: bottom center;
  will-change: transform;
}

.dancer-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  visibility: hidden;
  user-select: none;
  pointer-events: none;
  transform: translate3d(var(--frame-x, 0%), var(--frame-y, 0%), 0)
    scale(var(--frame-scale, 1));
  transform-origin: bottom center;
}

.dancer-frame.is-active {
  visibility: visible;
}

@media (max-width: 300px), (max-height: 530px) {
  .transport {
    grid-template-columns: 30px 70px 30px;
    gap: 6px;
  }

  .play-button {
    width: 30px;
    height: 30px;
  }

  .bpm-control {
    width: 70px;
    height: 42px;
  }

  .bpm-value {
    font-size: 17px;
  }

  .dance-speed-control {
    left: 112px;
    gap: 3px;
  }

  .speed-button {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 8px;
  }

  .metronome-button {
    left: 166px;
    width: 24px;
    height: 24px;
    border-radius: 7px;
  }

  .metronome-icon {
    width: 14px;
    height: 14px;
  }
}
