/* ============================================================
   Blackjack — Casino Royale Theme
   Primary: #059669 (emerald)   Gold: #fbbf24
   Font: Syne (display) · DM Sans (body)
   ============================================================ */

/* ─── Layout: 3-column (ad | game | ad) ─── */
.bj-layout {
    display: grid;
    grid-template-columns: 160px minmax(0, 580px) 160px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        ".       game   .      "
        "left    game   right  "
        ".       game   .      ";
    justify-content: center;
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: calc(100vh - 80px);
}

/* ─── Ad Slots ─── */
.ad-slot { display: flex; align-items: flex-start; justify-content: center; }
.ad-slot--left  { grid-area: left;  padding-top: 2rem; }
.ad-slot--right { grid-area: right; padding-top: 2rem; }
.ad-slot--top, .ad-slot--bottom { display: none; }

.ad-placeholder {
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.12);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    padding: 2rem 1rem;
    width: 100%;
}
.ad-placeholder--vertical {
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 5rem;
}

/* ─── Game Container ─── */
#blackjack-app {
    grid-area: game;
    text-align: center;
    position: relative;
    font-family: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ─── Screen Management ─── */
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ─── Panel Cards (UI containers) ─── */
.card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin-bottom: 0.75rem;
}
.card__title {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.75rem;
}
.card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.card--half { margin-bottom: 0; }

/* ─── Menu Header ─── */
.menu-header {
    padding: 2rem 0 1rem;
}
.menu-header h1 {
    font-family: 'Syne', sans-serif;
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 8px;
    color: #fff;
    margin: 0;
    line-height: 1;
    background: linear-gradient(180deg, #fff 30%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.subtitle {
    color: rgba(255,255,255,0.35);
    font-size: 0.85rem;
    margin-top: 0.4rem;
    font-weight: 400;
    letter-spacing: 1px;
}

/* ─── Table Select Grid ─── */
.table-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-top: 0.25rem;
}
.table-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.8rem 0.5rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    position: relative;
    overflow: hidden;
}
.table-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(5,150,105,0.08) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.18s ease;
}
.table-option:hover { border-color: rgba(5,150,105,0.35); }
.table-option:hover::before { opacity: 1; }
.table-option.selected {
    border-color: #059669;
    background: rgba(5,150,105,0.1);
    box-shadow: 0 0 0 1px rgba(5,150,105,0.3), 0 4px 16px rgba(27,94,32,0.3);
}
.table-option.selected::before { opacity: 1; }
.table-option .table-icon { font-size: 1.5rem; line-height: 1; }
.table-option .table-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.65);
}
.table-option .table-min-bet {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.3);
    font-variant-numeric: tabular-nums;
}

/* ─── Rules List ─── */
.rules-list {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 0;
}
.rules-list li {
    display: flex;
    align-items: center;
    padding: 0.38rem 0.5rem;
    border-radius: 6px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.5);
    transition: background 0.15s;
    gap: 0.5rem;
}
.rules-list li::before {
    content: '♠';
    color: rgba(5,150,105,0.5);
    font-size: 0.65rem;
    flex-shrink: 0;
}
.rules-list li:nth-child(odd) { background: rgba(255,255,255,0.02); }
.rules-list li:hover { background: rgba(5,150,105,0.06); }

