:root {
  color-scheme: light;
  --paper: #f6f1e8;
  --ink: #1d1a16;
  --muted: #71685c;
  --line: rgba(29, 26, 22, 0.12);
  --panel: rgba(255, 252, 245, 0.82);
  --shadow: 0 18px 48px rgba(42, 34, 24, 0.13), 0 2px 8px rgba(42, 34, 24, 0.08);
  --accent: #d84f31;
  --accent-dark: #9f321f;
  --green: #2b7a5f;
  --gold: #c88d1f;
  --blue: #346b93;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(216, 79, 49, 0.09), transparent 34%),
    linear-gradient(225deg, rgba(43, 122, 95, 0.1), transparent 40%),
    var(--paper);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
  align-content: start;
}

.meter,
.controls {
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 8px;
  backdrop-filter: blur(18px);
}

.meter {
  padding: 18px;
  display: grid;
  gap: 18px;
}

.controls {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
h1,
h2 {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin-top: 4px;
  font-size: clamp(1.45rem, 8vw, 2.1rem);
  line-height: 1;
  text-wrap: balance;
}

h2 {
  font-size: 0.92rem;
  line-height: 1;
}

.icon-button,
.step-button,
.play-button,
.segmented button,
.option-list button {
  min-height: 44px;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  transition-property: transform, opacity, background-color, color, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.icon-button:active,
.step-button:active,
.play-button:active,
.segmented button:active,
.option-list button:active {
  transform: scale(0.96);
}

.icon-button {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: rgba(29, 26, 22, 0.07);
  display: grid;
  place-items: center;
}

.sound-on,
.sound-off {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24px;
  height: 24px;
  transition-property: opacity, transform, filter;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.sound-on::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 8px;
  width: 7px;
  height: 8px;
  background: var(--ink);
  border-radius: 2px;
  box-shadow: 6px -4px 0 -2px var(--ink), 6px 4px 0 -2px var(--ink);
}

.sound-on::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 5px;
  width: 10px;
  height: 14px;
  border: 3px solid var(--ink);
  border-left: 0;
  border-radius: 0 14px 14px 0;
}

.sound-off::before,
.sound-off::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 11px;
  width: 17px;
  height: 3px;
  background: var(--accent-dark);
  border-radius: 4px;
}

.sound-off::before {
  transform: rotate(45deg);
}

.sound-off::after {
  transform: rotate(-45deg);
}

.sound-off {
  opacity: 0;
  transform: scale(0.25);
  filter: blur(4px);
}

.muted .sound-on {
  opacity: 0;
  transform: scale(0.25);
  filter: blur(4px);
}

.muted .sound-off {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.tempo-readout {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.step-button {
  width: 52px;
  height: 52px;
  border-radius: 26px;
  background: #fffaf1;
  box-shadow: 0 6px 16px rgba(42, 34, 24, 0.1);
  font-size: 1.55rem;
  font-weight: 800;
}

.tempo-number {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#bpmValue {
  display: block;
  font-size: clamp(4.8rem, 25vw, 7.6rem);
  line-height: 0.88;
  font-weight: 900;
}

.tempo-number span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.86rem;
}

.tempo-slider {
  width: 100%;
  height: 34px;
  margin: 0;
  accent-color: var(--accent);
}

.visual-shell {
  min-height: 226px;
  border-radius: 8px;
  background: #1e1b17;
  color: #fff8eb;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.visual {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.visual.active {
  opacity: 1;
}

.visual-pendulum {
  display: grid;
  place-items: end center;
  padding: 20px 26px 30px;
}

.pendulum-track {
  position: relative;
  width: 100%;
  height: 166px;
}

.pendulum-arm {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 4px;
  height: 154px;
  border-radius: 99px;
  background: linear-gradient(#f7d083, #c55b35);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(-26deg);
  transition-property: transform;
  transition-duration: 90ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.pendulum-arm span {
  position: absolute;
  left: 50%;
  top: 18px;
  width: 38px;
  height: 38px;
  border-radius: 19px;
  background: #f7d083;
  transform: translateX(-50%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.pendulum-scale {
  width: 100%;
  display: flex;
  justify-content: space-between;
  opacity: 0.75;
}

.pendulum-scale i {
  width: 2px;
  height: 15px;
  border-radius: 2px;
  background: currentColor;
}

.visual-pulse {
  display: grid;
  place-items: center;
}

.pulse-disc {
  position: absolute;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: radial-gradient(circle, #f8c86a, #d84f31 62%, #7f2b1f);
  box-shadow: 0 0 52px rgba(216, 79, 49, 0.5);
  transform: scale(0.88);
  transition-property: transform, box-shadow;
  transition-duration: 130ms;
}

.pulse-disc.hit {
  transform: scale(1.08);
  box-shadow: 0 0 76px rgba(248, 200, 106, 0.58);
}

.pulse-label {
  position: relative;
  z-index: 1;
  font-size: 3.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.visual-dots {
  display: grid;
  place-items: center;
  padding: 28px;
}

.dot-grid {
  width: min(100%, 330px);
  display: grid;
  grid-template-columns: repeat(var(--beats), 1fr);
  gap: 10px;
}

.beat-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 248, 235, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition-property: transform, background-color, box-shadow;
  transition-duration: 130ms;
}

.beat-dot.active {
  background: var(--gold);
  box-shadow: 0 0 24px rgba(248, 200, 106, 0.42);
  transform: scale(1.08);
}

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

.visual-still {
  display: grid;
  place-items: center;
}

.still-beat {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.still-beat span {
  font-size: 6.8rem;
  line-height: 0.9;
}

.still-beat small {
  color: rgba(255, 248, 235, 0.72);
  font-size: 1.4rem;
}

.play-button {
  min-height: 62px;
  border-radius: 31px;
  background: var(--ink);
  color: #fff8eb;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.08rem;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(29, 26, 22, 0.22);
}

.play-button.running {
  background: var(--accent-dark);
}

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

.play-button.running .play-icon {
  width: 14px;
  height: 16px;
  border: 0;
  border-left: 5px solid currentColor;
  border-right: 5px solid currentColor;
}

.control-group {
  display: grid;
  gap: 10px;
}

.segmented,
.option-list {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(4, 1fr);
  padding: 4px;
  border-radius: 8px;
  background: rgba(29, 26, 22, 0.08);
}

.segmented button,
.option-list button {
  border-radius: 7px;
  background: transparent;
  font-weight: 850;
}

.segmented button.selected {
  color: #fff8eb;
  background: var(--green);
  box-shadow: 0 5px 12px rgba(43, 122, 95, 0.28);
}

.option-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option-list button {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  background: rgba(255, 250, 241, 0.74);
  box-shadow: 0 4px 14px rgba(42, 34, 24, 0.08);
  white-space: nowrap;
}

.option-list button.selected {
  color: #fff8eb;
  background: var(--blue);
  box-shadow: 0 7px 18px rgba(52, 107, 147, 0.26);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.swatch.wood {
  background: var(--accent);
}

.swatch.bell {
  background: var(--gold);
}

.swatch.tick {
  background: var(--green);
}

@media (max-width: 360px) {
  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .meter {
    padding: 14px;
  }

  .option-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
  }
}
