:root {
    --void: #000000;
    --maze-blue: #2121ff;
    --neon-yellow: #ffff00;
    --neon-cyan: #00ffff;
    --ghost-pink: #ffb8ff;
    --alert-red: #ff0000;
    --felt-ink: #0a0a1a;
    --card-white: #f8f8f8;
    --card-w: 90px;
    --card-h: 130px;
}

* {
    box-sizing: border-box;
}
html {
    min-height: 100%;
    background: var(--void);
}
body {
    min-height: 100vh;
    margin: 0;
    padding: 22px 14px;
    overflow-x: hidden;
    background: var(--void);
    color: var(--card-white);
    font-family: "Press Start 2P", "VT323", "Courier New", monospace;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
button {
    font: inherit;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
button:focus-visible {
    outline: 3px solid var(--neon-cyan);
    outline-offset: 4px;
}
button:disabled {
    opacity: 0.28;
    cursor: not-allowed;
    filter: grayscale(1);
}

.scanlines {
    position: fixed;
    inset: 0;
    z-index: 99;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 3px,
        rgba(255, 255, 255, 0.025) 3px,
        rgba(255, 255, 255, 0.025) 4px
    );
    box-shadow: inset 0 0 100px 18px #000;
}
.cabinet {
    position: relative;
    width: min(960px, calc(100vw - 28px));
    min-height: calc(100vh - 44px);
    margin: auto;
    border: 3px solid var(--maze-blue);
    outline: 3px solid var(--maze-blue);
    outline-offset: 6px;
    border-radius: 16px;
    background: var(--void);
    box-shadow:
        0 0 12px var(--maze-blue),
        inset 0 0 10px rgba(33, 33, 255, 0.6);
}
.marquee {
    min-height: 92px;
    position: relative;
    display: grid;
    place-items: center;
    border-bottom: 4px solid var(--maze-blue);
    overflow: hidden;
}
.marquee h1 {
    z-index: 2;
    margin: 0;
    padding: 8px 20px;
    color: var(--neon-yellow);
    background: #000;
    font-size: clamp(1.6rem, 5vw, 3rem);
    letter-spacing: 0.2em;
    text-shadow:
        3px 0 var(--alert-red),
        0 0 9px var(--neon-yellow);
    animation: marquee-flash 1.3s steps(2, end) infinite;
}
.chase {
    position: absolute;
    inset: 0 auto 0 -220px;
    display: flex;
    align-items: center;
    gap: 22px;
    color: var(--ghost-pink);
    font-size: 18px;
    animation: chase 8s linear infinite;
}
.chase span:nth-child(3) {
    color: var(--alert-red);
}
.chase span:nth-child(4) {
    color: var(--neon-cyan);
}
.chase span:nth-child(5) {
    color: var(--ghost-pink);
}
.chomper {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--neon-yellow);
    clip-path: polygon(0 0, 100% 0, 52% 50%, 100% 100%, 0 100%);
    animation: chomp 0.32s steps(2, end) infinite;
}
.icon-button {
    position: absolute;
    z-index: 3;
    right: 12px;
    top: 50%;
    translate: 0 -50%;
    padding: 8px;
    border: 2px solid var(--neon-cyan);
    border-radius: 8px;
    background: #000;
    color: var(--neon-cyan);
    cursor: pointer;
}
.hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 12px;
    border-bottom: 3px solid var(--maze-blue);
    text-align: center;
}
.hud div {
    border-right: 2px solid var(--maze-blue);
}
.hud div:last-child {
    border: 0;
}
.hud-label {
    display: block;
    margin-bottom: 5px;
    color: var(--neon-cyan);
    font-size: 0.62rem;
}
.hud strong {
    color: var(--neon-yellow);
    font-size: clamp(0.8rem, 2vw, 1.15rem);
    text-shadow: 0 0 7px currentColor;
}

