/* ============================================================
   VIDEO POKER — Vegas machine cabinet + CRT screen styling
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #ffd24a;
    --gold-bright: #ffe98a;
    --screen-blue-1: #0a1a6e;
    --screen-blue-2: #051040;
    --cabinet-1: #2b2b33;
    --cabinet-2: #17171d;
    --red: #e02020;
    --green: #2ee65f;
    --font-lcd: 'VT323', 'Courier New', monospace;
}

/* Pixel-stepped corners (slightly low-res look, not full 8-bit) */
.px,
.card,
.btn,
.pay-table,
.game-status,
.lcd,
.combining-help,
.win-banner {
    clip-path: polygon(
        0 6px, 3px 6px, 3px 3px, 6px 3px, 6px 0,
        calc(100% - 6px) 0, calc(100% - 6px) 3px, calc(100% - 3px) 3px, calc(100% - 3px) 6px, 100% 6px,
        100% calc(100% - 6px), calc(100% - 3px) calc(100% - 6px), calc(100% - 3px) calc(100% - 3px), calc(100% - 6px) calc(100% - 3px), calc(100% - 6px) 100%,
        6px 100%, 6px calc(100% - 3px), 3px calc(100% - 3px), 3px calc(100% - 6px), 0 calc(100% - 6px)
    );
}

body {
    font-family: var(--font-lcd);
    background:
        radial-gradient(ellipse at 50% -20%, #2a1b4d 0%, #12092b 45%, #060412 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 14px 10px;
    color: white;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.game-container {
    max-width: 720px;
    margin: 0 auto;
}

/* ============ SCREEN ============ */

.screen-bezel {
    background: linear-gradient(180deg, #3a3a44 0%, #1d1d24 20%, #101014 100%);
    border: 2px solid #000;
    border-radius: 14px;
    padding: 14px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.screen {
    position: relative;
    background: linear-gradient(180deg, var(--screen-blue-1) 0%, var(--screen-blue-2) 100%);
    border-radius: 6px;
    padding: 12px 14px 10px;
    overflow: hidden;
    box-shadow:
        inset 0 0 60px rgba(0, 0, 30, 0.8),
        inset 0 0 8px rgba(0, 0, 0, 0.9);
}

/* CRT scanlines + vignette overlay */
.scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.105) 0px,
            rgba(0, 0, 0, 0.105) 1px,
            transparent 1px,
            transparent 3px
        );
    z-index: 50;
}

.screen::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 20, 0.45) 100%);
    z-index: 51;
}

/* Screen flash on wins */
.screen.flash-win {
    animation: screenFlash 0.5s ease-out;
}

@keyframes screenFlash {
    0% { box-shadow: inset 0 0 120px rgba(255, 210, 74, 0.55); }
    100% { box-shadow: inset 0 0 60px rgba(0, 0, 30, 0.8); }
}

/* ============ TOP TICKER ============ */

.game-status {
    background: rgba(0, 0, 25, 0.55);
    border: 1px solid rgba(255, 210, 74, 0.35);
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 17px;
    letter-spacing: 1px;
    color: #9fb4ff;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.special-indicator {
    color: var(--gold);
}

.special-indicator.randomized {
    color: #ff5555;
    animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.35; }
}

.wild-indicator {
    color: #6f85c9;
}

.wild-indicator.active {
    color: var(--green);
    text-shadow: 0 0 8px rgba(46, 230, 95, 0.8);
    animation: blink 1.2s steps(2, start) infinite;
}

/* ============ PAY TABLE ============ */

.pay-table {
    background: rgba(0, 0, 25, 0.55);
    color: var(--gold);
    border: 1px solid rgba(255, 210, 74, 0.5);
    margin-bottom: 8px;
    overflow-x: auto;
    font-size: 17px;
    line-height: 1.05;
    letter-spacing: 0.5px;
}

