:root {
  --ground: #050506; --ink: #ecece8; --dim: rgba(236,236,232,.64); --faint: rgba(236,236,232,.4);
  --hair: rgba(236,236,232,.17); --veil: rgba(5,5,6,.84); --err: #e7a39b;
  --font: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(16px, 3vw, 44px);
  color-scheme: dark;
}
:root[data-paper="light"] {
  --ground: #f4f4f1; --ink: #101012; --dim: rgba(16,16,18,.66); --faint: rgba(16,16,18,.44);
  --hair: rgba(16,16,18,.18); --veil: rgba(244,244,241,.86); --err: #a8322a;
  color-scheme: light;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--ground); color: var(--ink);
  font-family: var(--font); font-weight: 300; -webkit-font-smoothing: antialiased;
  transition: background-color .5s ease, color .5s ease;
}
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: var(--cur, grab) }
canvas#c.drag { cursor: var(--grab, grabbing) }
#hud { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none }
#veil { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; mix-blend-mode: difference; opacity: 0 }
#veil .thin { stroke: #fff; stroke-width: 1; fill: none; opacity: .5; vector-effect: non-scaling-stroke }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit; text-transform: inherit }
button:focus-visible, label:focus-within, #pad:focus-visible { outline: 1px solid var(--dim); outline-offset: 4px }
html, button, label, .seg, .mbar, #foot, .joinbox { touch-action: manipulation }

.ui { transition: opacity .6s ease }
body.hide-ui .ui, body.joining .ui, body.gated .ui, body.gated .brand { opacity: 0; pointer-events: none }

/* the way in: one click starts the music and the site together */
.gate { position: fixed; inset: 0; z-index: 9; cursor: pointer; transition: opacity .9s cubic-bezier(.16,1,.3,1) }
body:not(.gated) .gate { opacity: 0; pointer-events: none }
.enter { position: absolute; left: 50%; top: calc(50% + clamp(84px, 11vw, 150px)); transform: translate(-50%, 10px); opacity: 0;
  display: flex; align-items: center; gap: 16px; padding: 15px 18px 15px 20px; border: 1px solid var(--dim);
  font-size: 10px; font-weight: 500; letter-spacing: .34em; color: var(--ink); white-space: nowrap;
  animation: enterIn 1.2s cubic-bezier(.16,1,.3,1) 1.4s forwards;
  transition: background-color .35s cubic-bezier(.16,1,.3,1), color .35s cubic-bezier(.16,1,.3,1), border-color .35s ease }
.enter .bars { width: 13px; height: 10px; fill: currentColor }
.enter .bars rect { transform-origin: 50% 100%; transform-box: fill-box; animation: eq 1.1s cubic-bezier(.45,0,.55,1) infinite alternate }
.enter .bars rect:nth-child(2) { animation-duration: .8s; animation-delay: -.3s }
.enter .bars rect:nth-child(3) { animation-duration: 1.3s; animation-delay: -.6s }
.enter .bars rect:nth-child(4) { animation-duration: .95s; animation-delay: -.2s }
.enter .jarrow { width: 16px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1 }
.gate:hover .enter, .enter:focus-visible { background: var(--ink); color: var(--ground); border-color: var(--ink) }
@keyframes enterIn { to { opacity: 1; transform: translate(-50%, 0) } }
@media (prefers-reduced-motion: reduce) { .enter { animation: none; opacity: 1; transform: translate(-50%, 0) } .enter .bars rect { animation: none } }
.brand, .foot, .corner, .cue { text-shadow: 0 0 6px var(--ground), 0 0 2px var(--ground) }

/* top left */
.brand { position: fixed; left: var(--pad); top: calc(var(--pad) + env(safe-area-inset-top, 0px)); display: grid; gap: 10px; z-index: 3; pointer-events: none }
.name { font-weight: 500; font-size: 15px; letter-spacing: .6em }
.status { font-size: 9px; letter-spacing: .3em; color: var(--faint); font-variant-numeric: tabular-nums; line-height: 1.9; text-transform: uppercase; max-width: min(62vw, 430px) }