/* ─── Volume Controls ─── */
.volume-controls {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.vol-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.vol-name {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.35);
    width: 28px;
    text-align: right;
    font-weight: 500;
}
.vol-slider {
    flex: 1;
    height: 4px;
    accent-color: #059669;
    cursor: pointer;
    max-width: 160px;
}
.vol-val {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    width: 22px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ─── Menu Best / Actions ─── */
.menu-best {
    color: rgba(5,150,105,0.7);
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0.4rem 0 0;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.menu-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin: 1.2rem 0 0.5rem;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.3px;
    line-height: 1.4;
}
.btn:focus-visible {
    outline: 2px solid #059669;
    outline-offset: 2px;
}
.btn--primary {
    background: linear-gradient(135deg, #059669 0%, #2e7d32 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(27,94,32,0.4);
}
.btn--primary:hover {
    background: linear-gradient(135deg, #66bb6a 0%, #388e3c 100%);
    box-shadow: 0 4px 16px rgba(27,94,32,0.5);
    transform: translateY(-1px);
}
.btn--primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(27,94,32,0.25);
}
.btn--primary:disabled {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.25);
    cursor: default;
    transform: none;
    box-shadow: none;
}
.btn--lg { padding: 0.8rem 2.4rem; font-size: 1rem; }
.btn--sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn--xs { padding: 0.25rem 0.6rem; font-size: 0.72rem; }
.btn--outline {
    background: transparent;
    color: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.12);
}
.btn--outline:hover {
    border-color: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.04);
}
.btn--ghost {
    background: transparent;
    color: rgba(255,255,255,0.4);
    border: none;
    font-size: 0.85rem;
}
.btn--ghost:hover { color: rgba(255,255,255,0.65); }

/* ─── HUD ─── */
#game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin-bottom: 0.5rem;
}
.hud__cell {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.hud__cell--right { text-align: right; align-items: flex-end; }
.hud__label {
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(255,255,255,0.25);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.hud__value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #059669;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.hud__value--sub { font-size: 0.95rem; color: rgba(255,255,255,0.4); }

/* ─── Betting Phase ─── */
.betting-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    margin-bottom: 0.5rem;
}
.betting-phase h2 {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0;
}

/* ─── Chip Selector ─── */
.chip-selector {
    display: flex;
    gap: 0.65rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

/* Casino chip buttons — round with layered design */
.chip-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    /* outer rim */
    box-shadow:
        0 0 0 3px rgba(0,0,0,0.35),
        0 4px 12px rgba(0,0,0,0.4);
}
/* Chip rim pattern via pseudo-element */
.chip-btn::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 2px dashed rgba(255,255,255,0.25);
    pointer-events: none;
}
.chip-btn:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow:
        0 0 0 3px rgba(0,0,0,0.35),
        0 8px 20px rgba(0,0,0,0.5);
}
.chip-btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow:
        0 0 0 3px rgba(0,0,0,0.35),
        0 2px 6px rgba(0,0,0,0.4);
}
/* Chip color variants by value */
.chip-btn[data-amount="10"] {
    background: radial-gradient(circle at 38% 38%, #ef9a9a, #c62828);
    color: #fff;
}
.chip-btn[data-amount="25"] {
    background: radial-gradient(circle at 38% 38%, #90caf9, #1565c0);
    color: #fff;
}
.chip-btn[data-amount="50"] {
    background: radial-gradient(circle at 38% 38%, #a5d6a7, #1b5e20);
    color: #fff;
}
.chip-btn[data-amount="100"] {
    background: radial-gradient(circle at 38% 38%, #ce93d8, #6a1b9a);
    color: #fff;
}
.chip-btn[data-amount="500"] {
    background: radial-gradient(circle at 38% 38%, #ffe082, #f57f17);
    color: #3e2723;
}

/* ─── Bet Display ─── */
.bet-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.8rem;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(5,150,105,0.25);
    border-radius: 24px;
    min-width: 120px;
}
.bet-display::before {
    content: '';
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #ffd54f 40%, #f9a825 100%);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(255,213,79,0.5);
}
#current-bet-display {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffd54f;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.bet-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

/* ─── Table Area (the felt) ─── */
.table-area {
    position: relative;
    background: radial-gradient(ellipse at 50% 40%, rgba(30,100,30,0.45) 0%, rgba(10,50,10,0.70) 100%);
    border: 3px solid rgba(27,94,32,0.55);
    border-radius: 24px;
    padding: 1.5rem 1rem 1rem;
    margin: 0.5rem 0;
    box-shadow:
        inset 0 0 60px rgba(0,0,0,0.3),
        0 4px 24px rgba(0,0,0,0.45),
        0 0 0 1px rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}
/* Subtle felt texture */
.table-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 50% 0%, rgba(5,150,105,0.08) 0%, transparent 60%);
    pointer-events: none;
    border-radius: inherit;
}
/* Inner rim line */
.table-area::after {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 20px;
    pointer-events: none;
}

/* ─── Hand Areas ─── */
.hand-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    position: relative;
    z-index: 1;
}
.hand-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.hand-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 0.5rem;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(5,150,105,0.3);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #a5d6a7;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transition: all 0.2s ease;
}
.hand-score.bust {
    border-color: rgba(229,57,53,0.5);
    color: #ef9a9a;
    background: rgba(229,57,53,0.1);
}
.hand-score.blackjack {
    border-color: rgba(255,213,79,0.6);
    color: #ffd54f;
    background: rgba(255,213,79,0.1);
    box-shadow: 0 0 10px rgba(255,213,79,0.2);
    animation: bjGlow 1s ease-in-out infinite alternate;
}

