/* Matt's Baccarat
   Layout: a black high-limit table with gold trim. Top bar, the two hands side by side,
   the three betting spots, a bead-road scoreboard, and one control dock whose contents
   follow the game phase ([data-phase] / [data-fastforward] on #game-container). */

:root {
    --felt: #16161a;
    --felt-edge: #070708;
    --rail: #0d0d0f;
    --trim: #d9b44a;
    --accent: #e9c96a;
    --panel: rgba(255, 255, 255, 0.045);
    --player: #3d7fd9;
    --banker: #d23c46;
    --tie: #2fa86a;
    --win: #46e08c;
    --serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 12px;
    box-sizing: border-box;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    color: #f4efe2;
    background-color: #050505;
    background-image:
        radial-gradient(ellipse at 50% -20%, rgba(217, 180, 74, 0.18) 0%, transparent 55%),
        repeating-linear-gradient(135deg, #0b0b0c 0 18px, #080809 18px 36px);
}

#game-container {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 860px;
    padding: 12px 18px 10px;
    text-align: center;
    border: 8px solid var(--rail);
    border-radius: 22px;
    background: radial-gradient(ellipse at 50% 30%, var(--felt) 0%, var(--felt-edge) 85%);
    box-shadow:
        0 22px 55px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(217, 180, 74, 0.25),
        inset 0 0 0 2px var(--trim),
        inset 0 0 80px rgba(0, 0, 0, 0.6);
}

h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 700;
    font-style: italic;
    letter-spacing: 0.04em;
    color: var(--accent);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

/* ---------- Top bar ---------- */

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 4px;
}

#other-games {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.other-game {
    padding: 5px 11px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(217, 180, 74, 0.35);
    border-radius: 999px;
    transition: background-color 0.15s ease, transform 0.08s ease;
}

.other-game:hover {
    background: rgba(217, 180, 74, 0.14);
    transform: translateY(-1px);
}

#game-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#stats-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

#balance, #wagered {
    margin: 0;
    padding: 4px 13px;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(217, 180, 74, 0.25);
    border-radius: 999px;
}

#shoe-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: rgba(244, 239, 226, 0.75);
}

#shoe {
    position: relative;
    width: 24px;
    height: 36px;
    overflow: hidden;
    box-sizing: border-box;
    background: #1d1d20;
    border: 2px solid rgba(217, 180, 74, 0.5);
    border-radius: 5px;
}

#shoe-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(#b5121b, #7a0b12);
    transition: height 0.4s ease-out;
}

#top-buttons {
    display: flex;
    gap: 8px;
}

#mute, #toggle-paytable {
    padding: 6px 12px;
    font-size: 13px;
}

/* ---------- Message ---------- */

#message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    margin: 2px 0 6px;
    overflow-y: auto;
    font-size: 16px;
    font-weight: 700;
    color: #fff1c2;
}

/* ---------- Paytable ---------- */

#paytable {
    margin-bottom: 8px;
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid rgba(217, 180, 74, 0.2);
    border-radius: 12px;
}

#paytable table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#paytable caption {
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--accent);
}

#paytable th, #paytable td {
    padding: 4px 6px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#paytable th:first-child, #paytable td:first-child {
    text-align: left;
}

#paytable-note {
    margin: 8px 0 0;
    font-size: 11.5px;
    line-height: 1.5;
    color: rgba(244, 239, 226, 0.6);
}

/* ---------- Hands ---------- */

#hands-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.hand-panel {
    padding: 8px 6px;
    background: var(--panel);
    border: 2px solid transparent;
    border-radius: 14px;
    box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.4);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

#player-panel { border-top-color: var(--player); }
#banker-panel { border-top-color: var(--banker); }

#player-panel.winner {
    border-color: var(--player);
    box-shadow: 0 0 18px rgba(61, 127, 217, 0.45), inset 0 3px 12px rgba(0, 0, 0, 0.4);
}

#banker-panel.winner {
    border-color: var(--banker);
    box-shadow: 0 0 18px rgba(210, 60, 70, 0.45), inset 0 3px 12px rgba(0, 0, 0, 0.4);
}

.hand-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#player-panel .hand-name { color: #8fb8f2; }
#banker-panel .hand-name { color: #f08a90; }

.score {
    display: inline-block;
    min-width: 26px;
    padding: 1px 9px;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
    letter-spacing: 0;
    color: #1b1b1b;
    background: var(--accent);
    border-radius: 999px;
}

.score[hidden] {
    display: none;
}

