/* Matt's Blackjack
   Layout: a felt table in a wooden rail. Top bar, dealer area, the player's spot (the
   betting circle while betting, the hands once dealt) and one control dock whose contents
   follow the game phase ([data-phase] on #game-container, set by script.js). */

/* ---------- Themes ---------- */

body {
    --page: #05261a;
    --page-stripe: #073322;
    --felt-center: #17804b;
    --felt-edge: #0a4a2c;
    --rail: #2b1a0f;
    --rail-light: #4a2e1a;
    --trim: #d9b44a;
    --accent: #ffd54a;
    --panel: rgba(0, 0, 0, 0.17);
    --win: #46e08c;
    --loss: #ff6b6b;
    --push: #b9c7d6;
    --serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif;
}

body.theme2 {
    --page: #101a26;
    --page-stripe: #142131;
    --felt-center: #3f6288;
    --felt-edge: #1f3550;
    --rail: #1b222b;
    --rail-light: #323d4b;
    --trim: #b9c4d2;
    --accent: #ffe08a;
}

body.theme3 {
    --page: #241030;
    --page-stripe: #2d1539;
    --felt-center: #8a48a8;
    --felt-edge: #4d2166;
    --rail: #2a1533;
    --rail-light: #47265a;
    --trim: #e0b8f0;
    --accent: #ffd75e;
}

/* ---------- Page and table ---------- */

* {
    -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: #ffffff;
    background-color: var(--page);
    background-image: repeating-linear-gradient(45deg, var(--page-stripe) 0 20px, transparent 20px 40px);
}

#game-container {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 880px;
    padding: 12px 18px 10px;
    text-align: center;
    border: 8px solid var(--rail);
    border-radius: 22px;
    background: radial-gradient(ellipse at 50% 32%, var(--felt-center) 0%, var(--felt-edge) 78%);
    box-shadow:
        0 22px 55px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(0, 0, 0, 0.6),
        inset 0 0 0 2px var(--trim),
        inset 0 0 80px rgba(0, 0, 0, 0.5);
}

h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 700;
    font-style: italic;
    letter-spacing: 0.03em;
    color: var(--accent);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ---------- Top bar ---------- */

#other-games {
    display: flex;
    gap: 6px;
}

.other-game {
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    transition: background-color 0.15s ease, transform 0.08s ease;
}

.other-game:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

.other-game:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 4px;
}

#game-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

#stats-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

#balance, #bet {
    margin: 0;
    padding: 4px 13px;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.34);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

#balance {
    font-size: 16px;
}

#shoe-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

#top-buttons {
    display: flex;
    gap: 8px;
}

#mute, #toggle-hints, #change-theme {
    padding: 6px 12px;
    font-size: 13px;
}

/* The shoe: a small card-back that drains as cards are dealt */

#shoe {
    position: relative;
    width: 28px;
    height: 42px;
    overflow: hidden;
    border-radius: 6px;
    background-color: #1c1c1c;
    border: 2px solid rgba(255, 255, 255, 0.35);
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}

#shoe-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background-color: #1266c4;
    transition: height 0.5s ease-out;
}

#shoe::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, #555, #555 8px, #333 8px, #333 16px);
    opacity: 0.3;
}

#shoe::after {
    content: '♠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #ffffff;
    opacity: 0.75;
}

#shoe.reshuffling::before {
    opacity: 1;
    animation: shuffle 1s linear infinite;
}

@keyframes shuffle {
    0% { background-position: 0 0; }
    100% { background-position: 40px 40px; }
}

/* ---------- Message ---------- */

#message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px; /* room for a multi-hand result, so the layout below doesn't shift */
    margin: 2px 0 6px;
    overflow-y: auto;
    font-size: 17px;
    font-weight: 700;
    color: #ffe3a3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* ---------- Dealer and player areas ---------- */

#dealer-hand,
#player-hands-container {
    position: relative; /* the cut card is positioned against the dealer's area */
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.3);
}

