:root {
  color-scheme: dark;
  --bg: #03070d;
  --panel: #071323;
  --panel-strong: #0a1c31;
  --line: rgba(114, 214, 255, 0.22);
  --text: #eaf9ff;
  --muted: #7ea6ba;
  --cyan: #37e6ff;
  --blue: #1284ff;
  --glow: rgba(42, 210, 255, 0.48);
  --hot-red: #ff2d55;
  --orange: #ff8a1f;
  --yellow: #f7f148;
  --green: #35ff79;
  --teal: #18ffd4;
  --purple: #a755ff;
  --pink: #ff4fd8;
  --white: #eaf9ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 48% -12%, rgba(34, 188, 255, 0.21), transparent 38rem),
    linear-gradient(155deg, #020409 0%, #06101d 48%, #02070f 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

.shell {
  width: min(100%, 1120px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar,
.control-strip,
.status-row,
.bank-panel {
  border: 1px solid var(--line);
  background: rgba(5, 17, 31, 0.76);
  box-shadow: 0 0 34px rgba(12, 132, 255, 0.1), inset 0 0 22px rgba(55, 230, 255, 0.04);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 43%, rgba(2, 8, 16, 0.8) 44% 56%, transparent 57%),
    linear-gradient(0deg, transparent 43%, rgba(2, 8, 16, 0.8) 44% 56%, transparent 57%),
    radial-gradient(circle, #c9fbff 0 9%, #37e6ff 10% 24%, #1284ff 25% 52%, #06111f 53%);
  box-shadow: 0 0 22px var(--glow), inset 0 0 10px rgba(255, 255, 255, 0.45);
}

h1 {
  margin: 0;
  font-size: clamp(1.3rem, 4vw, 2.15rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.meters {
  display: grid;
  grid-template-columns: repeat(4, 12px);
  align-items: end;
  gap: 6px;
  height: 48px;
  padding: 0 2px;
}

.meter {
  width: 12px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
  opacity: 0.76;
}

.meter.is-hot {
  height: 36px;
  color: var(--hot-red);
}

.meter.is-warm {
  height: 28px;
  color: var(--yellow);
}

.meter.is-cool {
  height: 42px;
  color: var(--teal);
}

.meter.is-blue {
  height: 22px;
  color: var(--blue);
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, auto)) minmax(172px, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
}

.control-button,
.bank-button {
  min-height: 46px;
  border: 1px solid rgba(108, 216, 255, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 43, 70, 0.92), rgba(5, 18, 32, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 rgba(55, 230, 255, 0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  transition: transform 90ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.control-button:active,
.bank-button:active {
  transform: translateY(1px) scale(0.99);
}

.control-button[aria-pressed="true"],
.bank-button.is-active {
  border-color: rgba(55, 230, 255, 0.9);
  background: linear-gradient(180deg, rgba(20, 94, 136, 0.94), rgba(7, 34, 61, 0.98));
  box-shadow: 0 0 22px rgba(55, 230, 255, 0.3), inset 0 0 18px rgba(55, 230, 255, 0.15);
}

.icon-play {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid var(--cyan);
  filter: drop-shadow(0 0 6px var(--cyan));
}

.icon-record {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--hot-red);
  box-shadow: 0 0 10px var(--hot-red);
}

.icon-clear {
  width: 16px;
  height: 16px;
  position: relative;
}

.icon-clear::before,
.icon-clear::after {
  content: "";
  position: absolute;
  inset: 7px 0 auto;
  height: 2px;
  border-radius: 2px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.icon-clear::before {
  transform: rotate(45deg);
}

.icon-clear::after {
  transform: rotate(-45deg);
}

.icon-bt {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(55, 230, 255, 0.65);
  border-radius: 50%;
  color: var(--cyan);
  font-size: 0.65rem;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(55, 230, 255, 0.25);
}

.icon-install {
  width: 15px;
  height: 17px;
  border: 2px solid var(--cyan);
  border-top: 0;
  position: relative;
  border-radius: 0 0 3px 3px;
  box-shadow: 0 0 8px rgba(55, 230, 255, 0.35);
}

.icon-install::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -12px;
  width: 2px;
  height: 14px;
  background: var(--cyan);
  transform: translateX(-50%);
  box-shadow: 0 0 8px var(--cyan);
}

.icon-install::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
  transform: translateX(-50%) rotate(45deg);
}

.tempo {
  min-width: 0;
  min-height: 46px;
  display: grid;
  grid-template-columns: auto 1fr 3.1rem;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(1, 8, 16, 0.42);
  color: var(--muted);
}

.tempo output {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-shadow: 0 0 10px rgba(55, 230, 255, 0.6);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.performance {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.bank-panel {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
}

.bank-button {
  min-width: 0;
  width: 100%;
}

.pad-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: 16px minmax(0, 1fr);
  gap: 10px;
}

.beat-lane {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 5px;
}

.beat-lane span {
  min-width: 0;
  border-radius: 999px;
  background: rgba(126, 166, 186, 0.2);
}

.beat-lane span.is-current {
  background: var(--cyan);
  box-shadow: 0 0 14px var(--cyan);
}

.pad-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: clamp(6px, 1.2vw, 12px);
  aspect-ratio: 1;
  width: min(100%, calc(100svh - 260px));
  max-width: 880px;
  place-self: start center;
  padding: clamp(8px, 2vw, 16px);
  border: 1px solid rgba(55, 230, 255, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(55, 230, 255, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(55, 230, 255, 0.05) 1px, transparent 1px),
    rgba(2, 9, 18, 0.74);
  background-size: 42px 42px;
  box-shadow: 0 0 48px rgba(18, 132, 255, 0.12), inset 0 0 44px rgba(55, 230, 255, 0.06);
}

.pad {
  --pad-color: var(--cyan);
  --pad-glow: rgba(55, 230, 255, 0.45);
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid color-mix(in srgb, var(--pad-color), white 18%);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 24%, color-mix(in srgb, var(--pad-color), white 24%) 0 11%, transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--pad-color), #06111f 50%), color-mix(in srgb, var(--pad-color), #020409 78%));
  box-shadow:
    0 0 11px color-mix(in srgb, var(--pad-color), transparent 50%),
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    inset 0 -10px 16px rgba(0, 0, 0, 0.34);
  color: rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: end center;
  padding: 0 3px 7px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: transform 75ms ease, filter 75ms ease, box-shadow 75ms ease;
}

.pad::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 46%);
  pointer-events: none;
}

.pad::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 255, 255, 0.8), transparent 24%);
  opacity: 0;
  pointer-events: none;
}

.pad span {
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.48rem, 1.15vw, 0.72rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.86);
}