@keyframes bjGlow {
    from { box-shadow: 0 0 8px rgba(255,213,79,0.2); }
    to   { box-shadow: 0 0 18px rgba(255,213,79,0.45); }
}

/* ─── Cards Row ─── */
.cards-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ─── Playing Cards ─── */
.card-face {
    width: 70px;
    height: 98px;
    background: linear-gradient(160deg, #ffffff 0%, #f4f4f4 100%);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    position: relative;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.9);
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Perspective for 3-D flip effect */
    transform-style: preserve-3d;
    backface-visibility: hidden;
}
.card-face:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
/* Corner pips */
.card-face .rank-top {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 800;
}
.card-face .suit-top {
    position: absolute;
    top: 19px;
    left: 7px;
    font-size: 0.6rem;
    line-height: 1;
}
.card-face .suit-center {
    font-size: 1.9rem;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.08));
}
.card-face .rank-bottom {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 800;
    transform: rotate(180deg);
}
.card-face .suit-bottom {
    position: absolute;
    bottom: 19px;
    right: 7px;
    font-size: 0.6rem;
    line-height: 1;
    transform: rotate(180deg);
}

/* Suit colors */
.card-red   { color: #c62828; }
.card-black { color: #1a1a2e; }

/* ─── Card Back ─── */
.card-back {
    width: 70px;
    height: 98px;
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 50%, #1b5e20 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.07);
    position: relative;
    overflow: hidden;
    user-select: none;
}
/* Diamond lattice pattern */
.card-back::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 5px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255,255,255,0.04) 5px,
        rgba(255,255,255,0.04) 10px
    );
}
/* Center badge */
.card-back::after {
    content: '♣';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.3rem;
    color: rgba(255,255,255,0.15);
}

/* ─── Card Deal Animation ─── */
@keyframes dealCard {
    0% {
        transform: translate(0, -100px) scale(0.3) rotate(-20deg);
        opacity: 0;
    }
    60% {
        transform: translate(0, 5px) scale(1.03) rotate(1.5deg);
        opacity: 1;
    }
    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
}
.card-deal {
    animation: dealCard 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.card-deal:nth-child(2) { animation-delay: 0.10s; }
.card-deal:nth-child(3) { animation-delay: 0.20s; }
.card-deal:nth-child(4) { animation-delay: 0.30s; }
.card-deal:nth-child(5) { animation-delay: 0.40s; }

/* ─── Card Flip Animation (reveal dealer hole card) ─── */
.card-flip-container {
    perspective: 700px;
    display: inline-flex;
}
@keyframes flipReveal {
    0%   { transform: rotateY(0deg) scale(1); }
    40%  { transform: rotateY(90deg) scale(0.95); }
    50%  { transform: rotateY(90deg) scale(0.95); }
    100% { transform: rotateY(0deg) scale(1); }
}
.card-flip {
    animation: flipReveal 0.55s ease-in-out;
    transform-style: preserve-3d;
}

/* ─── Action Buttons ─── */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0.6rem 0 0.2rem;
    position: relative;
    z-index: 1;
}
.action-buttons .btn {
    min-width: 80px;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}
