@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("../fonts/ibm-plex-mono-600-latin.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #080b0c;
    --panel: #0d1113;
    --panel-raised: #121719;
    --line: #273033;
    --line-soft: #1a2224;
    --ink: #f2f6f3;
    --muted: #8b9997;
    --dim: #52605f;
    --acid: #b7ff50;
    --echo-one: #55e3ff;
    --echo-two: #ff5d73;
    --echo-three: #ffc857;
    --radius: 18px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    background:
        radial-gradient(circle at 18% 5%, rgba(85, 227, 255, 0.055), transparent 27rem),
        radial-gradient(circle at 91% 92%, rgba(183, 255, 80, 0.045), transparent 30rem),
        var(--bg);
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--acid);
    outline-offset: 3px;
}

.app-shell {
    width: min(1560px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 24px;
}

.topbar {
    min-height: 70px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
}

.back-link {
    width: fit-content;
    color: var(--muted);
    text-decoration: none;
    transition: color 140ms ease;
}

.back-link:hover {
    color: var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--ink);
}

.brand-mark {
    color: var(--acid);
}

.prototype-label {
    justify-self: end;
    color: var(--dim);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    min-height: calc(100vh - 116px);
    border-bottom: 1px solid var(--line-soft);
}

.stage-panel {
    display: grid;
    align-content: center;
    min-width: 0;
    padding: 24px 24px 24px 0;
}

.stage {
    isolation: isolate;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 1px solid #303a3d;
    border-radius: var(--radius);
    background:
        linear-gradient(rgba(13, 17, 19, 0.72), rgba(13, 17, 19, 0.72)),
        repeating-linear-gradient(90deg, transparent 0 69px, rgba(255, 255, 255, 0.025) 70px),
        repeating-linear-gradient(0deg, transparent 0 69px, rgba(255, 255, 255, 0.025) 70px),
        #0c1113;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

#camera,
#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#camera {
    z-index: 0;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0;
    filter: saturate(0.52) contrast(1.12) brightness(0.48);
    transition: opacity 260ms ease;
}

.stage.has-camera #camera {
    opacity: 1;
}

.stage[data-experience="reset"].has-camera #camera {
    filter: saturate(0.72) contrast(1.06) brightness(0.72);
}

#gameCanvas {
    z-index: 1;
}

.scanlines {
    pointer-events: none;
    position: absolute;
    z-index: 2;
    inset: 0;
    opacity: 0.15;
    background: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 3px,
        rgba(5, 9, 10, 0.28) 4px
    );
}

.camera-state {
    position: absolute;
    z-index: 4;
    top: 17px;
    left: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    color: #c1cac8;
    background: rgba(7, 10, 11, 0.7);
    backdrop-filter: blur(10px);
    font-size: 0.59rem;
    letter-spacing: 0.08em;
}

.state-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #657170;
}

.camera-state.is-live .state-dot {
    background: var(--acid);
    box-shadow: 0 0 0 4px rgba(183, 255, 80, 0.12), 0 0 12px rgba(183, 255, 80, 0.7);
}

.camera-state.is-warning .state-dot {
    background: var(--echo-three);
}

.stage-overlay {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 6vw, 80px);
    text-align: center;
    background: radial-gradient(circle at center, rgba(11, 16, 17, 0.68), rgba(7, 10, 11, 0.91));
    transition: opacity 170ms ease, visibility 170ms ease;
}

.stage-overlay.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.overlay-kicker {
    margin: 0 0 17px;
    color: var(--acid);
    font-size: clamp(0.58rem, 1vw, 0.72rem);
    letter-spacing: 0.18em;
}

.stage-overlay h1 {
    max-width: 780px;
    margin: 0;
    text-wrap: balance;
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
    font-size: clamp(2rem, 4.8vw, 4.65rem);
    font-weight: 600;
    letter-spacing: -0.052em;
    line-height: 0.99;
}

.overlay-copy {
    max-width: 630px;
    margin: 22px 0 0;
    color: #a7b3b1;
    font-size: clamp(0.72rem, 1.2vw, 0.9rem);
    line-height: 1.75;
}

.mode-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: min(500px, 100%);
    margin-top: 24px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 5px;
    background: rgba(5, 8, 9, 0.62);
}

.mode-picker[hidden] {
    display: none;
}

.mode-option {
    display: grid;
    gap: 4px;
    min-height: 57px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 3px;
    color: #6f7c79;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.mode-option-primary {
    grid-column: 1 / -1;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 52px;
}

.mode-option-primary span {
    text-align: right;
}

.mode-option:hover {
    color: #c7d0ce;
}

.mode-option[aria-pressed="true"] {
    color: var(--ink);
    border-color: rgba(183, 255, 80, 0.52);
    background: rgba(183, 255, 80, 0.08);
}

.mode-option strong {
    font-size: 0.64rem;
    letter-spacing: 0.1em;
}