.pay-header, .pay-row {
    display: grid;
    grid-template-columns: 2.2fr 1fr 1fr 1fr 1fr 1fr;
    gap: 4px;
    padding: 3px 8px;
}

.pay-header {
    color: var(--gold-bright);
    border-bottom: 1px solid rgba(255, 210, 74, 0.5);
    padding-bottom: 4px;
}

.pay-row div {
    text-align: center;
    padding: 1px 2px;
}

.pay-header div {
    text-align: center;
}

.pay-row div:first-child,
.pay-header div:first-child {
    text-align: left;
}

/* Selected-bet column: classic red highlight */
.pay-highlight {
    background: var(--red);
    color: #fff;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

/* Winning hand row flash after a win */
.pay-row.won-row {
    animation: wonRow 0.6s steps(2, start) 4;
}

@keyframes wonRow {
    0%, 49% { background: var(--gold); color: #201500; }
    50%, 100% { background: transparent; color: var(--gold); }
}

.pay-row.won-row div {
    color: inherit;
}

.randomized-table {
    border-color: #ff5555;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* ============ TITLE + MESSAGE ============ */

.game-title {
    text-align: center;
    font-size: 40px;
    letter-spacing: 4px;
    color: var(--gold);
    margin: 2px 0 6px;
    text-shadow:
        0 0 12px rgba(255, 210, 74, 0.55),
        2px 2px 0 rgba(0, 0, 0, 0.6);
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 8px rgba(255, 210, 74, 0.35), 2px 2px 0 rgba(0, 0, 0, 0.6); }
    50% { text-shadow: 0 0 18px rgba(255, 210, 74, 0.85), 2px 2px 0 rgba(0, 0, 0, 0.6); }
}

.game-message {
    text-align: center;
    font-size: 22px;
    letter-spacing: 1.5px;
    margin-top: 8px;
    min-height: 28px;
    color: #cdd8ff;
}

.game-message.msg-win {
    color: var(--gold-bright);
    text-shadow: 0 0 10px rgba(255, 210, 74, 0.8);
    animation: msgPop 0.35s ease-out;
}

.game-message.msg-lose {
    color: #ff7070;
}

.game-message.msg-info {
    color: #cdd8ff;
}

@keyframes msgPop {
    0% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* ============ CARDS ============ */

.cards-stage {
    position: relative;
}

.cards-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 26px 0 14px;
    flex-wrap: wrap;
}

.card {
    width: 88px;
    height: 126px;
    background: linear-gradient(160deg, #ffffff 0%, #eef0f4 70%, #dfe3ea 100%);
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, filter 0.15s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    user-select: none;
    touch-action: none;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.card:hover {
    transform: translateY(-5px);
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.6));
}

.card.held {
    transform: translateY(-12px);
    box-shadow: inset 0 0 0 3px var(--gold);
    filter: drop-shadow(0 0 10px rgba(255, 210, 74, 0.9));
}

.card.held:hover {
    transform: translateY(-14px);
}

.card.drag-over {
    transform: scale(1.06);
    box-shadow: inset 0 0 0 3px var(--green);
    filter: drop-shadow(0 0 10px rgba(46, 230, 95, 0.9));
}

.card.wild {
    background: linear-gradient(160deg, #fff6d8 0%, #ffe98a 100%);
    animation: bonusGlow 1.6s infinite;
}

@keyframes bonusGlow {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 210, 74, 0.7)); }
    50% { filter: drop-shadow(0 0 16px rgba(255, 210, 74, 1)); }
}

/* Winning cards after draw */
.card.winning {
    animation: winningCard 0.7s ease-in-out infinite;
    box-shadow: inset 0 0 0 3px var(--gold);
}

@keyframes winningCard {
    0%, 100% {
        transform: translateY(0);
        filter: drop-shadow(0 0 6px rgba(255, 210, 74, 0.8));
    }
    50% {
        transform: translateY(-10px);
        filter: drop-shadow(0 0 18px rgba(255, 210, 74, 1));
    }
}

