:root {
    --felt-green-1: #2a6551;
    --felt-green-2: #163f33;
    --felt-red-1: #5a2530;
    --felt-red-2: #37151d;
    --cream: #f3e9cc;
    --cream-shadow: #d9cba0;
    --ink: #2a2018;
    --red-suit: #a5241f;
    --gold: #ca9c4d;
    --gold-bright: #f0cf7a;
    --silver: #c8ccd6;
    --teal: #2fa79a;
    --text: #f4ecd6;
    --muted: #b7a888;
    --edge: #0d0906;

    /* Softer, slower motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-soft: cubic-bezier(0.34, 1.28, 0.64, 1);
}

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

html, body { height: 100%; }

body {
    background: #120b07;
    color: var(--text);
    font-family: "Georgia", "Times New Roman", serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.table {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-shadow: inset 0 0 0 2px rgba(202, 156, 77, 0.2);
    display: flex;
    flex-direction: column;
}

.felt {
    position: relative;
    padding: 18px 22px;
}

.felt::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1.4px);
    background-size: 7px 7px;
    pointer-events: none;
    opacity: 0.6;
}

.felt-top {
    background: radial-gradient(120% 90% at 50% 12%, var(--felt-green-1), var(--felt-green-2));
    border-bottom: 3px solid var(--edge);
    flex: 1 1 auto;               /* absorbs slack so there is never empty space below */
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.felt-bottom {
    background: radial-gradient(120% 130% at 50% 100%, var(--felt-red-1), var(--felt-red-2));
    flex: 0 0 auto;
}

.top-rail {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--gold);
    letter-spacing: 4px;
    font-size: 13px;
    text-transform: uppercase;
    flex: 0 0 auto;
}
.top-rail::before, .top-rail::after {
    content: "";
    height: 1px;
    flex: 1;
    max-width: 150px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.felt-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    gap: 18px;
}

.hand-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

/* ---- Hand of cards ---- */
.hand {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(6px, 1.4vw, 16px);
    perspective: 1200px;
}

.card {
    position: relative;
    width: clamp(64px, 8.5vw, 104px);
    aspect-ratio: 25 / 35;
    background: linear-gradient(160deg, var(--cream), var(--cream-shadow));
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
    color: var(--ink);
    overflow: hidden;
    transform-origin: bottom center;
}

/* One-shot deal animation; stripped after the deal so .win/.flash never replay it. */
.card.deal-in {
    animation: dealIn 0.72s var(--ease-out) backwards;
}

@keyframes dealIn {
    0% { opacity: 0; transform: translate(-150px, -70px) rotate(-22deg) scale(0.8); }
    100% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
}

.card.red { color: var(--red-suit); }

.card .corner {
    position: absolute;
    font-weight: 700;
    line-height: 1;
    font-size: clamp(18px, 2.9vw, 28px);
    z-index: 2;
}
.card .corner.tr { top: 7%; right: 9%; }
.card .corner.bl { bottom: 7%; left: 9%; }

.card .center-rank {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: "Georgia", "Times New Roman", serif;
    font-weight: 700;
    font-size: clamp(30px, 5.6vw, 54px);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
    z-index: 2;
}

.card .badge {
    position: absolute;
    top: 6%;
    left: 10%;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 6px;
    display: none;
    z-index: 3;
}

/* Diagonal sheen streak for the metallic editions */
.card.ed-silver::before,
.card.ed-gold::before {
    content: "";
    position: absolute;
    inset: -20%;
    background: linear-gradient(122deg, transparent 38%, rgba(255, 255, 255, 0.7) 48%, transparent 58%);
    pointer-events: none;
    z-index: 1;
}

