:root {
  --bg-top: #f7f1df;
  --bg-bottom: #d7e8f2;
  --card-bg: rgba(255, 252, 245, 0.88);
  --card-border: rgba(42, 66, 81, 0.14);
  --text-main: #1f2d3a;
  --text-muted: #5d6a74;
  --accent: #e35d3d;
  --accent-dark: #b84427;
  --accent-soft: rgba(227, 93, 61, 0.14);
  --shadow: 0 24px 60px rgba(54, 72, 84, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 30%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--card-border);
  border-radius: 28px;
  background: var(--card-bg);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  color: var(--accent-dark);
}

.card-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.language-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(42, 66, 81, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.language-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.language-select {
  min-width: 126px;
  padding: 9px 36px 9px 12px;
  border: 1px solid rgba(42, 66, 81, 0.12);
  border-radius: 999px;
  font: inherit;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.description {
  margin: 14px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.tempo-panel,
.beat-panel {
  margin-top: 28px;
  padding: 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.66);
}

.tempo-readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tempo-label,
.tempo-unit {
  color: var(--text-muted);
}

#bpm-value {
  font-size: clamp(3rem, 10vw, 4.4rem);
  line-height: 1;
}

.tempo-slider {
  width: 100%;
  margin-top: 18px;
  accent-color: var(--accent);
}

.tempo-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.tap-panel {
  margin-top: 18px;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.ghost-button,
.primary-button,
.tap-button {
  border-radius: 16px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.ghost-button {
  padding: 12px 0;
  color: var(--text-main);
  background: var(--accent-soft);
}

.tap-button {
  width: 100%;
  padding: 14px 20px;
  color: var(--text-main);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(42, 66, 81, 0.1);
}

.tap-button.is-active {
  background: linear-gradient(135deg, #ffe6ca, #ffd4bb);
  box-shadow: 0 10px 24px rgba(227, 93, 61, 0.18);
}

.primary-button {
  width: 100%;
  padding: 16px 20px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  box-shadow: 0 16px 34px rgba(227, 93, 61, 0.28);
}

.ghost-button:hover,
.primary-button:hover,
.tap-button:hover {
  transform: translateY(-1px);
}

.tap-status {
  margin: 12px 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

.metronome-display {
  margin-bottom: 18px;
}

.metronome-body {
  position: relative;
  min-height: 220px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 241, 231, 0.9));
  border: 1px solid rgba(42, 66, 81, 0.08);
  overflow: hidden;
}

.metronome-body::after {
  content: "";
  position: absolute;
  inset: auto 24px 18px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #dba278, #ba7650);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.metronome-scale {
  position: absolute;
  top: 26px;
  left: 50%;
  width: 6px;
  height: 134px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(93, 106, 116, 0.22) 0 4px,
      transparent 4px 14px
    );
}

.pendulum-frame {
  position: relative;
  display: grid;
  place-items: start center;
  min-height: 220px;
  padding-top: 18px;
}

.pivot-slot {
  position: absolute;
  top: 132px;
  left: 50%;
  width: 88px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #d0966d, #ab6847);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 8px 16px rgba(73, 48, 34, 0.12);
}

.pivot-slot::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 16px;
  height: 10px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #6d4b3b;
}

.pendulum {
  --swing-angle: 24deg;
  --beat-duration: 0.5s;
  position: relative;
  width: 48px;
  height: 172px;
  transform-origin: 50% 120px;
  transform: rotate(-24deg);
  animation: pendulum-swing var(--beat-duration) cubic-bezier(0.42, 0, 0.58, 1) infinite alternate;
  animation-play-state: paused;
}

.pendulum.is-running {
  animation-play-state: running;
}

.pendulum-upper-arm,
.pendulum-lower-arm,
.pendulum-tail {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #485866, #26343f);
}

.pendulum-upper-arm {
  top: 10px;
  width: 4px;
  height: 110px;
}

.pendulum-pivot {
  position: absolute;
  top: 112px;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #5e6c77, #22303a 72%);
  box-shadow:
    0 0 0 4px rgba(227, 93, 61, 0.08),
    0 4px 8px rgba(31, 45, 58, 0.18);
}

.pendulum-lower-arm {
  top: 120px;
  width: 4px;
  height: 28px;
}

.pendulum-tail {
  top: 146px;
  width: 5px;
  height: 18px;
  background: linear-gradient(180deg, #2e3b45, #111921);
}

.pendulum-weight {
  position: absolute;
  top: 38px;
  left: 50%;
  width: 36px;
  height: 28px;
  transform: translateX(-50%);
  border-radius: 14px;
  background: linear-gradient(180deg, #f7b27f, #e56b43);
  box-shadow:
    0 12px 20px rgba(227, 93, 61, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.beat-status {
  margin: 12px 0 0;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
}

@keyframes pendulum-swing {
  from {
    transform: rotate(-24deg);
  }

  to {
    transform: rotate(24deg);
  }
}

@media (max-width: 520px) {
  .card {
    padding: 24px;
    border-radius: 22px;
  }

  .card-topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .language-picker {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    padding: 10px 12px;
  }

  .language-label {
    flex: 0 0 auto;
  }

  .language-select {
    min-width: 0;
    width: min(100%, 170px);
  }

  .tempo-panel,
  .beat-panel {
    padding: 18px;
  }

  .tempo-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .metronome-body {
    min-height: 200px;
  }

  .pivot-slot {
    top: 126px;
    width: 78px;
  }

  .pendulum {
    height: 160px;
    transform-origin: 50% 114px;
  }

  .pendulum-upper-arm {
    height: 104px;
  }

  .pendulum-pivot {
    top: 106px;
  }

  .pendulum-lower-arm {
    top: 114px;
  }

  .pendulum-tail {
    top: 140px;
  }

  .pendulum-weight {
    top: 34px;
  }
}
