/* ==========================================================================
   Texas Jack — styles.css
   ========================================================================== */

:root {
    --font-ui: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-num: 'DIN Alternate', 'Bahnschrift', 'Segoe UI', system-ui, sans-serif;

    --felt-1: #10634a;
    --felt-2: #0a4433;
    --felt-3: #052a20;
    --rail: #3a2216;

    --gold: #f2c76a;
    --gold-hot: #ffe6a8;
    --card-gold: #b98f3e;

    --good: #46e08b;
    --warn: #ffbe3d;

    --ink: #f6f1e6;
    --ink-dim: rgba(246, 241, 230, .58);

    /* Cards are sized off the viewport height so the three lanes always fill
       the felt, then width follows the 5:7 card ratio. */
    --card-h: clamp(84px, 18.5vh, 208px);
    --card-w: calc(var(--card-h) / 1.4);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font-ui);
    color: var(--ink);
    background:
        radial-gradient(120% 90% at 50% -10%, #1d3b31 0%, #0a1712 60%, #05100c 100%);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

/* ---- Shell --------------------------------------------------------------- */

.table {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: clamp(8px, 1.4vh, 18px) clamp(10px, 2vw, 28px) 0;
    gap: clamp(6px, 1vh, 12px);
    max-width: 1500px;
    margin: 0 auto;
}

/* ---- Top bar ------------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.brand {
    height: clamp(26px, 4.6vh, 48px);
    width: auto;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .55));
}

.readouts {
    display: flex;
    gap: clamp(6px, 1.2vw, 14px);
}

.readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 6px clamp(10px, 1.6vw, 20px);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .03));
    border: 1px solid rgba(255, 255, 255, .10);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10), 0 4px 14px rgba(0, 0, 0, .28);
    min-width: 84px;
}

.readout-label {
    font-size: 9px;
    letter-spacing: .16em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-dim);
}

.readout-value {
    font-family: var(--font-num);
    font-size: clamp(15px, 2.1vh, 21px);
    font-weight: 700;
    letter-spacing: .01em;
    font-variant-numeric: tabular-nums;
}

.readout.bankroll .readout-value { color: var(--gold); text-shadow: 0 0 18px rgba(242, 199, 106, .35); }
.readout.streak.hot { border-color: rgba(255, 138, 61, .5); background: linear-gradient(180deg, rgba(255, 138, 61, .22), rgba(255, 90, 40, .07)); }
.readout.streak.hot .readout-value { color: #ffb066; }

.readout-value.bump { animation: bump .42s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.28); } 100% { transform: scale(1); } }

.tools { display: flex; gap: 8px; }

.icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .06);
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .18s, background .18s, border-color .18s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .14); transform: translateY(-2px); border-color: rgba(242, 199, 106, .5); }
.icon-btn:active { transform: translateY(0); }

/* ---- Felt ---------------------------------------------------------------- */

.felt {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(6px, 1.2vh, 16px);
    padding: clamp(10px, 1.8vh, 22px) clamp(12px, 2vw, 28px);
    border-radius: 28px;
    background:
        radial-gradient(120% 80% at 50% 40%, var(--felt-1) 0%, var(--felt-2) 52%, var(--felt-3) 100%);
    border: clamp(6px, 1vw, 12px) solid var(--rail);
    box-shadow:
        inset 0 0 0 2px rgba(255, 215, 140, .16),
        inset 0 12px 60px rgba(0, 0, 0, .48),
        0 24px 60px rgba(0, 0, 0, .55);
    overflow: hidden;
}

/* woven felt texture */
.felt::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .30;
    background-image:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(-45deg, rgba(0, 0, 0, .045) 0 1px, transparent 1px 3px);
}

/* the sweep of a real table's betting arc */
.felt::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -46%;
    width: 148%;
    height: 112%;
    transform: translateX(-50%);
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 140, .09);
    pointer-events: none;
}

.felt-glow {
    position: absolute;
    inset: -20% 10% auto 10%;
    height: 70%;
    pointer-events: none;
    background: radial-gradient(50% 50% at 50% 50%, rgba(255, 240, 200, .16), transparent 70%);
    filter: blur(10px);
}