/* Non-winning cards fade back a bit */
.card.dimmed {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)) brightness(0.55) saturate(0.6);
}

/* Deal / draw flip-in animation (staggered via inline animation-delay) */
.card.deal-in {
    animation: dealIn 0.3s ease-out backwards;
}

@keyframes dealIn {
    0% {
        transform: translateY(-30px) rotateY(90deg);
        opacity: 0;
    }
    100% {
        transform: translateY(0) rotateY(0deg);
        opacity: 1;
    }
}

/* Red strip overlaid across the middle of a held card (clip-path on .card
   would cut off anything positioned outside the card bounds) */
.held-indicator {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    background: var(--red);
    color: white;
    text-align: center;
    padding: 1px 0;
    font-size: 16px;
    letter-spacing: 3px;
    line-height: 1.2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.card-rank {
    font-size: 26px;
    font-weight: bold;
    line-height: 1;
    font-family: var(--font-lcd);
}

.card-suit {
    font-size: 40px;
    text-align: center;
    line-height: 1;
}

.card-red { color: #d21e1e; }
.card-black { color: #14141a; }

/* Card backs for betting phase */
.card-back {
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 4px, transparent 4px 8px),
        linear-gradient(160deg, #14346e, #0a1f4a);
    box-shadow: inset 0 0 0 3px #2d5a9e;
    cursor: default;
}

.card-back:hover {
    transform: none;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.card-back-pattern {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back-design {
    color: #4a90c2;
    font-size: 22px;
    text-align: center;
    opacity: 0.7;
    transform: rotate(45deg);
}

/* ============ WIN BANNER ============ */

.win-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(180deg, #b31212 0%, #7d0a0a 100%);
    border: 3px solid var(--gold);
    color: var(--gold-bright);
    font-size: 34px;
    letter-spacing: 3px;
    padding: 10px 28px;
    text-align: center;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
    z-index: 40;
    white-space: nowrap;
    animation:
        bannerIn 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) backwards,
        bannerBlink 0.8s steps(2, start) 0.4s 3,
        bannerFade 0.5s ease 2.6s forwards;
    pointer-events: none;
}

/* Fade out after a couple seconds so the glowing winning cards stay visible */
@keyframes bannerFade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes bannerIn {
    0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes bannerBlink {
    0%, 49% { border-color: var(--gold); }
    50%, 100% { border-color: #fff; }
}

.win-banner .banner-payout {
    display: block;
    font-size: 26px;
    color: #fff;
}

/* ============ COIN PARTICLES ============ */

.particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 45;
}

.coin {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--gold);
    box-shadow: inset -2px -2px 0 #c99a1e, inset 2px 2px 0 var(--gold-bright);
    animation: coinFall linear forwards;
}

@keyframes coinFall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    80% { opacity: 1; }
    100% {
        transform: translateY(240px) rotate(540deg);
        opacity: 0;
    }
}

/* ============ CONSOLE (buttons + LCDs) ============ */

.console {
    margin-top: 12px;
    background: linear-gradient(180deg, #34343e 0%, #1c1c22 30%, #121216 100%);
    border: 2px solid #000;
    border-radius: 12px;
    padding: 14px 16px 10px;
    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Status Bar — LCD readouts */
.status-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.lcd {
    background: #050a04;
    border: 1px solid #333;
    padding: 4px 16px 6px;
    text-align: center;
    min-width: 130px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
}

.lcd-label {
    display: block;
    font-size: 14px;
    letter-spacing: 2px;
    color: #6a7a68;
}

.lcd-value {
    display: block;
    font-size: 30px;
    line-height: 1;
    color: #ffcf3f;
    text-shadow: 0 0 8px rgba(255, 207, 63, 0.6);
}

.lcd-value.bump {
    animation: lcdBump 0.25s ease-out;
}

@keyframes lcdBump {
    0% { transform: scale(1.25); color: #fff; }
    100% { transform: scale(1); }
}

/* Controls — fixed 3-slot grid so DEAL and DRAW land on the same key */
.controls {
    display: grid;
    grid-template-columns: 1fr 1fr 2.2fr;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 10px;
}

/* Result phase: NEW GAME takes the whole row */
.controls.result-phase .btn-bet {
    display: none;
}

.controls.result-phase .action-slot {
    grid-column: 1 / -1;
}

.action-slot {
    display: flex;
}

.btn {
    width: 100%;
    padding: 12px 10px 14px;
    border: none;
    font-family: var(--font-lcd);
    font-size: 22px;
    letter-spacing: 2px;
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.08s ease;
    text-transform: uppercase;
    color: white;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.55));
}

.btn:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 7px 0 rgba(0, 0, 0, 0.55)) brightness(1.1);
}

.btn:active {
    transform: translateY(3px);
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.55));
}

