*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --bg: #0f0f12;
  --surf: #1a1a1f;
  --surf2: #22222a;
  --surf3: #2b2b35;
  --brd: rgba(255, 255, 255, 0.07);
  --brd2: rgba(255, 255, 255, 0.15);
  --txt: #eeede6;
  --muted: rgba(238, 237, 230, 0.42);
  --acc: #c8f060;
  --acc2: #a8e040;
  --red: #ff4d4d;
  --grn: #35d474;
  --mono: "Space Mono", monospace;
  --sans: "DM Sans", sans-serif;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 4rem;
  transition: background 0.5s;
  overflow-x: hidden;
}
body {
  transition: background-color 0.5s ease;
}
body.playing {
  background-color: #071a0d;
}
.wrap {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
h1 {
  font-family: var(--mono);
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--acc);
  line-height: 1;
  text-align: center;
}
.subtitle {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.3rem;
}
.card {
  background: var(--surf);
  border: 1px solid var(--brd);
  border-radius: 14px;
  padding: 1.3rem;
}
.clabel {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.card-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0.85rem;
}

/* BPM */
.bpm-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.bpm-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
input.bpm-num {
  font-family: var(--mono);
  font-size: clamp(2.4rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--acc);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  outline: none;
  width: 3.6ch;
  text-align: center;
  line-height: 1;
  caret-color: var(--acc);
  -moz-appearance: textfield;
  transition: border-color 0.2s;
}
input.bpm-num::-webkit-outer-spin-button,
input.bpm-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
input.bpm-num:focus {
  border-bottom-color: var(--acc);
}
.bpm-unit {
  font-size: 0.6rem;
  font-family: var(--mono);
  color: var(--muted);
  margin-top: 0.1rem;
}
.bpm-right {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.range-lbl {
  display: flex;
  justify-content: space-between;
  font-size: 0.58rem;
  color: var(--muted);
  font-family: var(--mono);
}
.step-row {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.nb {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  color: var(--txt);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition:
    background 0.12s,
    transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.nb:hover {
  background: var(--surf3);
}
.nb:active {
  transform: scale(0.93);
}

/* Sliders */
.styled-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  touch-action: none;
  background: transparent;
}
.styled-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    var(--acc) 0%,
    var(--acc) var(--pct, 0%),
    var(--surf3) var(--pct, 0%),
    var(--surf3) 100%
  );
}
.styled-range::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: var(--surf3);
}
.styled-range::-moz-range-progress {
  background: var(--acc);
  height: 6px;
  border-radius: 99px;
}
.styled-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--acc);
  cursor: pointer;
  margin-top: -8px;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.4),
    0 0 0 3px rgba(200, 240, 96, 0.18);
  transition:
    box-shadow 0.15s,
    transform 0.12s;
}
.styled-range::-webkit-slider-thumb:hover {
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.4),
    0 0 0 6px rgba(200, 240, 96, 0.22);
}
.styled-range::-webkit-slider-thumb:active {
  transform: scale(1.15);
}
.styled-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--acc);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.vol-row {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}
.vol-name {
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--txt);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 64px;
}
.vol-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  padding-left: 0.9rem;
}
.vol-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.vol-min {
  font-size: 0.58rem;
  color: var(--muted);
  font-family: var(--mono);
}
.vol-val {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: var(--acc);
  font-weight: 700;
}

