:root {
  --ink: #f5ecda;
  --paper: #f1e5ca;
  --night: #171512;
  --panel: #282824;
  --sea: #5aa6a1;
  --coral: #dc6d52;
  --gold: #f0b84b;
  --steel-1: #ecf2f3;
  --steel-2: #aebdc3;
  --steel-3: #667983;
  --shadow: rgba(18, 29, 36, 0.22);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background-color: var(--night);
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(#171512, #211e19 72%, #161815);
  background-size: 28px 100%, 100% 100%;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 44px);
}

.stage {
  width: min(100%, 1280px);
  min-height: min(780px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto 1fr auto auto auto auto;
  align-items: center;
  gap: clamp(16px, 2.4vw, 28px);
}

.topbar,
.readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  font-weight: 500;
  line-height: 0.88;
  letter-spacing: 0;
}

.brand-lockup > span {
  display: block;
  margin-bottom: 7px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.controls {
  display: flex;
  gap: 10px;
}

.icon-button {
  width: 48px;
  aspect-ratio: 1;
  border: 1px solid rgba(240, 184, 75, 0.34);
  border-radius: 50%;
  background: #2d2a25;
  color: var(--paper);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 10px 22px rgba(0, 0, 0, 0.24);
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: #3a352d;
  color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(23, 32, 39, 0.12);
  outline: none;
}

.icon-button:active {
  transform: translateY(0) scale(0.96);
}

.icon-button span {
  font-size: 1.25rem;
  line-height: 1;
}

.pan-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  place-items: center;
  gap: clamp(14px, 3vw, 38px);
  min-height: 0;
  width: 100%;
}

.pan {
  position: relative;
  width: min(100%, 570px, 70vh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #171717 url("assets/steel-pan.png") center / cover no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 9px rgba(0, 0, 0, 0.16),
    0 32px 58px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.upper-pan {
  filter: sepia(0.08) hue-rotate(12deg);
}

.pan::before,
.pan::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  pointer-events: none;
}

.pan::before {
  background: radial-gradient(circle, transparent 58%, rgba(0, 0, 0, 0.22));
}

.pan::after {
  inset: 5%;
  border: 1px solid rgba(255, 222, 159, 0.18);
}

.note {
  position: absolute;
  width: var(--size);
  left: var(--x);
  top: var(--y);
  aspect-ratio: 1.2 / 0.86;
  border: 1px solid rgba(255, 246, 222, 0.38);
  border-radius: 50%;
  background: rgba(24, 24, 22, 0.34);
  color: #fff8e9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  place-items: center;
  font-weight: 800;
  font-size: clamp(0.82rem, 2vw, 1.5rem);
  letter-spacing: 0;
  cursor: pointer;
  z-index: 2;
  transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
  text-shadow: 0 1px 5px #000;
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.24);
  transition: transform 100ms ease, filter 100ms ease, box-shadow 100ms ease;
  touch-action: manipulation;
  line-height: 1;
}

.note small {
  display: block;
  margin-top: 2px;
  font-size: 0.58em;
  font-weight: 750;
}

.note.natural {
  background-color: rgba(214, 125, 66, 0.22);
}

.note.accidental {
  background-color: rgba(31, 111, 108, 0.3);
  color: #e9fffb;
}

.note:hover,
.note:focus-visible {
  filter: brightness(1.06);
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 184, 75, 0.16), 0 8px 22px rgba(0, 0, 0, 0.28);
}

.note.playing {
  transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(0.94);
  filter: saturate(1.18) brightness(1.08);
}

.readout {
  justify-content: center;
  color: var(--gold);
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-weight: 750;
}

.effect-rack {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 1px;
  padding: 10px;
  border: 1px solid #4c463b;
  border-radius: 7px;
  background: #171715;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 18px 38px rgba(0, 0, 0, 0.28);
}

.effect-panel {
  margin: 0;
  padding: 14px;
  border: 1px solid #3c3932;
  border-radius: 2px;
  background: #292824;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
}

.effect-panel legend {
  padding: 0 6px;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 850;
}

.effect-panel label {
  display: grid;
  grid-template-columns: minmax(68px, 0.35fr) 1fr;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  color: rgba(245, 236, 218, 0.72);
  font-size: 0.82rem;
  font-weight: 760;
}

.effect-panel label + label {
  margin-top: 8px;
}

.effect-panel input[type="range"] {
  width: 100%;
  accent-color: var(--sea);
  cursor: pointer;
}

.looper-console {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(310px, 1.25fr);
  gap: 14px 24px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid #594f3f;
  border-radius: 7px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035), transparent 2px),
    #24221e;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 18px 38px rgba(0, 0, 0, 0.28);
}

.looper-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.looper-kicker {
  color: var(--coral);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.looper-heading h2 {
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
  font-weight: 500;
  letter-spacing: 0;
}

.looper-heading output {
  min-width: 104px;
  padding: 8px 10px;
  border: 1px solid #5c4933;
  border-radius: 4px;
  background: #171512;
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  text-align: center;
  white-space: nowrap;
}

.looper-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 8px;
}