.btn-bet {
    background: linear-gradient(180deg, #ffcf3f 0%, #d99f10 100%);
    color: #3a2800;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-bet:disabled {
    background: #4a4a52;
    color: #83838d;
    cursor: not-allowed;
    transform: none;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.4));
    text-shadow: none;
}

.btn-deal, .btn-draw {
    background: linear-gradient(180deg, #ff4a3a 0%, #b31210 100%);
    font-size: 26px;
    padding: 14px 10px 16px;
}

.btn-deal:disabled {
    background: #4a4a52;
    color: #83838d;
    cursor: not-allowed;
    transform: none;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.4));
}

.btn-draw {
    animation: btnAttract 1.4s ease-in-out infinite;
}

@keyframes btnAttract {
    0%, 100% { filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.55)); }
    50% { filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.55)) brightness(1.25); }
}

.btn-new-game {
    background: linear-gradient(180deg, #3f7bff 0%, #1440b3 100%);
    font-size: 26px;
    padding: 14px 10px 16px;
}

.hidden {
    display: none;
}

/* Combining Help */
.combining-help {
    background: rgba(0, 0, 0, 0.45);
    color: #b7a26a;
    padding: 6px 10px;
    text-align: center;
    font-size: 16px;
    letter-spacing: 1px;
}

/* ============ MOBILE ============ */

@media (max-width: 768px) {
    body { padding: 6px 4px; }

    .screen-bezel { padding: 8px; }
    .screen { padding: 8px 8px 6px; }

    .pay-table { font-size: 13px; }
    .game-status { font-size: 13px; }

    .game-title { font-size: 28px; letter-spacing: 2px; }
    .game-message { font-size: 17px; }

    .card {
        width: 62px;
        height: 92px;
        padding: 6px;
    }

    .card-rank { font-size: 18px; }
    .card-suit { font-size: 28px; }
    .held-indicator { font-size: 13px; letter-spacing: 2px; }

    .cards-container { gap: 6px; padding: 22px 0 10px; }

    .win-banner { font-size: 24px; padding: 8px 18px; }
    .win-banner .banner-payout { font-size: 18px; }

    .controls { gap: 8px; }
    .btn { padding: 10px 4px 12px; font-size: 18px; letter-spacing: 1px; }
    .btn-deal, .btn-draw, .btn-new-game { padding: 12px 4px 14px; font-size: 21px; }

    .lcd { min-width: 96px; padding: 3px 10px 5px; }
    .lcd-value { font-size: 24px; }
    .lcd-label { font-size: 12px; }

    .combining-help { font-size: 13px; }
}

@media (max-width: 480px) {
    .card {
        width: 52px;
        height: 78px;
        padding: 4px;
    }

    .card-rank { font-size: 14px; }
    .card-suit { font-size: 22px; }

    .game-title { font-size: 22px; }
    .pay-table { font-size: 11px; }
    .game-status { font-size: 11px; }
    .win-banner { font-size: 19px; white-space: normal; }
    .combining-help { font-size: 11px; }
}