/* Toggle */
.toggle-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  border-radius: 10px;
}
.toggle-label {
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--muted);
  flex: 1;
  line-height: 1.4;
}
.toggle-label strong {
  color: var(--txt);
  font-weight: 600;
}
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surf3);
  border-radius: 99px;
  border: 1px solid var(--brd2);
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.toggle input:checked ~ .toggle-track {
  background: var(--acc);
  border-color: var(--acc);
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.toggle input:checked ~ .toggle-thumb {
  transform: translateX(18px);
}

/* Toolbar */
.toolbar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0.9rem;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  border-radius: 10px;
  overflow: hidden;
}
.tb-section {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tb-section::-webkit-scrollbar {
  display: none;
}
.tb-section + .tb-section {
  border-top: 1px solid var(--brd);
}
.trow-label {
  font-size: 0.52rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  align-self: center;
  margin-right: 0.3rem;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 30px;
}
.ntool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.07rem;
  padding: 0.22rem 0.28rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition:
    background 0.1s,
    border-color 0.12s,
    transform 0.1s;
  user-select: none;
  flex-shrink: 0;
  width: 34px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ntool:hover {
  background: rgba(255, 255, 255, 0.06);
}
.ntool:active {
  transform: scale(0.9);
}
.ntool.sel {
  border-color: var(--acc);
  background: rgba(200, 240, 96, 0.14);
}
.ntool.sel-rest {
  border-color: rgba(200, 240, 96, 0.5);
  background: rgba(200, 240, 96, 0.07);
}
.ntool svg {
  display: block;
}
.tool-divider {
  width: 1px;
  background: var(--brd2);
  align-self: stretch;
  margin: 0 0.2rem;
  flex-shrink: 0;
}

/* Setup row */
.setup-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}
.sg {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}
.glabel {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
select {
  padding: 0.44rem 0.65rem;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  color: var(--txt);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  padding-right: 1.8rem;
  min-height: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(238,237,230,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}
select:focus {
  border-color: var(--acc);
}
.stepper {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.sbtn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  color: var(--txt);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition:
    background 0.1s,
    transform 0.1s;
  font-family: var(--mono);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sbtn:hover {
  background: var(--surf3);
}
.sbtn:active {
  transform: scale(0.9);
}
.sval {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--acc);
  min-width: 2ch;
  text-align: center;
}
.clr-btn {
  font-family: var(--mono);
  font-size: 0.63rem;
  background: var(--surf2);
  border: 1px solid var(--brd2);
  color: var(--muted);
  border-radius: 8px;
  min-height: 36px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
  margin-left: auto;
  align-self: flex-end;
  touch-action: manipulation;
}
.clr-btn:hover {
  background: var(--surf3);
  color: var(--txt);
}

/* Score */
.score-outer {
  margin-top: 1rem;
  width: 100%;
}
.score-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}
svg.score-svg {
  width: 100%;
  display: block;
  overflow: visible;
  cursor: default;
  touch-action: manipulation;
}
.ph-info {
  font-size: 0.6rem;
  font-family: var(--mono);
  color: var(--muted);
  margin-top: 0.5rem;
}
.ph-info span {
  color: var(--acc);
  font-weight: 700;
}

/* Mic section */
.mic-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.mic-btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--brd2);
  background: var(--surf2);
  color: var(--txt);
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.2s,
    color 0.15s;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 36px;
}
.mic-btn:hover {
  background: var(--surf3);
}
.mic-btn.granted {
  border-color: var(--grn);
  color: var(--grn);
}
.mic-btn.denied {
  border-color: var(--red);
  color: var(--red);
}
.mic-state {
  font-size: 0.65rem;
  font-family: var(--mono);
  color: var(--muted);
  flex: 1;
}
.mic-state.on {
  color: var(--grn);
}
.vu {
  flex: 0 0 80px;
  height: 5px;
  background: var(--surf3);
  border-radius: 99px;
  overflow: hidden;
}
.vu-bar {
  height: 100%;
  width: 0;
  background: var(--grn);
  border-radius: 99px;
  transition: width 0.04s;
}

