:root {
  color-scheme: dark;

  --background: #090b0f;
  --surface: #12161c;
  --surface-raised: #181d25;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f5f7fa;
  --muted: #89919e;
  --accent: #67e8f9;
  --accent-strong: #22d3ee;
  --accent-soft: rgba(103, 232, 249, 0.1);
  --progress: #668c7a;
}

@property --beat-sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;

  background:
    radial-gradient(
      circle at 50% 42%,
      rgba(34, 211, 238, 0.075),
      transparent 38%
    ),
    var(--background);
  color: var(--text);

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app {
  min-height: 100vh;

  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 24px;

  padding: 20px clamp(20px, 4vw, 56px);

  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;

  gap: 9px;

  color: var(--text);

  font-size: 13px;
  font-weight: 700;

  text-decoration: none;
}

.brand-mark {
  width: 10px;
  height: 10px;

  background: linear-gradient(135deg, var(--accent), #a78bfa);

  border-radius: 50%;

  box-shadow: 0 0 15px rgba(103, 232, 249, 0.45);
}

.site-header p {
  margin: 0;

  color: var(--muted);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.metronome {
  width: min(100%, 780px);

  align-self: center;
  justify-self: center;

  display: flex;
  flex-direction: column;
  align-items: center;

  padding: clamp(28px, 5vh, 60px) 24px;
}

.intro {
  text-align: center;
}

.eyebrow {
  margin: 0 0 7px;

  color: var(--muted);

  font-size: 9px;
  font-weight: 750;

  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1 {
  margin: 0;

  font-size: clamp(24px, 3vw, 36px);
  font-weight: 600;

  letter-spacing: -0.045em;
}

.tempo-display {
  display: grid;
  grid-template-columns: 48px auto 48px;
  align-items: center;

  gap: clamp(20px, 5vw, 50px);

  margin-top: 27px;
}

.step-button {
  width: 48px;
  height: 48px;

  padding: 0;

  background: transparent;
  color: var(--muted);

  border: 1px solid var(--line);
  border-radius: 50%;

  font-size: 24px;
}

.step-button:hover {
  color: var(--accent);

  border-color: rgba(103, 232, 249, 0.45);
}

.bpm-control {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bpm-control input {
  width: 3.2ch;

  padding: 0;

  appearance: textfield;

  background: transparent;
  color: var(--text);

  border: 0;

  font-size: clamp(48px, 7vw, 68px);
  font-weight: 540;

  line-height: 0.9;
  letter-spacing: -0.075em;
  text-align: center;
}

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

.bpm-control span {
  margin-top: 10px;

  color: var(--muted);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: 0.16em;
}

.tempo-slider {
  width: min(100%, 520px);
  height: 3px;

  margin: 21px 0 0;

  appearance: none;

  background: var(--line);

  border-radius: 10px;
}

.tempo-slider::-webkit-slider-thumb {
  width: 17px;
  height: 17px;

  appearance: none;

  background: var(--accent);

  border: 0;
  border-radius: 50%;

  box-shadow: 0 0 16px rgba(103, 232, 249, 0.4);
}

.tempo-slider::-moz-range-thumb {
  width: 17px;
  height: 17px;

  background: var(--accent);

  border: 0;
  border-radius: 50%;
}

.beat-stage {
  width: min(100%, 650px);

  margin-top: clamp(32px, 6vh, 64px);

  text-align: center;
}

.beat-stage-label {
  margin: 0 0 clamp(22px, 4vh, 38px);

  color: var(--muted);

  font-size: 9px;
  font-weight: 700;

  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.beat-indicators {
  min-height: 118px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: clamp(13px, 3.5vw, 32px);
}

.beat-dot {
  --beat-sweep: 0deg;
  --beat-surface: var(--surface);

  position: relative;

  width: clamp(58px, 12vw, 92px);
  height: clamp(58px, 12vw, 92px);

  display: grid;
  place-items: center;

  background:
    radial-gradient(
      circle,
      var(--beat-surface) calc(50% - 1px),
      transparent calc(50% - 1px)
    ),
    conic-gradient(var(--progress) var(--beat-sweep), transparent 0deg),
    conic-gradient(var(--line) 0deg 360deg);

  border-radius: 50%;
}

.beat-dot::before {
  content: "";

  width: 14%;
  height: 14%;

  background: #4b5360;

  border-radius: 50%;
}

.beat-dot::after {
  content: attr(data-beat);

  position: absolute;
  top: calc(100% + 12px);
  left: 50%;

  color: #59616e;

  font-size: 9px;
  font-weight: 750;

  transform: translateX(-50%);
}

.beat-dot.upcoming {
  animation: anticipate var(--beat-duration, 0.667s) linear forwards;
}

.beat-dot.active {
  --beat-surface: var(--surface-raised);
}

.beat-dot.active::before {
  background: var(--accent);
}

@keyframes anticipate {
  from {
    --beat-sweep: 0deg;
  }

  to {
    --beat-sweep: 360deg;
  }
}

.start-button {
  min-width: 172px;
  height: 54px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  margin-top: 26px;

  background: var(--accent);
  color: #082126;

  border: 0;
  border-radius: 999px;

  font-weight: 750;
}

.start-button.running {
  background: var(--surface-raised);
  color: var(--text);

  border: 1px solid var(--line);
}

.play-icon {
  font-size: 11px;
}

.settings {
  width: 100%;

  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));

  gap: 9px;

  margin-top: clamp(30px, 5vh, 52px);
}

.setting {
  min-width: 0;
  min-height: 67px;

  display: flex;
  flex-direction: column;
  justify-content: space-between;

  padding: 12px;

  background: var(--surface);
  color: var(--text);

  border: 1px solid var(--line);
  border-radius: 8px;
}

.setting > span {
  color: var(--muted);

  font-size: 9px;
  font-weight: 700;

  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.setting select {
  width: 100%;

  padding: 0;

  appearance: none;

  background: transparent;
  color: var(--text);

  border: 0;
  outline: none;

  font-size: 15px;
  font-weight: 650;
}

.setting select option {
  background: var(--surface-raised);
  color: var(--text);
}

.setting.toggle,
.tap-button {
  text-align: left;
}

.setting strong {
  color: var(--text);

  font-size: 15px;
}

.setting.toggle.active strong {
  color: var(--accent);
}

.volume-setting input {
  width: 100%;
  height: 3px;

  appearance: none;

  background: #343a45;

  border-radius: 5px;
}

.volume-setting input::-webkit-slider-thumb {
  width: 13px;
  height: 13px;

  appearance: none;

  background: var(--text);

  border-radius: 50%;
}

.tap-button:hover strong {
  color: var(--accent);
}

.tap-button.tapped {
  background: var(--accent-soft);

  border-color: rgba(103, 232, 249, 0.38);
}

.shortcuts {
  margin: 22px 0 0;

  color: #59616e;

  font-size: 9px;
}

.shortcuts span {
  padding: 0 5px;
}

kbd {
  padding: 2px 5px;

  color: var(--muted);

  border: 1px solid var(--line);
  border-radius: 4px;

  font-family: inherit;
  font-size: 8px;
}

@media (max-width: 650px) {
  .site-header {
    padding: 17px;
  }

  .metronome {
    padding: 30px 17px;
  }

  .beat-indicators {
    gap: 10px;
  }

  .settings {
    grid-template-columns: repeat(2, 1fr);
  }

  .shortcuts {
    display: none;
  }
}

@media (max-height: 700px) and (min-width: 651px) {
  .metronome {
    padding-top: 22px;
    padding-bottom: 22px;
  }

  .beat-stage {
    margin-top: 25px;
  }

  .beat-stage-label {
    margin-bottom: 20px;
  }

  .settings {
    margin-top: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .beat-dot.upcoming {
    animation: none;
  }
}
