:root {
  --bg: #ffffff;
  --ink: #0e0f12;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

#track { width: 1px; }

/* The artwork sits between the section navigation and the controls; the page colour fills the rest. */
#stage, #fx {
  position: fixed;
  left: 0;
  top: 52px;
  width: 100vw;
  height: calc(100vh - 52px - 68px);
  height: calc(100dvh - 52px - 68px);
  display: block;
}

/* Keyframe reference number, shown only at rest */
#kf {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: baseline;
  gap: 10px;
  font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 2;
}
#kf b { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
#kf span { opacity: 0.55; font-weight: 500; }
#kf em { font: 500 13px/1 ui-sans-serif, system-ui, -apple-system, sans-serif; font-style: normal; margin-left: 6px; }

/* Slanted to the mark's 16 degree angle */
#controls {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  z-index: 2;
}

#controls button {
  width: 52px;
  height: 44px;
  border: 0;
  padding: 0;
  background: var(--ink);
  color: var(--bg);
  transform: skewX(-16deg);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.2s, transform 0.15s;
}

#controls button svg {
  width: 22px;
  height: 22px;
  transform: skewX(16deg);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: square;
}

#controls button:hover { transform: skewX(-16deg) translateY(-2px); }
#controls button:active { transform: skewX(-16deg) translateY(0); }
#controls button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
#controls button:disabled { opacity: 0.2; cursor: default; transform: skewX(-16deg); }

#fx { pointer-events: none; }

#progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: transparent;
}

#progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ink);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* Section navigation along the top */
#sections {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  gap: 4px;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#sections::-webkit-scrollbar { display: none; }
#sections button {
  flex: none;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 13px/1 ui-sans-serif, system-ui, -apple-system, sans-serif;
  padding: 8px 10px 9px;
  cursor: pointer;
  opacity: 0.5;
  position: relative;
  transition: opacity 0.2s;
}
#sections button small {
  font: 500 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  margin-left: 5px;
  opacity: 0.7;
  letter-spacing: 0.02em;
}
#sections button:hover { opacity: 0.85; }
#sections button[aria-current="true"] { opacity: 1; }
#sections button[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 2px;
  background: var(--ink);
  transform: skewX(-16deg);
}
#sections button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; opacity: 1; }
#stage, #fx { transition: opacity 0.18s ease; }

/* Cover hint: arrow keys on desktop, swipe on touch screens */
#hint {
  position: fixed;
  right: calc(max(16px, env(safe-area-inset-right)) + 136px);
  bottom: max(20px, env(safe-area-inset-bottom));
  height: 44px;
  margin: 0;
  display: flex;
  align-items: center;
  color: var(--ink);
  font: 500 13px/1 ui-sans-serif, system-ui, -apple-system, sans-serif;
  opacity: 0.75;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 2;
}
#hint.gone { opacity: 0; }
#hint kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  margin-right: 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font: inherit;
}
#hint kbd:first-of-type { margin-left: 8px; }
#hint kbd:last-of-type { margin-right: 0; }
#hint .touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  #hint .keys { display: none; }
  #hint .touch { display: inline; }
}
@media (max-width: 600px) {
  #hint { right: max(16px, env(safe-area-inset-right)); bottom: calc(max(20px, env(safe-area-inset-bottom)) + 52px); }
}