.hand-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--accent);
}

.score {
    display: inline-block;
    min-width: 26px;
    padding: 1px 9px;
    box-sizing: border-box;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.5;
    color: #1b1b1b;
    background: var(--accent);
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.score[hidden] {
    display: none;
}

.score.twenty-one {
    background: var(--win);
}

.score.bust {
    color: #fff;
    background: #e5484d;
}

#dealer-cards {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    height: 112px;
}

/* Rules printed on the felt, like a real table */
#game-container[data-phase="betting"] #dealer-cards:empty::after {
    content: 'BLACKJACK PAYS 3 TO 2  \00b7  DEALER STANDS ON ALL 17s  \00b7  INSURANCE PAYS 2 TO 1';
    max-width: 90%;
    font-family: var(--serif);
    font-size: 13px;
    letter-spacing: 0.16em;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.34);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

#player-hands {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    min-height: 190px;
}

.hand {
    position: relative;
    flex: 0 1 auto;
    min-width: 0;
    margin: 0 10px;
    padding: 8px 10px;
    border: 2px solid transparent;
    border-radius: 14px;
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.hand.active-hand {
    background-color: rgba(255, 213, 74, 0.13);
    border-color: rgba(255, 213, 74, 0.6);
    box-shadow: 0 0 20px rgba(255, 213, 74, 0.28);
}

.hand[data-result="win"],
.hand[data-result="blackjack"] {
    border-color: rgba(70, 224, 140, 0.55);
    background-color: rgba(70, 224, 140, 0.08);
}

.hand[data-result="loss"] {
    border-color: rgba(255, 107, 107, 0.45);
    background-color: rgba(255, 107, 107, 0.07);
}

.hand-cards {
    display: flex;
    flex-wrap: nowrap; /* cards overlap (see fitCards in script.js) instead of wrapping */
    justify-content: center;
    align-items: center;
    height: 112px;
    perspective: 1000px;
}

.hand-bet {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
}

.hand-status {
    min-height: 18px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

.hand[data-result="win"] .hand-status { color: var(--win); }
.hand[data-result="blackjack"] .hand-status { color: var(--accent); text-shadow: 0 0 10px rgba(255, 213, 74, 0.7); }
.hand[data-result="loss"] .hand-status { color: var(--loss); }
.hand[data-result="push"] .hand-status { color: var(--push); }
.hand[data-result="surrender"] .hand-status { color: #ffb066; }

/* ---------- Cards ---------- */

.card {
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 70px;
    height: 105px;
    margin: 0 5px 5px 0;
    font-family: var(--serif);
    line-height: 1;
    cursor: default;
    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.42), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.card.red { color: #cc1f2b; }
.card.black { color: #15181d; }

/* A card that has just been dealt flies in from the shoe */
@keyframes dealIn {
    from {
        opacity: 0;
        transform: translate(-100px, -100px) rotate(-90deg);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.card.deal-in {
    animation: dealIn 0.5s ease-out;
}

.card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20px;
    font-size: 15px;
}

.top-left {
    top: 5px;
    left: 5px;
}

.bottom-right {
    bottom: 5px;
    right: 5px;
    transform: rotate(180deg);
}

.card-value {
    font-weight: 700;
}

.card-suit {
    font-size: 15px;
}

.card-center-suit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
}

.card.card-back {
    background-color: #0d5cb0;
    background-image:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 2px, transparent 2px 9px),
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.16) 0 2px, transparent 2px 9px);
    border: 5px solid #ffffff;
}

.card-back::after {
    content: '♠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 20px;
    color: #0d5cb0;
    background: #ffffff;
    border-radius: 50%;
}

.cut-card {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 7px 18px;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: #ffffff;
    background: #d92b2b;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s ease-out;
    z-index: 10;
}

/* ---------- The betting circle ---------- */

#bet-display {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 360px;
    max-width: 100%;
    height: 170px;
    margin: 0 auto;
    border: 3px dashed rgba(255, 213, 74, 0.5);
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.08));
    box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.3);
}