.table {
    position: relative;
    min-height: 480px;
    padding: 18px 20px;
    background: var(--felt-ink);
}
.table h2 {
    margin: 0 0 6px;
    color: var(--neon-cyan);
    font-size: 0.72rem;
}
.dealer-zone {
    min-height: 190px;
    text-align: center;
}
.player-zone {
    min-height: 230px;
    margin-top: 12px;
    text-align: center;
}
.hand-status {
    min-height: 18px;
    margin-bottom: 8px;
    color: var(--neon-cyan);
    font-size: 0.7rem;
}
.cards {
    min-height: var(--card-h);
    display: flex;
    justify-content: center;
}
.cards .card + .card {
    margin-left: -18px;
}
.hands {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 4px 12px;
}
.hand {
    min-width: calc(var(--card-w) + 34px);
    padding: 7px;
    border: 3px solid transparent;
    border-radius: 8px;
}
.hand.active {
    border-color: var(--neon-yellow);
    box-shadow: 0 0 10px var(--neon-yellow);
    animation: active-pulse 1s steps(2, end) infinite;
}
.hand.win {
    border-color: var(--ghost-pink);
    box-shadow: 0 0 10px var(--ghost-pink);
}
.hand.lose,
.hand.bust {
    border-color: var(--alert-red);
}
.hand-meta {
    margin-top: 7px;
    color: var(--neon-yellow);
    font-size: 0.58rem;
    line-height: 1.7;
    white-space: nowrap;
}
.result-label {
    display: block;
    color: var(--ghost-pink);
}
.bust .result-label,
.lose .result-label {
    color: var(--alert-red);
}

.card {
    width: var(--card-w);
    height: var(--card-h);
    flex: 0 0 var(--card-w);
    perspective: 600px;
    image-rendering: pixelated;
}
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.34s steps(4, end);
}
.card.hidden .card-inner {
    transform: rotateY(180deg);
}
.card-face,
.card-back {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border: 4px solid #000;
    border-radius: 8px;
    backface-visibility: hidden;
}
.card-face {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-white);
    color: #000;
    font-weight: 900;
}
.card-back {
    transform: rotateY(180deg);
    background-color: var(--maze-blue);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent 0 10px,
            var(--neon-yellow) 10px 13px
        ),
        repeating-linear-gradient(
            90deg,
            transparent 0 10px,
            var(--neon-yellow) 10px 13px
        );
    border-color: var(--card-white);
    box-shadow:
        inset 0 0 0 5px var(--maze-blue),
        inset 0 0 0 8px var(--card-white);
}
.card.red .card-face {
    color: var(--alert-red);
}
.corner {
    position: absolute;
    top: 5px;
    left: 6px;
    font-size: 1rem;
    line-height: 1.05;
    letter-spacing: 0;
}
.corner.bottom {
    inset: auto 6px 5px auto;
    transform: rotate(180deg);
}
.suit-large {
    font-size: 2.2rem;
}
.card.dealt {
    animation: deal-in 0.38s steps(5, end) both;
}
.message {
    min-height: 42px;
    display: grid;
    place-items: center;
    padding: 9px;
    border-top: 3px solid var(--maze-blue);
    color: var(--neon-yellow);
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.5;
}
.controls {
    min-height: 82px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-top: 2px solid var(--maze-blue);
}
.action,
.utility {
    min-height: 44px;
    padding: 9px 15px;
    border: 3px solid var(--neon-cyan);
    border-radius: 8px;
    background: #000;
    color: var(--neon-cyan);
    cursor: pointer;
    box-shadow: 0 0 5px currentColor;
}
.action.primary {
    border-color: var(--neon-yellow);
    color: var(--neon-yellow);
}
.action.danger {
    border-color: var(--alert-red);
    color: var(--alert-red);
}
.chip {
    width: 58px;
    height: 58px;
    border: 5px dashed currentColor;
    border-radius: 50%;
    background: #000;
    cursor: pointer;
    font-size: 0.65rem;
    box-shadow:
        inset 0 0 0 3px #000,
        0 0 7px currentColor;
}
.chip:nth-child(1) {
    color: var(--neon-yellow);
}
.chip:nth-child(2) {
    color: var(--neon-cyan);
}
.chip:nth-child(3) {
    color: var(--ghost-pink);
}
.chip:nth-child(4) {
    color: var(--alert-red);
}
.toast {
    position: fixed;
    z-index: 110;
    left: 50%;
    top: 18px;
    translate: -50% -80px;
    padding: 13px 18px;
    border: 3px solid var(--neon-cyan);
    background: #000;
    color: var(--neon-cyan);
    transition: translate 0.2s steps(2, end);
}
.toast.show {
    translate: -50% 0;
}
.overlay {
    position: fixed;
    z-index: 105;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: grid;
    place-items: center;
    padding: 20px;
}
.overlay[hidden] {
    display: none;
}
.modal {
    max-width: 560px;
    padding: 28px;
    border: 4px solid var(--maze-blue);
    outline: 3px solid var(--maze-blue);
    outline-offset: 7px;
    background: #000;
    text-align: center;
}
.modal h2 {
    color: var(--alert-red);
    text-shadow: 0 0 8px currentColor;
    line-height: 1.5;
}
.modal p {
    color: var(--neon-yellow);
    line-height: 1.7;
    font-size: 0.75rem;
}
.modal-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 20px;
}
.burst {
    pointer-events: none;
    position: absolute;
    z-index: 5;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    color: var(--ghost-pink);
    font-size: clamp(1.5rem, 8vw, 4rem);
    text-shadow: 0 0 12px currentColor;
    opacity: 0;
}
.burst.show {
    animation: burst 0.8s steps(4, end);
}
.burst.blackjack {
    animation:
        burst 1.1s steps(4, end),
        rainbow 0.45s steps(1, end) infinite;
}
.table.shake {
    animation: shake 0.24s steps(2, end);
}

