/* Casino page (gurbs.net/casino) — matches the tracker's look. */

.btn {
    display: inline-block;
    border: none;
    border-radius: 6px;
    background: #242424;
    color: #fff;
    padding: 11px 20px;
    font: inherit;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #3a3a3a; }
.btn:disabled { background: #999; cursor: default; }
.btn-discord { background: #5865f2; }
.btn-discord:hover { background: #4752c4; }
.btn-light { background: #fff; color: #333; border: 1px solid #ccc; }
.btn-light:hover:not(:disabled) { background: #e9e9e9; }

/* ----- Account bar ----- */
.account {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.account-out, .account-in { display: flex; align-items: center; gap: 16px; }
.account-out[hidden], .account-in[hidden] { display: none; }
.account-out > div { flex: 1; }
.account-out h2 { margin-bottom: 4px; }
.account-out p { margin: 0; color: #666; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: #ddd; }
.who { flex: 1; display: flex; flex-direction: column; }
.who .name { font-weight: bold; font-size: 1.1em; }
.who .coins { color: #666; }
.who .coins strong { color: #333; font-size: 1.4em; font-variant-numeric: tabular-nums; }
.rate { color: #1e7d32; font-weight: bold; margin-left: 6px; }
.account-msg { margin: 12px 0 0; color: #b3261e; }

/* ----- Tabs ----- */
.tabs {
    display: flex;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}
.tabs a {
    flex: 1;
    margin: 0;
    padding: 12px 8px;
    text-align: center;
    color: #333;
    font-weight: bold;
    text-decoration: none;
    border-left: 1px solid #ddd;
    white-space: nowrap;
}
.tabs a:first-child { border-left: none; }
.tabs a:hover { background: #f0f0f0; }
.tabs a[aria-selected="true"] { background: #242424; color: #fff; }

/* ----- Screens ----- */
.screen {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 22px;
    margin: 0;
}
.screen[hidden] { display: none; }
.screen-head h2 { margin-bottom: 2px; }
.rules { margin: 0 0 16px; color: #666; line-height: 1.5; }
.controls {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.4fr) auto;
    gap: 12px;
    margin-top: 16px;
    align-items: stretch;
}
.bet { display: flex; }
.bet input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 6px 0 0 6px;
    padding: 10px 12px;
    font: inherit;
}
.bet .max, .toggle button, select {
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    padding: 10px 12px;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
}
.bet .max { border-radius: 0 6px 6px 0; }
.bet .max:hover, .toggle button:hover { background: #e9e9e9; }
select { border-radius: 6px; font-weight: normal; }
.toggle { display: flex; border: 1px solid #ccc; border-radius: 6px; overflow: hidden; }
.toggle button { flex: 1; border: none; border-left: 1px solid #ccc; padding: 10px 6px; }
.toggle button:first-child { border-left: none; }
.toggle button[aria-pressed="true"] { background: #242424; color: #fff; }
.result { min-height: 1.6em; margin: 14px 0 0; font-weight: bold; font-size: 1.1em; }
.result.win { color: #1e7d32; }
.result.lose { color: #b3261e; }
.result.error { color: #b3261e; font-weight: normal; font-size: 1em; }

.stage {
    background: #f5f5f5;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

/* Coin */
.coin-stage { height: 260px; display: flex; align-items: center; justify-content: center; perspective: 600px; }
.coin {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe28a, #e0a800 70%, #b07d00);
    border: 5px solid #b07d00;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    color: #6b4b00;
    font-size: 60px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}
.coin.flipping { animation: flip 0.32s linear infinite; }
@keyframes flip {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

/* Roulette wheel */
.wheel-stage { padding: 18px; display: flex; justify-content: center; }
#wheel { width: 450px; max-width: 100%; height: auto; aspect-ratio: 1; }
.wheel-result {
    position: absolute;
    top: 16px;
    right: 16px;
    min-width: 56px;
    padding: 8px 12px;
    border-radius: 6px;
    color: #fff;
    font-size: 26px;
    font-weight: bold;
    text-align: center;
}
.wheel-result.red { background: #c62828; }
.wheel-result.black { background: #222; }
.wheel-result.green { background: #2e7d32; }

/* Chicken race: a 3D track (race3d.js), or emoji lanes until/unless it loads */
.race-stage { position: relative; height: 300px; padding: 0; overflow: hidden; }
.lanes { height: 100%; display: flex; flex-direction: column; justify-content: space-around; padding: 10px 0; box-sizing: border-box; }
.race-stage.is-3d .lanes { display: none; }
.r3d-canvas { display: block; width: 100%; height: 100%; }
.r3d-label {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2px 7px;
    border-radius: 7px;
    border-left: 4px solid var(--c);
    background: rgba(255, 255, 255, 0.88);
    color: #222;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.r3d-label .pot { font-size: 11px; font-weight: bold; color: #7a5a00; }
.r3d-label .pot:empty { display: none; }
.r3d-label.winner { background: #ffe082; }
/* Narrow screens: a small tag riding above each chicken */
.r3d-along .r3d-label { flex-direction: row; gap: 4px; padding: 1px 6px; border-left-width: 3px; font-size: 11px; }
.r3d-along .r3d-label .nm { display: none; }
.r3d-along .r3d-label .pot { font-size: 10px; }
.lane { position: relative; height: 40px; border-bottom: 1px dashed #ccc; margin: 0 48px 0 120px; }
.lane:last-child { border-bottom: none; }
.lane .tag { position: absolute; left: -112px; top: 10px; font-size: 14px; font-weight: bold; white-space: nowrap; }
.lane .finish { position: absolute; right: -40px; top: 6px; font-size: 22px; }
.racer {
    position: absolute;
    top: 2px;
    left: 0;
    font-size: 30px;
    line-height: 36px;
    transform: translateX(-50%);
    transition: left 0.55s ease-out;
}
.lane.winner { background: #fff6cc; }

/* Workers */
.income {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.income div { background: #f5f5f5; border-radius: 6px; padding: 12px 14px; }
.income span { display: block; color: #666; font-size: 0.9em; }
.income strong { font-size: 1.3em; }
.worker-list { display: flex; flex-direction: column; gap: 10px; }
.worker {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: center;
    border: 1px solid #e3e3e3;
    border-radius: 6px;
    padding: 12px 14px;
}
.worker .emoji { font-size: 34px; text-align: center; }
.worker .info strong { font-size: 1.05em; }
.worker .info span { display: block; color: #666; font-size: 0.92em; }
.worker .owned { color: #333; font-weight: bold; }
.worker .buy { display: flex; gap: 6px; }
.worker .buy .btn { padding: 9px 12px; }
.worker.locked .emoji { filter: grayscale(1); opacity: 0.6; }

@media (max-width: 700px) {
    .controls { grid-template-columns: 1fr; }
    .tabs a { font-size: 0.85em; padding: 10px 4px; }
    .income { grid-template-columns: 1fr; }
    .worker { grid-template-columns: 40px 1fr; }
    .worker .buy { grid-column: 1 / -1; }
    .worker .buy .btn { flex: 1; }
    .lane { margin-left: 34px; margin-right: 34px; }
    .lane .tag { left: -30px; }
    .lane .tag .racer-name { display: none; }
    .race-stage { height: 380px; }
    .r3d-label { font-size: 11px; padding: 1px 5px; }
    .account-out { flex-direction: column; align-items: stretch; text-align: center; }
    .wheel-stage { padding: 12px; }
    .wheel-result { top: 6px; right: 6px; min-width: 36px; padding: 4px 8px; font-size: 17px; }
    .chip { width: 38px; height: 38px; font-size: 10px; }
    .chip.call { font-size: 8px; }
    .chips { gap: 5px; }
    .bet-actions .btn { padding: 9px 10px; }
}

/* ----- Roulette table (felt + chips) ----- */
.chip-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0 10px;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
    --c: #f5f5f5;
    --t: #222;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    font: bold 13px Arial, sans-serif;
    color: var(--t);
    /* striped edge like a real casino chip */
    background:
        radial-gradient(circle, var(--c) 0 58%, transparent 59%),
        repeating-conic-gradient(var(--c) 0 22.5deg, #fff 22.5deg 45deg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s;
}
.chip:hover { transform: translateY(-2px); }
.chip[aria-checked="true"] { transform: translateY(-4px); box-shadow: 0 0 0 3px #f1c40f, 0 4px 8px rgba(0, 0, 0, 0.4); }
.chip.c0 { --c: #eeeeee; --t: #222; }
.chip.c1 { --c: #d32f2f; --t: #fff; }
.chip.c2 { --c: #1565c0; --t: #fff; }
.chip.c3 { --c: #2e7d32; --t: #fff; }
.chip.c4 { --c: #212121; --t: #fff; }
.chip.c5 { --c: #7b1fa2; --t: #fff; }
.chip.call { --c: #f1c40f; --t: #3b2a00; font-size: 10px; line-height: 1.05; letter-spacing: -0.2px; }
.bet-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bet-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.bet-actions .btn { padding: 10px 14px; }
.total { font-size: 1.05em; white-space: nowrap; }
.total strong { font-size: 1.2em; font-variant-numeric: tabular-nums; }
.hint { color: #666; font-size: 0.9em; margin: 8px 0 0; }

.felt-wrap { overflow-x: auto; border-radius: 8px; }
.felt {
    display: grid;
    grid-template-columns: 52px repeat(12, minmax(38px, 1fr)) 56px;
    grid-template-rows: repeat(3, 50px) 44px 44px;
    min-width: 640px;
    background: #0b6623;
    border: 6px solid #4a2c12;
    border-radius: 8px;
    padding: 6px;
    gap: 2px;
    user-select: none;
}
.spot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
    font-size: 15px;
}
.spot:hover { background: rgba(255, 255, 255, 0.15); }
.spot.num.red { background: #c62828; }
.spot.num.black { background: #1d1d1d; }
.spot.num.green { background: #2e7d32; }
.spot.num:hover { filter: brightness(1.25); }
.spot.zero { grid-row: 1 / 4; grid-column: 1; border-radius: 26px 3px 3px 26px; }
.spot .diamond { width: 22px; height: 22px; transform: rotate(45deg); border: 1px solid #fff; }
.spot .diamond.red { background: #c62828; }
.spot .diamond.black { background: #1d1d1d; }
.spot.hit { animation: hit 0.6s ease-in-out 4 alternate; outline: 3px solid #f1c40f; z-index: 2; }
@keyframes hit { to { filter: brightness(1.8); } }
/* A placed bet: one chip showing the total on that spot */
.stack {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: var(--t, #fff);
    background:
        radial-gradient(circle, var(--c) 0 56%, transparent 57%),
        repeating-conic-gradient(var(--c) 0 22.5deg, #fff 22.5deg 45deg);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 3;
}
.stack.c0 { --c: #eeeeee; --t: #222; }
.stack.c1 { --c: #d32f2f; }
.stack.c2 { --c: #1565c0; }
.stack.c3 { --c: #2e7d32; }
.stack.c4 { --c: #212121; }
.stack.c5 { --c: #7b1fa2; }
.stack.call { --c: #f1c40f; --t: #3b2a00; }
.stack.won { box-shadow: 0 0 0 3px #f1c40f, 0 0 12px #f1c40f; }
.stack.lost { opacity: 0.35; }

/* ----- Shared tables ----- */
.round-status {
    margin: 12px 0;
    padding: 9px 14px;
    border-radius: 6px;
    background: #f3f3f3;
    color: #444;
    font-weight: bold;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.round-status.open { background: #e8f5e9; color: #1b5e20; }
.round-status.urgent { background: #fff3cd; color: #7a4f00; }
.round-status.closed { background: #242424; color: #fff; }
/* Other players' chips: a small grey stack in the spot's corner */
.others {
    position: absolute;
    right: 1px;
    bottom: 1px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border-radius: 10px;
    background: #cfd8dc;
    color: #263238;
    border: 2px dashed #fff;
    font-size: 9px;
    font-weight: bold;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 4;
}
.others.won { background: #f1c40f; color: #3b2a00; }
.others.lost { opacity: 0.35; }
.players { margin-top: 16px; border: 1px solid #e3e3e3; border-radius: 6px; padding: 10px 14px; }
.players h3 { margin: 0 0 8px; font-size: 0.95em; color: #666; text-transform: uppercase; letter-spacing: 0.04em; }
.player { display: grid; grid-template-columns: 28px minmax(80px, auto) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; border-top: 1px solid #f0f0f0; }
.player:first-of-type { border-top: none; }
.player.me { font-weight: bold; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; background: #ddd; }
.pname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbets { color: #666; font-weight: normal; font-size: 0.92em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnet { font-weight: bold; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pnet.win { color: #1e7d32; }
.pnet.lose { color: #b3261e; }
.pnet.ready { color: #1e7d32; font-weight: normal; font-size: 0.9em; }
.race-buttons { display: flex; gap: 8px; }
.race-buttons[hidden] { display: none; }
.race-buttons .btn { flex: 1; white-space: nowrap; }
/* Table picker: a small live table for each of the 4 */
.table-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 4px 0 14px; }
.mini-table {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    padding: 6px 6px 7px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: #f5f5f5;
    color: #222;
    font: inherit;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}
.mini-table:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12); }
.mini-table[aria-pressed="true"] { border-color: #242424; background: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15); }
.mini-table.mine { border-color: #f1c40f; }
.mini-table:disabled { opacity: 0.45; cursor: not-allowed; }
.mini-felt {
    position: relative;
    width: 100%;
    height: 66px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #fff;
    background: radial-gradient(ellipse at 50% 0%, #138a3a, #0b6623 70%);
    border: 4px solid #4a2c12;
    border-radius: 50% / 50%;
}
/* Blackjack: the dealer's side on top, 7 seats around the curve */
.mini-table.blackjack .mini-felt {
    flex-direction: column-reverse;
    justify-content: space-between;
    padding: 5px 0 6px;
    border-radius: 6px 6px 50% 50% / 6px 6px 60% 60%;
}
.mini-table.race .mini-felt {
    background: repeating-linear-gradient(180deg, #7cc576 0 13px, #fff 13px 14px);
    border-color: #8d6e63;
    border-radius: 8px;
}
.mini-faces:empty { display: none; }
.mini-faces { display: flex; align-items: flex-end; justify-content: center; gap: 3px; min-height: 20px; }
.mini-table .face {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    color: #0b6623;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.mini-table .face img { width: 100%; height: 100%; object-fit: cover; }
.mini-table .face.me { box-shadow: 0 0 0 2px #f1c40f; }
.mini-table .face.more { background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 9px; }
.mini-table.blackjack .face { width: 16px; height: 16px; font-size: 9px; }
.mini-table.blackjack .face:empty { background: rgba(255, 255, 255, 0.1); border: 1px dashed rgba(255, 255, 255, 0.5); box-shadow: none; }
.mini-table.blackjack .face:nth-child(1), .mini-table.blackjack .face:nth-child(7) { margin-bottom: 9px; }
.mini-table.blackjack .face:nth-child(2), .mini-table.blackjack .face:nth-child(6) { margin-bottom: 4px; }
.mini-table.blackjack .face:nth-child(3), .mini-table.blackjack .face:nth-child(5) { margin-bottom: 1px; }
.mini-status {
    padding: 1px 8px;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 0.72em;
    font-weight: bold;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.mini-status:empty { visibility: hidden; }
.mini-status.free { background: rgba(255, 255, 255, 0.2); }
.mini-status.open { background: #fff3cd; color: #7a4f00; }
.mini-status.busy { background: #242424; }
.mini-table.race .mini-status.free { background: rgba(0, 0, 0, 0.35); }
.mini-name { font-weight: bold; font-size: 0.9em; }
.mini-table.mine .mini-name::after { content: " · you"; color: #a07800; }
.mini-count { font-size: 0.75em; color: #666; min-height: 1.2em; }
.lane .pot { position: absolute; right: 4px; top: -2px; font-size: 11px; color: #7a5a00; font-weight: bold; }

/* ----- Blackjack ----- */
.bj-table {
    background: radial-gradient(ellipse at 50% 0%, #138a3a, #0b6623 70%);
    border: 6px solid #4a2c12;
    border-radius: 10px 10px 120px 120px / 10px 10px 40px 40px;
    padding: 16px 16px 26px;
    color: #fff;
    position: relative;
}
.bj-dealer { text-align: center; margin-bottom: 22px; }
.bj-label { font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; margin-bottom: 6px; }
.bj-label strong { font-size: 1.25em; letter-spacing: 0; margin-left: 4px; }
.bj-dealer .cards { justify-content: center; }
/* Bets: top right corner of the table */
.bj-bets {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    min-width: 120px;
    max-width: 30%;
    padding: 6px 10px 7px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.82em;
}
.bj-bets[hidden] { display: none; }
.bj-bets h3 { margin: 0 0 3px; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.bj-bet { display: flex; align-items: baseline; gap: 8px; line-height: 1.5; }
.bj-bet .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bj-bet.me .who { color: #ff8a80; font-weight: bold; }
.bj-bet .amt, .bj-bet .net { font-weight: bold; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bj-bet .net { min-width: 3.5em; text-align: right; }
.bj-bet .net.win { color: #b9f6ca; }
.bj-bet .net.lose { color: #ff8a80; }
/* Hands: just the cards on the felt, centered under the dealer */
.bj-seats { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 18px 28px; }
.bj-empty { width: 100%; text-align: center; opacity: 0.85; margin: 14px 0; }
.hand { display: flex; flex-direction: column; align-items: center; gap: 7px; max-width: 100%; }
.hand .cards { width: calc(var(--w) * (1 + var(--spread) * (var(--n, 1) - 1))); max-width: 100%; }
.hand.me .card { border-color: #e53935; box-shadow: 0 0 0 2px #e53935, -2px 2px 5px rgba(0, 0, 0, 0.35); }
.hand.acting .cards { filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.75)); }
.card.spot { background: rgba(255, 255, 255, 0.06); border: 2px dashed rgba(255, 255, 255, 0.45); box-shadow: none; }
.hand.me .card.spot { border-color: #ff5252; box-shadow: none; }
.hand-total {
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.4);
    font-size: 0.85em;
    font-weight: bold;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.hand.acting .hand-total { background: #fff3cd; color: #7a4f00; }
.hand-total.win { background: #2e7d32; }
.hand-total.lose { color: #ffab91; }
/* Playing cards, drawn like a real deck. --w is the card width; everything
   else scales from it (1em = a quarter of the card width). */
.cards {
    --w: 58px;
    --spread: 0.55; /* how much of each covered card shows */
    display: flex;
    container-type: inline-size;
    min-height: calc(var(--w) * 1.4);
}
.bj-dealer .cards { --w: 70px; --spread: 1.1; justify-content: center; } /* side by side unless it runs out of room */
.card {
    --back:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.22) 0 1.5px, transparent 1.5px 6px),
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.22) 0 1.5px, transparent 1.5px 6px),
        #a91d27;
    position: relative;
    flex: none;
    width: var(--w);
    height: calc(var(--w) * 1.4);
    font-size: calc(var(--w) / 4);
    border-radius: calc(var(--w) * 0.08);
    background: linear-gradient(160deg, #fff 55%, #efede6);
    color: #1b1b1b;
    border: 1px solid #c4c4c4;
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.35);
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1;
    user-select: none;
    isolation: isolate; /* keeps each card's corners under the card on top of it */
}
/* Fanned like a hand on the felt: each card covers the last one but its corner,
   and they bunch up more when the hand is wider than the seat. */
.card + .card {
    margin-left: calc(min(var(--w) * var(--spread), (100cqw - var(--w)) / max(var(--n, 2) - 1, 1)) - var(--w));
}
.card.red { color: #c3161c; }
.card .corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0.9em;
    font-weight: bold;
}
.card .corner.tl { top: 0.2em; left: 0.14em; }
.card .corner.br { bottom: 0.2em; right: 0.14em; transform: rotate(180deg); }
.card .corner { z-index: 1; }
.card .corner .rank { font-size: 0.8em; letter-spacing: -0.12em; }
.card .corner .suit { font-size: 0.66em; margin-top: 0.06em; }
.card .face { position: absolute; inset: 19% 34%; }
.card .pip { position: absolute; transform: translate(-50%, -50%); font-size: 0.86em; }
.card .pip.flip { transform: translate(-50%, -50%) rotate(180deg); }
.card .pip.ace { left: 50%; top: 50%; font-size: 2.3em; }
/* J / Q / K: a framed, two-headed picture like a real court card */
.card .court {
    position: absolute;
    inset: 8% 25%;
    display: flex;
    flex-direction: column;
    border: 1px solid #1f4e9c;
    border-radius: 2px;
    background: linear-gradient(135deg, #fff5d6, #ecd187 50%, #fff5d6);
    overflow: hidden;
}
.card .court .half { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card .court .bottom { transform: rotate(180deg); border-bottom: 1px solid rgba(31, 78, 156, 0.55); }
.card .court .figure { font-size: 1.45em; font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif; }
.card .court .suit { font-size: 0.62em; margin-top: -0.05em; }
.card.back {
    background: var(--back);
    border: calc(var(--w) * 0.065) solid #fff;
    box-shadow: inset 0 0 0 2px #a91d27, inset 0 0 0 3px rgba(255, 255, 255, 0.75), -2px 2px 5px rgba(0, 0, 0, 0.35);
}
/* Dealt from the shoe (top right), and the hole card flips over */
.card.new { animation: deal 0.4s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes deal { from { transform: translate(60px, -80px) rotate(18deg); opacity: 0; } }
.card.turn { animation: turn 0.5s ease-in-out; }
.card.turn::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--back);
    border: calc(var(--w) * 0.065) solid #fff;
    animation: turn-back 0.5s steps(1, end) forwards;
}
@keyframes turn { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0); } }
@keyframes turn-back { 0% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .card.new, .card.turn, .card.turn::after { animation: none; }
    .card.turn::after { display: none; }
}
.bj-controls { grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.6fr); }

/* Phones: this comes last so it wins over the roulette table styles above */
@media (max-width: 700px) {
    .chip { width: 38px; height: 38px; font-size: 10px; }
    .chip.call { font-size: 8px; }
    .chips { gap: 5px; flex-wrap: nowrap; }
    .bet-actions { flex-wrap: wrap; }
    .bet-buttons { width: 100%; flex-wrap: nowrap; }
    .bet-buttons .btn { flex: 1; padding: 9px 6px; }
    .player { grid-template-columns: 28px 1fr auto; }
    .pbets { grid-column: 2 / 4; grid-row: 2; }
    .bj-controls { grid-template-columns: 1fr; }
    .bj-seats { gap: 14px 18px; }
    /* Not enough room beside the dealer: the bets sit at the top right, above the cards */
    .bj-bets { position: static; max-width: none; width: fit-content; margin: 0 0 8px auto; }
    .cards { --w: 46px; }
    .bj-dealer .cards { --w: 56px; }
    .bj-table { padding: 12px 10px 20px; }
    .table-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
