.matter-canvas {
    position: fixed;
    z-index: 10;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: transparent;
    opacity: 1;
    transition: opacity .6s ease;
}

body {
    --game-dock-height: 60px;
}

html.is-game-mode,
body.is-game-mode {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body.is-game-mode .matter-canvas {
    opacity: 1;
    background: #000;
    touch-action: none;
}

.site-header,
.site-footer,
.media-block,
.cookie-bar,
.mobile-project-slot,
.mobile-game-cta-slot {
    transition: opacity .5s ease, transform .5s ease;
}

body.is-game-mode .site-header,
body.is-game-mode .site-footer,
body.is-game-mode .media-block,
body.is-game-mode .hero,
body.is-game-mode .cookie-bar,
body.is-game-mode .mobile-project-slot,
body.is-game-mode .mobile-game-cta-slot {
    opacity: 0;
    pointer-events: none;
}

body.is-game-mode .cookie-bar {
    display: none;
}

body.is-game-mode .site-header {
    transform: translateY(-20px);
}

body.is-game-mode .site-footer {
    transform: translateY(20px);
}

body.is-game-mode .media-block {
    transform: translateY(-16px);
}

body.is-game-mode .hero {
    transform: translateY(-8px) scale(.98);
}

.game-hud {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity .24s ease, visibility 0s linear .24s;
}

body.is-game-mode .game-hud {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.game-hud button {
    cursor: pointer;
}

.game-fps {
    position: fixed;
    z-index: 80;
    top: 24px;
    left: 24px;
    color: rgba(255, 255, 255, .74);
    font: 12px/1.2 Consolas, "Courier New", monospace;
    letter-spacing: 0;
}

.game-utilities {
    position: fixed;
    z-index: 80;
    top: 20px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
}

.game-utility-button {
    position: relative;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .46);
    border-radius: 50%;
    background: rgba(0, 0, 0, .52);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #fff;
    transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.game-exit-button {
    display: none;
}

.game-utility-button:hover,
.game-utility-button:focus-visible,
.game-utility-button.is-active {
    border-color: var(--color-accent);
    background: var(--color-accent);
}

.game-utility-button:focus-visible {
    outline: 1px solid #fff;
    outline-offset: 3px;
}

.game-utility-button svg {
    width: 20px;
    height: 20px;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.35;
}

.game-utility-button .game-utility-icon--info {
    width: 26px;
    height: 26px;
    stroke-width: 1.7;
}

.game-utility-button::after {
    position: absolute;
    top: 50%;
    right: calc(100% + 8px);
    padding: 5px 7px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: #000;
    color: #fff;
    content: attr(data-tooltip);
    font: 10px/1 Consolas, "Courier New", monospace;
    opacity: 0;
    pointer-events: none;
    transform: translate(3px, -50%);
    transition: opacity .1s ease, transform .1s ease;
    white-space: nowrap;
}

.game-utility-button:hover::after,
.game-utility-button:focus-visible::after {
    opacity: 1;
    transform: translate(0, -50%);
}

.game-control-icon--start {
    display: none;
    fill: currentColor !important;
    stroke: none !important;
}

.game-control-icon--stop rect {
    fill: currentColor;
    stroke: none;
}

.game-utility-button[aria-pressed="true"] .game-control-icon--stop {
    display: none;
}

.game-utility-button[aria-pressed="true"] .game-control-icon--start {
    display: block;
}

.game-dock {
    position: fixed;
    z-index: 79;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    height: var(--game-dock-height);
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, .18);
    background: #000;
    justify-content: center;
    pointer-events: auto;
}

.game-info[hidden] {
    display: none;
}

.game-info {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    overflow: auto;
    padding: clamp(72px, 10vh, 120px) clamp(24px, 6vw, 104px);
    background: #000;
    color: #fff;
    pointer-events: auto;
    scrollbar-color: var(--color-accent) #000;
    scrollbar-width: thin;
}

.game-info::-webkit-scrollbar {
    width: 9px;
}

.game-info::-webkit-scrollbar-track {
    background: #000;
}

.game-info::-webkit-scrollbar-thumb {
    border: 2px solid #000;
    border-radius: 0;
    background: var(--color-accent);
}

.game-info__terminal {
    width: min(100%, 980px);
    margin: auto 0;
    font-family: Consolas, "Courier New", monospace;
    letter-spacing: 0;
}

.game-info__terminal h2 {
    margin: 18px 0 36px;
    color: #fff;
    font: 400 72px/.94 Consolas, "Courier New", monospace;
    letter-spacing: 0;
}

.game-info__terminal h3 {
    margin: 0 0 18px;
    color: #fff;
    font: 400 20px/1.2 Consolas, "Courier New", monospace;
    letter-spacing: 0;
    text-transform: none;
}

.game-info__steps + h3 {
    margin-top: 54px;
}

.game-info__terminal ol {
    display: grid;
    max-width: 820px;
    margin: 0;
    padding: 0;
    counter-reset: help-step;
    gap: 10px;
    list-style: none;
}

.game-info__terminal li {
    color: rgba(255, 255, 255, .78);
    counter-increment: help-step;
    font-size: 16px;
    line-height: 1.45;
}

.game-info__terminal li::before {
    color: var(--color-accent);
    content: "[0" counter(help-step) "] ";
}

.game-info__prompt {
    margin: 0;
    color: var(--color-accent);
    font-size: 13px;
}

.game-info__disclaimer + .game-info__prompt {
    margin-top: 34px;
}

.game-info__tips {
    display: grid;
    width: min(100%, 980px);
    margin: 0;
}

.game-info__tip {
    display: grid;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .13);
    grid-template-columns: 156px minmax(0, 1fr);
    gap: 20px;
}