/* top right */
.corner { position: fixed; right: var(--pad); top: calc(var(--pad) + env(safe-area-inset-top, 0px)); z-index: 3; pointer-events: none; display: grid; justify-items: end; gap: 18px }
.corner .label { font-weight: 500; font-size: 11px; letter-spacing: .32em; padding-left: .32em }

/* join the resistance: the button on the stage, the field full screen */
.joinbtn { pointer-events: auto; text-shadow: none; display: flex; align-items: center; gap: 16px; padding: 15px 18px 15px 20px; border: 1px solid var(--dim); font-size: 10px; font-weight: 500; letter-spacing: .34em; color: var(--ink); background: color-mix(in srgb, var(--ground) 55%, transparent); transition: background-color .35s cubic-bezier(.16,1,.3,1), color .35s cubic-bezier(.16,1,.3,1), border-color .35s ease }
.joinbtn:hover, .joinbtn:focus-visible { background: var(--ink); color: var(--ground); border-color: var(--ink) }
.jarrow { width: 16px; height: 10px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.2; transition: transform .35s cubic-bezier(.16,1,.3,1) }
.joinbtn:hover .jarrow, #jgo:hover:not(:disabled) .jarrow { transform: translateX(4px) }

.cue { position: fixed; left: 50%; bottom: calc(var(--foot-gap, 140px) + 8px); transform: translateX(-50%); z-index: 3; display: grid; justify-items: center; gap: 10px; font-size: 9px; letter-spacing: .42em; padding: 6px 0 6px .42em; color: var(--dim); transition: opacity .6s ease, color .3s ease }
.cue:hover { color: var(--ink) }
.cue svg { width: 10px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.1; animation: cue 2.4s cubic-bezier(.16,1,.3,1) infinite }
@keyframes cue { 0% { transform: translateY(-3px); opacity: 0 } 30% { opacity: 1 } 70% { transform: translateY(4px); opacity: 1 } 100% { transform: translateY(6px); opacity: 0 } }
body[data-scene="cover"] .cue { opacity: 0; pointer-events: none }

.joinbox { position: fixed; inset: 0; z-index: 10; opacity: 0; transition: opacity .5s cubic-bezier(.16,1,.3,1);
  background: radial-gradient(ellipse 62% 34% at 50% calc(var(--jtop, 52vh) + 90px), color-mix(in srgb, var(--ground) 82%, transparent), transparent 72%) }
.joinbox.open { opacity: 1 }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0 }
.joinbox .join { position: absolute; left: 50%; top: var(--jtop, 52vh); width: min(560px, calc(100vw - 32px)); display: grid; gap: 12px; transform: translate(-50%, 16px); transition: transform .8s cubic-bezier(.16,1,.3,1) }
.joinbox.open .join { transform: translate(-50%, 0) }
.jhud, .jfoot { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-size: 9px; letter-spacing: .3em; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap }
#jstate { color: var(--ink); transition: color .3s ease }
#jstate.bad { color: var(--err) }
.jfield { position: relative; display: flex; align-items: center; gap: 16px; padding: 14px 14px 14px 20px }
.br { position: absolute; width: 12px; height: 12px; border: 0 solid var(--ink); opacity: .9; transition: transform .7s cubic-bezier(.16,1,.3,1), opacity .4s ease }
.b1 { left: 0; top: 0; border-left-width: 1px; border-top-width: 1px; transform: translate(-14px, -14px) }
.b2 { right: 0; top: 0; border-right-width: 1px; border-top-width: 1px; transform: translate(14px, -14px) }
.b3 { left: 0; bottom: 0; border-left-width: 1px; border-bottom-width: 1px; transform: translate(-14px, 14px) }
.b4 { right: 0; bottom: 0; border-right-width: 1px; border-bottom-width: 1px; transform: translate(14px, 14px) }
.joinbox.open .br { transform: none; transition-delay: .25s }
.jfield:focus-within .br { opacity: 1 }
.join input[type=email] {
  flex: 1; min-width: 0; font: inherit; font-weight: 300; font-size: clamp(18px, 2.1vw, 23px); letter-spacing: .08em; color: var(--ink); caret-color: var(--ink);
  background: transparent; border: 0; padding: 8px 0; outline: none; border-radius: 0;
}
.join input::placeholder { color: var(--dim); letter-spacing: .34em; font-size: 11px }
.join .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0 }
#jgo { display: flex; align-items: center; gap: 12px; padding: 11px 14px 11px 16px; border: 1px solid var(--dim); font-size: 10px; font-weight: 500; letter-spacing: .34em; color: var(--ink); white-space: nowrap; transition: background-color .3s cubic-bezier(.16,1,.3,1), color .3s cubic-bezier(.16,1,.3,1), border-color .3s ease }
#jgo:hover:not(:disabled), #jgo:focus-visible { background: var(--ink); color: var(--ground); border-color: var(--ink) }
#jgo:disabled { opacity: .45; cursor: default }
.jruler { position: relative; height: 8px; opacity: .75;
  background: linear-gradient(var(--dim), var(--dim)) bottom / 100% 1px no-repeat,
              repeating-linear-gradient(90deg, var(--dim) 0 1px, transparent 1px 8px) bottom / 100% 4px no-repeat,
              repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 56px) bottom / 100% 8px no-repeat }