@keyframes chase {
    to {
        transform: translateX(calc(100vw + 500px));
    }
}
@keyframes chomp {
    50% {
        clip-path: polygon(0 0, 100% 25%, 52% 50%, 100% 75%, 0 100%);
    }
}
@keyframes marquee-flash {
    50% {
        text-shadow:
            3px 0 var(--ghost-pink),
            0 0 14px var(--neon-yellow);
    }
}
@keyframes deal-in {
    from {
        transform: translate(300px, -180px) rotate(12deg);
        opacity: 0;
    }
}
@keyframes active-pulse {
    50% {
        box-shadow: 0 0 18px var(--neon-yellow);
    }
}
@keyframes burst {
    0% {
        opacity: 0;
        scale: 0.5;
    }
    30%,
    70% {
        opacity: 1;
        scale: 1.15;
    }
    100% {
        opacity: 0;
        scale: 1.5;
    }
}
@keyframes rainbow {
    0% {
        color: var(--neon-yellow);
    }
    25% {
        color: var(--neon-cyan);
    }
    50% {
        color: var(--ghost-pink);
    }
    75% {
        color: var(--alert-red);
    }
}
@keyframes shake {
    25% {
        transform: translateX(-7px);
    }
    75% {
        transform: translateX(7px);
    }
}

@media (max-width: 600px) {
    :root {
        --card-w: 62px;
        --card-h: 90px;
    }
    body {
        padding: 10px 8px;
        letter-spacing: 0.06em;
    }
    .cabinet {
        width: calc(100vw - 16px);
        min-height: calc(100vh - 20px);
        outline-offset: 4px;
    }
    .marquee {
        min-height: 66px;
    }
    .marquee h1 {
        font-size: 1.35rem;
        letter-spacing: 0.12em;
    }
    .chase {
        opacity: 0.65;
        gap: 12px;
    }
    .hud {
        padding: 8px 2px;
    }
    .hud-label {
        font-size: 0.45rem;
    }
    .hud strong {
        font-size: 0.7rem;
    }
    .table {
        min-height: 390px;
        padding: 12px 5px;
    }
    .dealer-zone {
        min-height: 140px;
    }
    .player-zone {
        min-height: 180px;
    }
    .corner {
        top: 3px;
        left: 3px;
        font-size: 0.7rem;
    }
    .corner.bottom {
        inset: auto 3px 3px auto;
    }
    .suit-large {
        font-size: 1.5rem;
    }
    .cards .card + .card {
        margin-left: -13px;
    }
    .hands {
        justify-content: flex-start;
        gap: 2px;
    }
    .hand {
        min-width: calc(var(--card-w) + 20px);
        padding: 4px;
    }
    .hand-meta {
        font-size: 0.43rem;
    }
    .controls {
        gap: 7px;
        padding: 9px 5px;
    }
    .action,
    .utility {
        min-height: 40px;
        padding: 7px 9px;
        font-size: 0.59rem;
    }
    .chip {
        width: 48px;
        height: 48px;
        border-width: 4px;
        font-size: 0.55rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
    .chase {
        display: none;
    }
    .burst.show {
        opacity: 1;
    }
}
