:root {
  --bg: #F3F0E8;
  --ink: #161E2E;
  --muted: #5C6574;
  --line: #E3DED4;
  --accent: #161E2E;
  --accent-hover: #243044;
  --accent-soft: #EDE6D6;
  --gold: #C49A52;
  --gold-soft: #F3E8D0;
  --card: #FFFCF6;
  --on-accent: #FFFCF6;
  --shadow: 0 18px 44px rgba(22, 30, 46, 0.08);
  --radius: 22px;
  --safe-t: max(20px, env(safe-area-inset-top));
  --safe-b: max(24px, env(safe-area-inset-bottom));
  --safe-l: max(20px, env(safe-area-inset-left));
  --safe-r: max(20px, env(safe-area-inset-right));
  --ad-space: 0px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  min-height: 100dvh;
}

.app {
  width: min(440px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: var(--safe-t) var(--safe-r) calc(var(--safe-b) + var(--ad-space)) var(--safe-l);
  display: flex;
  flex-direction: column;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 4px 0 12px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
}

.brand-mark svg {
  display: block;
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 1px 0 rgba(22, 30, 46, 0.08));
}

.brand h1 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.info-btn {
  appearance: none;
  justify-self: end;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 50%;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  font-style: italic;
  font-family: "Times New Roman", "Iowan Old Style", serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.info-btn:hover {
  border-color: #d8d2c6;
}

.info-btn:focus-visible,
.step:focus-visible,
.tap:focus-visible,
.start:focus-visible,
.sheet-primary:focus-visible,
.sheet-secondary:focus-visible,
.sheet-close:focus-visible,
.remove-ads-link:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 8px 4px 12px;
}

.tempo {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  gap: 8px;
}

.bpm {
  text-align: center;
  min-width: 0;
}

.bpm-value {
  font-size: clamp(84px, 26vw, 132px);
  font-weight: 680;
  line-height: 0.9;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.bpm-unit {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.step {
  appearance: none;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 50%;
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, var(--shadow);
  touch-action: manipulation;
  user-select: none;
}

.step:hover {
  border-color: #d8d2c6;
}

.step:active {
  transform: scale(0.96);
  background: #f7f2e9;
}

.slider-wrap {
  display: block;
  padding: 6px 4px 2px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) var(--fill, 33.3%), var(--line) var(--fill, 33.3%));
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--gold);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(196, 154, 82, 0.28);
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(196, 154, 82, 0.28);
}

.pulse {
  width: 14px;
  height: 14px;
  margin: 6px auto 4px;
  border-radius: 50%;
  background: var(--line);
}

.pulse.on {
  background: var(--gold);
  box-shadow: 0 0 0 6px var(--gold-soft);
  animation: pulse-flash 0.14s ease-out;
}

@keyframes pulse-flash {
  0% { transform: scale(1.55); }
  100% { transform: scale(1); }
}

.tap,
.start,
.sheet-primary,
.sheet-secondary,
.sheet-close,
.remove-ads-link {
  appearance: none;
  width: 100%;
  border: 0;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  user-select: none;
}

.tap {
  height: 54px;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 16px;
  font-weight: 650;
}

.tap:active,
.tap.is-hot {
  background: var(--gold-soft);
  border-color: #e2d2b0;
}

.start {
  height: 64px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(22, 30, 46, 0.22);
}

.start:hover {
  background: var(--accent-hover);
}

.start:active {
  transform: translateY(1px);
}

.start.is-on {
  background: #0E1318;
  box-shadow: none;
}

.remove-ads-link {
  margin-top: -8px;
  height: auto;
  padding: 4px 8px 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.remove-ads-link:hover {
  color: var(--ink);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 19, 24, 0.4);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop[hidden] {
  display: none;
}

.sheet {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(22, 30, 46, 0.18);
  max-height: min(88dvh, 720px);
  overflow: auto;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 16px;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.sheet-lead,
.sheet-note,
.sheet-links,
.sheet-status {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.sheet-status:empty {
  display: none;
}

.sheet-primary,
.sheet-secondary,
.sheet-close {
  margin-bottom: 10px;
}

.sheet-primary {
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 700;
}

.sheet-primary:disabled,
.sheet-secondary:disabled {
  opacity: 0.55;
  cursor: default;
}

.sheet-secondary,
.sheet-close {
  height: 48px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 16px;
  font-weight: 650;
}

.sheet-links a {
  color: var(--ink);
  font-weight: 650;
}

.sr-live,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-height: 800px) {
  main {
    gap: 28px;
    padding-bottom: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse,
  .step,
  .start {
    transition: none;
    animation: none;
  }
}