/* ---- Lanes --------------------------------------------------------------- */

.lane {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    flex: 1;
    padding: clamp(4px, .8vh, 10px) clamp(8px, 1.4vw, 16px);
    border-radius: 16px;
    transition: box-shadow .3s, background .3s;
}

.lane-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.lane-name {
    font-size: clamp(9px, 1.4vh, 12px);
    letter-spacing: .22em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .62);
    font-weight: 600;
}

.lane-hint {
    font-size: clamp(9px, 1.3vh, 11px);
    color: rgba(255, 235, 190, .55);
    letter-spacing: .04em;
}
.lane-hint em { color: var(--gold); font-style: normal; font-weight: 700; }
.lane-hint.tell-hit  { color: #ffbe3d; }
.lane-hint.tell-pat  { color: rgba(70, 224, 139, .9); }
.lane-hint.tell-maybe { color: rgba(255, 235, 190, .7); }

.lane-community {
    background: linear-gradient(180deg, rgba(255, 231, 176, .09), rgba(255, 231, 176, .02));
    box-shadow: inset 0 0 0 1px rgba(255, 215, 140, .26);
    flex: 1.05;
}
.lane-community::before,
.lane-community::after {
    content: '';
    position: absolute;
    left: 14px; right: 14px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 140, .45), transparent);
}
.lane-community::before { top: 0; }
.lane-community::after { bottom: 0; }

.lane.active { box-shadow: inset 0 0 0 1px rgba(70, 224, 139, .5), 0 0 34px rgba(70, 224, 139, .12); }
.lane-community.active { box-shadow: inset 0 0 0 1px rgba(255, 215, 140, .6), 0 0 34px rgba(255, 215, 140, .16); }

.cards {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    gap: clamp(4px, .8vw, 10px);
    padding: 2px 0;
    flex-wrap: nowrap;
    overflow: visible;
}
.lane-player .cards,
.lane-dealer .cards { justify-content: flex-start; }
.lane-community .cards { justify-content: center; }

/* When a hand runs long the cards fan into each other instead of overflowing. */
.cards .card + .card { margin-left: calc(var(--card-w) * var(--overlap, 0) * -1); }

/* ---- Pill totals --------------------------------------------------------- */

.pill {
    font-family: var(--font-num);
    font-size: clamp(13px, 1.9vh, 18px);
    font-weight: 700;
    letter-spacing: .02em;
    padding: 2px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .34);
    border: 1px solid rgba(255, 255, 255, .16);
    font-variant-numeric: tabular-nums;
    transition: color .25s, border-color .25s, background .25s, transform .25s;
}
.pill[data-state="idle"] { color: var(--ink-dim); }
.pill[data-state="range"] {
    color: rgba(255, 236, 194, .9);
    border-color: rgba(255, 215, 140, .38);
    letter-spacing: 0;
}
.pill[data-state="safe"] { color: var(--good); border-color: rgba(70, 224, 139, .45); }
.pill[data-state="warm"] { color: var(--warn); border-color: rgba(255, 190, 61, .5); }
.pill[data-state="bust"] { color: #fff; background: rgba(255, 60, 60, .78); border-color: rgba(255, 120, 120, .8); }
.pill[data-state="perfect"] {
    color: #10240f;
    background: linear-gradient(180deg, var(--gold-hot), var(--gold));
    border-color: rgba(255, 255, 255, .5);
    box-shadow: 0 0 22px rgba(242, 199, 106, .55);
}
.pill.tick { transform: scale(1.14); }

/* ---- Cards --------------------------------------------------------------- */

/* The card fills its lane and derives width from the 5:7 ratio, capped at
   --card-h. Sizing from the lane rather than the viewport means a card can
   never spill over its own heading. */
.card {
    position: relative;
    height: 100%;
    max-height: var(--card-h);
    width: auto;
    aspect-ratio: 5 / 7;
    flex: 0 0 auto;
    perspective: 900px;
    transition: transform .25s cubic-bezier(.2, .8, .3, 1), filter .25s;
}
.card:hover { transform: translateY(-10px) scale(1.04); z-index: 5; }

.card-inner {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.4, .05, .2, 1);
    will-change: transform;
}
.card.face-down .card-inner { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 9%;
    overflow: hidden;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .48), 0 1px 2px rgba(0, 0, 0, .5);
}
.card-face.back { transform: rotateY(180deg); }
.card-svg { display: block; width: 100%; height: 100%; }

