/* Blackjack Game - Premium UI
 *
 * Extends casino.css design system for blackjack-specific components.
 * Uses same CSS variables defined in casino.css.
 */

/* ========== Scroll Lock During Gameplay ========== */
/* Prevents unwanted scrolling on mobile during game actions */
body.blackjack-playing {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ========== Blackjack Table Container ========== */
.blackjack-container {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    position: relative; /* For sound toggle absolute positioning */
}

.blackjack-table {
    background: linear-gradient(180deg, #1a472a 0%, #0f2d1a 100%);
    border-radius: 20px;
    padding: 2rem;
    position: relative;
    overflow: visible;
    border: 4px solid var(--primary);
    box-shadow:
        inset 0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(247, 147, 26, 0.2);
    min-height: 400px;
}

/* Green felt texture overlay */
.blackjack-table::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(34, 197, 94, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(34, 197, 94, 0.1) 0%, transparent 40%);
    border-radius: 16px;
    pointer-events: none;
}

/* Table dimmed state */
.blackjack-table.dimmed {
    opacity: 0.5;
    transition: opacity 0.4s ease;
}

/* ========== Dealer Area ========== */
.dealer-area {
    text-align: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.area-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.75rem;
}

/* Dealer value display - always reserve space to prevent layout shifts */
.dealer-value,
.dealer-hand-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.25rem; /* Reduced from 0.5rem */
    min-height: 2rem; /* Reserve space even when empty */
    line-height: 2rem;
    text-align: center;
}

.dealer-value.blackjack-text,
.dealer-hand-value.blackjack {
    color: var(--primary);
    text-shadow: 0 0 15px rgba(247, 147, 26, 0.5);
}

.dealer-value.bust-text,
.dealer-hand-value.bust {
    color: var(--danger);
}

/* ========== Cards Container ========== */
.cards-container {
    display: flex;
    justify-content: center;
    min-height: 120px;
    flex-wrap: wrap;
    padding: 0.5rem;
}

/* Card containers - fan effect with overlap */
.dealer-hand,
.hand-cards {
    display: flex;
    justify-content: center;
    min-height: 120px;
    padding: 0.25rem 0.5rem; /* Reduced vertical padding */
}

/* Cards overlap slightly for a fan effect */
.dealer-hand .bj-card,
.hand-cards .bj-card {
    margin-left: -20px;
}

.dealer-hand .bj-card:first-child,
.hand-cards .bj-card:first-child {
    margin-left: 0;
}

/* Hover effect to reveal overlapped cards - only after dealing completes */
.dealer-hand .bj-card:not(.dealing):hover,
.hand-cards .bj-card:not(.dealing):hover {
    transform: translateY(-5px);
    z-index: 10;
}

/* ========== Playing Cards ========== */
.bj-card {
    width: 80px;
    height: 112px;
    border-radius: 8px;
    position: relative;
    transform-style: preserve-3d;
    cursor: default;
    /* No transition by default - prevents conflict with deal animation */
}

/* Only enable transition for hover effects after card is dealt */
.bj-card:not(.dealing) {
    transition: transform 0.2s ease;
}

.bj-card.dealing {
    animation: dealCard 0.3s ease-out forwards;
}

