:root {
  --mist: #d8dcdc;
  --ink: #14181b;
  --slate: #566064;
  --sand: #ece8de;
  --dim: #a9a69d;
  --serif: 'Gowun Batang', 'Iowan Old Style', Georgia, serif;
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #000; color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

/* Stage */
#stage { position: fixed; inset: 0; background: #000; color: var(--dim); font-size: 0.86rem; container-type: size; }
/* Frames for recording: 16 by 9, or an upright 9 by 16, in the middle of the window. The outline sits just outside it. */
#stage.reel { margin: auto; width: min(100vw, calc(100vh * 9 / 16)); height: min(100vh, calc(100vw * 16 / 9)); outline: 1px solid #2a2d2f; }
#stage.wide { margin: auto; width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16)); outline: 1px solid #2a2d2f; }
body:has(#stage.reel:not([hidden])) { background: #000; }
#stage[hidden] { display: none; }
#mount { position: absolute; inset: 0; display: grid; place-items: center; cursor: crosshair; touch-action: none; }
#mount canvas.square { width: min(84cqh, 92cqw); height: min(84cqh, 92cqw); display: block; }
/* In flight the picture takes the whole window, edge to edge. */
#mount canvas.square.fill { width: 100cqw; height: 100cqh; }
#mount .error { max-width: 28rem; padding: 2rem; color: var(--sand); font-size: 1rem; }
.tools, .readout, .foot, .lead, .by { position: absolute; margin: 0; z-index: 2; text-shadow: 0 0 12px #000, 0 0 3px #000; }
.tools { top: 1.1rem; right: 1.4rem; display: flex; align-items: center; gap: 1rem; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.tools a { color: var(--sand); text-decoration: none; padding: 0.1rem 0; }
.tools button { background: none; border: 0; padding: 0.1rem 0; font: inherit; color: var(--sand); cursor: pointer; border-bottom: 1px solid transparent; transition: opacity 0.2s; }
.tools .sound { display: flex; align-items: center; padding: 0.3rem 0; opacity: 0.55; }
.tools .sound[aria-pressed="true"] { opacity: 1; }
.tools .sound svg { display: block; overflow: visible; }
.foot { right: 1.4rem; bottom: 1.1rem; display: flex; align-items: center; gap: 1rem; font-size: 0.8rem; }
.foot button { background: none; border: 0; padding: 0.1rem 0; font: inherit; color: rgba(255, 255, 255, 0.77); cursor: pointer; border-bottom: 1px solid transparent; }
.foot [aria-pressed="true"] { border-bottom-color: currentColor; }
.foot [hidden] { display: none; }
.foot .view { padding: 0.3rem 0; border: 0; }
.foot .as, .foot .shape, .foot .angle, .foot .dice { display: flex; padding: 0.3rem 0; border: 0; }
.foot .as svg, .foot .shape svg, .foot .angle svg, .foot .dice svg { display: block; overflow: visible; }
.foot .drums { display: flex; padding: 0.3rem 0; border: 0; }
.foot .drums svg { display: block; overflow: visible; }
.foot .drums .h { transition: fill 0.2s; }
.foot .drums[aria-pressed="true"] .h { fill: currentColor; }
.foot .dice.roll svg { animation: roll 0.5s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes roll { from { transform: rotate(-200deg) scale(0.7); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .foot .dice.roll svg { animation: none; } }
.foot .shape g { display: none; }
.foot .shape[data-i="0"] g[data-i="0"], .foot .shape[data-i="1"] g[data-i="1"], .foot .shape[data-i="2"] g[data-i="2"], .foot .shape[data-i="3"] g[data-i="3"] { display: inline; }
.foot .as[aria-pressed="false"] .cells, .foot .as[aria-pressed="true"] .layers { display: none; }
/* What is playing is a word at the bottom left; the small icons keep the right. */
.lead { left: 1.4rem; bottom: 1.1rem; display: flex; align-items: center; gap: 0.9rem; }
.feat { background: none; border: 0; border-bottom: 1px solid transparent; padding: 0.1rem 0; font-family: var(--serif); font-size: 0.95rem; color: rgba(255, 255, 255, 0.77); cursor: pointer; }
.feat[aria-expanded="true"] { border-bottom-color: currentColor; }
/* Whose work it is, small, under the top buttons. */
.by { top: 2.75rem; right: 1.4rem; font-size: 0.72rem; color: var(--dim); pointer-events: none; }
/* The three dots sit beside the play word, large enough to find. */
.lead .menu { display: flex; align-items: center; background: none; border: 0; padding: 0.2rem 0.3rem; margin: -0.2rem -0.3rem; color: rgba(255, 255, 255, 0.77); cursor: pointer; }
.lead .menu svg { display: block; overflow: visible; transition: rotate 0.25s; }
.lead .menu[aria-expanded="true"] svg { rotate: 90deg; }
.foot .as[hidden] { display: none; }
.foot .view span { display: block; height: 0.72rem; border: 1px solid currentColor; transition: aspect-ratio 0.25s; }
.readout { font-size: 0.8rem; line-height: 1.3; left: 1.4rem; top: 1.38rem; max-width: calc(100cqw - 18.4rem); white-space: pre; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; pointer-events: none; }
.readout::first-line { color: var(--sand); }

/* One small word on arrival. It breaks into view, holds, and breaks up again. */
.touch { position: absolute; inset: 0; z-index: 2; margin: 0; display: grid; place-content: center; pointer-events: none; color: rgba(255, 255, 255, 0.77); mix-blend-mode: difference; font-size: 0.8rem; font-variant-caps: all-small-caps; letter-spacing: 0.32em; text-indent: 0.32em; text-shadow: 0 0 12px #000, 0 0 3px #000; opacity: 0; animation: touch 4.6s steps(1, end) 0.9s both; }
#stage.bare .touch { display: none; }
/* With a mouse there is nothing to be told: moving it already plays. */
@media (hover: hover) and (pointer: fine) { .touch { display: none; } }
#stage:has(.ask:not([hidden])) .touch { display: none; }
@keyframes touch {
  0% { opacity: 0; }
  2% { opacity: 1; translate: -9px 0; clip-path: inset(46% 0 50% 0); text-shadow: -3px 0 #f36, 3px 0 #3cf; }
  4% { opacity: 0; }
  6% { opacity: 1; translate: 6px 0; clip-path: inset(50% 0 47% 0); text-shadow: 2px 0 #f36, -2px 0 #3cf; }
  8% { opacity: 0.5; translate: -3px 1px; clip-path: inset(47% 0 49% 0); }
  9% { opacity: 0; }
  11%, 86% { opacity: 1; translate: 0 0; clip-path: none; text-shadow: 0 0 12px #000, 0 0 3px #000; }
  87% { opacity: 1; translate: 5px 0; clip-path: inset(49% 0 47% 0); text-shadow: -2px 0 #f36, 2px 0 #3cf; }
  89% { opacity: 0; }
  91% { opacity: 1; translate: -8px 0; clip-path: inset(46% 0 51% 0); text-shadow: 3px 0 #f36, -3px 0 #3cf; }
  93% { opacity: 0.4; translate: 2px -1px; clip-path: inset(50% 0 46% 0); }
  95%, 100% { opacity: 0; }
}
/* Arriving at a section by its address: PLAY flickers in and out until the first press, with a mouse too. */
.touch.press { display: grid; font-size: 1rem; animation: touch 3.4s steps(1, end) 0.5s infinite both; }
#stage.bare .touch.press { display: none; }
.touch.soon { display: grid; animation-delay: 0s; }
@media (prefers-reduced-motion: reduce) {
  .touch.press { animation: touch-plain 3.4s ease 0.5s infinite both; }
  .touch { animation: touch-plain 4.6s ease 0.9s both; }
  @keyframes touch-plain { 0%, 100% { opacity: 0; } 15%, 85% { opacity: 1; } }
}

/* Hum's two words, small, in the middle of the picture. */
.ask { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; text-align: center; pointer-events: none; text-shadow: 0 0 18px #000, 0 0 4px #000; }
.ask[hidden] { display: none; }
.ask p { margin: 0; }
.ask .big { font-size: 0.8rem; font-variant-caps: all-small-caps; letter-spacing: 0.32em; text-indent: 0.32em; color: rgba(255, 255, 255, 0.77); }
.ask .small { margin-top: 0.6rem; font-size: 0.62rem; font-variant-caps: all-small-caps; letter-spacing: 0.32em; text-indent: 0.32em; color: rgba(255, 255, 255, 0.77); }
#stage.bare .ask { display: none; }
/* In Sleep the sand dims slowly, so the screen does not keep anyone awake. */
#mount canvas { transition: opacity 1.5s; }
#stage.sleeping #mount canvas { opacity: 0.25; transition: opacity 90s linear 20s; }


/* With the controls hidden only the picture is left. The button to bring them back shows on hover. */
#stage:not(.open) .tone:not(.own), #stage.choose .own, #stage.choose .tone:not(.own), #stage.choose .journey, .own[hidden], #stage:not(.choose) .feats { display: none; }
/* What to play: a short list of names. */
.feats { position: absolute; left: 1.4rem; bottom: 3.4rem; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; text-shadow: 0 0 12px #000, 0 0 3px #000; }
.feats button { background: none; border: 0; border-bottom: 1px solid transparent; padding: 0.2rem 0 0.1rem; font-family: var(--serif); font-size: 0.95rem; color: var(--sand); opacity: 0.5; cursor: pointer; }
.feats button:hover { opacity: 0.85; }
.feats button[aria-pressed="true"] { opacity: 1; border-bottom-color: currentColor; }
#stage.bare .feats { display: none; }
.journey { position: absolute; left: 1.4rem; bottom: 3.1rem; z-index: 2; max-width: calc(100cqw - 2.8rem); display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; font-size: 0.74rem; text-shadow: 0 0 12px #000, 0 0 3px #000; transition: opacity 0.4s; }
.journey .chips { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 0.1rem 0.95rem; }
.journey .chips[hidden] { display: none; }
.journey button { background: none; border: 0; border-bottom: 1px solid transparent; padding: 0.3rem 0 0.1rem; font: inherit; color: var(--dim); cursor: pointer; white-space: nowrap; }
.journey button[aria-pressed="true"] { color: var(--sand); border-bottom-color: currentColor; }
#stage.bare .journey { display: none; }
.uli { position: absolute; z-index: 3; bottom: 1.1rem; height: 1.6rem; display: flex; align-items: center; gap: 0.7rem; color: rgba(255, 255, 255, 0.77); font-size: 0.8rem; text-shadow: 0 0 12px #000, 0 0 3px #000; transition: opacity 0.4s; }
.uli[hidden], #stage.bare .uli { display: none; }
#stage.idle .uli { opacity: 0; transition-duration: 2.5s; }
.uli button { background: none; border: 0; padding: 0.4rem 0.2rem; margin: -0.4rem -0.2rem; color: inherit; font: inherit; cursor: pointer; }
.uli .play { display: flex; }
.uli .play .stop, .uli .play.on .go { display: none; }
.uli .play.on .stop { display: inline; }
.uli .nm { font-family: var(--serif); font-size: 0.95rem; }
.uli .line { flex: 1; min-width: 1.5rem; height: 1.6rem; position: relative; cursor: pointer; touch-action: none; }
.uli .line::before, .uli .line i { content: ''; position: absolute; left: 0; top: 50%; height: 1px; background: #4a4d4f; width: 100%; }
.uli .line i { background: #fff; width: 0; }
.uli .line i::after { content: ''; position: absolute; right: -3px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.uli .open { color: var(--dim); border-bottom: 1px solid transparent; padding-bottom: 0.1rem; }
.uli .open[aria-expanded="true"] { color: rgba(255, 255, 255, 0.77); }
.uli .parts { display: none; position: absolute; right: 0; bottom: 2rem; flex-direction: column; align-items: flex-end; gap: 0.1rem; }
.uli .parts.on { display: flex; }
.uli .parts button { margin: 0; padding: 0.35rem 0 0.1rem; color: var(--dim); border-bottom: 1px solid transparent; white-space: nowrap; }
.uli .parts button[aria-pressed="true"] { color: rgba(255, 255, 255, 0.77); border-bottom-color: currentColor; }
@media (max-width: 700px) { .uli .parts button { padding: 0.5rem 0 0.1rem; font-size: 0.95rem; } }
#stage.open .journey, #stage.open .tone.own { bottom: calc(3.5rem + var(--menu-h, 0px)); }
#stage.idle .journey { opacity: 0; transition-duration: 2.5s; }
#stage.bare .readout, #stage.bare .tone, #stage.bare .foot, #stage.bare .lead, #stage.bare .by, #stage.bare .tools button:not(.hide), #stage.bare .tools a { display: none; }
#stage.bare .hide { opacity: 0; }
#stage.bare .hide:hover, #stage.bare .hide:focus-visible { opacity: 1; }


/* The pointer: a disc that inverts what is under it. */
.own-cursor, .own-cursor * { cursor: none !important; }
.cursor { position: fixed; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; color: #000; mix-blend-mode: difference; pointer-events: none; z-index: 10; opacity: 0; font: 18px/1 var(--sans); transition: scale 0.1s ease-out, opacity 0.3s; }
.cursor.on { opacity: 1; }
.cursor.over { scale: 1.3; }
.cursor.down { scale: 0.88; }
.cursor.over.down { scale: 1.15; }
/* Over a setting, a small mark beside the disc shows which way it will step. */
.cursor::after { position: absolute; top: 50%; translate: 0 -58%; color: rgba(255, 255, 255, 0.77); }
.cursor[data-d="-1"]::after { content: '‹'; right: calc(100% + 5px); }
.cursor[data-d="1"]::after { content: '›'; left: calc(100% + 5px); }

/* Left alone, the words fade and only the sand is left. Any movement or key brings them back. */
.tools, .tone, .readout, .foot, .feats, .lead, .by { transition: opacity 0.4s; }
#stage.idle .feats, #stage.idle .lead, #stage.idle .by, #stage.idle .tools, #stage.idle .tone, #stage.idle .readout, #stage.idle .foot { opacity: 0; transition-duration: 2.5s; }
#stage.idle .tone:has(:focus-visible), #stage.idle .tools:has(:focus-visible) { opacity: 1; }

/* Tone controls: what sets the tone, then each setting as a name and a value. The right half of a setting steps on, the left half steps back. */
.tone { position: absolute; left: 50%; translate: -50% 0; bottom: 3.4rem; width: min(13.5rem, calc(100cqw - 2.8rem)); text-shadow: 0 0 12px #000, 0 0 3px #000; z-index: 3; color: var(--sand); cursor: default; font-size: 0.8rem; line-height: 1.3; }
.tone .row[hidden] { display: none; }
.tone button { background: none; border: 0; padding: 0; font: inherit; color: var(--sand); cursor: pointer; }
.tone .src { display: flex; justify-content: space-between; margin-bottom: 0.55rem; }
.tone .src button { font-family: var(--serif); font-size: 0.95rem; opacity: 0.45; padding: 0.1rem 0; border-bottom: 1px solid transparent; }
.tone .src button:hover { opacity: 0.8; }
.tone .src button[aria-pressed="true"] { opacity: 1; border-bottom-color: currentColor; }
.tone .row { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 0.45rem; padding: 0.22rem 0; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.tone .row.wide { justify-content: flex-end; }
.tone .row span { color: var(--dim); transition: color 0.2s; }
.tone .row:hover span { color: var(--sand); }
.tone .row output { white-space: nowrap; }
/* Small arrows either side of a value say it can be stepped through. */
.tone .row output::before { content: '‹'; margin-right: 0.5em; color: var(--dim); }
.tone .row output::after { content: '›'; margin-left: 0.5em; color: var(--dim); }
.tone .row button { position: absolute; top: 0; bottom: 0; width: 50%; outline-offset: 0; }
.tone .row button:first-of-type { left: 0; cursor: w-resize; }
.tone .row button:last-of-type { right: 0; cursor: e-resize; }
/* The options open straight above the three dots that call them, on the left. */
.tone:not(.own) { left: 1.4rem; translate: none; bottom: 3.1rem; }
/* The chosen play's own settings sit over its word, on the left. */
.tone.own { left: 1.4rem; translate: none; bottom: 2.9rem; width: min(9.5rem, calc(100cqw - 2.8rem)); }
.tone.own .row.wide { justify-content: flex-start; }
.tone .say { color: var(--dim); font-size: 0.74rem; margin: 0.5rem 0 0; }
/* The setting the arrow keys are on: its name brightens, a small dot sits before it, and its arrows show. */
.tone .row.keyed { outline: none !important; }
.tone .row.keyed span, .tone .row.keyed output::before, .tone .row.keyed output::after { color: var(--sand); }
.tone .row.keyed::before { content: ''; position: absolute; left: -0.75rem; top: 50%; width: 3px; height: 3px; margin-top: -1.5px; border-radius: 50%; background: var(--sand); }
#stage.idle .tone:has(.keyed) { opacity: 1; }
.tone .say:empty { display: none; }


/* On a phone the picture always takes the whole screen: no recording frames. */
@media (pointer: coarse) and (max-width: 700px) { .tools { gap: 0.8rem; } .tools .frame { display: none; } .readout { max-width: calc(100cqw - 15rem); } }
.by a { pointer-events: auto; text-decoration: none; padding: 0.4rem 0; }
.by a:hover, .by a:focus-visible { color: var(--sand); }
.tools .hide[hidden] { display: none; }