/* A board card the dealer was already too pat to take — it counts for you only. */
.card.solo .card-face.front { box-shadow: 0 0 0 2px var(--good), 0 5px 14px rgba(0, 0, 0, .48); }
.card-tag {
    position: absolute;
    top: 4%;
    right: 4%;
    z-index: 2;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: clamp(7px, 1.1vh, 9px);
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #07200f;
    background: var(--good);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
    pointer-events: none;
}

.card.fresh { animation: cardPop .4s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes cardPop { 0% { filter: brightness(1.9); } 100% { filter: brightness(1); } }

.card.shared-jump { animation: sharedJump .6s cubic-bezier(.3, 1.2, .4, 1); }
@keyframes sharedJump {
    0%   { transform: translateY(0) scale(1); }
    35%  { transform: translateY(-16px) scale(1.09); }
    100% { transform: translateY(0) scale(1); }
}

.card.doomed { animation: doomed .5s ease both; }
@keyframes doomed {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px) rotate(-3deg); }
    50% { transform: translateX(7px) rotate(3deg); }
    80% { transform: translateX(-3px); }
}

/* ---- Shoe ---------------------------------------------------------------- */

.shoe {
    position: absolute;
    top: clamp(8px, 1.6vh, 18px);
    right: clamp(8px, 1.6vw, 20px);
    width: calc(var(--card-w) * .7);
    height: calc(var(--card-h) * .7);
    display: grid;
    place-items: end center;
    pointer-events: none;
    opacity: .9;
}

.shoe-stack {
    position: absolute;
    inset: 0;
    border-radius: 9%;
    background: linear-gradient(160deg, #8f1524, #4a0912);
    box-shadow:
        0 0 0 1.5px rgba(255, 215, 140, .35) inset,
        3px 3px 0 rgba(90, 12, 22, .9),
        6px 6px 0 rgba(70, 9, 18, .85),
        9px 9px 16px rgba(0, 0, 0, .5);
}

.shoe-count {
    position: relative;
    transform: translateY(140%);
    font-family: var(--font-num);
    font-size: 10px;
    letter-spacing: .12em;
    color: rgba(255, 235, 190, .6);
}

/* ---- Status -------------------------------------------------------------- */

.status {
    flex-shrink: 0;
    text-align: center;
    font-size: clamp(12px, 1.9vh, 16px);
    letter-spacing: .03em;
    color: var(--ink);
    min-height: 1.6em;
    line-height: 1.6;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.status b { color: var(--gold); }
.status.flash { animation: statusFlash .45s ease; }
@keyframes statusFlash {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.status .dots::after {
    content: '';
    animation: dots 1.1s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ''; } 25% { content: '·'; } 50% { content: '··'; } 75% { content: '···'; } }

/* ---- Dock ---------------------------------------------------------------- */

/* Chips on one row, actions on the next. Five action buttons never fit
   alongside the bet rail, so the split is unconditional rather than a
   breakpoint that quietly overflows. */
.dock {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(7px, 1.1vh, 13px);
    padding: clamp(7px, 1.2vh, 14px) clamp(10px, 2vw, 22px) calc(clamp(7px, 1.2vh, 14px) + env(safe-area-inset-bottom));
}

.bet-rail {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 1.4vw, 16px);
    flex-wrap: wrap;
}

.bet-controls,
.play-money {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.4vw, 16px);
    flex-wrap: wrap;
    justify-content: center;
}
.bet-controls[hidden], .play-money[hidden] { display: none; }