.mode-option span {
    color: #71807d;
    font-size: 0.55rem;
}

.hands-free-hint {
    display: grid;
    grid-template-columns: 1fr 104px;
    align-items: center;
    gap: 16px;
    width: min(500px, 100%);
    margin-top: 14px;
    padding: 11px 13px;
    border: 1px solid rgba(255, 200, 87, 0.42);
    border-radius: 4px;
    color: #f7e1ad;
    background: rgba(30, 23, 8, 0.72);
    text-align: left;
}

.hands-free-hint[hidden] {
    display: none;
}

.hands-free-hint > div {
    display: grid;
    gap: 4px;
}

.hands-free-hint strong {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
}

.hands-free-hint span {
    color: #a99b78;
    font-size: 0.54rem;
}

.gesture-track {
    position: relative;
    height: 5px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.11);
}

.gesture-track i {
    display: block;
    width: 0;
    height: 100%;
    background: var(--echo-three);
    box-shadow: 0 0 10px rgba(255, 200, 87, 0.4);
    transition: width 80ms linear;
}

.primary-button {
    min-width: 190px;
    min-height: 48px;
    margin-top: 30px;
    padding: 0 24px;
    border: 1px solid var(--acid);
    border-radius: 3px;
    color: #0a0d0d;
    background: var(--acid);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.11em;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.mode-picker:not([hidden]) ~ .primary-button {
    margin-top: 14px;
}

.hands-free-hint:not([hidden]) + .primary-button {
    margin-top: 14px;
}

.primary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(183, 255, 80, 0.18);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.primary-button[hidden] {
    display: none;
}

.privacy-note {
    margin: 14px 0 0;
    color: #667370;
    font-size: 0.58rem;
}

.privacy-note span {
    color: var(--acid);
}

.sync-banner {
    position: absolute;
    z-index: 3;
    top: 17px;
    left: 50%;
    padding: 8px 12px;
    border: 1px solid rgba(255, 200, 87, 0.6);
    border-radius: 2px;
    color: #ffdd90;
    background: rgba(24, 19, 8, 0.8);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    opacity: 0;
    transform: translate(-50%, -8px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.sync-banner.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.sync-banner.is-hit {
    border-color: rgba(183, 255, 80, 0.8);
    color: #e8ffc9;
    background: rgba(22, 35, 11, 0.88);
    box-shadow: 0 0 28px rgba(183, 255, 80, 0.24);
}

.mobile-note {
    display: none;
    margin-top: 10px;
    color: var(--dim);
    font-size: 0.61rem;
    line-height: 1.5;
}

.hud {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--line-soft);
    background: rgba(12, 16, 18, 0.5);
}

.hud-section {
    padding: 22px;
    border-bottom: 1px solid var(--line-soft);
}

.hud-section[hidden] {
    display: none;
}

.hud-label {
    margin-bottom: 14px;
    color: var(--dim);
    font-size: 0.58rem;
    letter-spacing: 0.14em;
}

.loop-number {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--dim);
    font-size: 0.72rem;
}

.loop-number span:first-child {
    color: var(--ink);
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
    font-size: 3.15rem;
    font-weight: 600;
    letter-spacing: -0.06em;
    line-height: 1;
}

.reset-score {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--dim);
    font-size: 0.72rem;
}

.reset-score span:first-child {
    color: var(--ink);
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
    font-size: 3.15rem;
    font-weight: 600;
    letter-spacing: -0.06em;
    line-height: 1;
}

.reset-track {
    height: 5px;
    margin-top: 15px;
    overflow: hidden;
    background: #1c2426;
}

.reset-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--echo-one), var(--acid));
    box-shadow: 0 0 12px rgba(85, 227, 255, 0.28);
}

.reset-cue {
    position: relative;
    min-height: 174px;
    overflow: hidden;
}

.reset-cue h2 {
    position: relative;
    max-width: 220px;
    margin: 0 0 8px;
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.reset-cue p {
    position: relative;
    max-width: 240px;
    margin: 0;
    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.65;
}

.release-orbit {
    position: absolute;
    top: 35px;
    right: 10px;
    color: rgba(85, 227, 255, 0.18);
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
    font-size: 4.5rem;
    font-weight: 600;
    letter-spacing: -0.08em;
    line-height: 1;
    transform: scale(calc(0.84 + var(--hold, 0) * 0.16));
    transition: color 300ms ease, transform 500ms ease;
}

.reset-step-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.reset-step-list li {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 7px;
    min-height: 29px;
    padding: 0 8px;
    border: 1px solid #1c2426;
    color: #657270;
    font-size: 0.54rem;
}

.reset-step-list li span {
    color: #3f4c4a;
}

.reset-step-list li em {
    color: #4d5a58;
    font-style: normal;
}

.reset-step-list li.is-current {
    color: var(--ink);
    border-color: rgba(85, 227, 255, 0.42);
    background: rgba(85, 227, 255, 0.05);
}

.reset-step-list li.is-current span,
.reset-step-list li.is-current em {
    color: var(--echo-one);
}

.reset-step-list li.is-complete {
    color: #9eaaa7;
}

.reset-step-list li.is-complete span {
    color: var(--acid);
}

.safety-note p {
    margin: 0;
    color: #6f7c79;
    font-size: 0.57rem;
    line-height: 1.55;
}

.loop-track {
    position: relative;
    height: 5px;
    margin-top: 15px;
    overflow: visible;
    background: #1c2426;
}

.loop-track > span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--acid);
    box-shadow: 0 0 12px rgba(183, 255, 80, 0.32);
}