.looper-button {
  min-height: 42px;
  border: 1px solid rgba(240, 184, 75, 0.42);
  border-radius: 5px;
  background: #343027;
  color: var(--paper);
  cursor: pointer;
  font-weight: 850;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.looper-button:hover:not(:disabled),
.looper-button:focus-visible:not(:disabled) {
  border-color: var(--gold);
  background: #413a2d;
  outline: none;
  transform: translateY(-1px);
}

.looper-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.looper-button.record span {
  display: inline-block;
  width: 9px;
  aspect-ratio: 1;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 8px rgba(220, 109, 82, 0.5);
}

.looper-button.recording {
  border-color: var(--coral);
  background: rgba(220, 109, 82, 0.2);
}

.looper-button.recording span {
  border-radius: 1px;
}

.looper-button.looping {
  border-color: var(--sea);
  background: rgba(90, 166, 161, 0.2);
}

.looper-button.quiet {
  border-color: rgba(245, 236, 218, 0.2);
}

.loop-track {
  grid-column: 1 / -1;
  height: 10px;
  overflow: hidden;
  border: 1px solid #51483a;
  border-radius: 2px;
  background: #11110f;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.loop-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--coral);
  box-shadow: 0 0 10px rgba(220, 109, 82, 0.65);
  transition: width 50ms linear;
}

.looper-console.looping .loop-track span {
  background: var(--sea);
  box-shadow: 0 0 10px rgba(90, 166, 161, 0.65);
}

.loop-state {
  grid-column: 1 / -1;
  color: rgba(245, 236, 218, 0.62);
  font-size: 0.76rem;
  font-weight: 760;
}

.drum-machine {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(260px, 1.4fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: center;
  position: relative;
  min-height: 410px;
  padding: clamp(28px, 5vw, 64px);
  border: 1px solid rgba(240, 184, 75, 0.25);
  border-radius: 8px;
  background: #181817 url("assets/vintage-drum-machine.png") center / cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 24px 48px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.drum-machine::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(13, 13, 12, 0.12), rgba(13, 13, 12, 0.38) 46%, rgba(13, 13, 12, 0.82));
  pointer-events: none;
}

.drum-machine > * {
  position: relative;
  z-index: 1;
  align-self: end;
  padding: 12px;
  border: 1px solid rgba(236, 215, 175, 0.18);
  border-radius: 5px;
  background: rgba(22, 21, 19, 0.78);
  backdrop-filter: blur(5px);
}

.machine-top,
.machine-sliders {
  display: grid;
  gap: 12px;
}

.machine-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #fff7e8;
  font-weight: 850;
}

.machine-title output {
  color: var(--gold);
  font-size: 0.9rem;
  white-space: nowrap;
}

.machine-buttons,
.pattern-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.machine-button,
.pattern-button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(238, 222, 191, 0.12);
  color: #fff7e8;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.machine-button {
  padding: 0 18px;
}

.pattern-button {
  flex: 1 1 76px;
  padding: 0 12px;
}

.machine-button:hover,
.machine-button:focus-visible,
.pattern-button:hover,
.pattern-button:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  transform: translateY(-1px);
}

.machine-button.primary,
.pattern-button.active {
  border-color: rgba(240, 191, 78, 0.8);
  background: rgba(240, 191, 78, 0.22);
  color: #ffffff;
}

.machine-button.running {
  border-color: rgba(217, 93, 79, 0.9);
  background: rgba(217, 93, 79, 0.28);
}

.machine-sliders label {
  display: grid;
  grid-template-columns: minmax(58px, 0.3fr) 1fr;
  align-items: center;
  gap: 10px;
  color: rgba(255, 247, 232, 0.82);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.step-lights {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}

.step-light {
  width: 100%;
  aspect-ratio: 1;
  max-height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.step-light.downbeat {
  background: rgba(255, 255, 255, 0.24);
}

.step-light.active {
  background: var(--gold);
  box-shadow:
    0 0 14px rgba(240, 191, 78, 0.75),
    inset 0 1px 2px rgba(255, 255, 255, 0.45);
}

@media (max-width: 620px) {
  .stage {
    min-height: calc(100vh - 28px);
    gap: 12px;
  }

  .topbar {
    align-items: flex-start;
    gap: 14px;
  }

  .icon-button {
    width: 44px;
  }

  .pan {
    width: min(94vw, 420px);
  }

  .effect-panel {
    padding: 12px;
  }

  .machine-buttons,
  .pattern-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .looper-console {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  .looper-controls {
    grid-template-columns: 1.15fr 1.25fr 0.8fr;
  }

  .loop-track,
  .loop-state {
    grid-column: 1;
  }
}

@media (max-width: 760px) {
  .pan-wrap {
    grid-template-columns: 1fr;
  }

  .effect-rack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .drum-machine {
    grid-template-columns: 1fr;
    min-height: 620px;
    background-position: center top;
  }
}
