:root {
    color-scheme: dark;
    --background: #10161d;
    --surface: #17212b;
    --well: #0b111a;
    --line: #334454;
    --text: #edf2f1;
    --muted: #a7b9c4;
    --accent: #a8e0cb;
    font: 16px/1.5 system-ui, sans-serif;
    background: var(--background);
    color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .22em; }
button, select, input { font: inherit; }
button, select {
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    min-height: 44px;
}
button { padding: .4rem .8rem; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.top, main { width: min(100% - 40px, 1040px); margin-inline: auto; }
.top {
    min-height: 62px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    font-size: .88rem;
}
.wordmark { font-weight: 750; letter-spacing: .035em; text-decoration: none; color: var(--text); }
.wordmark span { color: var(--accent); }
main { padding: clamp(27px, 5vw, 58px) 0 65px; }
h1, h2, h3, p, figure { margin: 0; }
h1 { font-size: clamp(2.45rem, 6vw, 4.5rem); line-height: 1.03; letter-spacing: -.055em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); letter-spacing: -.035em; line-height: 1.18; }
h3 { font-size: 1.15rem; }
.lede { color: var(--muted); margin-top: .65rem; }
.pickers { display: grid; align-items: start; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; max-width: 560px; margin-top: 1.5rem; }
.pickers label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); min-width: 0; }
#facing-note { margin-top: 4px; color: var(--muted); font-size: .78rem; }
select { width: 100%; padding: .5rem; font-size: 1rem; }
.environment { max-width: 64ch; margin-top: 1rem; color: var(--muted); }
#status:not(:empty) { margin-top: 1rem; color: var(--accent); }
#walkthrough > section { margin-top: 2rem; }
.section-heading, .viewport-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading { margin-bottom: .65rem; }
.viewport {
    background: var(--well);
    border: 1px solid var(--line);
    border-radius: 10px 10px 0 0;
    overflow: clip;
    display: grid;
    place-items: center;
    --view-size: clamp(246px, 64vw, 360px);
    height: var(--view-size);
    position: relative;
}
.viewport canvas { height: var(--view-size); width: var(--view-size); max-width: 100%; display: block; touch-action: none; cursor: grab; }
.viewport canvas:active { cursor: grabbing; }
.viewport canvas:focus-visible { outline-offset: -3px; }
#mesh-fallback { position: absolute; color: var(--muted); }
.viewport-footer { padding: 4px .7rem; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
.viewport-footer p { margin-right: auto; color: var(--muted); font-size: .82rem; }
.viewport-footer button { min-width: 44px; border: 0; font-size: 1.25rem; }
.phase-nav {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    gap: 10px;
    align-items: center;
    width: min(100%, 35rem);
    margin: .65rem auto .6rem;
    text-align: center;
}
.phase-nav button { padding-inline: 0; font-size: 1.2rem; }
.phase-nav button[aria-disabled="true"] { opacity: .45; cursor: default; }
#phase-count, #phase-caption { color: var(--muted); font-size: .88rem; }
#phase-caption { max-width: 52ch; min-height: 2.65em; margin: .55rem auto 0; text-align: center; }
.phase-view {
    --well-height: clamp(255px, 76vw, 408px);
    --peek-size: clamp(42px, 8vw, 104px);
    height: var(--well-height);
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    overflow: clip;
    touch-action: pan-y pinch-zoom;
}
.phase-preview, .layer-thumb, .composite, .sprite-stage {
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    overflow: clip;
}
.phase-preview {
    grid-area: 1 / 1;
    width: 76%;
    height: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    transform: translateX(calc(var(--offset) * (90% + 6px))) scale(.76);
    position: relative;
    --art-position: 50%;
    visibility: hidden;
    opacity: .68;
}
.phase-preview[data-near] { visibility: visible; }
.phase-preview[data-side="previous"] { --art-position: calc(100% - var(--peek-size) / 2 - 4px); }
.phase-preview[data-side="next"] { --art-position: calc(var(--peek-size) / 2 + 4px); }
.phase-preview[aria-hidden="false"] { transform: none; opacity: 1; }
.phase-view[data-motion] .phase-preview {
    transition: transform 190ms ease-out, opacity 190ms ease-out, visibility 190ms;
}
.checker {
    background-color: var(--well);
    background-image: conic-gradient(#17212a 25%, transparent 0 50%, #17212a 0 75%, transparent 0);
    background-size: 16px 16px;
}
.checker canvas {
    display: block;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    width: min(var(--tile-width), 100%, calc(var(--well-height) * var(--tile-ratio)));
    height: auto;
}
.phase-preview canvas {
    position: absolute;
    top: 50%;
    left: var(--art-position);
    width: min(var(--tile-width), calc(100% - 24px), calc((var(--well-height) - 24px) * var(--tile-ratio)));
    transform: translate(-50%, -50%);
}
.phase-preview[data-side] canvas { width: min(var(--peek-size), calc(var(--peek-size) * var(--tile-ratio))); }
.phase-view[data-motion] .phase-preview canvas { transition: left 190ms ease-out, width 190ms ease-out; }
@media (prefers-reduced-motion: reduce) {
    .phase-view[data-motion] .phase-preview,
    .phase-view[data-motion] .phase-preview canvas { transition: none; }
}
.layers-section > p { margin-top: .4rem; color: var(--muted); font-size: .92rem; }
.layer-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(125px, .75fr); gap: 14px; align-items: start; margin-top: .8rem; }
.layer-workspace figure { min-width: 0; }
.layer-workspace figcaption { color: var(--muted); font-size: .78rem; text-align: center; padding-top: 6px; }
#layers { display: grid; gap: 6px; }
.layer {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px;
    align-items: center;
}
.layer-thumb { --well-height: 48px; width: 42px; height: var(--well-height); border-radius: 3px; }
.layer label { display: flex; align-items: center; gap: 6px; font-size: .82rem; min-height: 30px; cursor: pointer; }
.layer input { accent-color: var(--accent); }
.layer input[type="range"] { display: block; width: min(100%, 180px); height: 26px; margin: 0; }
.layer input[type="checkbox"] { margin: 0; flex: none; }
.composite, .sprite-stage { --well-height: 200px; height: var(--well-height); border: 1px solid var(--line); border-radius: 7px; }
.sprite { margin-top: .7rem; display: grid; grid-template-columns: minmax(115px, .75fr) minmax(0, 1fr); gap: 16px; align-items: center; }
.transport { display: grid; justify-items: start; gap: .5rem; }
.transport p { font-size: .88rem; color: var(--muted); }
@media (max-width: 540px) {
    .top, main { width: calc(100% - 28px); }
    .phase-preview { width: 78%; }
    .composite, .sprite-stage { --well-height: 152px; }
    #walkthrough > section { margin-top: 1.5rem; }
}