.sync-marker {
    position: absolute;
    top: -4px;
    left: 73.333%;
    width: 1px;
    height: 13px;
    background: var(--echo-three);
}

.timer-row {
    display: flex;
    justify-content: space-between;
    margin-top: 9px;
    color: #71807d;
    font-size: 0.53rem;
}

.objective-panel {
    position: relative;
    min-height: 174px;
    overflow: hidden;
}

.target-symbol {
    position: absolute;
    top: 40px;
    right: 15px;
    color: rgba(85, 227, 255, 0.15);
    font-family: Arial, sans-serif;
    font-size: 5.7rem;
    line-height: 1;
}

.objective-panel h2 {
    position: relative;
    max-width: 210px;
    margin: 0 0 8px;
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.17rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.objective-panel p {
    position: relative;
    max-width: 238px;
    margin: 0;
    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.65;
}

.echo-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.echo-list li {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    align-items: center;
    gap: 9px;
    min-height: 30px;
    padding: 0 8px;
    border: 1px solid #1c2426;
    color: #697674;
    font-size: 0.58rem;
}

.echo-list li.is-recorded {
    color: #d3dcd9;
    border-color: #314044;
    background: rgba(255, 255, 255, 0.02);
}

.echo-list li.is-current {
    color: var(--ink);
    border-color: #54605f;
}

.echo-list em {
    color: #4e5a58;
    font-style: normal;
}

.echo-list .is-recorded em,
.echo-list .is-current em {
    color: #8d9a98;
}

.echo-swatch {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3b4545;
}

.echo-one { background: var(--echo-one); }
.echo-two { background: var(--echo-two); }
.echo-three { background: var(--echo-three); }

.how-to ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 0.61rem;
    line-height: 1.5;
}

.hud-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;
    padding: 18px;
}

.hud-controls button {
    min-height: 39px;
    padding: 0 8px;
    border: 1px solid #2a3436;
    border-radius: 2px;
    color: #879492;
    background: transparent;
    font-size: 0.52rem;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.hud-controls button:hover:not(:disabled) {
    color: var(--ink);
    border-color: #596563;
}

.hud-controls button:disabled {
    color: #414b4a;
    cursor: not-allowed;
}

.footer-note {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #45514f;
    font-size: 0.54rem;
    letter-spacing: 0.07em;
}

.no-script {
    color: var(--echo-two);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1000px) {
    .app-shell {
        padding: 0 16px;
    }

    .game-layout {
        grid-template-columns: 1fr;
        padding-bottom: 24px;
    }

    .stage-panel {
        padding: 18px 0 0;
    }

    .hud {
        display: grid;
        grid-template-columns: 1fr 1fr;
        margin-top: 14px;
        border: 1px solid var(--line-soft);
    }

    .hud-section {
        border-right: 1px solid var(--line-soft);
    }

    .hud-controls {
        align-self: end;
    }

    .mobile-note {
        display: block;
    }
}

@media (max-width: 650px) {
    .app-shell {
        padding: 0 10px;
    }

    .topbar {
        min-height: 58px;
        grid-template-columns: 1fr auto;
    }

    .brand {
        justify-self: end;
    }

    .prototype-label {
        display: none;
    }

    .stage {
        aspect-ratio: 3 / 5;
        border-radius: 12px;
    }

    .stage-overlay {
        justify-content: flex-end;
        padding: 56px 21px 35px;
    }

    .stage-overlay h1 {
        font-size: clamp(2rem, 10vw, 3.1rem);
    }

    .overlay-copy {
        margin-top: 14px;
        line-height: 1.55;
    }

    .mode-picker {
        margin-top: 16px;
    }

    .mode-option {
        min-height: 52px;
        padding: 8px;
    }

    .hands-free-hint {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .primary-button {
        width: 100%;
        margin-top: 20px;
    }

    .camera-state {
        top: 12px;
        left: 12px;
    }

    .sync-banner {
        top: 50px;
    }

    .hud {
        grid-template-columns: 1fr;
    }

    .hud-section {
        border-right: 0;
    }

    .how-to {
        display: none;
    }

    .footer-note {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
