:root {
  color-scheme: dark;
  --bar: #121214;
}

* {
  box-sizing: border-box;
  /* No double-tap zoom: pads are hit twice quickly all the time. */
  touch-action: manipulation;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  /* iOS tints the status bar area from the page background. */
  background: var(--bar);
}

body {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* A dark desk under a lamp. */
  background: radial-gradient(ellipse at 50% 30%, #2a2a2e, var(--bar) 70%);
  color: #cfd0d4;
  font: 600 12px/1 ui-rounded, 'Helvetica Neue', system-ui, sans-serif;
  /* Stop the page itself bouncing, zooming or selecting like a website. */
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* --- The case ------------------------------------------------------------- */

/* Every size inside is in cqw, hundredths of the case's width, so the whole
   thing scales as one object. It is about 1.7 times as tall as it is wide. */
#device {
  container-type: inline-size;
  width: min(96vw, (100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px) / 1.7);
}

#device::before {
  content: '';
  position: absolute;
  z-index: -1;
}

#device > * {
  position: relative;
}

#device {
  position: relative;
  padding: 0;
  border-radius: 5cqw;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.07), transparent 30%),
    linear-gradient(#2c2d31, #1a1b1e);
  box-shadow:
    inset 0 0.3cqw 0.3cqw rgba(255, 255, 255, 0.16),
    inset 0 -0.6cqw 0.8cqw rgba(0, 0, 0, 0.6),
    0 0.6cqw 0 #0c0c0e,
    0 4cqw 8cqw rgba(0, 0, 0, 0.65);
}

header {
  display: flex;
  align-items: center;
  gap: 2.5cqw;
  padding: 4cqw 4cqw 1.5cqw;
}

#brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1cqw;
}

/* The name is pressed into the plastic. */
#brand b {
  font-size: 5.6cqw;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #17181a;
  text-shadow: 0 0.2cqw 0.1cqw rgba(255, 255, 255, 0.14), 0 -0.15cqw 0.1cqw rgba(0, 0, 0, 0.7);
}

#brand span {
  font-size: 1.9cqw;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #6f7178;
}

/* A grey-green liquid crystal screen behind a recessed window. */
#lcd {
  display: flex;
  align-items: center;
  gap: 2cqw;
  padding: 1.6cqw 2.4cqw;
  border-radius: 1.4cqw;
  background: linear-gradient(#a9b596, #96a383);
  color: #1d2417;
  box-shadow:
    inset 0 0.5cqw 1cqw rgba(0, 0, 0, 0.45),
    inset 0 0 0 0.3cqw rgba(0, 0, 0, 0.35),
    0 0.2cqw 0 rgba(255, 255, 255, 0.1);
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

#tempo {
  min-width: 3ch;
  font-size: 8cqw;
  font-style: italic;
  letter-spacing: -0.04em;
  text-align: right;
  text-shadow: 0.25cqw 0.25cqw 0 rgba(29, 36, 23, 0.18);
}

#lcd div {
  display: flex;
  flex-direction: column;
  gap: 0.7cqw;
  font-size: 2.1cqw;
  text-transform: uppercase;
}

#key {
  text-transform: none;
}

#tempo-keys {
  display: flex;
  flex-direction: column;
  gap: 1cqw;
}

#tempo-keys button {
  width: 8cqw;
  height: 4.6cqw;
  border-radius: 1cqw;
  background: linear-gradient(#55575d, #3a3b40);
  box-shadow: inset 0 0.2cqw 0 rgba(255, 255, 255, 0.2), 0 0.4cqw 0 #0e0e10, 0 0.8cqw 1cqw rgba(0, 0, 0, 0.5);
  font-size: 4cqw;
  line-height: 1;
}

#tempo-keys button:active {
  transform: translateY(0.3cqw);
  box-shadow: inset 0 0.2cqw 0 rgba(255, 255, 255, 0.1), 0 0.1cqw 0 #0e0e10;
}

/* The strip display: a dark glowing panel behind a pane of glass. */
#window {
  position: relative;
  height: 17cqw;
  margin: 1cqw 3cqw 1.5cqw;
  border-radius: 1.6cqw;
  overflow: hidden;
  background: #060708;
  box-shadow:
    inset 0 0.6cqw 1.2cqw #000,
    inset 0 0 0 0.3cqw rgba(0, 0, 0, 0.6),
    0 0.2cqw 0 rgba(255, 255, 255, 0.09);
}

#scope {
  display: block;
  width: 100%;
  height: 100%;
}

/* Light catching the glass. */
#window::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.09), transparent 38%);
  pointer-events: none;
}

/* --- Pads and round buttons ----------------------------------------------- */

#grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1.5cqw;
  margin: 1.5cqw 3cqw 0;
  padding: 2cqw;
  border-radius: 2.5cqw;
  /* The pads sit in a shallow tray. */
  background: #121315;
  box-shadow: inset 0 0.4cqw 0.8cqw rgba(0, 0, 0, 0.8), 0 0.2cqw 0 rgba(255, 255, 255, 0.07);
}

#grid > * {
  aspect-ratio: 1;
  min-width: 0;
}

/* A pad is translucent silicone over a light. Unlit, it shows a little of
   its colour; lit, it glows from the middle. */