/* Hit - bright green */
#hit-btn {
    background: linear-gradient(135deg, #059669 0%, #2e7d32 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(27,94,32,0.4);
    font-weight: 700;
}
#hit-btn:hover {
    background: linear-gradient(135deg, #66bb6a 0%, #388e3c 100%);
    box-shadow: 0 4px 14px rgba(27,94,32,0.5);
    transform: translateY(-1px);
}
/* Stand - amber */
#stand-btn {
    background: rgba(255,152,0,0.14);
    color: #ffa726;
    border: 1px solid rgba(255,152,0,0.3);
}
#stand-btn:hover {
    background: rgba(255,152,0,0.24);
    color: #ffb74d;
    border-color: rgba(255,152,0,0.45);
}
/* Double Down - blue */
#double-btn {
    background: rgba(33,150,243,0.14);
    color: #42a5f5;
    border: 1px solid rgba(33,150,243,0.3);
}
#double-btn:hover {
    background: rgba(33,150,243,0.24);
    color: #64b5f6;
    border-color: rgba(33,150,243,0.45);
}
/* Split - purple */
#split-btn {
    background: rgba(156,39,176,0.14);
    color: #ce93d8;
    border: 1px solid rgba(156,39,176,0.3);
}
#split-btn:hover {
    background: rgba(156,39,176,0.24);
    color: #e040fb;
    border-color: rgba(156,39,176,0.45);
}
/* Insurance - ghost */
#insurance-btn {
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.45);
    border: 1px solid rgba(255,255,255,0.1);
}
#insurance-btn:hover {
    background: rgba(255,255,255,0.09);
    color: rgba(255,255,255,0.65);
}
.action-buttons .btn:disabled {
    background: rgba(255,255,255,0.04) !important;
    color: rgba(255,255,255,0.15) !important;
    border-color: rgba(255,255,255,0.06) !important;
    box-shadow: none !important;
    cursor: default;
    transform: none !important;
}

/* ─── Result Banner ─── */
.result-banner {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 3px;
    padding: 0.4rem 0;
    text-transform: uppercase;
    z-index: 2;
    position: relative;
    animation: resultAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.result-banner.win {
    color: #ffd54f;
    text-shadow: 0 0 24px rgba(255,213,79,0.5), 0 0 48px rgba(255,213,79,0.2);
}
.result-banner.blackjack-win {
    color: #ffd54f;
    font-size: 2rem;
    text-shadow: 0 0 30px rgba(255,213,79,0.7), 0 0 60px rgba(255,213,79,0.3);
    animation: resultAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both,
               bannerPulse 0.9s ease-in-out infinite alternate 0.5s;
}
.result-banner.lose {
    color: rgba(255,100,100,0.65);
}
.result-banner.push {
    color: rgba(255,255,255,0.45);
}
.result-banner.bust {
    color: rgba(229,57,53,0.75);
    text-shadow: 0 0 16px rgba(229,57,53,0.3);
}

@keyframes resultAppear {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes bannerPulse {
    from { text-shadow: 0 0 20px rgba(255,213,79,0.5); }
    to   { text-shadow: 0 0 40px rgba(255,213,79,0.8), 0 0 80px rgba(255,213,79,0.3); }
}

/* Next Hand Button */
#next-hand-btn {
    margin-top: 0.25rem;
    position: relative;
    z-index: 1;
}

/* ─── Overlays ─── */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.overlay__box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 2rem 3rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.overlay__box h2 {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

/* ─── Pause Stats ─── */
.pause-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.4rem;
}
.pause-stats .stat-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.pause-stats .stat-item .stat-val {
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
}

/* ─── New Best Overlay ─── */
.new-best-overlay {
    background: rgba(0,0,0,0.55) !important;
    pointer-events: none;
}
.new-best-text {
    color: #ffd54f !important;
    font-size: 2.8rem !important;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 0 40px rgba(5,150,105,0.6), 0 0 80px rgba(27,94,32,0.4);
    animation: newBestPulse 0.65s ease-out;
}
@keyframes newBestPulse {
    0%   { transform: scale(0.4); opacity: 0; }
    55%  { transform: scale(1.18); }
    100% { transform: scale(1); opacity: 1; }
}

/* ─── Tutorial Overlay ─── */
.tutorial-overlay {
    background: rgba(0,0,0,0.88);
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 300;
}
.tutorial-overlay.hidden { display: none !important; }
.tutorial-box {
    max-width: 400px;
    width: 92%;
    padding: 1.5rem;
    text-align: left;
}
.tutorial-box h2 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
    color: #e0e0e0;
}
.tut-content {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.72);
    line-height: 1.65;
    min-height: 90px;
    margin-bottom: 1rem;
}
.tut-items { display: flex; flex-direction: column; gap: 0.3rem; }
.tut-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.tut-step-indicator {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.38);
}
#tut-skip {
    display: block;
    margin: 0 auto;
    opacity: 0.45;
}