#bet-label {
    margin-bottom: 6px;
    font-family: var(--serif);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

#bet-chips {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    max-width: 100%;
    min-height: 64px;
}

/* Chips in the circle are a little smaller and fan out so every value stays readable */
#bet-chips .chip {
    width: 46px;
    height: 46px;
}

#bet-chips .chip::before {
    inset: 7px;
}

#bet-chips .chip-value {
    font-size: 12px;
}

#bet-chips .chip + .chip {
    margin-left: -12px;
}

#game-container[data-phase="betting"] #bet-display {
    display: flex;
}

#game-container[data-phase="betting"] #player-hands {
    display: none;
}

/* ---------- Chips ---------- */

.chip {
    --chip: #999999;
    --ink: #ffffff;
    --spot: #ffffff;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    color: var(--ink);
    background-color: var(--chip);
    background-image: repeating-conic-gradient(var(--spot) 0 9deg, transparent 9deg 30deg);
    box-shadow:
        0 4px 7px rgba(0, 0, 0, 0.45),
        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, opacity 0.2s ease;
}

.chip::before {
    content: '';
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: var(--chip);
    border: 2px dashed rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

.chip-value {
    position: relative;
    z-index: 1;
    font-size: 15px;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.chip:hover {
    transform: translateY(-4px);
    box-shadow:
        0 9px 10px rgba(0, 0, 0, 0.4),
        inset 0 -3px 4px rgba(0, 0, 0, 0.28),
        inset 0 3px 3px rgba(255, 255, 255, 0.25);
}

.chip:active {
    transform: translateY(0);
}

.chip.locked {
    pointer-events: none;
    opacity: 0.4;
    filter: grayscale(0.5);
}

.chip.chip-in {
    animation: chipIn 0.22s ease-out;
}

@keyframes chipIn {
    from {
        opacity: 0;
        transform: translateY(-18px) scale(0.6);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.chip-1 { --chip: #e8ecf1; --ink: #2a2f36; --spot: #a9b5c4; }
.chip-5 { --chip: #e0392f; }
.chip-25 { --chip: #2f9e6b; }
.chip-100 { --chip: #23262b; }
.chip-500 { --chip: #7b4397; }
.chip-1000 { --chip: #e6b800; --ink: #3a2a00; }

/* ---------- Buttons ---------- */

button {
    padding: 10px 18px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #1d1a10;
    cursor: pointer;
    background: linear-gradient(#ffe57a, #f2bf10);
    border: none;
    border-radius: 9px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.38), 0 6px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.38);
}

/* Enabled action buttons, Deal and Next Hand are green; Clear Bet and New Game red; Hint blue */
button.enabled,
#deal,
#next-hand {
    color: #ffffff;
    background: linear-gradient(#4fc46a, #2d9448);
}

#clear-bet,
#restart {
    color: #ffffff;
    background: linear-gradient(#ff6a4d, #d8391c);
}

#hint {
    color: #ffffff;
    background: linear-gradient(#63a9ea, #3a7bc4);
}

#rebet {
    background: linear-gradient(#f4f6f8, #cfd6de);
}

#deal {
    padding: 10px 30px;
    font-size: 17px;
}

button:disabled,
button.enabled:disabled,
#deal:disabled,
#hint:disabled,
#rebet:disabled,
#clear-bet:disabled,
#restart:disabled,
#next-hand:disabled {
    color: rgba(255, 255, 255, 0.6);
    cursor: not-allowed;
    background: linear-gradient(#8b9892, #6f7c76);
    box-shadow: none;
    filter: none;
    transform: none;
}

button:focus-visible,
.chip:focus-visible,
#bet-amount:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

#bet-amount {
    width: 120px;
    padding: 10px;
    box-sizing: border-box;
    font: inherit;
    font-size: 15px;
    color: #1d1a10;
    background: #ffffff;
    border: none;
    border-radius: 9px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

#bet-amount:disabled {
    cursor: not-allowed;
    background: #b8c1bd;
}

/* ---------- Control dock ---------- */

#dock {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 116px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.35);
}

.dock-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

#end-dock {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
}

#game-container[data-phase="betting"] #bet-dock,
#game-container[data-phase="dealing"] #play-dock,
#game-container[data-phase="insurance"] #play-dock,
#game-container[data-phase="playerTurn"] #play-dock,
#game-container[data-phase="dealerTurn"] #play-dock,
#game-container[data-phase="gameOver"] #end-dock {
    display: flex;
}

#chip-container,
#bet-controls,
#actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

#chip-container {
    gap: 12px;
}

#stats {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.72);
}

/* ---------- Popups and notices ---------- */

.result-popup {
    --tone: var(--accent);
    position: absolute;
    top: 42%;
    left: 50%;
    z-index: 100;
    padding: 8px 22px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.84);
    border: 2px solid var(--tone);
    border-radius: 12px;
    box-shadow: 0 0 22px var(--tone);
    pointer-events: none;
    animation: popupRise 3s ease both;
}

.result-win, .result-blackjack { --tone: var(--win); }
.result-loss { --tone: var(--loss); }
.result-push { --tone: var(--push); }
.result-surrender { --tone: #ffb066; }

@keyframes popupRise {
    0% { opacity: 0; transform: translate(-50%, -35%) scale(0.85); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    88% { opacity: 1; transform: translate(-50%, -58%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -66%) scale(1); }
}

.streak-message {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1000;
    padding: 18px 28px;
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%);
    animation: fadeInOut 3s ease-in-out;
}

.hot-streak {
    background: linear-gradient(135deg, #ff5a36, #d81f26);
}

.cold-streak {
    background: linear-gradient(135deg, #3b8bff, #2748c9);
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

@keyframes blackjackPopup {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 20px #ffd700; }
    50% { box-shadow: 0 0 40px #ffd700, 0 0 60px #ff6347; }
}

.blackjack-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1000;
    padding: 30px 50px;
    font-family: var(--serif);
    font-size: 48px;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #b8860b, #daa520);
    border-radius: 15px;
    transform: translate(-50%, -50%);
    animation:
        blackjackPopup 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        glowPulse 2s infinite;
}

.blackjack-popup::before,
.blackjack-popup::after {
    content: '♠♥♦♣';
    position: absolute;
    font-size: 24px;
    color: #ffffff;
    opacity: 0.7;
}

.blackjack-popup::before {
    top: 10px;
    left: 15px;
}

.blackjack-popup::after {
    bottom: 10px;
    right: 15px;
}

/* Tooltips for the keyboard shortcuts */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    z-index: 5;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    color: #ffffff;
    background: #1d1d1d;
    border-radius: 6px;
    transform: translate(-50%, -6px);
    pointer-events: none;
}

/* ---------- Short windows (small laptops) ---------- */

@media (max-height: 730px) {
    .card {
        width: 60px;
        height: 90px;
    }

    .card-corner,
    .card-suit {
        font-size: 13px;
    }

    .card-center-suit {
        font-size: 30px;
    }

    .card-back::after {
        width: 26px;
        height: 26px;
        font-size: 17px;
    }

    #dealer-cards,
    .hand-cards {
        height: 96px;
    }

    #player-hands {
        min-height: 168px;
    }

    #bet-display {
        height: 140px;
    }

    #message {
        height: 40px;
        margin-bottom: 4px;
    }

    .chip {
        width: 50px;
        height: 50px;
    }

    .chip::before {
        inset: 8px;
    }

    .chip-value {
        font-size: 14px;
    }

    #dock {
        min-height: 100px;
    }

    #game-container {
        padding-top: 8px;
        padding-bottom: 6px;
    }

    h1 {
        font-size: 21px;
    }
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    #game-container {
        padding: 10px 10px 8px;
        border-width: 6px;
        border-radius: 16px;
    }

    h1 {
        font-size: 18px;
    }

    #top-bar {
        justify-content: space-between;
        gap: 4px 8px;
    }

    #top-buttons {
        gap: 5px;
    }

    #game-info {
        order: 3;
        flex-basis: 100%;
        flex-wrap: wrap;
        gap: 6px 12px;
    }

    #stats-bar {
        gap: 8px;
    }

    #balance, #bet {
        padding: 3px 10px;
        font-size: 14px;
    }

    #mute, #toggle-hints, #change-theme {
        padding: 5px 8px;
        font-size: 11.5px;
    }

    #message {
        font-size: 15px;
    }

    #dealer-hand,
    #player-hands-container {
        padding: 6px;
    }

    .card {
        width: 60px;
        height: 90px;
    }

    .card-corner,
    .card-suit {
        font-size: 13px;
    }

    .card-center-suit {
        font-size: 30px;
    }

    .card-back {
        border-width: 4px;
    }

    #dealer-cards {
        height: 100px;
    }

    .hand-cards {
        height: 100px;
    }

    #player-hands {
        min-height: 178px;
    }

    .hand {
        margin: 0 3px;
        padding: 6px 4px;
    }

    #player-hands[data-hands="3"] .card,
    #player-hands[data-hands="4"] .card {
        width: 46px;
        height: 69px;
        margin-right: 4px;
        border-radius: 5px;
    }

    #player-hands[data-hands="3"] .card-corner,
    #player-hands[data-hands="4"] .card-corner {
        width: 14px;
        font-size: 10px;
    }

    #player-hands[data-hands="3"] .card-corner.top-left,
    #player-hands[data-hands="4"] .card-corner.top-left {
        top: 3px;
        left: 3px;
    }

    #player-hands[data-hands="3"] .card-corner.bottom-right,
    #player-hands[data-hands="4"] .card-corner.bottom-right {
        right: 3px;
        bottom: 3px;
    }

    #player-hands[data-hands="3"] .card-suit,
    #player-hands[data-hands="4"] .card-suit {
        font-size: 10px;
    }

    #player-hands[data-hands="3"] .card-center-suit,
    #player-hands[data-hands="4"] .card-center-suit {
        font-size: 24px;
    }

    .hand-title {
        gap: 4px;
        margin-bottom: 6px;
        font-size: 12px;
    }

    .score {
        min-width: 22px;
        padding: 0 6px;
        font-size: 12px;
    }

    .hand-bet,
    .hand-status {
        font-size: 12px;
    }

    #bet-display {
        height: 140px;
    }

    #game-container[data-phase="betting"] #dealer-cards:empty::after {
        font-size: 11px;
        letter-spacing: 0.1em;
    }

    .chip {
        width: 48px;
        height: 48px;
    }

    .chip::before {
        inset: 7px;
    }

    .chip-value {
        font-size: 13px;
    }

    #chip-container {
        gap: 8px;
    }

    #dock {
        min-height: 108px;
        padding: 8px 6px;
    }

    button {
        padding: 8px 12px;
        font-size: 13px;
    }

    #deal {
        padding: 8px 22px;
        font-size: 15px;
    }

    #bet-amount {
        width: 96px;
        padding: 8px;
        font-size: 14px;
    }

    .result-popup {
        font-size: 18px;
    }

    .blackjack-popup {
        padding: 20px 28px;
        font-size: 30px;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    #cards-remaining {
        display: none; /* the shoe icon stays; its tooltip and fill still show the count */
    }

    #balance, #bet {
        padding: 3px 8px;
        font-size: 13px;
    }

    .chip {
        width: 44px;
        height: 44px;
    }

    .chip::before {
        inset: 6px;
    }

    .chip-value {
        font-size: 12px;
    }

    #chip-container {
        gap: 6px;
    }

    #bet-amount {
        width: 84px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