.hand-cards {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 108px;
}

.hand-cards:empty::after {
    content: '';
    width: 64px;
    height: 96px;
    border: 2px dashed rgba(217, 180, 74, 0.25);
    border-radius: 7px;
}

/* Cards: the same look as the blackjack table */
.card {
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 64px;
    height: 96px;
    margin: 0 3px;
    font-family: var(--serif);
    line-height: 1;
    background: linear-gradient(160deg, #ffffff 0%, #f3efe6 100%);
    border: 1px solid rgba(0, 0, 0, 0.28);
    border-radius: 7px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.card.red { color: #cc1f2b; }
.card.black { color: #15181d; }

@keyframes dealIn {
    from { opacity: 0; transform: translate(-80px, -80px) rotate(-90deg); }
    to { opacity: 1; transform: none; }
}

.card.deal-in {
    animation: dealIn 0.45s ease-out both;
}

.card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 18px;
    font-size: 14px;
}

.top-left { top: 4px; left: 4px; }
.bottom-right { bottom: 4px; right: 4px; transform: rotate(180deg); }
.card-value { font-weight: 700; }
.card-suit { font-size: 14px; }

.card-center-suit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
}

/* ---------- Betting spots ---------- */

#bet-spots {
    display: grid;
    grid-template-columns: 1fr 0.8fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.bet-spot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 74px;
    padding: 6px 4px;
    font: inherit;
    color: #ffffff;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 40px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45);
    transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.spot-player { background: radial-gradient(ellipse at 50% 30%, #2f66b3, #183a6b); }
.spot-banker { background: radial-gradient(ellipse at 50% 30%, #b3313a, #6b1a20); }
.spot-tie { background: radial-gradient(ellipse at 50% 30%, #258a56, #134a2e); }

.bet-spot:hover:not(:disabled) {
    transform: translateY(-2px);
}

.bet-spot:disabled {
    cursor: default;
}

.spot-name {
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.spot-pays {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.spot-badge {
    min-height: 16px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 800;
    color: #1d1a10;
    background: var(--accent);
    border-radius: 999px;
}

.spot-badge:empty {
    background: none;
    padding: 0;
}

.bet-spot.has-bet {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(233, 201, 106, 0.45), inset 0 2px 10px rgba(0, 0, 0, 0.45);
}

.bet-spot.bet-won {
    border-color: var(--win);
    box-shadow: 0 0 18px rgba(70, 224, 140, 0.7), inset 0 2px 10px rgba(0, 0, 0, 0.45);
}

.bet-spot.bet-lost {
    opacity: 0.5;
}

.bet-spot.bet-push {
    border-color: #b9c7d6;
}

/* ---------- Scoreboard (bead road) ---------- */

#scoreboard {
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(217, 180, 74, 0.18);
    border-radius: 10px;
}

#bead-road {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    min-height: 20px;
}

.bead {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 800;
    color: #ffffff;
    border-radius: 50%;
}

.bead-player { background: var(--player); }
.bead-banker { background: var(--banker); }
.bead-tie { background: var(--tie); }

#scoreboard-counts {
    margin-top: 4px;
    font-size: 11.5px;
    color: rgba(244, 239, 226, 0.65);
}

#fastforward-summary {
    margin: 0 0 8px;
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    line-height: 1.6;
    background: rgba(217, 180, 74, 0.08);
    border: 1px solid rgba(217, 180, 74, 0.4);
    border-radius: 10px;
}

#fastforward-summary h3 {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--accent);
}

/* ---------- Chips ---------- */

.chip {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    color: #ffffff;
    box-shadow: 0 4px 7px rgba(0, 0, 0, 0.5), inset 0 -3px 4px rgba(0, 0, 0, 0.28), inset 0 3px 3px rgba(255, 255, 255, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chip::before {
    content: '';
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.6);
}

.chip-value {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.chip:hover {
    transform: translateY(-4px);
}

.chip.selected {
    box-shadow: 0 0 0 3px var(--accent), 0 6px 10px rgba(0, 0, 0, 0.5);
}

.chip-1 { background: radial-gradient(circle at 35% 30%, #f4f6f8, #a9b5c4 75%); color: #2a2f36; }
.chip-5 { background: radial-gradient(circle at 35% 30%, #ff6a5a, #b31b29 75%); }
.chip-25 { background: radial-gradient(circle at 35% 30%, #4fc46a, #1e7a38 75%); }
.chip-100 { background: radial-gradient(circle at 35% 30%, #4a4d55, #15171c 75%); }
.chip-500 { background: radial-gradient(circle at 35% 30%, #a57bd6, #5b2d8f 75%); }

/* ---------- Buttons and inputs ---------- */

button {
    padding: 10px 18px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #1d1a10;
    cursor: pointer;
    background: linear-gradient(#f3dc8f, #c99a26);
    border: none;
    border-radius: 9px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 6px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

button:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

#deal-button, #next-round {
    color: #ffffff;
    background: linear-gradient(#4fc46a, #2d9448);
}

#deal-button {
    padding: 10px 30px;
    font-size: 17px;
}

#clear-bets, #restart, #ff-stop-button {
    color: #ffffff;
    background: linear-gradient(#ff6a4d, #c8301a);
}

/* Betting spots are disabled once the cards are out, but keep their own colors - the
   result highlighting (won / lost / push) is drawn on top of them. */
button:disabled:not(.bet-spot) {
    color: rgba(255, 255, 255, 0.55);
    cursor: not-allowed;
    background: linear-gradient(#5c5f63, #45484c);
    box-shadow: none;
    filter: none;
    transform: none;
}

button:focus-visible, .chip:focus-visible, input:focus-visible, .other-game:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

input[type="number"] {
    box-sizing: border-box;
    width: 90px;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    color: #1d1a10;
    background: #fbf8ef;
    border: none;
    border-radius: 9px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

input[type="number"]:disabled {
    cursor: not-allowed;
    background: #8f9296;
}

#set-bankroll, #set-custom-amount, #fast-forward-button {
    padding: 8px 16px;
    font-size: 14px;
}

/* ---------- Control dock ---------- */

#dock {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 120px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(217, 180, 74, 0.15);
    border-radius: 14px;
}

.dock-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

#results-dock {
    flex-direction: row;
    flex-wrap: wrap;
}

#game-container[data-phase="betting"] #betting-dock,
#game-container[data-phase="results"] #results-dock {
    display: flex;
}

#game-container[data-fastforward="true"] #betting-dock,
#game-container[data-fastforward="true"] #results-dock {
    display: none !important;
}

#game-container[data-fastforward="true"] #fastforward-dock {
    display: flex;
}

#bankroll-controls, #chip-container, #bet-controls, #fastforward-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(244, 239, 226, 0.8);
}

#fastforward-controls {
    padding-top: 8px;
    border-top: 1px dashed rgba(217, 180, 74, 0.2);
}

#ff-progress {
    width: 100%;
    max-width: 420px;
    height: 18px;
    box-sizing: border-box;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(217, 180, 74, 0.3);
    border-radius: 999px;
}

#ff-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f3dc8f, #c99a26);
    border-radius: 999px;
    transition: width 0.15s ease-out;
}

#ff-progress-label {
    font-size: 13px;
    font-weight: 600;
}

#stats {
    margin-top: 8px;
    font-size: 11.5px;
    color: rgba(244, 239, 226, 0.6);
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
    body { padding: 8px; }

    #game-container {
        padding: 10px 8px 8px;
        border-width: 6px;
        border-radius: 16px;
    }

    h1 { font-size: 19px; }

    #balance, #wagered {
        padding: 3px 9px;
        font-size: 13px;
    }

    #mute, #toggle-paytable, .other-game {
        padding: 5px 8px;
        font-size: 11px;
    }

    #hands-area { gap: 6px; }

    .card {
        width: 44px;
        height: 66px;
        margin: 0 1px;
    }

    .card-corner, .card-suit { font-size: 11px; }
    .card-corner { width: 13px; }
    .top-left { top: 2px; left: 2px; }
    .bottom-right { bottom: 2px; right: 2px; }
    .card-center-suit { font-size: 22px; }

    .hand-cards { min-height: 72px; }

    .hand-cards:empty::after {
        width: 44px;
        height: 66px;
    }

    .hand-title { font-size: 14px; }

    .bet-spot { min-height: 62px; }
    .spot-name { font-size: 14px; }
    .spot-pays { font-size: 10.5px; }

    .chip {
        width: 42px;
        height: 42px;
    }

    .chip-value { font-size: 11.5px; }

    button {
        padding: 8px 12px;
        font-size: 13px;
    }

    #deal-button {
        padding: 8px 22px;
        font-size: 15px;
    }

    input[type="number"] {
        width: 76px;
        padding: 7px 8px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        transition-duration: 0.01ms !important;
    }
}
