:root {
    color-scheme: dark;
    --background: #090d16;
    --surface: #101521;
    --surface-raised: #141b29;
    --surface-deep: #0b111b;
    --line: rgba(162, 184, 212, 0.12);
    --line-strong: rgba(162, 184, 212, 0.2);
    --text: #eef4fc;
    --muted: #8792a6;
    --green: #7dffa8;
    --green-soft: rgba(125, 255, 168, 0.11);
    --cyan: #69dbff;
    --pink: #ff708d;
    --gold: #ffd071;
    --radius: 22px;
    --font: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;

    background:
        radial-gradient(
            ellipse at 20% 0%,
            rgba(91, 194, 151, 0.075),
            transparent 32%
        ),
        radial-gradient(
            ellipse at 88% 17%,
            rgba(73, 111, 209, 0.09),
            transparent 34%
        ),
        var(--background);

    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

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

button {
    color: inherit;
    font: inherit;
}

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

.ambient-glow {
    position: fixed;
    z-index: -1;
    width: 310px;
    height: 310px;
    pointer-events: none;
    filter: blur(110px);
    opacity: 0.18;
}

.ambient-glow-left {
    top: 32%;
    left: -180px;
    background: var(--green);
}

.ambient-glow-right {
    right: -200px;
    bottom: 14%;
    background: var(--cyan);
}

.arcade-shell {
    width: min(1340px, calc(100% - 72px));
    margin: 0 auto;
    padding: 32px 0 28px;
}

.hero,
.hero-actions,
.brand,
.game-card-header,
.game-controls,
.action-buttons,
.settings-heading,
.footer {
    display: flex;
    align-items: center;
}

.hero,
.game-card-header,
.game-controls,
.settings-heading,
.footer {
    justify-content: space-between;
}

.brand {
    gap: 13px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;

    border: 1px solid rgba(125, 255, 168, 0.32);
    border-radius: 15px;

    background: linear-gradient(
        145deg,
        rgba(125, 255, 168, 0.21),
        rgba(105, 219, 255, 0.08)
    );

    color: var(--green);
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 800;
}

.brand-copy {
    display: grid;
    gap: 4px;
}

.brand-kicker,
.eyebrow,
.live-badge,
.game-status,
.game-mode-indicator,
.card-label,
.settings-heading span,
.option-group legend,
.overlay-kicker,
.overlay-shortcut,
.bonus-badge,
.footer {
    font-family: var(--mono);
    letter-spacing: 0.1em;
}

.brand-kicker {
    color: var(--muted);
    font-size: 9px;
}

.brand-name {
    font-size: 19px;
    font-weight: 850;
    letter-spacing: 0.055em;
}

.brand-name span,
.introduction h1 span {
    color: var(--green);
}

.hero-actions {
    gap: 14px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #becad8;
    font-size: 10px;
}

.live-dot,
.status-dot,
.legend-dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 14px rgba(125, 255, 168, 0.68);
}

.icon-button {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;

    border: 1px solid var(--line);
    border-radius: 14px;

    background: rgba(16, 21, 33, 0.84);
    color: var(--muted);

    cursor: pointer;
    transition:
        color 160ms ease,
        border-color 160ms ease;
}

.icon-button:hover,
.icon-button[aria-pressed="true"] {
    border-color: rgba(125, 255, 168, 0.34);
    color: var(--green);
}

.sound-icon {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.6;
}

.sound-on,
.icon-button[aria-pressed="true"] .sound-off {
    display: none;
}

.icon-button[aria-pressed="true"] .sound-on {
    display: block;
}

.introduction {
    padding: 52px 0 30px;
}

.eyebrow {
    margin: 0 0 11px;
    color: var(--green);
    font-size: 10px;
}

.introduction h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 48px);
    font-weight: 850;
    letter-spacing: -0.055em;
    line-height: 1.12;
}

.introduction-copy {
    margin: 11px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.arcade-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    gap: 22px;
}

.game-card,
.stats-card,
.mini-card,
.settings-card,
.legend-card {
    border: 1px solid var(--line);

    background: linear-gradient(
        150deg,
        rgba(20, 27, 41, 0.94),
        rgba(13, 18, 29, 0.98)
    );
}

.game-card {
    padding: 19px;
    border-radius: var(--radius);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
}

.game-card-header {
    min-height: 29px;
    padding: 0 2px 17px;
}

.game-status,
.game-mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
}

.game-status {
    color: #c7d0dc;
}

.game-mode-indicator,
.separator {
    color: var(--muted);
}

.status-dot[data-state="paused"] {
    background: var(--gold);
    box-shadow: 0 0 14px rgba(255, 208, 113, 0.65);
}

