:root {
    color-scheme: dark;
    --void: #080612;
    --panel: #15102b;
    --panel-light: #251849;
    --ink: #f7f2ff;
    --muted: #aaa1c7;
    --cyan: #45f2ff;
    --pink: #ff4db8;
    --yellow: #ffe66d;
    --purple: #a76dff;
    --line: rgba(224, 214, 255, 0.18);
    font-family: "Courier New", Courier, monospace;
    background: var(--void);
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 50% 12%, rgba(119, 49, 194, 0.35), transparent 34rem),
        linear-gradient(180deg, #130b29 0%, var(--void) 72%);
}

body:has(dialog[open]) {
    overflow: hidden;
}

button,
a {
    font: inherit;
}

button {
    color: inherit;
}

.scanlines {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    opacity: 0.12;
    background:
        repeating-linear-gradient(
            180deg,
            transparent 0 3px,
            rgba(0, 0, 0, 0.8) 4px 5px
        );
    mix-blend-mode: multiply;
}

.topbar,
.footer {
    width: min(1180px, calc(100% - 32px));
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar {
    min-height: 76px;
}

.brand {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    color: var(--ink);
    text-decoration: none;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.brand__pixel {
    width: 18px;
    height: 18px;
    background: var(--cyan);
    box-shadow:
        6px 6px 0 var(--pink),
        -3px -3px 0 rgba(69, 242, 255, 0.3);
}

.language-switch {
    display: flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(8, 6, 18, 0.72);
}

.language-switch button {
    min-width: 44px;
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.language-switch button[aria-pressed="true"] {
    color: var(--void);
    background: var(--cyan);
    box-shadow: 0 0 18px rgba(69, 242, 255, 0.35);
}

.page-shell {
    width: min(1120px, 100%);
    margin: 12px auto 28px;
    padding: 0 20px;
}

.arcade-machine {
    padding: 18px 18px 0;
    border: 2px solid rgba(255, 77, 184, 0.55);
    border-radius: 30px 30px 18px 18px;
    background:
        linear-gradient(145deg, #2b1853, #120d28 52%, #321453);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.55),
        0 0 46px rgba(255, 77, 184, 0.1);
}

.marquee {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--yellow);
    border-radius: 14px;
    color: var(--yellow);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-align: center;
    background: #291547;
    box-shadow:
        inset 0 0 20px rgba(255, 230, 109, 0.12),
        0 0 20px rgba(255, 230, 109, 0.12);
}

.screen-frame {
    margin-top: 16px;
    padding: clamp(24px, 5vw, 52px);
    border: 8px solid #080612;
    border-radius: 28px;
    background:
        linear-gradient(rgba(69, 242, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(69, 242, 255, 0.035) 1px, transparent 1px),
        #0d091d;
    background-size: 20px 20px;
    box-shadow:
        0 0 0 2px var(--cyan),
        inset 0 0 60px rgba(69, 242, 255, 0.05);
}

.eyebrow {
    margin: 0;
    color: var(--cyan);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2em;
}

h1 {
    margin: 12px 0 0;
    color: var(--ink);
    font-size: clamp(2.8rem, 8vw, 6.4rem);
    line-height: 0.9;
    letter-spacing: -0.07em;
    text-shadow:
        5px 5px 0 var(--pink),
        -2px -2px 0 rgba(69, 242, 255, 0.5);
}

.intro {
    max-width: 720px;
    margin: 26px 0 34px;
    color: var(--muted);
    line-height: 1.65;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.game-card {
    position: relative;
    min-height: 165px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    text-align: left;
    background: linear-gradient(145deg, var(--panel-light), var(--panel));
}

.game-card:not(:disabled) {
    cursor: pointer;
}

.game-card:not(:disabled):hover,
.game-card:not(:disabled):focus-visible {
    border-color: var(--cyan);
    outline: none;
    transform: translateY(-2px);
    box-shadow:
        0 0 0 2px rgba(69, 242, 255, 0.15),
        0 14px 34px rgba(0, 0, 0, 0.32);
}

.game-card--cosmo::before {
    content: "";
    position: absolute;
    width: 190px;
    height: 190px;
    top: -100px;
    right: -55px;
    border: 2px solid var(--cyan);
    border-radius: 50%;
    box-shadow:
        0 0 0 16px rgba(69, 242, 255, 0.05),
        0 0 40px rgba(69, 242, 255, 0.18);
}

.game-card--empty {
    opacity: 0.52;
}

.game-card__number {
    position: absolute;
    top: 16px;
    right: 18px;
    color: rgba(247, 242, 255, 0.18);
    font-size: 2.4rem;
    font-weight: 900;
}

.game-card__status {
    margin-bottom: 10px;
    color: var(--cyan);
    font-size: 0.68rem;
    letter-spacing: 0.15em;
}

.game-card--empty .game-card__status {
    color: var(--muted);
}

.game-card strong {
    font-size: clamp(1.5rem, 4vw, 2.4rem);
    letter-spacing: 0.08em;
}

.game-card__action {
    margin-top: 12px;
    color: var(--yellow);
    font-size: 0.8rem;
    font-weight: 900;
}

.control-deck {
    min-height: 130px;
    display: flex;
    gap: 22px;
    align-items: center;
    justify-content: flex-end;
    padding: 20px 34px;
}

.deck-label {
    margin-right: auto;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
}

.joystick {
    position: relative;
    width: 54px;
    height: 18px;
    margin-right: 22px;
    border-radius: 50%;
    background: #05040a;
}

.joystick::before {
    content: "";
    position: absolute;
    width: 10px;
    height: 48px;
    left: 22px;
    bottom: 7px;
    border-radius: 8px;
    background: #b7accd;
}

.joystick::after {
    content: "";
    position: absolute;
    width: 34px;
    height: 34px;
    left: 10px;
    bottom: 43px;
    border-radius: 50%;
    background: var(--pink);
    box-shadow: 0 0 18px rgba(255, 77, 184, 0.42);
}

.arcade-button {
    width: 44px;
    height: 44px;
    border: 8px solid #090711;
    border-radius: 50%;
}

.arcade-button--pink {
    background: var(--pink);
}

.arcade-button--cyan {
    background: var(--cyan);
}

.footer {
    min-height: 68px;
    gap: 24px;
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
}

.game-dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--ink);
    background: rgba(5, 3, 12, 0.92);
}

.game-dialog::backdrop {
    background: rgba(5, 3, 12, 0.92);
    backdrop-filter: blur(7px);
}

.game-shell {
    width: min(1320px, calc(100% - 28px));
    height: min(900px, calc(100% - 28px));
    margin: 14px auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 14px;
    border: 2px solid var(--pink);
    border-radius: 22px;
    background: linear-gradient(145deg, #2b1853, #120d28);
    box-shadow: 0 0 50px rgba(255, 77, 184, 0.18);
}

.game-shell__header,
.game-shell__footer {
    min-height: 62px;
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
}

.game-shell__label {
    display: block;
    margin-bottom: 4px;
    color: var(--cyan);
    font-size: 0.66rem;
    letter-spacing: 0.16em;
}

.close-button,
.game-shell__footer button,
.home-button {
    min-height: 44px;
    border: 1px solid var(--cyan);
    border-radius: 5px;
    color: var(--cyan);
    background: transparent;
    cursor: pointer;
}

.close-button {
    width: 44px;
    font-size: 1.6rem;
}

.game-shell__footer button,
.home-button {
    padding: 0 20px;
}

.close-button:hover,
.close-button:focus-visible,
.game-shell__footer button:hover,
.game-shell__footer button:focus-visible,
.home-button:hover,
.home-button:focus-visible {
    color: var(--void);
    background: var(--cyan);
    outline: none;
}

.game-shell__screen {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border: 7px solid #05040a;
    border-radius: 14px;
    background: #05040a;
    box-shadow: 0 0 0 1px rgba(69, 242, 255, 0.55);
}

.game-shell iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #05040a;
}

.game-status {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    color: var(--yellow);
    text-align: center;
    letter-spacing: 0.12em;
    animation: pulse 1.2s steps(2) infinite;
}

.error-page {
    min-height: calc(100vh - 144px);
    display: grid;
    place-items: center;
    padding: 24px;
}

.error-panel {
    width: min(760px, 100%);
    padding: clamp(32px, 7vw, 72px);
    border: 8px solid #080612;
    border-radius: 28px;
    text-align: center;
    background:
        linear-gradient(rgba(69, 242, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(69, 242, 255, 0.035) 1px, transparent 1px),
        #0d091d;
    background-size: 20px 20px;
    box-shadow:
        0 0 0 2px var(--cyan),
        0 24px 70px rgba(0, 0, 0, 0.5);
}

.error-panel h1 {
    margin: 14px 0 0;
    color: var(--yellow);
    font-size: clamp(5rem, 18vw, 10rem);
    line-height: 0.9;
}

.error-panel h2 {
    margin: 28px 0 12px;
}

.error-panel p:not(.eyebrow) {
    max-width: 570px;
    margin: 0 auto 28px;
    color: var(--muted);
    line-height: 1.65;
}

.home-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

@keyframes pulse {
    50% {
        opacity: 0.35;
    }
}

@media (max-width: 720px) {
    .topbar {
        min-height: 64px;
    }

    .brand {
        font-size: 0.78rem;
    }

    .page-shell {
        margin-top: 4px;
        padding-inline: 10px;
    }

    .arcade-machine {
        padding: 10px 10px 0;
        border-radius: 20px 20px 12px 12px;
    }

    .marquee {
        min-height: 46px;
        font-size: 0.67rem;
    }

    .screen-frame {
        margin-top: 10px;
        padding: 28px 18px;
        border-width: 5px;
        border-radius: 20px;
    }

    h1 {
        font-size: clamp(2.4rem, 16vw, 4rem);
    }

    .intro {
        margin: 18px 0 26px;
        font-size: 0.88rem;
    }

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

    .game-card {
        min-height: 130px;
        padding: 16px;
    }

    .control-deck {
        min-height: 104px;
        padding-inline: 16px;
    }

    .deck-label {
        display: none;
    }

    .game-shell {
        width: calc(100% - 12px);
        height: calc(100% - 12px);
        margin: 6px auto;
        padding: 8px;
        border-radius: 14px;
    }

    .game-shell__footer span {
        display: none;
    }
}

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