.game-info__tip dt,
.game-info__tip dd {
    margin: 0;
    font: 14px/1.45 Consolas, "Courier New", monospace;
    letter-spacing: 0;
}

.game-info__tip dt {
    color: var(--color-accent);
}

.game-info__tip dd {
    color: rgba(255, 255, 255, .74);
}

.game-info__disclaimer {
    max-width: 900px;
    margin-top: 54px;
}

.game-info__disclaimer p {
    margin: 0 0 12px;
    color: rgba(255, 255, 255, .66);
    font: 14px/1.55 Consolas, "Courier New", monospace;
    letter-spacing: 0;
}

.game-info__caret {
    display: inline-block;
    width: 8px;
    height: 1em;
    background: #fff;
    vertical-align: -2px;
    animation: terminal-caret .9s steps(1) infinite;
}

.game-info__brand {
    margin: 46px 0 0;
    color: rgba(255, 255, 255, .45);
    font-size: 12px;
}

.game-info__close {
    position: fixed;
    z-index: 101;
    top: 22px;
    right: 24px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .42);
    border-radius: 50%;
    background: #000;
}

.game-info__close:hover,
.game-info__close:focus-visible {
    border-color: var(--color-accent);
    background: var(--color-accent);
}

.game-info__close svg {
    width: 22px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.2;
}

@keyframes terminal-caret {
    50% { opacity: 0; }
}

.shake-vertical {
    animation: shake-vertical 10000ms ease-in-out infinite;
    animation-play-state: running;
    transform-origin: center;
}