.pad {
  --c: #fff;
  border-radius: 1.3cqw;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.1), transparent 60%),
    color-mix(in srgb, var(--c) 14%, #2e2f33);
  box-shadow:
    inset 0 0.25cqw 0.2cqw rgba(255, 255, 255, 0.14),
    inset 0 -0.5cqw 0.5cqw rgba(0, 0, 0, 0.45),
    0 0.3cqw 0.3cqw rgba(0, 0, 0, 0.7);
  transition: filter 0.28s ease-out;
}

.pad:active {
  transform: scale(0.94);
}

.pad.on {
  background:
    radial-gradient(circle at 50% 45%, #fff 0%, color-mix(in srgb, var(--c) 55%, #fff) 22%, var(--c) 62%, color-mix(in srgb, var(--c) 72%, #000));
  box-shadow:
    inset 0 0.25cqw 0.2cqw rgba(255, 255, 255, 0.5),
    inset 0 -0.5cqw 0.5cqw rgba(0, 0, 0, 0.25),
    0 0 2.2cqw color-mix(in srgb, var(--c) 75%, transparent),
    0 0 0.6cqw var(--c);
  filter: brightness(0.82);
}

/* Chosen, but the clock is stopped: lit without the glow. */
.pad.armed {
  background: color-mix(in srgb, var(--c) 48%, #2e2f33);
}

/* Stopped, the play button breathes to say what to press. */
.stopped [data-fn='play'] {
  animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    background: radial-gradient(circle at 50% 40%, #fff3c4, #ffb300 70%, #a86c00);
    box-shadow: inset 0 0.2cqw 0.2cqw rgba(255, 255, 255, 0.6), 0 0 2cqw rgba(255, 179, 0, 0.6);
    color: #3a2600;
  }
}

/* A hit flares at once and fades by the transition above. */
.pad.hit {
  filter: brightness(1.5) saturate(1.2);
  transition: none;
}

/* Waiting for the bar line: blinks. */
.pad.queued {
  animation: blink 0.24s steps(2, jump-none) infinite;
}

@keyframes blink {
  from {
    background: color-mix(in srgb, var(--c) 75%, #2e2f33);
  }
  to {
    background: color-mix(in srgb, var(--c) 14%, #2e2f33);
  }
}

.round {
  margin: 8%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #4a4b51, #2a2b2f);
  box-shadow:
    inset 0 0.2cqw 0.2cqw rgba(255, 255, 255, 0.22),
    inset 0 -0.4cqw 0.4cqw rgba(0, 0, 0, 0.5),
    0 0.4cqw 0.4cqw rgba(0, 0, 0, 0.7);
  color: #a9abb2;
  font-size: 2.1cqw;
  font-weight: 700;
  text-transform: uppercase;
  transition: filter 0.2s ease-out;
}

.round:active {
  transform: scale(0.92);
}

.round.lit {
  background: radial-gradient(circle at 50% 40%, #fff, #ffe9a6 30%, #ffb300 70%, #a86c00);
  box-shadow: inset 0 0.2cqw 0.2cqw rgba(255, 255, 255, 0.6), 0 0 2cqw rgba(255, 179, 0, 0.7);
  color: #3a2600;
}

.round.hit {
  filter: brightness(1.7);
  transition: none;
}

.scene {
  font-size: 3cqw;
}

/* Where the top row meets the side column there is no button, only a
   small lamp that says the power is on. */
.badge {
  margin: 38%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #b9ffcf, #19c15a 55%, #0a5a2a);
  box-shadow: 0 0 1.2cqw rgba(25, 193, 90, 0.8);
}

/* The instrument names are printed on the case under their columns. */
#names {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1.5cqw;
  margin: 1.2cqw 3cqw 0;
  padding: 0 2cqw;
  font-size: 1.75cqw;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  color: #7d7f86;
}

/* --- Knobs ---------------------------------------------------------------- */

#knobs {
  display: flex;
  justify-content: space-between;
  padding: 3cqw 5cqw 4.5cqw;
}

.knob {
  --turn: 0deg;
  --lit: 0deg;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6cqw;
  touch-action: none;
  cursor: ns-resize;
}

.knob span {
  font-size: 2cqw;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8c93;
}

/* The ring of light round the knob, lit as far as it is turned. */
.dial {
  display: grid;
  place-items: center;
  width: 14cqw;
  height: 14cqw;
  border-radius: 50%;
  background:
    radial-gradient(circle, #17181a 58%, transparent 59%),
    conic-gradient(from 225deg, #ffb300 var(--lit), #3a3b40 var(--lit) 270deg, transparent 270deg);
  box-shadow: inset 0 0.3cqw 0.5cqw rgba(0, 0, 0, 0.6);
}

/* The knob itself: brushed metal, with a notch showing where it points. */
.cap {
  position: relative;
  width: 9.6cqw;
  height: 9.6cqw;
  border-radius: 50%;
  transform: rotate(var(--turn));
  background:
    conic-gradient(#8f9197, #e3e4e8, #7e8086, #d5d6da, #8a8c92, #ececf0, #7c7e84, #d9dade, #8f9197);
  box-shadow:
    inset 0 0 0 0.5cqw rgba(0, 0, 0, 0.18),
    0 0.6cqw 0.3cqw rgba(0, 0, 0, 0.5),
    0 1.2cqw 1.6cqw rgba(0, 0, 0, 0.55);
}

.cap::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 6%;
  width: 0.9cqw;
  height: 32%;
  border-radius: 1cqw;
  transform: translateX(-50%);
  background: #17181a;
}