/* Wild = photographic negative: dark body, light ink */
.card.ed-wild {
    background: linear-gradient(160deg, #17211e, #0b1310);
    color: #eafaf6;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5), inset 0 0 0 2px var(--teal), 0 0 18px rgba(47, 167, 154, 0.55);
}
.card.ed-wild .center-rank { filter: drop-shadow(0 0 12px rgba(47, 167, 154, 0.85)); }
.card.ed-wild .center-rank::after {
    content: "";
    position: absolute;
    width: 82%;
    aspect-ratio: 1;
    background: radial-gradient(circle, rgba(47, 167, 154, 0.32), transparent 70%);
    border-radius: 50%;
    z-index: -1;
}
.card.ed-wild .corner { color: #8ff0e2; text-shadow: 0 0 8px rgba(47, 167, 154, 0.9); }
.card.ed-wild .badge { display: block; background: var(--teal); color: #052b25; }

/* Silver — cooler, brighter metal */
.card.ed-silver {
    background: linear-gradient(158deg, #fbfdff 4%, #d3d9e5 44%, #9aa3b4 100%);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45), inset 0 0 0 2px #f2f5fb, 0 0 20px rgba(198, 210, 230, 0.7);
    color: #26303c;
}
.card.ed-silver.red { color: #7a2a2a; }
.card.ed-silver .badge { display: block; background: linear-gradient(#fbfdff, #a9b1c1); color: #2a3340; }

/* Gold — richer, more saturated */
.card.ed-gold {
    background: linear-gradient(158deg, #fff2b0 4%, #f4c944 46%, #cf9c1e 100%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5), inset 0 0 0 2px #ffe487, 0 0 24px rgba(240, 200, 90, 0.8);
    color: #5a3d0a;
}
.card.ed-gold.red { color: #7a2f0a; }
.card.ed-gold .badge { display: block; background: linear-gradient(#ffe487, var(--gold)); color: #4a3410; }

/* Card states */
.card.win {
    animation: cardWin 1s var(--ease-inout) infinite alternate;
    z-index: 4;
}
@keyframes cardWin {
    from { transform: translateY(0); box-shadow: 0 8px 16px rgba(0,0,0,0.45), inset 0 0 0 2px var(--gold), 0 0 16px rgba(202,156,77,0.5); }
    to   { transform: translateY(-18px); box-shadow: 0 22px 28px rgba(0,0,0,0.5), inset 0 0 0 2px var(--gold-bright), 0 0 34px rgba(240,207,122,0.9); }
}

/* Winning-combination cards stay lifted and highlighted until the next deal. */
.card.won {
    transform: translateY(-16px);
    box-shadow: 0 22px 28px rgba(0,0,0,0.5), inset 0 0 0 2px var(--gold-bright), 0 0 30px rgba(240,207,122,0.85);
    transition: transform 0.45s var(--ease-out), box-shadow 0.45s var(--ease-out);
    z-index: 3;
}

.card.flash-silver { animation: flashSilver 0.85s var(--ease-out); z-index: 4; }
.card.flash-gold { animation: flashGold 0.85s var(--ease-out); z-index: 4; }
@keyframes flashSilver {
    0%, 100% { filter: none; transform: translateY(0) scale(1); }
    45% { filter: brightness(1.7) drop-shadow(0 0 20px var(--silver)); transform: translateY(-12px) scale(1.06); }
}
@keyframes flashGold {
    0%, 100% { filter: none; transform: translateY(0) scale(1); }
    45% { filter: brightness(1.6) drop-shadow(0 0 24px var(--gold-bright)); transform: translateY(-14px) scale(1.09); }
}

.card.burning { animation: burnOut 0.55s var(--ease-inout) forwards; }
@keyframes burnOut {
    to { opacity: 0; transform: translateY(12px) rotateX(80deg) scale(0.85); }
}

.float {
    position: absolute;
    z-index: 8;
    font-weight: 800;
    color: var(--gold-bright);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    animation: floatUp 1.25s var(--ease-out) forwards;
    font-size: 20px;
}
@keyframes floatUp {
    0% { opacity: 0; transform: translateY(8px) scale(0.8); }
    22% { opacity: 1; transform: translateY(-4px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-54px) scale(1); }
}

/* ---- Combination banner (transient, during play) ---- */
.combo-banner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(#3a1820ee, #241015dd);
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 10px 30px;
    text-align: center;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6);
    animation: bannerIn 0.55s var(--ease-soft);
    z-index: 6;
}
@keyframes bannerIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.75); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.combo-name {
    display: block;
    font-size: clamp(20px, 3.4vw, 30px);
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold-bright);
    text-shadow: 0 2px 12px rgba(240, 207, 122, 0.55);
}
.combo-win { display: block; font-size: 18px; color: var(--text); margin-top: 2px; }

/* ---- Result bubbles (persistent, after the round) — one per payout source ---- */
.result {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 92%;
}
.result-bubble {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    background: rgba(0, 0, 0, 0.34);
    border: 1px solid rgba(202, 156, 77, 0.5);
    border-radius: 999px;
    padding: 6px 18px;
    animation: resultIn 0.42s var(--ease-soft) backwards;
}
@keyframes resultIn { from { opacity: 0; transform: translateY(10px) scale(0.85); } to { opacity: 1; transform: translateY(0) scale(1); } }
.result-bubble .rb-name { font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold-bright); }
.result-bubble .rb-win { font-size: 15px; font-weight: 700; color: var(--text); }
.result-bubble.combo { border-color: var(--gold); }
.result-bubble.gold { border-color: var(--gold-bright); box-shadow: 0 0 14px rgba(240, 207, 122, 0.3); }
.result-bubble.gold .rb-name { color: var(--gold-bright); }
.result-bubble.silver { border-color: var(--silver); box-shadow: 0 0 14px rgba(200, 210, 225, 0.25); }
.result-bubble.silver .rb-name { color: var(--silver); }
.result-bubble.none { border-color: rgba(255, 255, 255, 0.15); }
.result-bubble.none .rb-name { color: var(--muted); }

/* ---- Paytable side panel ---- */
.paytable-panel {
    flex: 0 0 clamp(170px, 19vw, 234px);
    align-self: stretch;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(0,0,0,0.32), rgba(0,0,0,0.16));
    border: 1px solid rgba(202, 156, 77, 0.35);
    border-radius: 14px;
    padding: 12px 14px;
    margin: 8px 0;
    min-height: 0;
}
.pt-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    color: var(--gold);
    letter-spacing: 2px;
    font-size: 13px;
    border-bottom: 1px solid rgba(202, 156, 77, 0.3);
    padding-bottom: 6px;
    margin-bottom: 4px;
}
.pt-head span { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.pay-list { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: space-evenly; overflow: hidden; }
.pay-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: clamp(11px, 1.15vw, 13.5px);
    padding: 1px 0;
}
.pay-row .k { color: var(--text); }
.pay-row .v { color: var(--gold-bright); font-weight: 700; }
.pay-row.top .k { color: var(--gold-bright); }
.pt-foot {
    border-top: 1px solid rgba(202, 156, 77, 0.3);
    padding-top: 7px;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 11px;
    color: var(--muted);
}
.pt-foot b { color: var(--text); }
.pt-foot .silver b { color: var(--silver); }
.pt-foot .gold b { color: var(--gold-bright); }
.pt-foot .dim { width: 100%; font-style: italic; opacity: 0.8; }

/* ---- HUD ---- */
.hud {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 9px 12px;
    background: #1c120c;
    border-bottom: 3px solid var(--edge);
    flex: 0 0 auto;
}
.chip {
    background: radial-gradient(circle at 50% 30%, #34241a, #1a120c);
    border: 2px dashed rgba(202, 156, 77, 0.4);
    border-radius: 12px;
    padding: 5px 16px;
    min-width: 104px;
    text-align: center;
    display: flex;
    flex-direction: column;
}
.chip .label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.chip span:last-child { font-size: 17px; font-weight: 700; }
.chip.gold { border-color: var(--gold); }
.chip.gold span:last-child { color: var(--gold-bright); }

/* ---- Boosters ---- */
.boosters-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    color: var(--gold);
    letter-spacing: 3px;
    font-size: 12px;
    margin-bottom: 9px;
    padding: 0 4px;
}
.boosters-head .hint { letter-spacing: 0; font-size: 11px; color: var(--muted); font-style: italic; }

.boosters {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.booster {
    position: relative;
    background: linear-gradient(165deg, #f0e6cb, #cdbe95);
    color: #2a2018;
    border: none;
    border-radius: 10px;
    padding: 10px 10px 12px;
    cursor: pointer;
    text-align: left;
    min-height: 104px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), filter 0.25s var(--ease-out);
    filter: saturate(0.85) brightness(0.96);
}
.booster:hover { transform: translateY(-3px); }
.booster.on {
    filter: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 0 0 3px var(--gold), 0 0 20px rgba(240, 207, 122, 0.5);
    transform: translateY(-4px);
}
.booster .b-name {
    font-weight: 800;
    font-size: clamp(12px, 1.5vw, 15px);
    font-style: italic;
    display: block;
    margin-bottom: 3px;
    letter-spacing: 0.3px;
}
.booster .b-icon { font-size: 21px; display: block; margin-bottom: 3px; }
.booster .b-tag { font-size: 10.5px; line-height: 1.25; color: #5a4b34; }
.booster .b-price {
    position: absolute;
    top: -8px;
    right: -6px;
    background: #cdbb8a;
    color: #3a2c18;
    border: 1px solid #8a7448;
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 800;
    transform: rotate(6deg);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
}
.booster .b-check {
    position: absolute;
    bottom: 7px;
    right: 10px;
    font-size: 12px;
    color: #8a7448;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.booster.on .b-check { color: #7a5a12; font-weight: 800; }

/* ---- Controls ---- */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
}
.btn {
    font-family: inherit;
    font-weight: 700;
    color: var(--text);
    background: #2a1a12;
    border: 2px solid rgba(202, 156, 77, 0.5);
    border-radius: 10px;
    padding: 9px 18px;
    cursor: pointer;
    transition: transform 0.2s var(--ease-out), filter 0.2s var(--ease-out);
}
.btn:hover { filter: brightness(1.12); }
.btn.ghost { background: rgba(0, 0, 0, 0.25); font-size: 13px; }
.btn.deal {
    background: radial-gradient(circle at 50% 30%, #b8322f, #7c1f22);
    border: 3px solid var(--gold);
    color: #fff;
    font-size: 20px;
    letter-spacing: 4px;
    padding: 13px 52px;
    border-radius: 40px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 2px 6px rgba(255, 255, 255, 0.2);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.btn.deal:active { transform: translateY(2px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.speed { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.speed select {
    font: inherit;
    background: #2a1a12;
    color: var(--text);
    border: 1px solid rgba(202, 156, 77, 0.4);
    border-radius: 6px;
    padding: 3px 6px;
}

/* ---- Toast / Big win / Modal ---- */
.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: #3a1820;
    border: 1px solid var(--gold);
    border-radius: 10px;
    padding: 10px 18px;
    z-index: 60;
}

.bigwin {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background: rgba(10, 6, 4, 0.8);
    cursor: pointer;
}
/* Scale from the grid centre — no translate, so it never starts off-centre */
.bigwin-card { text-align: center; animation: bigwinPop 0.6s var(--ease-soft); }
@keyframes bigwinPop {
    from { opacity: 0; transform: scale(0.55); }
    to { opacity: 1; transform: scale(1); }
}
.bigwin-emoji { font-size: 92px; animation: bigwinFloat 2.4s var(--ease-inout) infinite alternate; }
@keyframes bigwinFloat { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-10px) rotate(4deg); } }
.bigwin-text { font-size: 46px; font-weight: 900; letter-spacing: 5px; color: var(--gold-bright); text-shadow: 0 4px 24px rgba(240, 207, 122, 0.6); }
.bigwin-amt { font-size: 30px; color: var(--text); margin-top: 6px; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(10, 6, 4, 0.78);
    padding: 16px;
}
.modal-card {
    width: min(94vw, 760px);
    max-height: 86vh;
    overflow: auto;
    background: linear-gradient(180deg, #2a1810, #1c1109);
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 18px 22px;
    animation: bigwinPop 0.45s var(--ease-soft);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h2 { color: var(--gold-bright); font-size: 22px; letter-spacing: 1px; }
.info-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.info-col h3 { color: var(--gold); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; margin: 10px 0 6px; display: flex; justify-content: space-between; }
.info-col h3 .dim { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.info-col .muted { color: var(--muted); font-size: 12px; line-height: 1.4; }
.info-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px solid rgba(202,156,77,0.15); }
.info-row .k { color: var(--text); }
.info-row .v { color: var(--gold-bright); font-weight: 700; white-space: nowrap; }
.info-row .d { color: var(--muted); font-size: 11.5px; }

.hidden { display: none !important; }

@media (max-width: 640px) {
    /* Paytable becomes a compact strip stacked above the hand. */
    .felt-main { flex-direction: column; gap: 10px; }
    .hand-wrap { height: auto; }
    .paytable-panel {
        order: -1;
        flex: 0 0 auto;
        width: 100%;
        margin: 2px 0 0;
        padding: 9px 13px;
    }
    .pt-head { font-size: 11px; padding-bottom: 5px; margin-bottom: 4px; }
    .pay-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px 18px;
        overflow: visible;
    }
    .pay-row { font-size: 11.5px; padding: 1px 0; }
    .pt-foot { padding-top: 6px; margin-top: 4px; font-size: 10px; gap: 3px 12px; }
    .pt-foot .dim { width: auto; }
    .info-body { grid-template-columns: 1fr; }

    .felt { padding: 12px 11px; }
    .top-rail { font-size: 10px; letter-spacing: 2px; gap: 8px; }
    .top-rail::before, .top-rail::after { max-width: 40px; }

    .hand { gap: clamp(4px, 1.6vw, 9px); }
    .card { width: clamp(42px, 13.5vw, 66px); }
    .card .center-rank { font-size: clamp(22px, 8vw, 34px); }
    .card .corner { font-size: clamp(15px, 4.6vw, 21px); }
    .card .badge { font-size: 8px; padding: 1px 4px; }

    .combo-banner { padding: 8px 18px; }
    .combo-name { font-size: 22px; letter-spacing: 2px; }
    .combo-win { font-size: 15px; }
    .result { gap: 6px; }
    .result-bubble { padding: 5px 13px; gap: 7px; }
    .result-bubble .rb-name { font-size: 12.5px; letter-spacing: 1px; }
    .result-bubble .rb-win { font-size: 12.5px; }

    .hud { gap: 6px; padding: 7px 6px; }
    .chip { min-width: 70px; padding: 4px 8px; }
    .chip .label { font-size: 8px; letter-spacing: 1px; }
    .chip span:last-child { font-size: 14px; }

    .boosters-head { font-size: 11px; margin-bottom: 7px; }
    .boosters-head .hint { display: none; }
    .boosters { gap: 6px; }
    .booster { min-height: 72px; padding: 8px 5px 17px; border-radius: 8px; }
    .booster .b-tag { display: none; }
    .booster .b-name { font-size: 10.5px; margin-bottom: 0; }
    .booster .b-icon { font-size: 17px; margin-bottom: 2px; }
    .booster .b-price { font-size: 9px; padding: 1px 4px; top: -6px; }
    .booster .b-check { font-size: 9px; bottom: 4px; right: 5px; letter-spacing: 0; }

    .controls { gap: 8px; margin-top: 10px; }
    .btn.deal { font-size: 16px; padding: 11px 30px; letter-spacing: 2px; }
    .btn.ghost { padding: 8px 10px; font-size: 12px; }
    .speed { font-size: 12px; }

    .bigwin-emoji { font-size: 66px; }
    .bigwin-text { font-size: 32px; letter-spacing: 3px; }
    .bigwin-amt { font-size: 22px; }
}