/* ─── Result Card (game over) ─── */
.result-card {
    max-width: 420px;
    margin: 2rem auto;
    padding: 2rem 1.5rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.result-card h2 {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.result-score {
    font-size: 2rem;
    font-weight: 800;
    color: #059669;
    font-variant-numeric: tabular-nums;
}
.result-best {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.35);
}
.result-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.8rem;
}

#nickname-input { width: 100%; display: flex; justify-content: center; }
#nickname {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: #e0e0e0;
    border-radius: 8px;
    width: 200px;
    text-align: center;
    transition: border-color 0.15s;
}
#nickname:focus {
    outline: none;
    border-color: #059669;
}
#nickname::placeholder { color: rgba(255,255,255,0.2); }

/* ─── Game Stats ─── */
.game-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin: 0.5rem 0;
    width: 100%;
}
.game-stats .stat-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.game-stats .stat-item .stat-val {
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ─── Leaderboard ─── */
.lb-card {
    max-width: 450px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    text-align: center;
}
.lb-card h2 {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}
#leaderboard-list {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}
#leaderboard-list li {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
    transition: background 0.15s;
}
#leaderboard-list li:nth-child(odd) { background: rgba(255,255,255,0.02); }
#leaderboard-list li:hover { background: rgba(5,150,105,0.07); }
#leaderboard-list li .rank {
    color: rgba(255,255,255,0.3);
    font-weight: 700;
    width: 28px;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
#leaderboard-list li:nth-child(1) .rank { color: #ffd54f; }
#leaderboard-list li:nth-child(2) .rank { color: #b0bec5; }
#leaderboard-list li:nth-child(3) .rank { color: #a1887f; }
#leaderboard-list li .lb-name {
    flex: 1;
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
}
#leaderboard-list li .lb-score {
    color: #059669;
    font-weight: 700;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
#leaderboard-list li .lb-time {
    color: rgba(255,255,255,0.2);
    font-size: 0.7rem;
    margin-left: 0.6rem;
    white-space: nowrap;
}

/* ─── Win / Lose chip-flash effect ─── */
@keyframes chipWin {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.25) rotate(8deg); }
    60%  { transform: scale(0.95) rotate(-4deg); }
    100% { transform: scale(1) rotate(0deg); }
}
.chip-win { animation: chipWin 0.55s ease-out; }