@keyframes dealCard {
    0% {
        opacity: 0;
        transform: translateY(-100px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.bj-card.flipping {
    animation: flipCard 0.6s ease-in-out forwards;
}

@keyframes flipCard {
    0% {
        transform: rotateY(0);
    }
    50% {
        transform: rotateY(90deg);
    }
    100% {
        transform: rotateY(0);
    }
}

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.card-front {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.card-back {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #1e3a8a 100%);
    border: 2px solid #3b82f6;
    transform: rotateY(180deg);
}

.card-back::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255, 255, 255, 0.05) 5px,
        rgba(255, 255, 255, 0.05) 10px
    );
}

/* Card is face down */
.bj-card.face-down .card-front {
    display: none;
}

.bj-card.face-down .card-back {
    transform: rotateY(0);
}

/* Card rank and suit */
.card-corner {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.card-corner.top-left {
    align-items: flex-start;
    align-self: flex-start;
}

.card-corner.bottom {
    align-items: flex-start;
    align-self: flex-end;
    transform: rotate(180deg);
}

.card-rank {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.card-suit-small {
    font-size: 0.75rem;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
}

/* Card colors */
.bj-card.hearts .card-rank,
.bj-card.hearts .card-suit-small,
.bj-card.hearts .card-center,
.bj-card.diamonds .card-rank,
.bj-card.diamonds .card-suit-small,
.bj-card.diamonds .card-center {
    color: #dc2626;
}

.bj-card.spades .card-rank,
.bj-card.spades .card-suit-small,
.bj-card.spades .card-center,
.bj-card.clubs .card-rank,
.bj-card.clubs .card-suit-small,
.bj-card.clubs .card-center {
    color: #1f2937;
}

/* ========== Player Area ========== */
.player-area {
    text-align: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.player-hands-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.player-hand {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    min-width: 200px;
    flex: 1; /* Expand to fill available width */
    max-width: 100%; /* But don't exceed container */
    transition: all 0.3s ease;
    border: 2px solid transparent; /* Reserve space for active border */
}

.player-hand.active {
    background: rgba(247, 147, 26, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(247, 147, 26, 0.3);
}

.player-hand.won {
    border: 2px solid var(--success);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.player-hand.lost {
    opacity: 0.6;
}

.player-hand.push {
    border: 2px solid var(--warning);
}

/* Player hand value - always reserve space to prevent layout shifts */
.hand-value,
.player-hand-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.25rem; /* Reduced from 0.5rem */
    min-height: 1.75rem; /* Reserve space even when empty */
    line-height: 1.75rem;
    text-align: center;
}

.hand-value.blackjack-text,
.player-hand-value.blackjack {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(247, 147, 26, 0.5);
}

.hand-value.bust-text,
.player-hand-value.bust {
    color: var(--danger);
}

/* Hand wager/bet display - always reserve space to prevent layout shifts */
.hand-wager,
.hand-bet {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    min-height: 1.25rem; /* Reserve space even when empty */
    line-height: 1.25rem;
    text-align: center;
}

.hand-result {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    display: inline-block;
}

.hand-result.win {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.hand-result.lose {
    background: rgba(248, 81, 73, 0.2);
    color: var(--danger);
}

.hand-result.push {
    background: rgba(210, 153, 34, 0.2);
    color: var(--warning);
}

.hand-result.blackjack {
    background: rgba(247, 147, 26, 0.3);
    color: var(--primary);
}

/* ========== Game Action Buttons (Hit/Stand/Double/Split) ========== */
/* Scoped to blackjack container to avoid affecting sidebar buttons */
.blackjack-container #action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.btn-action {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-action.hit {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-action.hit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.btn-action.stand {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-action.stand:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-action.double {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-action.double:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-action.split {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-action.split:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-action.insurance {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.btn-action.insurance:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.btn-action.decline {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-action.decline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* ========== Bet Controls ========== */
.bet-controls {
    margin-top: 1.5rem;
    text-align: center;
}

/* Hidden state - maintains space to prevent layout shifts */
.bet-controls.hidden {
    visibility: hidden;
    pointer-events: none;
}

/* Ensure all children hide instantly (no staggered transitions) */
.bet-controls.hidden * {
    visibility: hidden !important;
    transition: none !important;
}

.bet-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.bet-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.bet-btn {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
}

.bet-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
    color: var(--text-primary);
}

.bet-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--bg-dark);
    box-shadow: 0 0 15px rgba(247, 147, 26, 0.4);
}

.deal-btn {
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    box-shadow: 0 4px 20px rgba(247, 147, 26, 0.4);
}

.deal-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(247, 147, 26, 0.5);
}

.deal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== Result Display ========== */
/* Always takes up space to prevent layout shifts */
.result-display {
    text-align: center;
    display: flex !important; /* Always flex, use visibility to hide */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    margin: 0.5rem 0;
    gap: 0;
    min-height: 3.5rem; /* Reserve space for result label + amount with bold text */
    visibility: hidden; /* Hidden but takes space */
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.result-display.visible {
    visibility: visible;
    opacity: 1;
}

.result-label {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.4;
    min-height: 1.82rem; /* 1.3rem * 1.4 line-height */
    margin: 0;
}

.result-label.win {
    color: var(--success);
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
    animation: resultPulse 1s ease-out;
}

.result-label.lose {
    color: var(--danger);
}

.result-label.push {
    color: var(--warning);
}

.result-label.blackjack {
    color: var(--primary);
    text-shadow: 0 0 30px rgba(247, 147, 26, 0.6);
    animation: blackjackWin 1.5s ease-out;
}

.result-amount {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    min-height: 1.4rem; /* 1rem * 1.4 line-height */
    margin: 0;
}

.result-amount.win {
    color: var(--success);
}

.result-amount.lose {
    color: var(--danger);
}

.result-amount.push {
    color: var(--text-secondary);
}

@keyframes resultPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes blackjackWin {
    0% { transform: scale(1) rotate(0); }
    25% { transform: scale(1.2) rotate(-3deg); }
    50% { transform: scale(1.15) rotate(3deg); }
    75% { transform: scale(1.1) rotate(-1deg); }
    100% { transform: scale(1) rotate(0); }
}

.result-payout {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.result-payout .amount {
    color: var(--success);
    font-weight: 600;
}

/* ========== Insurance Prompt ========== */
.insurance-prompt {
    background: rgba(236, 72, 153, 0.1);
    border: 2px solid rgba(236, 72, 153, 0.3);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    text-align: center;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.insurance-text {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.3;
}

.insurance-prompt h4 {
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.insurance-prompt p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
}

.insurance-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.btn-insurance-yes,
.btn-insurance-no {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-insurance-yes {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    color: white;
    border: none;
}

.btn-insurance-no {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-insurance-yes:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.btn-insurance-no:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* ========== Rules Text (above Provably Fair) ========== */
.rules-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .rules-text {
        font-size: 0.65rem;
    }
}

@media (max-width: 380px) {
    .rules-text {
        font-size: 0.6rem;
        letter-spacing: -0.02em;
    }
}

/* Legacy rules-list styles - kept for backwards compatibility */
.rules-summary h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.rules-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rules-list li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
}

.rules-list li:last-child {
    border-bottom: none;
}

.rules-list .rule-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* ========== Payout Table ========== */
.payout-table {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.payout-table h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.payout-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.85rem;
}

.payout-row .label {
    color: var(--text-secondary);
}

.payout-row .value {
    color: var(--primary);
    font-weight: 600;
}

/* ========== Sound Toggle (inherited from casino.css, customized position) ========== */
/* Sound toggle - positioned inside blackjack-container */
.blackjack-container .sound-toggle {
    position: absolute;
    top: auto; /* Override any top value */
    bottom: 0.75rem;
    right: 0.75rem;
    width: auto;
    height: auto;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    /* Prevent stretching */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.blackjack-container .sound-toggle:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: var(--primary);
}

.blackjack-container .sound-icon {
    font-size: 1.25rem;
    display: block;
    line-height: 1;
}

/* ========== Game Status Messages ========== */
.game-status {
    text-align: center;
    padding: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.game-status.dealing {
    color: var(--primary);
}

.game-status.player-turn {
    color: var(--success);
}

.game-status.dealer-turn {
    color: var(--warning);
}

/* ========== Responsive Styles ========== */

@media (max-width: 1024px) {
    .blackjack-table {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .blackjack-container {
        padding: 1rem;
    }

    .blackjack-table {
        padding: 1.25rem;
        min-height: 350px;
    }

    /* Playing cards (not sidebar .card containers) */
    .bj-card {
        width: 65px;
        height: 91px;
    }

    .card-rank {
        font-size: 0.875rem;
    }

    .card-suit-small {
        font-size: 0.625rem;
    }

    .card-center {
        font-size: 2rem;
    }

    .dealer-value,
    .dealer-hand-value,
    .hand-value,
    .player-hand-value {
        font-size: 1.2rem;
    }

    .btn-action {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-width: 85px;
    }

    .deal-btn {
        padding: 0.875rem 2rem;
        font-size: 1.1rem;
    }

    .player-hands-container {
        gap: 1rem;
    }

    .player-hand {
        min-width: 160px;
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .blackjack-container {
        padding: 0.75rem;
        padding-bottom: 1rem; /* Extra bottom padding to contain all elements */
        border-radius: 16px;
    }

    .blackjack-table {
        padding: 0.75rem;
        border-radius: 12px;
        border-width: 2px;
        min-height: auto; /* Let content determine height - Deal button must be visible */
    }

    /* Playing cards (not sidebar .card containers) */
    .bj-card {
        width: 52px;
        height: 73px;
    }

    .card-face {
        padding: 4px;
    }

    .card-rank {
        font-size: 0.75rem;
    }

    .card-suit-small {
        font-size: 0.5rem;
    }

    .card-center {
        font-size: 1.5rem;
    }

    .cards-container,
    .dealer-hand,
    .hand-cards {
        gap: 0.5rem;
        min-height: 75px; /* Compact on mobile - cards expand this when dealt */
    }

    .dealer-value,
    .dealer-hand-value {
        font-size: 1.1rem;
        min-height: 1.5rem;
        line-height: 1.5rem;
    }

    .hand-value,
    .player-hand-value {
        font-size: 1rem;
        min-height: 1.4rem;
        line-height: 1.4rem;
    }

    .hand-wager,
    .hand-bet {
        font-size: 0.75rem;
        min-height: 1.1rem;
        line-height: 1.1rem;
    }

    .area-label {
        font-size: 0.65rem;
    }

    .action-buttons {
        gap: 0.5rem;
    }

    .btn-action {
        padding: 0.625rem 1rem;
        font-size: 0.8rem;
        min-width: 70px;
        border-radius: 8px;
    }

    .bet-selector {
        gap: 0.375rem;
    }

    .bet-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-width: 50px;
    }

    .deal-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .player-hand {
        min-width: 140px;
        padding: 0.5rem;
    }

    .dealer-area {
        margin-bottom: 0.25rem;
        padding-bottom: 0.25rem;
    }

    .player-area {
        margin-top: 0.25rem;
        padding-top: 0.25rem;
    }

    /* Compact labels on mobile */
    .dealer-label,
    .player-label {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
    }

    .result-label {
        font-size: 1.1rem;
        line-height: 1.3;
        min-height: 1.43rem; /* 1.1rem * 1.3 */
    }

    .result-amount {
        font-size: 0.9rem;
        line-height: 1.3;
        min-height: 1.17rem; /* 0.9rem * 1.3 */
    }

    .result-display {
        padding: 0.25rem 0;
        margin: 0.25rem 0;
        min-height: 2.75rem; /* Reserve space for result label + amount */
    }

    .insurance-prompt {
        padding: 0.75rem;
    }

    .insurance-prompt h4 {
        font-size: 1rem;
    }

    .insurance-prompt p {
        font-size: 0.8rem;
    }

    .insurance-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Compact wager info on mobile */
    .wager-info {
        margin-top: 0.5rem;
        margin-bottom: 0;
        font-size: 0.8rem;
    }

    .hint-chip kbd {
        padding: 0.15rem 0.4rem;
        font-size: 0.7rem;
    }

    /* Compact bet controls on mobile */
    .bet-controls {
        margin-top: 0.75rem;
        padding-bottom: 0.5rem;
    }

    /* Reduce wager selector margin */
    .wager-selector {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 380px) {
    .blackjack-table {
        padding: 0.5rem;
    }

    /* Playing cards (not sidebar .card containers) */
    .bj-card {
        width: 45px;
        height: 63px;
    }

    .card-rank {
        font-size: 0.65rem;
    }

    .card-center {
        font-size: 1.25rem;
    }

    .bet-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        min-width: 45px;
    }

    .btn-action {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        min-width: 60px;
    }

    .player-hands-container {
        gap: 0.5rem;
    }

    .player-hand {
        min-width: 100%;
        padding: 0.375rem;
    }

    /* Extra compact card areas on small phones */
    .cards-container,
    .dealer-hand,
    .hand-cards {
        min-height: 65px;
    }

    .dealer-area,
    .player-area {
        margin-top: 0.125rem;
        margin-bottom: 0.125rem;
        padding-top: 0.125rem;
        padding-bottom: 0.125rem;
    }

    .bet-controls {
        margin-top: 0.5rem;
    }

    .deal-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* ========== Animations ========== */

/* Card hover effect */
.bj-card:not(.face-down):hover {
    transform: translateY(-4px);
    transition: transform 0.2s ease;
}

/* Win celebration */
@keyframes winCelebration {
    0%, 100% { transform: scale(1); }
    10% { transform: scale(1.05) rotate(-2deg); }
    20% { transform: scale(1.1) rotate(2deg); }
    30% { transform: scale(1.05) rotate(-1deg); }
    40% { transform: scale(1); }
}

.player-hand.won .cards-container {
    animation: winCelebration 0.8s ease-out;
}

/* Bust shake */
@keyframes bustShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.player-hand-value.bust {
    animation: bustShake 0.5s ease-out;
}

/* Dealing animation stagger - REMOVED
 * JS handles timing via sequential dealCard() calls with delays.
 * CSS delays were causing animation conflicts when .dealing class was removed.
 */

/* Loading state */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    z-index: 100;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(247, 147, 26, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== Blackjack Celebration ========== */
.blackjack-celebration {
    animation: blackjackPulse 0.8s ease-out;
}

@keyframes blackjackPulse {
    0% { transform: scale(1); }
    25% { transform: scale(1.15); }
    50% { transform: scale(1.1); }
    75% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Confetti particles */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: 0;
    border-radius: 2px;
    opacity: 0;
    animation: confettiFall 2s ease-out forwards;
    pointer-events: none;
    z-index: 100;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(400px) rotate(720deg) scale(0.5);
    }
}

/* Stagger confetti sizes for variety */
.confetti:nth-child(odd) {
    width: 8px;
    height: 8px;
}

.confetti:nth-child(3n) {
    width: 6px;
    height: 12px;
    border-radius: 0;
}

/* ========== History Modal Additions ========== */
.blackjack-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.blackjack-history-item .game-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.blackjack-history-item .game-hands {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.blackjack-history-item .game-result {
    font-size: 0.8rem;
}

.blackjack-history-item .game-result.win {
    color: var(--success);
}

.blackjack-history-item .game-result.lose {
    color: var(--danger);
}

.blackjack-history-item .game-result.push {
    color: var(--warning);
}

.blackjack-history-item .game-payout {
    font-size: 1rem;
    font-weight: 600;
}

.blackjack-history-item .game-payout.positive {
    color: var(--success);
}

.blackjack-history-item .game-payout.negative {
    color: var(--danger);
}

.blackjack-history-item .game-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
/* ========== Wager Selector (Blackjack-specific) ========== */
.wager-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.wager-chip {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
}

/* Only show hover effects on devices that support hover (not touch) */
@media (hover: hover) {
    .wager-chip:hover:not(:disabled):not(.selected) {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
        color: var(--text-primary);
    }
}

.wager-chip.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--bg-dark);
    box-shadow: 0 0 15px rgba(247, 147, 26, 0.4);
}

.wager-chip.disabled,
.wager-chip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Insufficient balance warning */
.insufficient-balance-msg {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-top: 0.75rem;
    text-align: center;
}

.insufficient-balance-msg span {
    font-weight: 600;
}

@media (max-width: 480px) {
    .wager-selector {
        gap: 0.25rem;
        flex-wrap: nowrap;
        justify-content: stretch;
        width: 100%;
    }

    .wager-chip {
        padding: 0.5rem 0.4rem;
        font-size: 0.8rem;
        min-width: 0;
        flex: 1;
    }
}

@media (max-width: 380px) {
    .wager-selector {
        gap: 0.2rem;
    }

    .wager-chip {
        padding: 0.4rem 0.25rem;
        font-size: 0.75rem;
    }
}

/* Fix sidebar recovery link text size */
.sidebar .recovery-link {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.sidebar .recovery-link:hover {
    color: var(--primary);
}


/* ============================================
   Balance Display
   ============================================ */

.bj-balance-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(247, 147, 26, 0.15) 0%, rgba(0, 0, 0, 0.3) 100%);
    border: 1px solid var(--btc-orange);
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

.bj-balance-display .balance-icon {
    font-size: 1.5rem;
}

.bj-balance-display .balance-value {
    color: var(--btc-orange);
    font-family: 'JetBrains Mono', monospace;
    min-width: 4ch;
    text-align: right;
}

.bj-balance-display .balance-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 400;
}

/* Balance animation on change */
.bj-balance-display.balance-updated .balance-value {
    animation: balancePulse 0.5s ease-out;
}

@keyframes balancePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); color: #4ade80; }
    100% { transform: scale(1); }
}

/* ============================================
   Recent Hands Sidebar Styling
   ============================================ */

.spin-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
}

.spin-bet {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.spin-separator {
    color: var(--text-muted, #666);
    font-size: 0.85rem;
}

.spin-result {
    font-size: 0.85rem;
}

.spin-result.push {
    color: var(--text-secondary);
}

.spin-amount {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.spin-amount.positive {
    color: var(--success, #4ade80);
}

.spin-amount.negative {
    color: var(--text-secondary);
}

/* Revealed seed row with copy button */
.revealed-seed-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.revealed-seed-row .revealed-seed {
    flex: 1;
    word-break: break-all;
}

.btn-copy {
    background: #2a2a4e;
    border: 1px solid #3a3a6e;
    color: #ccc;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-copy:hover {
    background: #3a3a6e;
    color: #fff;
}

/* Game history for verification */
.game-history-container {
    max-height: 150px;
    overflow-y: auto;
    background: #0d0d1a;
    border-radius: 4px;
    padding: 8px;
}

.game-history-loading {
    color: #666;
    font-size: 11px;
    text-align: center;
    padding: 10px;
}

.game-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: #1a1a2e;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.game-history-item:hover {
    background: #2a2a4e;
}

.game-history-item:last-child {
    margin-bottom: 0;
}

.game-history-result {
    font-weight: 600;
}

.game-history-result.win { color: #4ecdc4; }
.game-history-result.loss { color: #ff6b6b; }
.game-history-result.push { color: #ffd93d; }

.game-history-seed {
    color: #888;
    font-family: monospace;
    font-size: 10px;
}

.game-history-nonce {
    color: #666;
    font-size: 10px;
}

.game-history-empty {
    color: #666;
    font-size: 11px;
    text-align: center;
    padding: 10px;
}