@keyframes shake-vertical {
    2% { transform: translate(0, 2.1px) rotate(0); }
    4% { transform: translate(0, -.35px) rotate(0); }
    6% { transform: translate(0, -2.45px) rotate(0); }
    8% { transform: translate(0, -.35px) rotate(0); }
    10% { transform: translate(0, 3.15px) rotate(0); }
    12% { transform: translate(0, .35px) rotate(0); }
    14% { transform: translate(0, 1.05px) rotate(0); }
    16% { transform: translate(0, 2.1px) rotate(0); }
    18% { transform: translate(0, 0) rotate(0); }
    20% { transform: translate(0, .7px) rotate(0); }
    22% { transform: translate(0, .35px) rotate(0); }
    24% { transform: translate(0, 1.05px) rotate(0); }
    26% { transform: translate(0, 1.4px) rotate(0); }
    28% { transform: translate(0, 0) rotate(0); }
    30% { transform: translate(0, -2.8px) rotate(0); }
    32% { transform: translate(0, 2.1px) rotate(0); }
    34% { transform: translate(0, 2.1px) rotate(0); }
    36% { transform: translate(0, -1.4px) rotate(0); }
    38% { transform: translate(0, .7px) rotate(0); }
    40% { transform: translate(0, -2.8px) rotate(0); }
    42% { transform: translate(0, -3.15px) rotate(0); }
    44% { transform: translate(0, -1.05px) rotate(0); }
    46% { transform: translate(0, 0) rotate(0); }
    48% { transform: translate(0, -2.45px) rotate(0); }
    50% { transform: translate(0, 0) rotate(0); }
    52% { transform: translate(0, 1.05px) rotate(0); }
    54% { transform: translate(0, -1.4px) rotate(0); }
    56% { transform: translate(0, 1.05px) rotate(0); }
    58% { transform: translate(0, -3.15px) rotate(0); }
    60% { transform: translate(0, 3.15px) rotate(0); }
    62% { transform: translate(0, -2.1px) rotate(0); }
    64% { transform: translate(0, 0) rotate(0); }
    66% { transform: translate(0, -1.4px) rotate(0); }
    68% { transform: translate(0, .35px) rotate(0); }
    70% { transform: translate(0, 1.75px) rotate(0); }
    72% { transform: translate(0, 0) rotate(0); }
    74% { transform: translate(0, -2.1px) rotate(0); }
    76% { transform: translate(0, -1.05px) rotate(0); }
    78% { transform: translate(0, 1.05px) rotate(0); }
    80% { transform: translate(0, 2.1px) rotate(0); }
    82% { transform: translate(0, .7px) rotate(0); }
    84% { transform: translate(0, -1.05px) rotate(0); }
    86% { transform: translate(0, .35px) rotate(0); }
    88% { transform: translate(0, .35px) rotate(0); }
    90% { transform: translate(0, 3.5px) rotate(0); }
    92% { transform: translate(0, -.7px) rotate(0); }
    94% { transform: translate(0, -.7px) rotate(0); }
    96% { transform: translate(0, -2.1px) rotate(0); }
    98% { transform: translate(0, -3.15px) rotate(0); }

    0%, 100% {
        transform: translate(0, 0) rotate(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .matter-canvas,
    .site-header,
    .site-footer,
    .media-block,
    .hero,
    .game-hud {
        transition-duration: .01ms;
    }

    .shake-vertical {
        animation: none;
    }
}

@media (max-width: 780px) {
    body {
        --game-dock-height: 58px;
    }

    .game-fps {
        top: 18px;
        left: 14px;
    }

    .game-utilities {
        top: 12px;
        right: 14px;
        gap: 6px;
    }

    .game-utility-button {
        width: 38px;
        height: 38px;
    }

    .game-utility-button svg {
        width: 18px;
        height: 18px;
    }

    .game-dock {
        padding: 11px 0;
    }

    .toolbelt {
        width: 100%;
    }

    .toolbelt .tool-button {
        width: 82px;
        min-width: 82px;
    }

    .game-info {
        padding-top: 84px;
    }

    .game-info__terminal h2 {
        font-size: 42px;
    }

    .game-info__terminal li {
        font-size: 14px;
    }

    .game-info__tip {
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 12px;
    }

    .game-info__tip dt,
    .game-info__tip dd {
        font-size: 12px;
    }
}

@media (pointer: coarse) {
    .game-exit-button {
        display: grid;
    }
}

@media (max-width: 480px) {
    .game-info__terminal h2 {
        margin-bottom: 28px;
        font-size: 26px;
    }

    .game-info__tip {
        grid-template-columns: 1fr;
        gap: 3px;
    }
}

.debug-panel {
    position: fixed;
    z-index: 70;
    top: 84px;
    left: 24px;
    min-width: 160px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 8px;
    background: rgba(0, 0, 0, .68);
    color: #fff;
    font: 11px/1.45 monospace;
    pointer-events: none;
}