/* ─── Active hand highlight (split) ─── */
.hand-area.active {
    position: relative;
}
.hand-area.active::before {
    content: '';
    position: absolute;
    inset: -6px;
    border: 2px solid rgba(5,150,105,0.5);
    border-radius: 14px;
    pointer-events: none;
    animation: activeHandPulse 1.4s ease-in-out infinite;
}
@keyframes activeHandPulse {
    0%, 100% { border-color: rgba(5,150,105,0.4); box-shadow: 0 0 10px rgba(5,150,105,0.15); }
    50%       { border-color: rgba(5,150,105,0.75); box-shadow: 0 0 22px rgba(5,150,105,0.3); }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .new-best-text,
    .card-deal,
    .card-flip,
    .result-banner,
    .hand-area.active::before,
    .hand-score.blackjack { animation: none !important; }
    .card-face:hover { transform: none; }
    .chip-btn:hover { transform: none; }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* ─── Tablet: collapse to single column ─── */
@media (max-width: 1100px) {
    .bj-layout {
        grid-template-columns: 1fr;
        grid-template-areas: "game";
        max-width: 580px;
        gap: 0;
    }
    .bj-layout .ad-slot--left,
    .bj-layout .ad-slot--right { display: none; }
    .bj-layout .ad-slot--top,
    .bj-layout .ad-slot--bottom {
        display: flex;
        grid-area: unset;
        justify-content: center;
        padding: 0.5rem 0;
    }
    .bj-layout {
        grid-template-areas:
            "top"
            "game"
            "bottom";
        grid-template-rows: auto 1fr auto;
    }
    .bj-layout .ad-slot--top    { grid-area: top; }
    .bj-layout .ad-slot--bottom { grid-area: bottom; }
    .ad-placeholder--vertical { min-height: unset; position: static; }
    .ad-placeholder { min-height: 60px; padding: 1rem; }
}

/* ─── Mobile ─── */
@media (max-width: 480px) {
    .bj-layout { padding: 0 0.5rem; }
    .menu-header { padding: 1.2rem 0 0.8rem; }
    .menu-header h1 { font-size: 2rem; letter-spacing: 5px; }
    .card { padding: 0.8rem; }
    .card-row { grid-template-columns: 1fr; gap: 0.6rem; }
    .btn--lg { padding: 0.7rem 2rem; font-size: 0.9rem; }

    /* HUD compact */
    #game-hud { padding: 0.4rem 0.7rem; }
    .hud__value { font-size: 1.1rem; }

    /* Chips smaller on mobile */
    .chip-btn {
        width: 48px;
        height: 48px;
        font-size: 0.7rem;
    }
    .chip-selector { gap: 0.45rem; }

    /* Smaller cards */
    .card-face {
        width: 54px;
        height: 76px;
        font-size: 0.9rem;
    }
    .card-face .rank-top   { font-size: 0.6rem; top: 3px; left: 4px; }
    .card-face .suit-top   { font-size: 0.5rem; top: 15px; left: 5px; }
    .card-face .suit-center { font-size: 1.4rem; }
    .card-face .rank-bottom { font-size: 0.6rem; bottom: 3px; right: 4px; }
    .card-face .suit-bottom { font-size: 0.5rem; bottom: 15px; right: 5px; }

    .card-back { width: 54px; height: 76px; }

    .table-area {
        border-radius: 16px;
        padding: 1rem 0.6rem 0.8rem;
    }
    .table-area::after { border-radius: 13px; }

    .cards-row { gap: 4px; }
    .result-banner { font-size: 1.35rem; letter-spacing: 2px; }
    .action-buttons .btn { min-width: 64px; padding: 0.45rem 0.7rem; font-size: 0.8rem; }

    /* Overlays */
    .overlay__box { padding: 1.5rem 1.5rem; }
    #nickname { width: 170px; }
    .result-card { margin: 1rem auto; padding: 1.5rem 1rem; }
    .table-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Very small screens ─── */
@media (max-width: 360px) {
    .chip-btn { width: 42px; height: 42px; font-size: 0.65rem; }
    .card-face { width: 46px; height: 65px; }
    .card-back { width: 46px; height: 65px; }
    .card-face .suit-center { font-size: 1.1rem; }
    .action-buttons { gap: 0.35rem; }
    .action-buttons .btn { min-width: 54px; font-size: 0.75rem; padding: 0.4rem 0.5rem; }
}
