:root {
    color-scheme: dark;
    --bg: #06070d;
    --panel: #101522;
    --panel-2: #151c2b;
    --line: rgba(255, 255, 255, 0.14);
    --text: #f4f7fb;
    --muted: #aeb8c7;
    --accent: #ffbf2f;
    --accent-2: #42d8ff;
    --danger: #ff5b78;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at 20% 10%, rgba(66, 216, 255, 0.18), transparent 32rem),
        radial-gradient(circle at 80% 100%, rgba(255, 191, 47, 0.14), transparent 34rem),
        var(--bg);
    color: var(--text);
}

.arcade-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.arcade-panel {
    width: min(100%, 760px);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)), var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
}

.arcade-topbar,
.scoreboard,
.arcade-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.arcade-topbar {
    margin-bottom: 14px;
}

.arcade-home,
.arcade-button,
.arcade-link,
.touch-controls button {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.arcade-home,
.arcade-button {
    padding: 10px 14px;
    font-weight: 700;
}

.arcade-button--primary {
    border-color: rgba(255, 191, 47, 0.45);
    background: var(--accent);
    color: #11131a;
}

.arcade-link {
    padding: 8px 12px;
}

.arcade-title {
    text-align: center;
    line-height: 1.1;
}

.arcade-title span,
.scoreboard span,
.arcade-footer span {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
}

.arcade-title strong {
    display: block;
    margin-top: 2px;
    font-size: clamp(1.2rem, 4vw, 2rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.scoreboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 14px;
}

.scoreboard div {
    min-width: 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 6px;
    text-align: center;
}

.scoreboard strong {
    display: block;
    margin-top: 4px;
    color: var(--accent);
    font-size: 1.1rem;
}

.game-wrap {
    position: relative;
    width: 100%;
    display: grid;
    place-items: center;
}

canvas {
    width: min(100%, 504px);
    aspect-ratio: 1 / 1;
    height: auto;
    display: block;
    background: #050712;
    border: 1px solid rgba(66, 216, 255, 0.35);
    border-radius: 6px;
    image-rendering: crisp-edges;
}

.game-message {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
    background: rgba(5, 7, 18, 0.78);
    border-radius: 6px;
}

.game-message.is-hidden {
    display: none;
}

.game-message strong {
    font-size: clamp(1.7rem, 6vw, 3.4rem);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.game-message span {
    color: var(--muted);
}

.touch-controls {
    display: none;
    grid-template-columns: repeat(3, 58px);
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.touch-controls button {
    min-height: 48px;
    font-weight: 700;
}

.touch-controls button[data-dir="up"] {
    grid-column: 2;
}

.touch-controls button[data-dir="left"] {
    grid-column: 1;
}

.touch-controls button[data-dir="down"] {
    grid-column: 2;
}

.touch-controls button[data-dir="right"] {
    grid-column: 3;
}

.arcade-footer {
    margin-top: 14px;
}

.arcade-footer span {
    text-align: right;
}

@media (hover: none), (max-width: 760px) {
    .touch-controls {
        display: grid;
    }
}

@media (max-width: 540px) {
    .arcade-shell {
        padding: 10px;
    }

    .arcade-panel {
        padding: 12px;
    }

    .scoreboard {
        grid-template-columns: repeat(2, 1fr);
    }

    .arcade-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .arcade-footer span {
        text-align: left;
    }
}
