:root {
  --box-size: 50px;
  --box-bg: #242424;
  --box-stroke: #0ce49f;
  --box-stroke-width: 4px;
  --box-radius: 17px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0a0e27;
  color: #ffffff;
  font-family: "Syne", system-ui, sans-serif;
}

body {
  opacity: 0;
  transition: opacity 0.7s ease-out;
}

body.is-ready {
  opacity: 1;
}

#webGLApp {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.page-title {
  position: fixed;
  top: 1.5rem;
  left: 2rem;
  z-index: 10;
  font-family: "Syne", sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.attribution {
  position: fixed;
  bottom: 1rem;
  right: 1.25rem;
  z-index: 10;
  font-family: "Syne", sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
  user-select: none;
}

.attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.attribution a:hover {
  color: var(--box-stroke);
}

.signal-flow {
  position: fixed;
  top: 75%;
  width: 50%;
  left: 25%;
  height: 40px;
  transform: translateY(-50%);
  z-index: 5;
  pointer-events: none;
  overflow: visible;
}

.signal-flow line {
  stroke: #0ce49f;
  stroke-width: 6;
  stroke-dasharray: 20 10;
  animation: signal-flow 1s linear infinite;
}

@keyframes signal-flow {
  from {
    stroke-dashoffset: 30;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.box {
  position: fixed;
  top: 75%;
  width: var(--box-size);
  height: var(--box-size);
  background-color: var(--box-bg);
  border: var(--box-stroke-width) solid var(--box-stroke);
  border-radius: var(--box-radius);
  transform: translateY(-50%);
  z-index: 10;
  transition: opacity 0.3s;
}

.box:hover {
  opacity: 0.8;
}


.node-label {
  position: fixed;
  z-index: 10;
  font-family: "Syne", sans-serif;
  font-size: 24px;
  font-weight: 500;
  color: #ffffff;
  letter-spacing: 0.02em;
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
}

.node-label--source {
  left: 25%;
  bottom: calc(25% + var(--box-size) / 2 + 12px);
  transform: translateX(-50%);
}

.node-label--result {
  right: 25%;
  bottom: calc(25% + var(--box-size) / 2 + 12px);
  transform: translateX(50%);
}

.box--left {
  left: 25%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.source-icon {
  width: 22px;
  height: 22px;
  color: var(--box-stroke);
  pointer-events: none;
}

.source-icon--pause {
  display: none;
}

.box--playing .source-icon--play {
  display: none;
}

.box--playing .source-icon--pause {
  display: block;
}

.box--right {
  right: 25%;
  transform: translate(50%, -50%);
  width: calc(var(--box-size) * 2);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
}

.box--right:hover {
  opacity: 1;
}

.output-scope {
  width: 100%;
  height: 100%;
  display: block;
}

.box--muffle {
  top: auto;
  left: 12%;
  bottom: 6%;
  transform: translateX(-50%);
  cursor: grab;
}

.box--muffle:active {
  cursor: grabbing;
}

.node-label--muffle {
  left: 12%;
  bottom: calc(6% + var(--box-size) + 12px);
  transform: translateX(-50%);
}

.box--muffle,
.node-label--muffle {
  animation:
    muffle-wave-a 7s ease-in-out infinite,
    muffle-wave-b 11s ease-in-out infinite;
  animation-composition: add;
}

.box--snapped,
.node-label--snapped {
  animation: none;
  translate: 0 0;
}

@keyframes muffle-wave-a {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 8px -12px;
  }
}

@keyframes muffle-wave-b {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: -5px 7px;
  }
}

.sequencer {
  position: fixed;
  top: calc(15%);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  padding: 16px 20px;
  background: #0a0a0f;
  border-radius: 14px;
}

.sequencer-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-family: "Syne", sans-serif;
  font-size: 13px;
  color: #ffffff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}

.sequencer-controls input,
.sequencer-controls select {
  user-select: auto;
}

.ctrl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ctrl__unit {
  opacity: 0.6;
}

.ctrl input,
.ctrl select {
  background: #1a1a22;
  color: #ffffff;
  border: 1px solid #2c2c2c;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 13px;
}

.ctrl input {
  width: 56px;
  text-align: center;
}

.grid {
  display: grid;
  align-self: stretch;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 16px);
  column-gap: 8px;
  row-gap: 6px;
}

.cell {
  background: #2c2c2c;
  border-radius: 3px;
  cursor: pointer;
}

.cell:hover:not(.cell--active) {
  background: #3a3a3a;
}

.cell--active:hover {
  opacity: 0.6;
}

.cell--playhead:not(.cell--active) {
  background: #535353;
}

.cell--active {
  background: var(--box-stroke);
}

.cell--active.cell--playhead {
  background: #6cf2c0;
}

.osc-picker {
  position: fixed;
  left: 25%;
  bottom: calc(25% + var(--box-size) / 2 + 50px);
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  user-select: none;
}

.osc-btn {
  width: 36px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--box-stroke);
  opacity: 0.3;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 120ms linear;
}

.osc-btn:hover {
  opacity: 0.6;
}

.osc-btn--active,
.osc-btn--active:hover {
  opacity: 1;
}

.osc-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.filter-display {
  position: fixed;
  width: 100px;
  height: 38px;
  z-index: 20;
  display: none;
  pointer-events: none;
  overflow: visible;
}

.filter-display.is-active {
  display: block;
}

.filter-cutoff {
  cursor: ew-resize;
}

.filter-cutoff__hit {
  pointer-events: all;
}

.filter-cutoff__ring {
  pointer-events: none;
}

.tutorial {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  display: none;
}

body.is-tutorial-active .tutorial {
  display: block;
}

.tutorial-backdrop {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.65), rgba(10, 14, 39, 0.75));
  pointer-events: none;
}

.tutorial-card {
  position: fixed;
  width: 320px;
  padding: 20px 22px 16px;
  background: #242424;
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  font-family: "Syne", sans-serif;
  pointer-events: auto;
  user-select: none;
  transition:
    left 350ms cubic-bezier(0.4, 0, 0.2, 1),
    top 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.tutorial-message {
  font-size: 15px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  transition: background-color 200ms linear;
}

.tutorial-dot.is-active {
  background: var(--box-stroke);
}

.tutorial-button {
  display: block;
  margin: 0 auto;
  background: transparent;
  color: var(--box-stroke);
  border: 1px solid var(--box-stroke);
  border-radius: 8px;
  padding: 6px 18px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 120ms linear,
    color 120ms linear;
}

.tutorial-button:hover {
  background: var(--box-stroke);
  color: #0a0a0f;
}

body.is-tutorial-active .tutorial-spotlight {
  z-index: 101;
}

.mode-toggle {
  position: fixed;
  top: 1.5rem;
  right: 2rem;
  z-index: 10;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: transparent;
  border: 1px solid #2c2c2c;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 120ms linear,
    border-color 120ms linear;
}

.mode-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #555;
}

.mode-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.mode-icon--sun {
  display: none;
}

.mode-toggle.is-day .mode-icon--moon {
  display: none;
}

.mode-toggle.is-day .mode-icon--sun {
  display: block;
}