#jfill { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.16,1,.3,1) }
.jnote { margin: 0; letter-spacing: .2em }
.jmsg { margin: 0; min-height: 1.7em; color: var(--dim); font-size: 11px; letter-spacing: .16em; line-height: 1.7 }
.jmsg.bad { color: var(--err) }
.join.done .jfield, .join.done .jruler, .join.done .jfoot { display: none }
.join.done .jmsg { color: var(--ink); font-size: 13px; letter-spacing: .3em; text-transform: uppercase; text-align: center; padding-top: 8px }
.jclose { position: absolute; top: calc(var(--pad) + env(safe-area-inset-top, 0px)); right: var(--pad); display: flex; gap: 10px; font-size: 9px; letter-spacing: .3em; padding: 10px 0 10px .3em; color: var(--dim) }
.jclose:hover { color: var(--ink) }

/* the LUNA header waits for the cover; the small TL;DR in sand leads it */
body:not([data-scene="cover"]) .brand { opacity: 0; pointer-events: none }
.brand { pointer-events: none }
.mark { display: block; width: 320px; height: 44px; margin: -6px 0 0 -2px; pointer-events: auto }   /* the word is 136 wide; the rest is room for its tail */
.mark canvas { display: block; width: 100%; height: 100%; pointer-events: none }
@media (max-width: 759px) { .mark { width: 132px; height: 30px } }   /* short tail on phones: the label starts at ~146px */

