:root {
  --bg: #12141c;
  --panel: #1c1f2b;
  --panel-2: #252938;
  --text: #e8eaf2;
  --text-dim: #8b90a5;
  --accent: #ffb648;
  --accent-dim: #a97b34;
  --active: #4f7cff;
  --wood: #b5764a;
  --wood-dark: #8a5734;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
  gap: 10px;
}

.hidden { display: none !important; }

/* ---------- Pendulum ---------- */

#pendulum-wrap {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

#pendulum {
  width: min(46vw, 200px);
  height: auto;
}

.metro-body { fill: var(--wood); }
.metro-body-edge { fill: none; stroke: var(--wood-dark); stroke-width: 3; }
.metro-slot { fill: #10121a; }
.metro-arm { stroke: #d9dce8; stroke-width: 5; stroke-linecap: round; }
.metro-weight { fill: var(--accent); stroke: #c98d2f; stroke-width: 1.5; }
.metro-pivot { fill: #d9dce8; }
.metro-base { fill: var(--wood-dark); }

/* ---------- Tempo row ---------- */

#tempo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.round-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  background: var(--panel-2);
  color: var(--text);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.round-btn:active { background: var(--active); }

#bpm-center { text-align: center; min-width: 140px; }

#bpm-display {
  background: none;
  border: none;
  color: var(--text);
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  line-height: 1.05;
}

#bpm-label {
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Transport ---------- */

#transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
}

#play-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#play-btn:active { background: var(--accent-dim); }
#play-btn svg { width: 38px; height: 38px; fill: #1a1408; }

#tap-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2px solid var(--panel-2);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}
#tap-btn:active, #tap-btn.flash { background: var(--active); border-color: var(--active); }

#accent-toggle {
  width: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  line-height: 1.25;
}
#accent-toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Settings ---------- */

#settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 14px;
}

.setting-label {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  border: none;
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 15px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip.selected { background: var(--active); color: #fff; }

.trip-num {
  font-size: 11px;
  vertical-align: super;
  margin-right: 1px;
}

#volume { width: 100%; accent-color: var(--accent); }

/* ---------- Beat dots ---------- */

#dots-row {
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel-2);
  transition: transform 0.08s ease-out, background 0.08s ease-out, box-shadow 0.08s ease-out;
}
.dot.accented { border: 2px solid var(--accent-dim); }
.dot.hit {
  background: var(--active);
  transform: scale(1.35);
  box-shadow: 0 0 14px rgba(79, 124, 255, 0.7);
}
.dot.accented.hit {
  background: var(--accent);
  box-shadow: 0 0 14px rgba(255, 182, 72, 0.7);
}

/* ---------- BPM modal ---------- */

#bpm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#bpm-modal-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  width: min(86vw, 300px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#bpm-input {
  background: var(--panel-2);
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  padding: 10px;
  width: 100%;
}

#bpm-modal-btns { display: flex; gap: 10px; }
#bpm-modal-btns button {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  cursor: pointer;
}
#bpm-cancel { background: var(--panel-2); color: var(--text); }
#bpm-ok { background: var(--accent); color: #1a1408; font-weight: 700; }

/* Short screens: shrink pendulum */
@media (max-height: 700px) {
  #pendulum { width: min(38vw, 150px); }
  #bpm-display { font-size: 52px; }
}