/* Rhythm report */
.rhythm-card {
  display: none;
}
.rhythm-card.show {
  display: block;
}
.rhythm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.rhythm-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
}
.rhythm-score {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
}
.rhythm-score.good {
  color: var(--grn);
}
.rhythm-score.ok {
  color: var(--acc);
}
.rhythm-score.poor {
  color: var(--red);
}
.rhythm-rows {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.rr {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--brd);
}
.rr.rr-good {
  border-color: rgba(53, 212, 116, 0.3);
  background: rgba(53, 212, 116, 0.04);
}
.rr.rr-early {
  border-color: rgba(255, 200, 60, 0.3);
  background: rgba(255, 200, 60, 0.04);
}
.rr.rr-late {
  border-color: rgba(255, 120, 60, 0.3);
  background: rgba(255, 120, 60, 0.04);
}
.rr.rr-miss {
  border-color: rgba(255, 77, 77, 0.3);
  background: rgba(255, 77, 77, 0.05);
}
.rr-idx {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  min-width: 38px;
  flex-shrink: 0;
}
.rr-name {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--txt);
  flex: 1;
  min-width: 60px;
}
.rr-bar {
  flex: 2;
  height: 4px;
  background: var(--surf3);
  border-radius: 99px;
  position: relative;
  overflow: visible;
}
.rr-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 8px;
  transform: translate(-50%, -50%);
  background: var(--brd2);
}
.rr-dot {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.rr-verdict {
  font-family: var(--mono);
  font-size: 0.6rem;
  min-width: 52px;
  text-align: right;
  flex-shrink: 0;
}
.rr-ms {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  min-width: 46px;
  text-align: right;
  flex-shrink: 0;
}
.rhythm-note {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: var(--muted);
  margin-top: 0.55rem;
  line-height: 1.5;
}

/* Play buttons */
.btn-row {
  display: flex;
  gap: 0.6rem;
}
.btn-play {
  flex: 1;
  padding: 0.9rem;
  border-radius: 11px;
  border: none;
  background: var(--acc);
  color: #0a0a0c;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  min-height: 50px;
  transition:
    transform 0.12s,
    background 0.12s,
    box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-play:hover {
  background: var(--acc2);
  box-shadow: 0 4px 20px rgba(200, 240, 96, 0.3);
}
.btn-play:active {
  transform: scale(0.97);
}
.btn-stop {
  padding: 0.9rem 1.3rem;
  border-radius: 11px;
  border: 1px solid var(--brd2);
  background: transparent;
  color: var(--txt);
  font-family: var(--mono);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 50px;
  transition:
    background 0.12s,
    transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-stop:hover {
  background: var(--surf2);
}
.btn-stop:active {
  transform: scale(0.97);
}
.btn-stop:disabled,
.btn-play:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

@media (max-width: 520px) {
  body {
    padding: 1.2rem 0.7rem 3rem;
  }
  .card {
    padding: 1rem;
  }
  .ntool {
    width: 30px;
  }
  .btn-play,
  .btn-stop {
    font-size: 0.82rem;
  }
}

.back-link{display:inline-flex;align-items:center;gap:.45rem;font-family:var(--mono);font-size:.68rem;color:var(--muted);text-decoration:none;margin-bottom:.6rem;padding:.35rem .7rem;border:1px solid var(--brd);border-radius:7px;transition:color .15s,border-color .15s}
.back-link:hover{color:var(--txt);border-color:var(--brd2)}

/* Sidebar ads (desktop only) */
.ad-sidebar{display:none;position:fixed;top:50%;transform:translateY(-50%);width:160px;z-index:10}
.ad-sidebar-left{left:max(8px,calc(50% - 430px - 176px))}
.ad-sidebar-right{right:max(8px,calc(50% - 430px - 176px))}
@media(min-width:1200px){.ad-sidebar{display:block}}

/* Dot Matrix Grid */
@keyframes dotPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.65); }
  65%  { transform: scale(0.88); }
  100% { transform: scale(1); }
}
.dm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 0.5rem;
}
.dm-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 44px;
  position: relative;
}
.dm-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surf3);
  border: 1.5px solid var(--brd2);
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  cursor: default;
}
.dm-dot.dm-good {
  background: var(--grn);
  border-color: var(--grn);
  box-shadow: 0 0 14px rgba(53, 212, 116, 0.6);
  animation: dotPop 0.38s ease-out;
}
.dm-dot.dm-early {
  background: #ffc83c;
  border-color: #ffc83c;
  box-shadow: 0 0 12px rgba(255, 200, 60, 0.55);
  animation: dotPop 0.38s ease-out;
}
.dm-dot.dm-late {
  background: #ff7c3c;
  border-color: #ff7c3c;
  box-shadow: 0 0 12px rgba(255, 120, 60, 0.55);
  animation: dotPop 0.38s ease-out;
}
.dm-dot.dm-miss {
  background: var(--red);
  border-color: var(--red);
  opacity: 0.5;
  transform: scale(0.72);
}
.dm-lbl {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  line-height: 1;
}
/* ms tooltip on hover */
.dm-cell[data-ms]:hover::after {
  content: attr(data-ms);
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surf3);
  border: 1px solid var(--brd2);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 0.5rem;
  color: var(--txt);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* Timing Drift Lanes */
.td-panel {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.td-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.td-lbl {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 28px;
  flex-shrink: 0;
  color: var(--muted);
}
.td-lane {
  flex: 1;
  height: 18px;
  position: relative;
  background: var(--surf3);
  border-radius: 4px;
  border: 1px solid var(--brd);
  overflow: hidden;
}
.td-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--brd2);
}
.td-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  opacity: 0.45;
}
.td-dot.td-good  { background: var(--grn); }
.td-dot.td-early { background: #ffc83c; }
.td-dot.td-late  { background: #ff7c3c; }
.td-dot.td-miss  { background: var(--red); width: 5px; height: 5px; left: 50%; opacity: 0.4; }
.td-dot.td-newest {
  opacity: 1;
  box-shadow: 0 0 0 1.5px var(--txt);
  z-index: 1;
}
.td-axis {
  display: flex;
  justify-content: space-between;
  padding-left: 36px;
  font-family: var(--mono);
  font-size: 0.38rem;
  color: var(--muted);
  margin-top: 3px;
}

/* Bottom banner (all non-desktop) */
.ad-bottom{display:none;position:fixed;bottom:0;left:0;right:0;z-index:100;background:var(--bg);border-top:1px solid var(--brd);padding:4px 0;text-align:center}
@media(max-width:1199px){
  .ad-bottom{display:block}
  body{padding-bottom:6rem}
}
