@font-face {
    font-family: "Viceroy Script";
    src: url("assets/fonts/title-script.ttf") format("truetype");
    font-weight: 400 700;
    font-display: swap;
}
:root {
    color-scheme: dark;
    font-family: "Instrument Sans", system-ui, sans-serif;
    color: #f5ebdf;
    background: #100e18;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}
body {
    margin: 0;
    min-height: 100dvh;
    padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
        max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: radial-gradient(ellipse at 73% 0%, #332036, transparent 56%);
}
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, a:focus-visible, canvas:focus-visible {
    outline: 2px solid #65dfc6;
    outline-offset: 3px;
}
.cabinet { width: min(100%, 1180px); margin: 0 auto; }
.toolbar {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.brand {
    font-weight: 820;
    font-size: 0.88rem;
    letter-spacing: 0.09em;
    color: inherit;
    text-decoration: none;
}
.actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.actions button, .artwork-loading button {
    border: 1px solid #524354;
    border-radius: 5px;
    min-height: 38px;
    padding: 0 11px;
    background: #1e1827;
    color: #faefde;
    font: 600 0.8rem "Instrument Sans", system-ui, sans-serif;
    cursor: pointer;
}
.actions button:hover, .artwork-loading button:hover { background: #312539; }
.stage {
    --scene-edge: max(7px, 2.2%);
    --scene-bottom: max(7px, 4%);
    --scene-actions-width: min(23.5%, 86px);
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    isolation: isolate;
    overflow: hidden;
    border: 1px solid #493447;
    border-radius: 9px;
    background: #100e18;
    box-shadow: 0 20px 70px #07050d88;
}
.playfield { position: relative; }
.playfield:fullscreen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #100e18;
}
.playfield:fullscreen .stage {
    flex: none;
    width: min(100%, calc(100dvh * 16 / 9));
    border: 0;
    border-radius: 0;
}
canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.intro-title {
    position: absolute;
    top: 50%;
    left: 3%;
    width: min(67%, 930px);
    overflow: visible;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}
.stage:not([data-launch="playing"]) .intro-title {
    top: 44%;
}
.intro-print {
    font: 1000 78px "Arial Black", "Barlow Condensed", Impact, sans-serif;
    letter-spacing: -0.03em;
    fill: #fff7df;
    stroke: #191022;
    stroke-width: 8px;
    stroke-linejoin: round;
    paint-order: stroke fill;
    filter: drop-shadow(5px 7px #180e20);
    animation: print-arrival 0.64s cubic-bezier(.19,.82,.27,1) both;
}
.intro-lettering {
    font: 700 111px "Viceroy Script", cursive;
    fill: url("#title-neon");
    stroke: #411237;
    stroke-width: 4px;
    paint-order: stroke fill;
    filter: drop-shadow(1px 2px #ffc9de) drop-shadow(4px 6px #31112f);
    animation: neon-write 1.03s 0.43s cubic-bezier(.21,.68,.25,1) both;
}
.intro-crown {
    transform-box: fill-box;
    transform-origin: center bottom;
    filter: drop-shadow(2px 3px #31112f);
    animation: crown-seat .41s .57s both;
}
.crown-flash, .crown-shard {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}
.crown-shard { stroke: #38192f; stroke-width: 1.15; }
.stage:is([data-launch="shattering"], [data-launch="ready"], [data-launch="playing"]) .intro-crown {
    animation: crown-break .58s both;
}
.stage:is([data-launch="shattering"], [data-launch="ready"], [data-launch="playing"]) .crown-shard {
    animation: crown-shatter .37s .46s both;
}
.stage:is([data-launch="shattering"], [data-launch="ready"], [data-launch="playing"]) .crown-flash {
    animation: crown-impact .22s .46s both;
}
.stage[data-launch="playing"] .intro-crown { animation-delay: 2.88s; }
.stage[data-launch="playing"] :is(.crown-flash, .crown-shard) { animation-delay: 3.34s; }
@keyframes print-arrival {
    from { opacity: 0; transform: translate(-18px, 18px) scale(.91); }
    to { opacity: 1; transform: none; }
}
@keyframes neon-write {
    from { opacity: .2; clip-path: inset(-16px 100% -30px -12px); }
    to { opacity: 1; clip-path: inset(-16px -22px -30px -12px); }
}
@keyframes crown-seat {
    from { opacity: 0; transform: translateY(-9px) rotate(-12deg); }
    to { opacity: 1; transform: none; }
}
@keyframes crown-break {
    0% { opacity: 1; transform: none; }
    23% { opacity: 1; transform: translate(4px, -4px) rotate(24deg); }
    79% { opacity: 1; transform: translate(72px, 118px) rotate(146deg); }
    80%, 100% { opacity: 0; transform: translate(72px, 118px) rotate(146deg); }
}
@keyframes crown-shatter {
    from { opacity: 1; transform: none; }
    67% { opacity: 1; }
    to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); }
}
@keyframes crown-impact {
    0% { opacity: 0; transform: scale(.45); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: scale(1.63); }
}
.cover {
    --title-poster: url("assets/panels/title.png");
    position: absolute;
    inset: 0;
    display: grid;
    align-items: end;
    padding: clamp(15px, 5vw, 56px);
    background: linear-gradient(90deg, #110d19f2 0%, #160e20d9 30%, #190f24a0 52%, transparent 83%),
        linear-gradient(0deg, #170f1be8, transparent 45%),
        #472037 var(--title-poster) center center / cover;
}
@media (pointer: coarse) {
    .cover { --title-poster: url("assets/panels/mobile/0.webp"); }
}
.cabinet[data-profile="mobile"] .cover { --title-poster: url("assets/panels/mobile/0.webp"); }
.artwork-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    background: #151021ee;
    text-align: center;
}
.artwork-loading p { margin: 0; font-size: 0.9rem; }
.loader {
    width: min(260px, 70vw);
    padding: 11px 13px 12px;
    background: #190f23ed;
    border-left: 3px solid #f5aaca;
    box-shadow: 4px 4px #170d20a8;
}
.loader-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .6rem;
    font-size: .82rem;
    font-weight: 720;
}
#percent { color: #ffd175; font-variant-numeric: tabular-nums; }
.loader progress {
    display: block;
    appearance: none;
    width: 100%;
    height: 5px;
    margin-top: 8px;
    border: 0;
    border-radius: 2px;
    background: #51334e;
    accent-color: #ffd175;
}
.loader progress::-webkit-progress-bar { background: #51334e; border-radius: 2px; }
.loader progress::-webkit-progress-value { background: #ffd175; border-radius: 2px; }
.loader progress::-moz-progress-bar { background: #ffd175; border-radius: 2px; }
.stage[data-launch="ready"] .play { animation: play-arrival .4s cubic-bezier(.2,.72,.3,1) both; }
@keyframes play-arrival {
    from { opacity: 0; transform: translateY(11px); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    :is(.intro-print, .intro-lettering, .intro-crown, .crown-flash, .crown-shard, .play) {
        animation: none !important;
    }
    .stage:is([data-launch="shattering"], [data-launch="ready"]) .intro-crown { opacity: 0; }
}
.play {
    display: inline-grid;
    place-content: center;
    min-height: 46px;
    padding: 0 21px;
    font: 800 1rem "Instrument Sans", system-ui, sans-serif;
    color: #271622;
    background: #ffc565;
    border: 0;
    border-radius: 4px;
    box-shadow: 4px 4px #251726;
    cursor: pointer;
}
.play:disabled { opacity: 0.72; cursor: progress; }
.play:not(:disabled):hover { background: #ffdb90; }
.status { color: #fff4e8; margin: 0.85rem 0 0; font-size: 0.86rem; }
.status:empty { display: none; }
.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin: 13px 0 0;
    color: #cfc0d1;
    font-size: 0.79rem;
}
kbd {
    display: inline-block;
    padding: 1px 4px;
    background: #251d2d;
    color: #f8e8d8;
    border: 1px solid #483a4b;
    border-radius: 3px;
}
.touch-instruction { display: none; }
.touch-deck {
    width: 100%;
    margin: 9px auto 0;
    padding: 8px;
    border: 1px solid #493447;
    border-radius: 9px;
    background: #1a1423;
    user-select: none;
    -webkit-user-select: none;
}
.drive-deck {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-inline: max(0px, calc((100% - 490px) / 2));
    touch-action: none;
}
.touch-stick {
    width: clamp(92px, 27vw, 116px);
    aspect-ratio: 1;
    flex: none;
    display: grid;
    place-items: center;
    position: relative;
    border: 2px solid #50b4a9;
    border-radius: 50%;
    background:
        linear-gradient(to right, transparent 49%, #64bfb338 50%, transparent 51%),
        linear-gradient(to bottom, transparent 49%, #64bfb338 50%, transparent 51%),
        radial-gradient(circle, #252739, #10232ce8);
    touch-action: none;
}
.stick-knob {
    pointer-events: none;
    width: 37%;
    height: 37%;
    border: 2px solid #abf6dd;
    border-radius: 50%;
    background: #409c91;
    box-shadow: 0 2px 9px #100e18b8;
    transform: translate(var(--stick-x, 0), var(--stick-y, 0));
}
.touch-actions { display: grid; grid-template-columns: repeat(2, minmax(58px, 1fr)); gap: 7px; }
.scene-deck {
    position: absolute;
    right: var(--scene-edge);
    bottom: var(--scene-bottom);
    z-index: 1;
    display: grid;
    gap: 4px;
    width: var(--scene-actions-width);
    user-select: none;
    -webkit-user-select: none;
}
.scene-caption, .scene-thought {
    position: absolute;
    z-index: 1;
    left: var(--scene-edge);
    font: 500 clamp(1rem, 1.7vw, 1.125rem) / 1.25 "Atkinson Hyperlegible Next", system-ui, sans-serif;
}
.scene-caption {
    bottom: var(--scene-bottom);
    width: min(440px, calc(100% - 2 * var(--scene-edge) - var(--scene-actions-width) - 7px));
    max-height: calc(100% - 2 * var(--scene-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    touch-action: pan-y;
    padding: 8px 10px;
    border: 1px solid #685845;
    border-left: 3px solid #ffd06b;
    border-radius: 6px;
    background: #151421f5;
    color: #fff6e9;
    overflow-wrap: anywhere;
}
.scene-caption[data-top] { top: var(--scene-bottom); bottom: auto; }
.scene-caption[data-choices] {
    width: min(440px, calc(100% - 2 * var(--scene-edge)));
    padding: 6px 8px;
}
.caption-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 3px;
}
.scene-caption h2 {
    margin: 0;
    font-size: 1.04em;
    line-height: 1.2;
    font-weight: 800;
    color: #ffda91;
}
.caption-heading button {
    flex: none;
    min-height: 30px;
    min-width: 46px;
    padding: 0 6px;
    color: #fff6e9;
    background: #272337;
    border: 1px solid #806778;
    border-radius: 4px;
    font: 650 .81rem/1.2 system-ui, sans-serif;
    cursor: pointer;
}
.caption-context {
    margin: 0 0 2px;
    color: #d2c0d1;
    font-size: .86em;
}
.caption-body p { margin: 0; }
.caption-body p + p { margin-top: 4px; }
.caption-choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 5px;
}
.caption-choices button {
    min-width: 0;
    min-height: 44px;
    padding: 4px;
    color: #fff6e9;
    background: #322b40;
    border: 1px solid #806778;
    border-radius: 4px;
    font: inherit;
    line-height: 1.17;
    text-align: left;
    overflow-wrap: anywhere;
    touch-action: manipulation;
    cursor: pointer;
}
.caption-choices button:active { color: #211323; background: #ffda91; }
.caption-choices button:focus-visible { outline-offset: -2px; }
.scene-thought {
    top: var(--scene-bottom);
    width: max-content;
    max-width: min(61%, 360px);
    margin: 0;
    padding: 5px 11px;
    border: 2px solid #1b1621;
    border-radius: 17px;
    background: #fff3d6;
    color: #211724;
    font-size: clamp(.875rem, 1.5vw, 1rem);
    font-weight: 700;
    text-align: center;
}
.scene-thought::after {
    content: "";
    position: absolute;
    left: 25%;
    bottom: -8px;
    width: 7px;
    aspect-ratio: 1;
    border: 1px solid #1b1621;
    border-radius: 50%;
    background: #fff3d6;
}
.touch-deck button, .scene-deck button {
    min-width: 48px;
    min-height: 48px;
    border: 1px solid #528e89;
    border-radius: 6px;
    background: #212033;
    color: #f9e9ce;
    font: 750 0.86rem "Instrument Sans", system-ui, sans-serif;
    padding: 0 11px;
    touch-action: manipulation;
    cursor: pointer;
}
.touch-deck button:active,
.scene-deck button:active,
.touch-deck button[data-active="true"] { background: #ffd06b; color: #211323; border-color: #ffe4a4; }
.touch-deck button:disabled { border-color: #4b4057; color: #a99bb3; opacity: .70; }
.scene-deck button { min-width: 0; min-height: 44px; padding: 0 3px; }
.scene-deck #touch-next {
    color: #211323;
    background: #ffd06b;
    border-color: #ffe4a4;
}
.scene-deck #touch-next:active { background: #ffe4a4; }
@media (max-width: 350px) {
    .scene-caption[data-choices] {
        left: 4px;
        width: calc(100% - 8px);
        padding: 5px 6px;
    }
    .caption-heading button { min-height: 24px; }
    .caption-choices button { padding: 3px; }
}
@media (max-width: 480px) {
    .stage { min-height: 172px; }
    .cover { padding: 14px; background-position: 64% 50%; }
    .stage:not([data-launch="playing"]) .intro-title { top: 38%; width: min(75%, 310px); }
    .loader { width: min(218px, 70vw); padding: 7px 9px 8px; }
    .loader-label { font-size: .74rem; }
    .toolbar { gap: 6px; }
    .brand { font-size: .79rem; letter-spacing: .065em; white-space: nowrap; }
    .actions { gap: 4px; }
    .actions button { min-height: 44px; padding-inline: 6px; font-size: .73rem; }
}
.cabinet[data-input="touch"] .controls span:not(.touch-instruction) { display: none; }
.cabinet[data-input="touch"] .touch-instruction { display: inline; }
@media (max-height: 530px) and (orientation: landscape) {
    body { padding-top: 7px; padding-bottom: 7px; }
    .toolbar { min-height: 28px; margin-bottom: 6px; }
    .stage { width: min(100%, calc((100dvh - 74px) * 16 / 9)); margin-inline: auto; }
    .playfield[data-deck="drive"] .touch-deck {
        position: absolute;
        bottom: 5px;
        left: 0;
        right: 0;
        border: 0;
        padding: 0 max(5px, env(safe-area-inset-right), env(safe-area-inset-left));
        background: none;
        pointer-events: none;
    }
    .drive-deck { padding-inline: 0; }
    .drive-deck > * { pointer-events: auto; }
    .touch-stick { width: 94px; }
    .cover { padding: 14px 20px; }
    .controls { margin-top: 6px; }
    .cabinet[data-input="touch"] .controls { display: none; }
}
