* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, #0b1020 0%, #131a2c 50%, #1b2336 100%);
    color: #e2e8f0;
    min-height: 100vh;
    overflow-x: hidden;
    --banner-space: 100px;
}

.retro-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(88, 101, 242, 0.2), transparent 40%),
        radial-gradient(circle at 80% 10%, rgba(236, 72, 153, 0.2), transparent 45%),
        radial-gradient(circle at 50% 80%, rgba(34, 197, 94, 0.2), transparent 50%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04) 2px, transparent 2px, transparent 10px);
    z-index: -1;
    animation: drift 14s ease-in-out infinite alternate;
}

.app {
    height: 100vh;
    height: 100svh;
    padding: 16px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen {
    display: none;
    width: 100%;
    max-width: 900px;
}

.screen.active {
    display: block;
}

#game-screen {
    height: 100%;
}

#game-screen.active {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) rgba(15, 23, 42, 0.2);
    padding-bottom: calc(12px + var(--banner-space));
}

.menu-card,
.result-card,
.modal-card {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.6);
}

.menu-card {
    text-align: center;
}

.logo-chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: #111827;
    color: #facc15;
    letter-spacing: 1px;
    font-size: 12px;
}

.menu-card h1 {
    margin: 12px 0 8px;
    font-size: 36px;
}

.tagline {
    margin: 0 0 20px;
    color: #cbd5f5;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.menu-actions .btn {
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn {
    border: none;
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active {
    transform: translateY(2px);
}

.primary {
    background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(99, 102, 241, 0.4);
}

.ghost {
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.4);
}

.hud {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 0;
}

.hud-block {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 16px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.hud-sub {
    font-size: 12px;
    color: #cbd5f5;
}

.pause-hud {
    align-items: center;
    justify-content: center;
}

.hud-button {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 12px;
    box-shadow: none;
}

.next-hud {
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.hud-label {
    font-size: 12px;
    color: #94a3b8;
}

.arena {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.board-wrapper {
    position: relative;
    background: linear-gradient(180deg, rgba(10, 15, 32, 0.95) 0%, rgba(3, 7, 18, 0.9) 100%);
    border-radius: 18px;
    padding: 12px;
    box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.35), 0 24px 50px rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
}

.pause-card {
    background: rgba(15, 23, 42, 0.95);
    padding: 24px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pause-card h2 {
    margin: 0 0 12px;
}

#next-canvas {
    width: 56px;
    height: 56px;
}


.touch-controls {
    margin-top: 6px;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    width: fit-content;
    max-width: 100%;
}

.scroll-spacer {
    height: var(--banner-space);
    width: 100%;
}

.board-wrapper + .touch-controls {
    margin-top: 8px;
}

.control-pad {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(236, 72, 153, 0.95));
    color: #ffffff;
    font-size: 22px;
    box-shadow: 0 10px 22px rgba(99, 102, 241, 0.35);
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#game-screen.active::-webkit-scrollbar {
    width: 8px;
}

#game-screen.active::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.2);
    border-radius: 999px;
}

#game-screen.active::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.6);
    border-radius: 999px;
}

.result-card {
    text-align: center;
}

.result-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    font-size: 12px;
    margin-bottom: 12px;
}

.result-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 20px 0 24px;
    font-size: 14px;
}

.result-meta strong {
    display: block;
    font-size: 18px;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 10;
}

.modal-card {
    max-width: 420px;
    width: 100%;
}

.how-text {
    color: #cbd5f5;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 20px;
}

.settings-btn {
    width: 100%;
}

.hidden {
    display: none;
}

.level-flash {
    animation: levelFlash 0.8s ease;
}

@keyframes levelFlash {
    0% {
        box-shadow: 0 0 0 rgba(250, 204, 21, 0);
    }
    50% {
        box-shadow: 0 0 20px rgba(250, 204, 21, 0.8);
    }
    100% {
        box-shadow: 0 0 0 rgba(250, 204, 21, 0);
    }
}

@keyframes drift {
    0% {
        transform: translateY(0px);
    }
    100% {
        transform: translateY(-20px);
    }
}

@media (max-width: 860px) {
    .arena {
        grid-template-columns: 1fr;
    }
    .board-wrapper {
        max-width: 92vw;
        margin: 0 auto;
    }
}

@media (max-width: 600px) {
    .hud {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .menu-card h1 {
        font-size: 30px;
    }
    .control-btn {
        width: 56px;
        height: 56px;
    }
    .board-wrapper {
        padding: 10px;
    }
}