/* Money actions available while a hand is live. */
.money-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px clamp(12px, 1.6vw, 20px);
    border-radius: 12px;
    cursor: pointer;
    font-size: clamp(11px, 1.5vh, 13px);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink);
    background: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .03));
    border: 1px solid rgba(255, 255, 255, .16);
    transition: all .18s;
}
.money-btn b {
    font-family: var(--font-num);
    font-size: 1.15em;
    letter-spacing: 0;
    color: var(--gold);
}
.money-btn kbd { opacity: .45; font-size: .85em; }
.money-btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, .16); }
.money-btn:disabled { opacity: .38; cursor: not-allowed; }
.money-btn.raise:not(:disabled) { border-color: rgba(242, 199, 106, .55); }
.money-btn.scout:not(:disabled) { border-color: rgba(139, 91, 214, .6); }
.money-btn.scout b { color: #c9b1ff; }

/* The scouted top-of-shoe card, parked under the shoe. */
.scout-slot {
    position: absolute;
    top: calc(clamp(8px, 1.6vh, 18px) + var(--card-h) * .93);
    right: clamp(8px, 1.6vw, 20px);
    width: calc(var(--card-h) / 1.4 * .7);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    pointer-events: none;
}
.scout-slot[hidden] { display: none; }
.scout-label {
    font-size: 8px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: #c9b1ff;
}
.scout-card {
    width: 100%;
    aspect-ratio: 5 / 7;
    border-radius: 9%;
    overflow: hidden;
    box-shadow: 0 0 0 2px rgba(139, 91, 214, .8), 0 6px 16px rgba(0, 0, 0, .55);
}
.scout-card svg { display: block; width: 100%; height: 100%; }
.scout-slot.pop { animation: scoutPop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes scoutPop {
    0%   { transform: translateY(-14px) scale(.7); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.chips { display: flex; gap: clamp(6px, 1vw, 12px); }

.chip {
    --size: clamp(44px, 6.4vh, 62px);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    position: relative;
    font-family: var(--font-num);
    font-weight: 700;
    font-size: calc(var(--size) * .30);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
    background:
        radial-gradient(circle at 50% 50%, var(--chip) 0 46%, var(--chip-dark) 46% 100%);
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, .16) inset,
        0 0 0 8px var(--chip-dark) inset,
        0 6px 0 rgba(0, 0, 0, .35),
        0 10px 20px rgba(0, 0, 0, .45);
    transition: transform .16s cubic-bezier(.2, 1.4, .4, 1), box-shadow .16s, filter .2s;
}
.chip::after {
    content: '';
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, .35);
}
.chip:hover:not(:disabled) { transform: translateY(-6px) rotate(-4deg); }
.chip:active:not(:disabled) { transform: translateY(-1px) scale(.96); }
.chip:disabled { filter: grayscale(.85) brightness(.55); cursor: not-allowed; }

.bet-meta { display: flex; gap: 6px; }

.mini-btn {
    padding: 7px 12px;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink-dim);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    cursor: pointer;
    transition: all .18s;
}
.mini-btn:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, .14); }
.mini-btn:disabled { opacity: .35; cursor: not-allowed; }

.actions {
    display: flex;
    gap: clamp(6px, 1vw, 12px);
    width: 100%;
    justify-content: stretch;
}
.actions .btn { flex: 1 1 0; min-width: 0; }

.btn {
    position: relative;
    padding: clamp(11px, 1.7vh, 17px) clamp(14px, 2.2vw, 30px);
    font-size: clamp(12px, 1.7vh, 15px);
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #08160f;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 5px 0 rgba(0, 0, 0, .32), 0 10px 22px rgba(0, 0, 0, .38);
    transition: transform .14s, box-shadow .14s, filter .2s;
}
.btn kbd {
    font-family: var(--font-num);
    font-size: .72em;
    opacity: .5;
    margin-left: 6px;
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 0 4px;
}
.btn:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 0 rgba(0, 0, 0, .32), 0 14px 28px rgba(0, 0, 0, .42); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .32); }
.btn:disabled { filter: grayscale(1) brightness(.5); cursor: not-allowed; box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }

.btn[hidden] { display: none; }

.btn-deal   { background: linear-gradient(180deg, var(--gold-hot), var(--gold)); }
.btn-hit    { background: linear-gradient(180deg, #6ef2a6, #22c46e); }
.btn-hand   { background: linear-gradient(180deg, #6ef2a6, #22c46e); }
.btn-board  { background: linear-gradient(180deg, #f8dc9a, #e0a63c); }
.btn-stand  { background: linear-gradient(180deg, #ffd0a0, #ff9f5a); }
.btn-double { background: linear-gradient(180deg, #c9b1ff, #8b6ee8); color: #fff; }

/* Remaining private draws, shown on the Hand button. */
.tally {
    display: inline-block;
    min-width: 1.5em;
    margin-left: 6px;
    padding: 1px 4px;
    border-radius: 6px;
    background: rgba(8, 22, 15, .28);
    font-family: var(--font-num);
    font-size: .82em;
    line-height: 1.3;
}
.btn:disabled .tally { background: rgba(0, 0, 0, .2); }

.btn-deal:not(:disabled) { animation: dealPulse 2.4s ease-in-out infinite; }
@keyframes dealPulse {
    0%, 100% { box-shadow: 0 5px 0 rgba(0, 0, 0, .32), 0 10px 22px rgba(0, 0, 0, .38), 0 0 0 0 rgba(242, 199, 106, .5); }
    50%      { box-shadow: 0 5px 0 rgba(0, 0, 0, .32), 0 10px 22px rgba(0, 0, 0, .38), 0 0 0 12px rgba(242, 199, 106, 0); }
}

/* ---- Flying money -------------------------------------------------------- */

.money-fly {
    position: fixed;
    z-index: 900;
    pointer-events: none;
    font-family: var(--font-num);
    font-size: clamp(18px, 3vh, 30px);
    font-weight: 800;
    color: var(--gold-hot);
    text-shadow: 0 0 18px rgba(242, 199, 106, .8), 0 2px 4px rgba(0, 0, 0, .6);
    animation: moneyFly 1.15s cubic-bezier(.2, .9, .3, 1) forwards;
}
.money-fly.negative { color: #ff8080; text-shadow: 0 0 18px rgba(255, 90, 90, .6); }
@keyframes moneyFly {
    0%   { transform: translate(-50%, 0) scale(.6); opacity: 0; }
    18%  { transform: translate(-50%, -14px) scale(1.15); opacity: 1; }
    100% { transform: translate(-50%, -78px) scale(1); opacity: 0; }
}

/* ---- Result overlay ------------------------------------------------------ */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    grid-auto-flow: row;
    background: radial-gradient(70% 70% at 50% 50%, rgba(0, 0, 0, .55), rgba(0, 0, 0, .84));
    backdrop-filter: blur(3px);
    animation: fadeIn .22s ease;
}
.overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#resultImage {
    max-width: min(70vw, 620px);
    max-height: 46vh;
    filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .7));
    animation: splash 1.9s cubic-bezier(.2, 1.2, .3, 1) forwards;
}
@keyframes splash {
    0%   { opacity: 0; transform: scale(.2) rotate(-12deg); }
    18%  { opacity: 1; transform: scale(1.16) rotate(3deg); }
    28%  { transform: scale(1) rotate(0); }
    82%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(.86); }
}

.result-payout {
    font-family: var(--font-num);
    font-size: clamp(20px, 4.2vh, 42px);
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--gold-hot);
    text-shadow: 0 0 26px rgba(242, 199, 106, .6);
    animation: fadeIn .4s .35s both;
}
.result-payout.negative { color: #ff8f8f; text-shadow: 0 0 26px rgba(255, 90, 90, .45); }

/* ---- Modal --------------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 980;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(3, 10, 8, .72);
    backdrop-filter: blur(6px);
    animation: fadeIn .2s ease;
}
.modal.hidden { display: none; }

.modal-card {
    position: relative;
    width: min(560px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    padding: clamp(22px, 4vw, 36px);
    border-radius: 20px;
    background: linear-gradient(170deg, #123c2e, #0a241c 60%, #081913);
    border: 1px solid rgba(255, 215, 140, .28);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .08);
    animation: modalIn .3s cubic-bezier(.2, 1.2, .3, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-close {
    position: absolute;
    top: 14px; right: 14px;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(255, 255, 255, .06);
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, .16); }

.modal-card h2 {
    margin: 0 0 8px;
    font-size: clamp(20px, 3vh, 26px);
    color: var(--gold);
    letter-spacing: .01em;
}
.modal-card h3 {
    margin: 22px 0 8px;
    font-size: 12px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}
.lede { margin: 0 0 16px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }

.mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 18px;
}
.mode-switch button {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 12px;
    text-align: left;
    border-radius: 10px;
    cursor: pointer;
    color: var(--ink-dim);
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .10);
    transition: all .18s;
}
.mode-switch button b { font-size: 13.5px; color: var(--ink); }
.mode-switch button span { font-size: 11px; line-height: 1.35; }
.mode-switch button:hover:not(:disabled) { background: rgba(255, 255, 255, .09); }
.mode-switch button[aria-pressed="true"] {
    background: linear-gradient(180deg, rgba(242, 199, 106, .22), rgba(242, 199, 106, .06));
    border-color: rgba(242, 199, 106, .55);
}
.mode-switch button[aria-pressed="true"] b { color: var(--gold); }
.mode-switch button:disabled { opacity: .45; cursor: not-allowed; }

.rules { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.rules li { font-size: 14px; line-height: 1.55; color: rgba(246, 241, 230, .88); }
.rules strong { color: var(--gold); }
.rules em { color: var(--gold-hot); font-style: normal; }

.payouts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.payouts li {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .05);
}
.payouts b { color: var(--gold); font-family: var(--font-num); }

.stats {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.stats li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .07);
}
.stats b {
    font-family: var(--font-num);
    font-size: 18px;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}
.stats span {
    font-size: 9px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-dim);
    text-align: center;
}

.shortcuts { margin: 20px 0 0; font-size: 12px; color: var(--ink-dim); text-align: center; }
kbd {
    font-family: var(--font-num);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: .92em;
}
/* The call to action stays reachable no matter how far the rules scroll. */
.modal-foot {
    --pad: clamp(22px, 4vw, 36px);
    position: sticky;
    bottom: calc(var(--pad) * -1);
    margin: 18px calc(var(--pad) * -1) calc(var(--pad) * -1);
    padding: 18px var(--pad) var(--pad);
    background: linear-gradient(180deg, rgba(8, 25, 19, 0), #081913 40%);
}
.modal-cta { width: 100%; }

/* ---- Confetti canvas ----------------------------------------------------- */

#fx {
    position: fixed;
    inset: 0;
    z-index: 940;
    pointer-events: none;
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 760px) {
    /* Height still drives the card, just a shorter one so three lanes fit. */
    :root { --card-h: clamp(74px, 13.5vh, 150px); }

    .topbar { flex-wrap: wrap; gap: 8px; }
    .brand { height: 30px; }
    .readouts { order: 3; flex-basis: 100%; justify-content: space-between; }
    .readout { min-width: 0; flex: 1; padding: 5px 8px; }

    .felt { border-width: 6px; border-radius: 20px; }
    /* The community caption is decorative; the dealer read is the whole game. */
    .lane-hint { display: none; }
    #dealerRead { display: inline; }

    .btn { padding: 13px 4px; letter-spacing: .02em; font-size: 11.5px; }
    .btn kbd { display: none; }
    .tally { margin-left: 3px; min-width: 1.2em; padding: 0 3px; }
    .shoe { display: none; }
}

/* Five action buttons on a small phone need every pixel. */
@media (max-width: 400px) {
    .actions { gap: 4px; }
    .btn { font-size: 10px; padding: 12px 2px; }
}

@media (max-height: 560px) {
    .brand { height: 24px; }
    .lane-head { gap: 6px; }
    .status { min-height: 1.2em; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