.status-dot[data-state="gameover"] {
    background: var(--pink);
    box-shadow: 0 0 14px rgba(255, 112, 141, 0.65);
}

.board-wrapper {
    position: relative;
    overflow: hidden;
    aspect-ratio: 30 / 22;

    border: 1px solid rgba(142, 176, 210, 0.15);
    border-radius: 17px;

    background: var(--surface-deep);
    touch-action: none;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.game-overlay {
    position: absolute;
    z-index: 2;
    display: flex;
    inset: 0;

    align-items: center;
    flex-direction: column;
    justify-content: center;

    padding: 28px;

    background: rgba(8, 12, 19, 0.72);
    text-align: center;
    backdrop-filter: blur(5px);

    transition:
        opacity 180ms ease,
        visibility 180ms ease;
}

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

.overlay-kicker {
    color: var(--green);
    font-size: 10px;
}

.game-overlay h2 {
    margin: 12px 0 8px;
    font-size: clamp(26px, 4vw, 42px);
    letter-spacing: -0.055em;
}

.game-overlay p {
    max-width: 380px;
    margin: 0 0 21px;
    color: #b1bbca;
    font-size: 14px;
    line-height: 1.6;
}

.overlay-shortcut {
    margin-top: 13px;
    color: var(--muted);
    font-size: 9px;
}

.bonus-badge {
    position: absolute;
    top: 13px;
    right: 13px;
    z-index: 1;

    padding: 8px 10px;

    border: 1px solid rgba(255, 208, 113, 0.33);
    border-radius: 999px;

    background: rgba(23, 19, 12, 0.86);
    color: var(--gold);
    font-size: 9px;
}

.game-controls {
    min-height: 67px;
    padding-top: 16px;
}

.desktop-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.keyboard-key {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;

    border: 1px solid var(--line-strong);
    border-radius: 7px;

    background: #101623;
    color: #cbd7e7;
    font-size: 14px;
}

.controls-hint {
    margin-left: 6px;
    color: var(--muted);
    font-size: 11px;
}

.action-buttons {
    gap: 9px;
}

.button {
    min-height: 39px;
    padding: 0 16px;

    border: 1px solid transparent;
    border-radius: 11px;

    cursor: pointer;
    font-size: 12px;
    font-weight: 700;

    transition:
        transform 140ms ease,
        background 140ms ease,
        border-color 140ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.button-primary {
    background: var(--green);
    color: #092012;
}

.button-primary:hover {
    background: #a0ffbf;
}

.button-secondary {
    border-color: rgba(125, 255, 168, 0.24);
    background: rgba(125, 255, 168, 0.08);
    color: var(--green);
}

.button-ghost {
    border-color: var(--line);
    background: transparent;
    color: #c2cddd;
}

.touch-controls {
    display: none;
}

.dashboard {
    display: grid;
    gap: 14px;
}

.stats-card,
.mini-card,
.settings-card,
.legend-card {
    border-radius: 18px;
}

.score-card {
    position: relative;
    overflow: hidden;
    padding: 19px 21px 18px;
}

.score-card::after {
    position: absolute;
    right: -40px;
    bottom: -95px;

    width: 155px;
    height: 155px;
    border-radius: 50%;

    background: rgba(125, 255, 168, 0.13);
    content: "";
    filter: blur(30px);
}

.card-label {
    display: block;
    color: var(--muted);
    font-size: 9px;
}

.score-value {
    display: block;
    margin-top: 6px;
    color: var(--green);
    font-family: var(--mono);
    font-size: 53px;
    font-weight: 800;
    letter-spacing: -0.07em;
    line-height: 1.05;
}

.score-value.is-popping {
    animation: score-pop 220ms ease;
}

.score-feedback {
    display: block;
    margin-top: 5px;
    color: #aeb9c8;
    font-size: 11px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}

.mini-card {
    padding: 15px 16px 13px;
}

.mini-value {
    display: block;
    margin-top: 7px;
    font-family: var(--mono);
    font-size: 21px;
    letter-spacing: -0.04em;
}

.settings-card {
    padding: 17px 16px 16px;
}

.settings-heading {
    margin-bottom: 19px;
}

.settings-heading h2 {
    margin: 0;
    font-size: 15px;
}

.settings-heading span {
    color: var(--muted);
    font-size: 9px;
}

.option-group {
    margin: 0;
    padding: 0;
    border: 0;
}

.option-group + .option-group {
    margin-top: 20px;
}

.option-group legend {
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 9px;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;

    padding: 4px;

    border: 1px solid var(--line);
    border-radius: 12px;

    background: rgba(8, 12, 19, 0.5);
}

.option-button {
    min-height: 34px;
    border: 0;
    border-radius: 8px;

    background: transparent;
    color: #b4becc;

    cursor: pointer;
    font-size: 11px;
}

.option-button.is-selected {
    background: rgba(125, 255, 168, 0.14);
    color: var(--green);
}

.mode-options {
    display: grid;
    gap: 7px;
}

.mode-button {
    display: flex;
    min-height: 56px;
    align-items: center;
    gap: 10px;

    padding: 9px 10px;

    border: 1px solid transparent;
    border-radius: 11px;

    background: rgba(8, 12, 19, 0.4);
    color: #bdc8d6;

    cursor: pointer;
    text-align: left;

    transition:
        border-color 140ms ease,
        background 140ms ease;
}

.mode-button.is-selected {
    border-color: rgba(125, 255, 168, 0.27);
    background: var(--green-soft);
}

.mode-symbol {
    display: grid;
    width: 29px;
    height: 29px;
    flex: 0 0 auto;
    place-items: center;

    border-radius: 8px;

    background: rgba(128, 143, 168, 0.11);
    color: var(--green);
    font-size: 16px;
}

.mode-button strong,
.mode-button small {
    display: block;
}

.mode-button strong {
    color: #e2e9f3;
    font-size: 11px;
}

.mode-button small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.legend-card {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 15px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #bbc6d4;
    font-size: 10px;
}

.apple-dot {
    background: var(--pink);
    box-shadow: 0 0 12px rgba(255, 112, 141, 0.65);
}

.bonus-dot {
    background: var(--gold);
    box-shadow: 0 0 12px rgba(255, 208, 113, 0.65);
}

.footer {
    margin-top: 23px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 9px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@keyframes score-pop {
    50% {
        transform: scale(1.055);
    }
}

@media (max-width: 1110px) {
    .arcade-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 16px;
    }

    .controls-hint {
        display: none;
    }
}

@media (max-width: 850px) {
    .arcade-shell {
        width: min(700px, calc(100% - 38px));
        padding-top: 22px;
    }

    .introduction {
        padding: 42px 0 23px;
    }

    .arcade-layout {
        grid-template-columns: 1fr;
    }

    .dashboard {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .settings-card,
    .legend-card {
        grid-column: 1 / -1;
    }

    .mode-options {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 560px) {
    .arcade-shell {
        width: calc(100% - 26px);
        padding-top: 17px;
    }

    .brand-mark {
        width: 41px;
        height: 41px;
    }

    .brand-name {
        font-size: 16px;
    }

    .brand-kicker {
        font-size: 8px;
    }

    .live-badge {
        display: none;
    }

    .introduction {
        padding: 38px 0 20px;
    }

    .introduction h1 {
        max-width: 410px;
        font-size: 34px;
    }

    .introduction-copy {
        max-width: 290px;
        font-size: 13px;
    }

    .game-card {
        padding: 12px;
        border-radius: 17px;
    }

    .game-card-header {
        padding-bottom: 11px;
    }

    .game-status,
    .game-mode-indicator {
        gap: 5px;
        font-size: 8px;
    }

    .board-wrapper {
        border-radius: 12px;
    }

    .game-overlay {
        padding: 14px;
    }

    .game-overlay h2 {
        margin: 8px 0 5px;
        font-size: 26px;
    }

    .game-overlay p {
        margin-bottom: 11px;
        font-size: 11px;
        line-height: 1.4;
    }

    .overlay-shortcut {
        display: none;
    }

    .game-controls {
        justify-content: center;
        min-height: 51px;
        padding-top: 12px;
    }

    .desktop-controls {
        display: none;
    }

    .touch-controls {
        display: grid;
        width: 150px;
        height: 116px;

        grid-template-columns: repeat(3, 44px);
        grid-template-rows: repeat(2, 44px);

        justify-content: center;
        gap: 7px;
        margin: 5px auto 0;
    }

    .direction-button {
        display: grid;
        place-items: center;

        border: 1px solid var(--line-strong);
        border-radius: 12px;

        background: var(--surface-raised);
        color: var(--green);

        cursor: pointer;
        font-size: 20px;
    }

    .direction-button:active {
        background: rgba(125, 255, 168, 0.15);
    }

    .direction-up {
        grid-column: 2;
        grid-row: 1;
    }

    .direction-left {
        grid-column: 1;
        grid-row: 2;
    }

    .direction-down {
        grid-column: 2;
        grid-row: 2;
    }

    .direction-right {
        grid-column: 3;
        grid-row: 2;
    }

    .dashboard {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .settings-card,
    .legend-card {
        grid-column: auto;
    }

    .mode-options {
        grid-template-columns: 1fr;
    }

    .footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        font-size: 8px;
    }
}

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