.pad.is-playing,
.pad:active {
  transform: translateY(2px) scale(0.985);
  filter: saturate(1.28) brightness(1.2);
  box-shadow:
    0 0 28px color-mix(in srgb, var(--pad-color), transparent 16%),
    inset 0 0 24px rgba(255, 255, 255, 0.26),
    inset 0 -8px 15px rgba(0, 0, 0, 0.2);
}

.pad.is-playing::after,
.pad:active::after {
  opacity: 0.75;
}

.status-row {
  min-height: 38px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.credit {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(55, 230, 255, 0.4);
}

.status-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .shell {
    gap: 10px;
  }

  .topbar {
    min-height: 66px;
    padding: 12px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .meters {
    display: none;
  }

  .control-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tempo {
    grid-column: 1 / -1;
  }

  .performance {
    grid-template-columns: 1fr;
  }

  .bank-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px;
  }

  .bank-button,
  .control-button {
    min-height: 42px;
    font-size: 0.86rem;
  }

  .pad-grid {
    width: min(100%, calc(100svh - 330px));
    min-height: min(100vw - 24px, calc(100svh - 330px));
    gap: 6px;
    padding: 8px;
  }

  .pad span {
    font-size: clamp(0.44rem, 2vw, 0.58rem);
  }

  .status-row {
    font-size: 0.75rem;
  }
}

@media (max-width: 420px) {
  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .install-button {
    grid-column: auto;
  }

  .bank-panel {
    gap: 6px;
  }

  .pad-grid {
    width: min(100%, calc(100svh - 370px));
    min-height: min(100vw - 24px, calc(100svh - 370px));
  }
}
