.immersive-room {
  --room-x: 0.5;
  --room-y: 0.5;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
  border-bottom: 1px solid var(--line);
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
}

.room-side {
  position: sticky;
  top: 72px;
  z-index: 2;
  display: grid;
  height: calc(100vh - 72px);
  overflow: hidden;
  place-items: center;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(to right, rgba(251, 250, 245, 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(251, 250, 245, 0.16) 1px, transparent 1px),
    var(--ink);
  background-size: 72px 72px;
  color: var(--paper);
}

.room-side h2 {
  margin: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.room-side-left h2 {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.room-side-right {
  display: none;
  border-right: 0;
  border-left: 1px solid rgba(251, 250, 245, 0.4);
}

.room-side-right h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0;
}

.room-core {
  position: relative;
  min-height: calc(100vh - 72px);
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(to right, rgba(251, 250, 245, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(251, 250, 245, 0.12) 1px, transparent 1px),
    var(--ink);
  background-size: 72px 72px;
}

.room-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.room-badge {
  position: absolute;
  top: clamp(1rem, 4vw, 2.4rem);
  right: clamp(1rem, 5vw, 4rem);
  z-index: 1;
  width: clamp(8rem, 18vw, 18rem);
  filter: invert(1);
  opacity: 0.13;
  pointer-events: none;
}

.room-content {
  position: relative;
  z-index: 2;
  max-width: 74rem;
  padding: clamp(2rem, 6vw, 5rem);
}

.room-content p {
  margin: 0;
}

.room-content h1 {
  margin: clamp(1.8rem, 5vw, 3rem) 0 0;
  font-size: clamp(4.4rem, 12vw, 11rem);
  font-weight: 950;
  line-height: 0.74;
  letter-spacing: -0.09em;
  text-transform: uppercase;
}

.room-content h1 + p {
  max-width: 24rem;
  margin-top: clamp(2.4rem, 8vh, 5rem);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.05;
}

.room-warning {
  display: inline-grid;
  min-height: 2.6rem;
  align-items: center;
  margin-top: 1.5rem;
  border: 1px solid rgba(251, 250, 245, 0.48);
  padding: 0 0.85rem;
  background: rgba(251, 250, 245, 0.08);
}

.room-panel {
  position: relative;
  z-index: 3;
  width: auto;
  max-width: 24rem;
  margin: 0 clamp(1rem, 6vw, 4rem) 13rem;
  border: 1px solid rgba(251, 250, 245, 0.55);
  background: rgba(9, 9, 9, 0.72);
  backdrop-filter: blur(10px);
}

.room-panel > p {
  margin: 0;
  border-bottom: 1px solid rgba(251, 250, 245, 0.4);
  padding: 0.9rem 1rem;
}

.room-audio-button {
  display: flex;
  width: 100%;
  min-height: 4rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(251, 250, 245, 0.4);
  padding: 0 1rem;
  text-transform: uppercase;
}

.room-audio-button:hover,
.room-audio-button:focus-visible,
.room-audio-button.is-playing {
  background: var(--paper);
  color: var(--ink);
}

.room-readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.room-readouts span {
  display: grid;
  min-height: 5.25rem;
  align-content: center;
  gap: 0.55rem;
  border-right: 1px solid rgba(251, 250, 245, 0.4);
  padding: 0.75rem;
}

.room-readouts span:last-child {
  border-right: 0;
}

.room-readouts strong,
.room-readouts small {
  display: block;
}

.room-readouts strong {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 400;
  line-height: 0.85;
}

.room-strip {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: grid;
  border-top: 1px solid rgba(251, 250, 245, 0.34);
  background: rgba(9, 9, 9, 0.72);
  backdrop-filter: blur(12px);
}

.room-strip article {
  min-height: 8.5rem;
  border-bottom: 1px solid rgba(251, 250, 245, 0.3);
  padding: 1rem;
}

.room-strip article:last-child {
  border-bottom: 0;
}

.room-strip h2 {
  max-width: 22rem;
  margin: 1.85rem 0 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.room-strip .text-button {
  margin-top: 1.6rem;
  border-color: rgba(251, 250, 245, 0.5);
}

.room-board,
.room-engineer,
.room-tools {
  display: grid;
  border-bottom: 1px solid var(--line);
  background-color: var(--paper);
}

.room-section-index,
.room-engineer > div:not(.engineer-float-system),
.board-surface,
.tool-cloud {
  padding: clamp(1.25rem, 4vw, 2rem);
}

.room-section-index {
  border-bottom: 1px solid var(--line);
}

.room-section-index h2,
.room-engineer h2 {
  margin: 1.4rem 0 0;
  font-size: clamp(3rem, 7vw, 5.8rem);
  font-weight: 950;
  line-height: 0.78;
  letter-spacing: -0.08em;
  text-transform: uppercase;
}

.room-section-index h2 {
  max-width: 18rem;
}

.board-surface {
  --board-x: 0.5;
  --board-y: 0.5;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 34rem;
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.board-channel {
  --level: 0.5;
  --pan: 0.5;
  position: relative;
  display: grid;
  min-height: 16rem;
  align-content: space-between;
  overflow: hidden;
  background:
    linear-gradient(to right, rgba(9, 9, 9, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(9, 9, 9, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  padding: 1rem;
  transition: background-color 180ms ease;
}

.board-channel::before {
  content: "";
  position: absolute;
  left: calc(12% + var(--pan) * 76%);
  bottom: 2.4rem;
  width: 1px;
  height: 5.5rem;
  background: var(--ink);
  opacity: 0.28;
  transform: translateX(-50%);
}

.board-channel::after {
  content: "";
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 0.5rem;
  height: calc(var(--level) * 72%);
  background: var(--ink);
}

.board-channel p {
  margin: 0;
}

.board-channel input {
  width: 100%;
  accent-color: var(--ink);
}

.board-channel.is-room-linked::before {
  opacity: 0.52;
}

.board-channel span {
  display: block;
  width: 3rem;
  height: 0.32rem;
  background: var(--red);
}

.board-channel:nth-child(2) span {
  background: var(--blue);
}

.board-channel:nth-child(3) span {
  background: var(--yellow);
}

.board-channel:nth-child(4) span {
  background: var(--green);
}

.board-meter {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  z-index: 2;
  display: flex;
  width: min(26rem, 60%);
  height: 7rem;
  align-items: center;
  justify-content: space-between;
  transform: translateX(-50%);
  pointer-events: none;
}

.board-meter span {
  width: 1px;
  height: 28%;
  background: var(--ink);
  opacity: 0.35;
  transform-origin: center;
  animation: board-meter 1.3s ease-in-out infinite;
}

.board-surface.is-room-linked .board-meter span {
  animation: none;
}

.board-meter span:nth-child(3n) {
  height: 72%;
}

.board-meter span:nth-child(4n) {
  background: var(--blue);
  animation-delay: 120ms;
}

.board-meter span:nth-child(5n) {
  background: var(--red);
  animation-delay: 220ms;
}

.room-engineer {
  --engineer-x: 0.5;
  --engineer-y: 0.5;
  --engineer-energy: 0.55;
  --engineer-shift-x: 0rem;
  --engineer-shift-y: 0rem;
  --engineer-float-x: 0rem;
  --engineer-float-y: 0rem;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(to right, rgba(251, 250, 245, 0.13) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(251, 250, 245, 0.13) 1px, transparent 1px),
    var(--ink);
  background-size: 72px 72px;
  color: var(--paper);
}

.engineer-particle-field {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.95;
  pointer-events: none;
}

.room-engineer > div:not(.engineer-float-system) {
  position: relative;
  z-index: 3;
  border-bottom: 1px solid rgba(251, 250, 245, 0.24);
}

.engineer-float-system {
  position: absolute;
  top: calc(clamp(1rem, 5vw, 3rem) + var(--engineer-shift-y));
  right: calc(clamp(1rem, 7vw, 6rem) - var(--engineer-shift-x));
  z-index: 2;
  display: grid;
  width: min(42rem, 48vw);
  min-width: 18rem;
  height: clamp(9rem, 16vw, 15rem);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: center;
  border: 1px solid rgba(251, 250, 245, 0.22);
  background:
    linear-gradient(to right, rgba(251, 250, 245, 0.09) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(251, 250, 245, 0.09) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.86;
  pointer-events: none;
  transform: translate3d(var(--engineer-float-x), var(--engineer-float-y), 0) skewX(-8deg);
  animation: engineer-float 9s ease-in-out infinite;
}

.engineer-float-system::before,
.engineer-float-system::after {
  content: "";
  position: absolute;
  inset: 18% 8%;
  border: 1px solid rgba(251, 250, 245, 0.28);
  border-radius: 50%;
  transform: scaleX(1.8);
}

.engineer-float-system::after {
  inset: 36% 14%;
  border-color: rgba(251, 250, 245, 0.2);
  transform: scaleX(2.2);
}

.engineer-float-system span {
  justify-self: center;
  width: 1px;
  height: 40%;
  background: rgba(251, 250, 245, 0.68);
  transform-origin: center;
  animation: engineer-bar 2.4s ease-in-out infinite;
}

.engineer-float-system span:nth-child(3n) {
  height: 68%;
  background: rgba(31, 120, 255, 0.62);
  animation-delay: 160ms;
}

.engineer-float-system span:nth-child(4n) {
  height: 54%;
  background: rgba(250, 60, 47, 0.58);
  animation-delay: 280ms;
}

.engineer-float-system span:nth-child(5n) {
  height: 62%;
  background: rgba(48, 188, 108, 0.6);
  animation-delay: 420ms;
}

.engineer-copy {
  display: grid;
  align-content: end;
  gap: 1rem;
  min-height: 22rem;
}

.engineer-copy p {
  max-width: 34rem;
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.12;
}

.tool-cloud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 36rem;
  gap: 1rem;
  perspective: 1000px;
}

.tool-cloud article {
  position: relative;
  display: grid;
  min-height: 14rem;
  align-content: space-between;
  border: 1px solid var(--line);
  background: rgba(251, 250, 245, 0.86);
  padding: 1rem;
  transform: translateY(var(--float-y, 0)) rotateX(var(--tool-x, 0deg)) rotateY(var(--tool-y, 0deg));
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.tool-cloud article:hover,
.tool-cloud article:focus-within {
  background: var(--ink);
  color: var(--paper);
}

.tool-cloud article:nth-child(2) {
  --float-y: 2rem;
}

.tool-cloud article:nth-child(3) {
  --float-y: -1rem;
}

.tool-cloud article:nth-child(4) {
  --float-y: 1rem;
}

.tool-cloud p,
.tool-cloud strong {
  margin: 0;
}

.tool-cloud strong {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 0.82;
  letter-spacing: -0.08em;
  text-transform: uppercase;
}

@keyframes board-meter {
  0%,
  100% {
    transform: scaleY(0.62);
  }

  50% {
    transform: scaleY(1.18);
  }
}

@keyframes engineer-float {
  0%,
  100% {
    transform: translate3d(var(--engineer-float-x), var(--engineer-float-y), 0) skewX(-8deg);
  }

  50% {
    transform: translate3d(
        calc(var(--engineer-float-x) - 1.2rem),
        calc(var(--engineer-float-y) + 0.9rem),
        0
      )
      skewX(-8deg);
  }
}

@keyframes engineer-bar {
  0%,
  100% {
    transform: scaleY(0.62);
    opacity: 0.5;
  }

  50% {
    transform: scaleY(1.2);
    opacity: 0.9;
  }
}

@media (min-width: 900px) {
  .immersive-room {
    grid-template-columns: 104px minmax(0, 1fr) 120px;
  }

  .room-side-right {
    display: grid;
  }

  .room-panel {
    position: absolute;
    top: clamp(1rem, 4vw, 2.25rem);
    right: clamp(1rem, 4vw, 2.5rem);
    width: min(22rem, 30vw);
    max-width: none;
    margin: 0;
  }

  .room-content {
    padding-right: min(34vw, 27rem);
  }

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

  .room-strip article {
    border-right: 1px solid rgba(251, 250, 245, 0.3);
    border-bottom: 0;
  }

  .room-strip article:last-child {
    border-right: 0;
  }

  .room-board {
    grid-template-columns: minmax(20rem, 0.35fr) minmax(0, 1fr);
  }

  .room-board {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.35fr);
  }

  .room-board .board-surface {
    grid-column: 1;
    grid-row: 1;
  }

  .room-board .room-section-index {
    grid-column: 2;
    grid-row: 1;
    border-right: 0;
    border-left: 1px solid var(--line);
  }

  .room-section-index {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .room-engineer {
    grid-template-columns: minmax(0, 1fr) minmax(24rem, 0.72fr);
    min-height: 34rem;
    align-items: stretch;
  }

  .room-engineer > div:not(.engineer-float-system) {
    border-right: 1px solid rgba(251, 250, 245, 0.24);
    border-bottom: 0;
  }

  .room-tools {
    grid-template-columns: minmax(20rem, 0.35fr) minmax(0, 1fr);
  }

  .tool-cloud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

}

@media (max-width: 520px) {
  .immersive-room {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .room-side-left h2 {
    font-size: clamp(1.8rem, 8vw, 2.4rem);
  }

  .room-content {
    padding: 1.4rem;
  }

  .room-content h1 {
    font-size: clamp(4rem, 18vw, 5.2rem);
  }

  .room-content h1 + p {
    margin-top: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .room-canvas {
    cursor: default;
  }
}
