@font-face { font-family: Syne; src: url("assets/syne.woff2") format("woff2"); font-weight: 400 800; font-display: swap }
@font-face { font-family: Bricolage; src: url("assets/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap }
* { box-sizing: border-box }
:root { color-scheme: dark; --ink: #f3f5fa; --muted: #a8aeBC; --panel: #11141d; --edge: #444954; --accent: #c5c1ff; --mono: ui-monospace, "SFMono-Regular", Consolas, monospace; color: var(--ink); background: #080910; font: 15px Bricolage, sans-serif }
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none }
body { margin: 0; background: #080910 }
main { position: fixed; inset: 0; height: 100%; height: 100dvh; overflow: hidden }
.stage { width: 100%; height: 100%; position: relative; overflow: hidden; isolation: isolate; background: #080910; container-type: inline-size }
.stage, .stage * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent }
canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab }
canvas.dragging { cursor: grabbing }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent }
button:focus-visible, input:focus-visible + span, canvas:focus-visible { outline: 2px solid #fff; outline-offset: -3px }
canvas:focus:not(:focus-visible) { outline: none }
@media (pointer: coarse) { body[data-view=playing] canvas:focus { outline: none } }
[hidden] { display: none !important }
.sr { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap }
.overlay { --gutter: clamp(16px,5.5cqw,36px); position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: max(26px,calc(env(safe-area-inset-top) + 14px)) var(--gutter) max(26px,calc(env(safe-area-inset-bottom) + 18px)); opacity: 1; transition: opacity 760ms cubic-bezier(.4,0,.2,1), visibility 0s }
.mast { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; transition: transform 720ms ease }
h1 { min-width: 0; margin: 0; font: 800 clamp(28px,11cqw,76px)/.84 Syne,sans-serif; letter-spacing: -.065em; text-transform: uppercase; transform: skewX(-5deg); text-shadow: 0 3px 20px #08091088 }
.console { position: relative; display: grid; gap: 10px; width: 100%; transition: transform 720ms ease }
.overlay { padding-left: max(var(--gutter),env(safe-area-inset-left)); padding-right: max(var(--gutter),env(safe-area-inset-right)); touch-action: none }
.mast, .console { width: 100%; max-width: 520px; margin-inline: auto }
.overlay.departing { opacity: 0; visibility: hidden; pointer-events: none; transition-delay: 0s, 760ms }
.overlay.departing .console { transform: translateY(10px) }
.overlay p { margin: 0 0 6px; color: var(--accent); font: 12px var(--mono) }
.overlay p:empty { display: none }
/* The same softly rounded surfaces carry the active song colour through the controls. */

button, .settings summary { transition: transform 150ms ease-out, background-color 180ms, border-color 180ms, color 180ms }
button:active, .settings summary:active { transform: scale(.98) }
button:focus-visible, .settings summary:focus-visible { outline: 2px solid #fff; outline-offset: 2px }
.resume { min-height: 54px; width: 100%; border: 0; border-radius: 17px; background: var(--accent); color: #11141b; font: 710 19px Bricolage,sans-serif }
.settings { position: absolute; z-index: 3; top: max(7px,env(safe-area-inset-top)); right: max(8px,env(safe-area-inset-right)); transition: opacity 360ms ease-in-out, visibility 0s }
.settings[inert] { opacity: 0; visibility: hidden; pointer-events: none; transition-delay: 0s, 360ms }
.settings summary { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: #d7dae2; cursor: pointer; list-style: none }
.settings summary::-webkit-details-marker { display: none }
.settings[open] summary { color: var(--accent); background: #20232c }
@media (max-width: 540px) { h1 { font-size: clamp(28px,9.3cqw,49px) } }
.settings .setup-controls { position: absolute; top: calc(100% + 8px); right: 0; padding: 5px; display: grid; gap: 2px; width: min(210px,78vw); max-height: calc(100dvh - 120px - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; border: 1px solid #ffffff29; border-radius: 18px; background: #151821; box-shadow: 0 12px 30px #0005 }
.setup-controls :is(button,a) { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px; border-radius: 11px; border: 0; background: transparent; color: var(--ink); text-align: left; text-decoration: none; font: 550 14px Bricolage,sans-serif }
#restart-level { flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; min-height: 54px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none }
#restart-level small { color: #bbc0cc; font-size: 12px; font-variant-numeric: tabular-nums }
.setup-controls [aria-pressed]::after { content: ''; width: 25px; height: 15px; border-radius: 9px; background: radial-gradient(circle at 7.5px 50%,#bec2cc 4.5px,transparent 5px),#373b46 }
.setup-controls [aria-pressed=true]::after { background: radial-gradient(circle at 17.5px 50%,#171923 4.5px,transparent 5px),var(--accent) }
@media (hover: hover) { .resume:hover { filter: brightness(1.06) } .setup-controls :is(button,a):hover, .settings summary:hover { background-color: #343843 } }
@media (max-height: 620px) { .overlay { padding-top: max(10px,env(safe-area-inset-top)); padding-bottom: max(48px,calc(env(safe-area-inset-bottom) + 44px)) } .console { gap: 5px } }
@media (max-height: 440px) and (orientation: landscape) { .overlay { flex-direction: row; align-items: flex-end; gap: 16px } .mast { align-self: flex-start } h1 { font-size: 30px } .console { max-width: 52% } }
@media (prefers-reduced-motion: reduce) { .overlay, .mast, .console { transition: none } }

.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 59% 59% at 50% 52%, transparent 42%, rgba(2, 3, 8, .16) 66%, rgba(2, 3, 8, .62) 90%, rgba(2, 3, 8, .88) 116%) }
@media (prefers-reduced-motion: reduce) {
  button, .settings summary { transition: none }
  button:active, .settings summary:active { transform: none }
}



main { display: flex; flex-direction: column }
.stage { flex: 1; min-height: 0 }
#menu-banner { flex: none; display: grid; place-items: center; min-height: calc(var(--banner-height, 50px) + 12px + env(safe-area-inset-bottom)); padding: 12px 0 env(safe-area-inset-bottom); background: #080910 }


body[data-view=result] .overlay { background: linear-gradient(180deg,#090b15ee 0%,#0c0e19b8 15%,transparent 40%,transparent 48%,#0b0d16d9 70%,#0a0b12 96%); animation: result-fade .32s ease-out both }
body[data-view=result] .console { animation: result-rise .38s cubic-bezier(.16,.8,.28,1) both }
@keyframes result-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes result-rise { from { transform: translateY(8px) } to { transform: translateY(0) } }
@media (prefers-reduced-motion: reduce) {
  body[data-view=result] .overlay { animation-duration: .14s }
  body[data-view=result] .console { animation: none }
}

@property --level-sweep {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
.level-hud {
  position: absolute;
  z-index: 2;
  top: max(7px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  --hud-width: min(140px, 40vw);
  --slot-step: calc((var(--hud-width) + 48px) / 4);
  width: var(--hud-width);
  display: grid;
  grid-template-columns: 1fr 48px 1fr;
  grid-template-rows: 46px 14px;
  align-items: center;
  justify-items: center;
  pointer-events: none;
  color: #f2f1f8;
  font-variant-numeric: tabular-nums;
  isolation: isolate;
}
.level-hud::before {
  content: '';
  position: absolute;
  inset: -8px -8px -5px;
  z-index: -1;
  background: radial-gradient(ellipse closest-side, #0c0d18f5 48%, #0c0d1800);
}
.level-token {
  grid-area: 1 / 2;
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  transform: translateX(var(--slot, 0px)) scale(var(--size, 1));
}
.level-token strong { position: relative; font: 650 20px/1 Bricolage, sans-serif; letter-spacing: -.04em; }
.level-token.previous, .level-token.next { --size: .6; color: #c1c3ce; }
.level-token.previous { --slot: calc(-1 * var(--slot-step)); --level-sweep: 270deg; }
.level-token.next { --slot: var(--slot-step); }
.level-dial {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #1e2130 0%, #10121bf5 63%, #10121b00 71%);
  transition: --level-sweep 140ms linear;
}
.level-token.previous .level-dial { opacity: 0; }
.level-dial::before, .level-dial::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
.level-dial::before {
  background: conic-gradient(from 225deg, var(--accent) var(--level-sweep), #676b7e var(--level-sweep) 270deg, transparent 270deg);
}
.level-dial::after {
  inset: 6px;
  opacity: .55;
  background: repeating-conic-gradient(from 225deg, #e1e3ee 0deg 2deg, transparent 2deg 22.5deg);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 50%, 0 100%);
}
.level-rail {
  grid-area: 1 / 1;
  justify-self: end;
  width: 13px;
  height: 1px;
  margin-inline: 1px;
  background: linear-gradient(to right, #676b7e33, #a3a9b68c);
}
.level-rail.next { grid-column: 3; justify-self: start; transform: scaleX(-1); }
.level-hud[data-level="1"] .previous { visibility: hidden; }
.level-departed {
  grid-area: 1 / 1;
  color: #c1c3ce;
  opacity: 0;
  font: 650 12px/1 Bricolage, sans-serif;
}
.level-count {
  grid-area: 2 / 1 / 3 / 4;
  align-self: start;
  padding: 1px 6px 2px;
  border-radius: 8px;
  background: #10121be8;
  white-space: nowrap;
  font: 550 12px/1.1 Bricolage, sans-serif;
  color: #acafbf;
}
.level-count b { color: #f0eff6; font-weight: 650; }
/* Keep the completed dial and the full count together before swapping slots. */
.level-hud.complete, .shifting .previous { --accent: #f5d38b; }
.complete .level-count, .complete .level-count b, .complete #level-label { color: #f5d38b; }
.complete .level-count { background: #27221a; }
.shifting .level-dial { transition: none; }
@media (prefers-reduced-motion: no-preference) {
  .level-hud.shifting { --slide: 650ms cubic-bezier(.32,0,.18,1) backwards; }
  .shifting .level-token { animation: level-slide var(--slide); }
  .shifting .level-token.previous { --from-slot: 0px; --from-size: 1; }
  .shifting .level-token.current { --from-slot: var(--slot-step); --from-size: .6; }
  .shifting .level-token.next {
    --from-slot: calc(var(--slot-step) + 9px);
    --from-size: .6;
    animation: level-slide var(--slide), level-appear var(--slide);
  }
  .shifting .current .level-dial { animation: level-appear var(--slide); }
  .shifting .previous .level-dial { animation: level-dismiss var(--slide); }
  .shifting .level-departed { animation: level-exit 310ms ease-out backwards; }
}
@keyframes level-slide {
  from { transform: translateX(var(--from-slot)) scale(var(--from-size)); }
}
@keyframes level-appear { 0%, 12% { opacity: 0; } to { opacity: 1; } }
@keyframes level-dismiss { 0%, 18% { opacity: 1; } to { opacity: 0; } }
@keyframes level-exit { from { opacity: 1; } to { opacity: 0; transform: translateX(-9px); } }
@media (prefers-reduced-motion: reduce) {
  .level-dial { transition: none; }
  .level-hud.shifting #level-label { color: var(--accent); }
}
body:not([data-view=ready]):not([data-view=playing]):not(.course-complete) .level-hud { visibility:hidden }
@media (prefers-reduced-motion: reduce) { .settings, .settings[inert] { transition:none } }

body[data-view=ready] .overlay, .overlay.in-circle { pointer-events:none }
body[data-view=ready] :is(.settings,#open-shop), .overlay.in-circle :is(.settings,#open-shop) { pointer-events:auto }


#balance { position:absolute; z-index:3; right:max(14px,env(safe-area-inset-right)); top:max(12px,env(safe-area-inset-top)); padding:5px 9px; border-radius:12px; color:#f6d27c; background:#16151cdb; font:600 13px Bricolage,sans-serif; pointer-events:none }
body[data-view=result] .mast { padding-top:25px }

#shop { width:min(420px,92vw); max-height:80dvh; overflow:auto; overscroll-behavior:contain; touch-action:pan-y; padding:22px; border:1px solid #51515f; border-radius:22px; background:#15161e; color:var(--ink) }
#shop::backdrop { background:#05060bba }
#shop header,#shop-items section { display:flex; align-items:center; justify-content:space-between; gap:10px }
#shop h2 { margin:0; font:650 30px Bricolage,sans-serif }
#shop-wallet { color:#f6d27c }
#shop-items section { padding:11px 0; border-top:1px solid #ffffff20 }
#shop-items small { display:block; color:#b9b7c7; margin-top:3px }
#shop button { border:1px solid #ffffff30; border-radius:11px; min-height:42px; padding:6px 12px; background:#272934 }
#shop button:disabled { color:#a5a4b1; opacity:.72 }
#shop-message { min-height:1em; color:var(--accent) }

.review-replay { align-self: center; padding: 8px 16px; color: #d7dae2; font: 500 14px Bricolage,sans-serif; }

.course-complete .level-hud { z-index: 2; }
body.course-complete[data-view=result] .mast { margin-block: auto; padding-top: 0; justify-content: center; text-align: center; }
