:root {
  --bg: #070a12;
  --panel: rgba(10, 14, 26, 0.78);
  --stroke: rgba(170, 200, 255, 0.18);
  --text: #e9eefc;
  --muted: rgba(233, 238, 252, 0.72);
  --btn: #151c34;
  --btnStroke: #2a3562;
  --danger: #24111a;
  --dangerStroke: #7a2a3a;
  --radius: 18px;
  --pad: 12px;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow: hidden;
  touch-action: none;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + var(--pad))
    calc(env(safe-area-inset-right) + var(--pad))
    calc(env(safe-area-inset-bottom) + var(--pad))
    calc(env(safe-area-inset-left) + var(--pad));
  gap: 10px;
  box-sizing: border-box;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: #0c1224;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* UI overlay (bass image + buttons) */
.uiLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.bgDim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.bassImg {
  position: absolute;
  left: -10%;
  top: 8%;
  width: 122%;
  height: auto;
  opacity: 0.8;
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  transform: rotate(-6deg);
  transform-origin: 30% 70%;
}

/* “janky charm” subtle jitter */
@keyframes jiggle {
  0% {
    transform: rotate(-6deg) translate(0, 0);
  }
  25% {
    transform: rotate(-6.4deg) translate(1px, -1px);
  }
  50% {
    transform: rotate(-5.8deg) translate(-1px, 1px);
  }
  75% {
    transform: rotate(-6.2deg) translate(1px, 1px);
  }
  100% {
    transform: rotate(-6deg) translate(0, 0);
  }
}
.bassImg.jank {
  animation: jiggle 2.8s infinite linear;
}

.fretBtn {
  pointer-events: auto;
  position: absolute;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  font-size: 14px;
  letter-spacing: 0.2px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);

  /* CHANGED: keep centering even while scaling (held) */
  --scale: 1;
  transform: translate(-50%, -50%) scale(var(--scale)) translateZ(0);

  transition: transform 70ms ease, filter 70ms ease, opacity 70ms ease;
  opacity: 0.92;
}

/* CHANGED: increase effective tap hitbox without changing visuals */
.fretBtn::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.fretBtn.held {
  /* CHANGED: doesn't overwrite transform anymore */
  --scale: 0.92;
  filter: brightness(1.25);
  opacity: 1;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.1) inset,
    0 10px 26px rgba(0, 0, 0, 0.35);
}

.slapBtn {
  pointer-events: auto;
  position: absolute;
  left: 4%;
  bottom: 4%;
  width: 112px;
  height: 112px;
  border-radius: 999px;
  background: rgba(255, 60, 80, 0.94);
  border: 3px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  font-size: 14px;
  text-align: center;
  line-height: 1.05;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transform: translateZ(0);
  transition: transform 60ms ease;
}
.slapBtn:active {
  transform: scale(0.93);
}

.c-green {
  background: rgba(60, 220, 120, 0.88);
}
.c-red {
  background: rgba(255, 80, 80, 0.88);
}
.c-yellow {
  background: rgba(240, 210, 60, 0.9);
  color: rgba(10, 15, 30, 0.95);
}
.c-blue {
  background: rgba(70, 140, 255, 0.88);
}
.c-purple {
  background: rgba(180, 90, 255, 0.88);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 10px 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--muted);
}
.hud strong {
  color: var(--text);
}
.hud .col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
}
.card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.card h1 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: 0.2px;
}
.card p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 13px;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

button {
  -webkit-tap-highlight-color: transparent;
  border-radius: 14px;
  border: 1px solid var(--btnStroke);
  background: var(--btn);
  color: var(--text);
  padding: 12px 12px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.danger {
  background: var(--danger);
  border-color: var(--dangerStroke);
}

.mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px dashed rgba(170, 200, 255, 0.18);
  border-radius: 14px;
  padding: 10px 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}
input[type="number"] {
  width: 96px;
  font-weight: 950;
  padding: 12px 10px;
  border-radius: 14px;
  border: 1px solid var(--btnStroke);
  background: rgba(21, 28, 52, 0.9);
  color: var(--text);
  font-size: 14px;
}

.big {
  font-size: 28px;
  font-weight: 950;
  letter-spacing: 0.2px;
  margin: 8px 0 6px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.stat {
  border: 1px solid rgba(170, 200, 255, 0.14);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}
.stat strong {
  color: var(--text);
  font-size: 16px;
  display: block;
  margin-top: 4px;
}

.statusline {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(170, 200, 255, 0.14);
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}
.dot.ok {
  background: rgba(120, 255, 160, 0.9);
  box-shadow: 0 0 0 3px rgba(120, 255, 160, 0.15);
}
.dot.bad {
  background: rgba(255, 120, 140, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 120, 140, 0.15);
}

@media (max-width: 380px) {
  .slapBtn {
    width: 102px;
    height: 102px;
    font-size: 13px;
  }
  .fretBtn {
    width: 58px;
    height: 58px;
    font-size: 13px;
  }
  .card h1 {
    font-size: 16px;
  }
  button,
  input[type="number"] {
    font-size: 13px;
    padding: 11px 10px;
  }
  .big {
    font-size: 24px;
  }
}
