:root {
  color-scheme: light;
  --paper: #f6f0e6;
  --paper-soft: rgba(255, 250, 241, 0.82);
  --ink: #22231e;
  --muted: #606957;
  --moss: #506836;
  --moss-deep: #354827;
  --coral: #e9795f;
  --sky: #7eaaba;
  --amber: #dba640;
  --line: rgba(41, 45, 37, 0.16);
  --shadow: 0 18px 48px rgba(50, 46, 37, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.room {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 620px;
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(255, 252, 245, 0.72), rgba(255, 252, 245, 0.14) 12%, rgba(255, 252, 245, 0) 22%),
    var(--paper);
}

.room[data-theme="night"] {
  --paper: #e8ebe2;
  --paper-soft: rgba(241, 244, 236, 0.84);
  --ink: #1f261f;
  --muted: #536652;
  --moss: #496b4c;
  --moss-deep: #2f5136;
  --coral: #c86d61;
  --sky: #5e8da2;
  --amber: #c38f34;
  --line: rgba(31, 38, 31, 0.18);
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(246, 240, 230, 0.04), rgba(246, 240, 230, 0.04)),
    url("./assets/field-wash.png");
  background-size: cover;
  background-position: center;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(250, 247, 238, 0.22), rgba(250, 247, 238, 0) 30%),
    linear-gradient(0deg, rgba(255, 250, 240, 0.36), rgba(255, 250, 240, 0) 22%);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 28px;
  padding: 22px 36px 0 132px;
  pointer-events: none;
}

.identity,
.toolbar,
.mode-rail,
.control-strip {
  pointer-events: auto;
}

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

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: 0;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 9px 0 0;
  color: var(--moss);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.status span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--moss);
  box-shadow: 0 0 0 5px rgba(80, 104, 54, 0.12);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tool,
.mode {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(252, 248, 239, 0.78);
  box-shadow: 0 10px 24px rgba(48, 43, 35, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tool {
  width: 58px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: var(--radius);
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.tool svg,
.slider svg,
.keys svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool:hover,
.mode:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(48, 43, 35, 0.12);
}

.tool:focus-visible,
.mode:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(126, 170, 186, 0.48);
  outline-offset: 3px;
}

.tool.is-active {
  background: var(--moss-deep);
  color: #fffaf0;
  border-color: rgba(53, 72, 39, 0.24);
}

.mode-rail {
  position: absolute;
  z-index: 3;
  top: 100px;
  left: 14px;
  width: 76px;
  display: grid;
  gap: 10px;
}

.mode {
  width: 76px;
  min-height: 82px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 9px;
  padding: 10px 8px;
  border-radius: var(--radius);
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.mode svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode span {
  font-size: 0.92rem;
  line-height: 1;
  color: inherit;
}

.mode.is-selected {
  color: var(--moss-deep);
  background: rgba(229, 232, 211, 0.8);
  border-color: rgba(80, 104, 54, 0.2);
}

.control-strip {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 86px;
  display: grid;
  grid-template-columns: minmax(465px, 1.7fr) repeat(3, minmax(170px, 1fr)) minmax(80px, 0.4fr);
  align-items: center;
  gap: 28px;
  padding: 18px 34px;
  border-top: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 251, 244, 0.86);
  box-shadow: 0 -22px 42px rgba(68, 58, 44, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.keys,
.slider,
.hold {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--ink);
}

.keys {
  gap: 8px;
  flex-wrap: nowrap;
  font-size: 0.98rem;
  font-weight: 600;
}

kbd {
  width: 28px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(43, 42, 36, 0.18);
  border-bottom-color: rgba(43, 42, 36, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 -1px 0 rgba(52, 45, 34, 0.08);
  color: #38382f;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1;
}

kbd.is-hit {
  color: white;
  background: var(--coral);
  border-color: rgba(160, 72, 54, 0.42);
}

.slider {
  gap: 12px;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.slider span:not(.mini-icon) {
  width: 52px;
}

.mini-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--moss);
  font-size: 1.25rem;
  line-height: 1;
}

.mini-icon.star {
  font-size: 1.6rem;
}

input[type="range"] {
  flex: 1;
  min-width: 118px;
  height: 28px;
  accent-color: var(--moss);
}

#sparkRange {
  accent-color: var(--coral);
}

#tempoRange {
  accent-color: var(--amber);
}

.hold {
  justify-content: flex-end;
  gap: 14px;
  font-size: 0.98rem;
  font-weight: 600;
}

.hold input {
  appearance: none;
  width: 52px;
  height: 28px;
  border: 1px solid rgba(42, 48, 36, 0.22);
  border-radius: 999px;
  background: rgba(81, 103, 55, 0.42);
  position: relative;
  transition: background-color 180ms ease;
}

.hold input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 2px 6px rgba(38, 34, 27, 0.22);
  transition: transform 180ms ease;
}

.hold input:checked {
  background: var(--moss-deep);
}

.hold input:checked::after {
  transform: translateX(23px);
}

@media (max-width: 980px) {
  .room {
    min-height: 700px;
  }

  .topbar {
    padding: 18px 18px 0 106px;
    align-items: flex-start;
  }

  .toolbar {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 226px;
  }

  .tool {
    width: 46px;
    height: 44px;
  }

  .mode-rail {
    width: 64px;
  }

  .mode {
    width: 64px;
    min-height: 70px;
  }

  .mode svg {
    width: 26px;
    height: 26px;
  }

  .control-strip {
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
    padding: 14px 18px;
  }

  .keys {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }

  .hold {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  body {
    overflow: auto;
  }

  .room {
    min-height: 760px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px 16px 0 86px;
  }

  .identity {
    display: block;
  }

  h1 {
    white-space: normal;
    font-size: 2rem;
  }

  .status {
    margin-top: 8px;
  }

  .toolbar {
    max-width: none;
    justify-content: start;
    gap: 7px;
  }

  .tool {
    width: 42px;
    height: 42px;
  }

  .mode-rail {
    top: 86px;
    left: 10px;
    width: 58px;
    gap: 8px;
  }

  .mode {
    width: 58px;
    min-height: 62px;
    gap: 6px;
    padding: 7px 4px;
  }

  .mode span {
    font-size: 0.78rem;
  }

  .control-strip {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px 14px 82px;
  }

  .slider,
  .hold {
    min-height: 32px;
  }

  .keys kbd {
    width: 25px;
    height: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
