/* Layout: one 9:16 stage (the reel) laid out like a lab instrument — HUD counters, title,
   a polar "rhythm scope", a per-scene readout and a scrolling multitrack lane view.
   Phone: controls under the stage, no sound choices. Desktop: controls on both sides.
   Sizes inside the stage are in cqw (percent of the stage width) so it scales as one picture. */
:root {
  color-scheme: dark;
  --void: #07060b;
  --line: rgba(232, 226, 255, 0.16);
  --dim: rgba(232, 226, 255, 0.55);
  --fg: #ece8ff;
  --amber: #ffc53d; /* alfaia, main hand */
  --ember: #ff5a36; /* alfaia, answer hand */
  --ice: #3fd7ff; /* caixa */
  --magenta: #ff4fa3; /* agbê */
  --split-pink: rgba(255, 79, 163, 0.75);
  --split-cyan: rgba(63, 215, 255, 0.75);
  --f-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --gutter: 16px;
  --controls-height: 190px; /* room kept under the stage on phones */
  --desktop-side: 340px;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--void);
  color: var(--fg);
  font-family: var(--f-display);
  box-sizing: border-box;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-block: max(var(--gutter), env(safe-area-inset-top, 0px)) max(var(--gutter), env(safe-area-inset-bottom, 0px));
}
.wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  flex: none;
  width: min(100%, calc((100dvh - var(--controls-height)) * 9 / 16));
  min-width: min(100%, 300px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  container-type: inline-size;
  background: var(--void);
  border-radius: 12px;
  overflow: hidden;
  isolation: isolate;
}
.stage canvas {
  position: absolute;
  display: block;
}
#fx,
#bg {
  inset: 0;
  width: 100%;
  height: 100%;
}
#fx {
  z-index: -3;
}
#bg {
  z-index: -2;
}
.stage::after {
  /* scanlines */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px);
}
.inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 5cqw 5cqw 4.5cqw;
  gap: 2cqw;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 2cqw;
  font-family: var(--f-mono);
  font-size: 2.3cqw;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}
.hud b {
  color: var(--fg);
  font-weight: 700;
}
.hud .r {
  text-align: right;
}

/* fixed height: the title shrinks to fit long words, and that must never move the wheel */
.head {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.6cqw;
  height: 17cqw;
  flex: none;
}
.eyebrow {
  min-height: 1.2em;
  font-family: var(--f-mono);
  font-size: 2.5cqw;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}
.title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 13cqw;
  line-height: 0.9;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  transform-origin: left center;
  min-height: 0.9em;
  /* its chromatic split is drawn by src/title.js every frame, from TINTS */
}

.scope {
  position: relative;
  width: 74cqw;
  aspect-ratio: 1;
  align-self: center;
  max-width: 100%;
  flex: none;
  margin-block: -1cqw;
}
.scope svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* ---------- readout ---------- */
.read {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.4cqw;
  font-family: var(--f-mono);
  font-size: 2.6cqw;
}
.read .k {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 2.2cqw;
}
.read .big {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 9cqw;
  line-height: 1;
  text-transform: uppercase;
}
.read .row {
  display: flex;
  justify-content: space-between;
  gap: 2cqw;
  align-items: baseline;
}
.notation {
  display: grid;
  grid-template-columns: 13cqw 1fr 12cqw;
  gap: 0.4cqw 2cqw;
  align-items: center;
}
.notation .seq {
  letter-spacing: 0.12em;
  white-space: nowrap;
  font-size: 2.9cqw;
}
.notation .n {
  text-align: right;
  color: var(--dim);
  font-size: 2.2cqw;
}
.notation.tight {
  gap: 0.1cqw 2cqw;
}
.notation.tight .seq {
  font-size: 2.5cqw;
}
.notation.tight .k,
.notation.tight .n {
  font-size: 2cqw;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2cqw;
  text-align: center;
}
.stats.two {
  grid-template-columns: 1fr 1fr;
}
.stats b {
  display: block;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 11cqw;
  line-height: 1;
}
.stats.small b {
  font-size: 8cqw;
}
.stats b small {
  font-size: 5cqw;
  opacity: 0.6;
}
.score {
  position: relative;
  width: 100%;
}
.score svg {
  width: 100%;
  height: auto;
  display: block;
}
.score .scur {
  position: absolute;
  top: 6%;
  bottom: 6%;
  width: 0.4cqw;
  margin-left: -0.2cqw;
  background: var(--fg);
  opacity: 0.55;
  border-radius: 1cqw;
  box-shadow: 0 0 1.2cqw var(--fg);
}
.fade {
  animation: fade 0.35s ease-out both;
}
@keyframes fade {
  from {
    opacity: 0.2;
    transform: translateX(-1.2cqw);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lanes {
  position: relative;
  height: 37cqw;
  flex: none;
  border-top: 1px solid var(--line);
}
.lanes canvas {
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ---------- controls (outside the reel) ---------- */
.side {
  width: min(100%, 720px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  font-family: var(--f-mono);
}
.sounds,
.keys {
  display: none;
} /* phones: no sound choices */
.brand {
  /* phones: hidden from view but kept as the page's heading for screen readers */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.brand h1 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 44px;
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-shadow:
    -2px 0 0 var(--split-pink),
    2px 0 0 var(--split-cyan);
}
.brand p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--dim);
}
.trow {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
#play {
  background: var(--amber);
  color: var(--void);
  border: 0;
  border-radius: 99px;
  padding: 10px 24px;
  font-weight: 700;
  font-size: 14px;
  min-width: 130px;
}
#play:disabled {
  opacity: 0.6;
  cursor: progress;
}
#play:focus-visible,
.chip:focus-visible,
a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}
#clock {
  font-size: 13px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.chip {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--dim);
}
.chip:hover {
  border-color: var(--dim);
  color: var(--fg);
}
.chip[aria-current="true"],
.chip[aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
}
.lbl {
  font-size: 12px;
  color: var(--dim);
  margin: 0;
}
.sound {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.foot {
  font-size: 11px;
  color: var(--dim);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
}
.foot a {
  color: var(--dim);
}

/* ---------- desktop: the reel fills the height, controls on both sides ---------- */
@media (min-width: 900px) {
  .wrap {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    height: 100%;
  }
  .stage {
    order: 2;
    width: auto;
    height: 100%;
    min-width: 0;
  }
  .side {
    width: var(--desktop-side);
    align-items: flex-start;
    gap: 18px;
    max-height: 100%;
    overflow-y: auto;
    padding-top: 8px;
    /* room for the focus ring, which the scroll box would clip, without moving the controls */
    padding-left: 4px;
    margin-left: -4px;
  }
  .side.left {
    order: 1;
  }
  .side.right {
    order: 3;
  }
  .brand {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
  }
  .keys {
    display: block;
  }
  .sounds {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .trow,
  .chips,
  .foot {
    justify-content: flex-start;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fade {
    animation: none;
  }
}