/* sound */
#sound { pointer-events: auto; display: flex; align-items: center; gap: 10px; font-size: 8.5px; letter-spacing: .3em; color: var(--dim); padding: 4px 0 4px .3em }
#sound:hover, #sound.on { color: var(--ink) }
#sound .bars { width: 13px; height: 10px; fill: currentColor }
#sound .bars rect { transform-origin: 50% 100%; transform: scaleY(.18); transform-box: fill-box }
#sound.on .bars rect { animation: eq 1.1s cubic-bezier(.45,0,.55,1) infinite alternate }
#sound.on .bars rect:nth-child(2) { animation-duration: .8s; animation-delay: -.3s }
#sound.on .bars rect:nth-child(3) { animation-duration: 1.3s; animation-delay: -.6s }
#sound.on .bars rect:nth-child(4) { animation-duration: .95s; animation-delay: -.2s }
@keyframes eq { from { transform: scaleY(.2) } to { transform: scaleY(1) } }
@media (prefers-reduced-motion: reduce) { .cue svg, #sound.on .bars rect { animation: none } .joinbox, .joinbox .join, .br { transition: none } }

.hint { position: fixed; left: 50%; top: calc(var(--pad) * .42 + env(safe-area-inset-top, 0px)); transform: translateX(-50%); font-size: 10px; letter-spacing: .42em; color: var(--dim); pointer-events: none; transition: opacity .8s ease; text-align: center; white-space: nowrap; z-index: 3; max-width: max(280px, calc(100vw - 2 * var(--pad) - 640px)); overflow-wrap: anywhere }
@media (max-width: 1500px) { .hint { white-space: normal; line-height: 2 } }
.toast { position: fixed; left: 50%; top: calc(var(--pad) + 64px); transform: translateX(-50%); z-index: 12; font-size: 11px; letter-spacing: .14em; line-height: 1.7; color: var(--ink); max-width: min(560px, calc(100vw - 32px)); text-align: center; transition: opacity .6s ease; pointer-events: none }

/* bottom */
.foot { position: fixed; left: var(--pad); right: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px)); z-index: 3; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 32px; font-size: 10px; letter-spacing: .32em; color: var(--dim); pointer-events: none }
.foot > * { pointer-events: auto }
.foot button:hover, .foot label:hover { color: var(--ink) }
.transport { display: grid; gap: 10px; justify-items: start }
.transport button { display: flex; align-items: center; gap: 12px }
.key { color: var(--faint); font-size: 9px; letter-spacing: .26em }
.tri { width: 0; height: 0; border-left: 7px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; display: block }
.rdot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid currentColor; display: block }
.rdot.lit { background: var(--ink) }
.score { display: grid; gap: 14px; flex: 1 1 520px; max-width: 640px }
.sens { display: flex; flex-wrap: wrap; gap: 10px 26px }
.sens label { display: flex; align-items: center; gap: 12px; font-size: 9px; letter-spacing: .26em; color: var(--faint); cursor: default }
input[type=range] { -webkit-appearance: none; appearance: none; width: 86px; height: 18px; background: transparent; cursor: pointer; margin: 0 }
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--hair) }
input[type=range]::-moz-range-track { height: 1px; background: var(--hair) }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); margin-top: -4px; border: 0 }
input[type=range]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); border: 0 }
input[type=range]:focus-visible { outline: 1px solid var(--dim); outline-offset: 3px }
.layers { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between }
.seg { display: flex; align-items: center; gap: 14px; font-size: 9px; letter-spacing: .26em }
.seg > span { color: var(--faint) }
.seg button { color: var(--faint); padding-bottom: 3px; border-bottom: 1px solid transparent; transition: color .3s, border-color .3s }
.seg button.on { color: var(--ink); border-bottom-color: var(--dim) }
.padbox { display: grid; gap: 8px; justify-items: start; font-size: 9px; letter-spacing: .26em; color: var(--faint) }
#pad { width: 66px; height: 66px; display: block; cursor: crosshair; touch-action: none; overflow: hidden }
#pad .fr { fill: none; stroke: var(--hair); stroke-width: 1; vector-effect: non-scaling-stroke }
#pad #pdSide { fill: var(--ink); opacity: .11 }
#pad #pdLine { stroke: var(--ink); stroke-width: 1.2; vector-effect: non-scaling-stroke }
#pad #pdStem { stroke: var(--dim); stroke-width: 1; vector-effect: non-scaling-stroke }
#pad #pdTip { fill: var(--ink) }
#pad .end { fill: var(--ground); stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke }

/* phones */
.mbar { display: none }
@media (max-width: 759px) {
  .joinbtn { padding: 12px 14px 12px 16px; gap: 12px; font-size: 9px }
  .cue { bottom: calc(76px + 16px + env(safe-area-inset-bottom, 0px)) }
  .mbar { display: flex; position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 4; align-items: center; justify-content: space-between; font-size: 10px; letter-spacing: .3em; color: var(--dim); height: 44px }
  .mrow { display: flex; gap: 22px }
  .mbtn { display: flex; align-items: center; gap: 10px; min-height: 44px }
  #sheetBtn { min-height: 44px }
  .chev { display: inline-block; transition: transform .3s }
  body.sheet .chev { transform: rotate(180deg) }
  .foot { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); background: var(--veil); border: 1px solid var(--hair); padding: 16px; flex-direction: column; align-items: stretch; gap: 16px; display: none }
  body.sheet .foot { display: flex }
  body.sheet .joinbtn, body.sheet .cue { display: none }
  .transport { display: none }
  .score { flex: none; max-width: none }
  .sens { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px }
  .sens label { justify-content: space-between }
  .sens input[type=range] { width: 100%; max-width: 96px }
  .seg { flex-wrap: wrap; row-gap: 8px }
  .hint { top: auto; bottom: calc(76px + 150px + env(safe-area-inset-bottom, 0px)); white-space: normal; width: calc(100vw - 32px); letter-spacing: .3em; font-size: 9px }
  .status { display: none }
}
