/* ============================================================
   style.css — Main layout and global styles for Blackjack
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    height: 100%;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    background: linear-gradient(160deg, #1b4332 0%, #2d6a4f 40%, #245a40 70%, #1b4332 100%);
    color: #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* ---------- Header ---------- */
#header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75em 1.5em;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 2px solid rgba(212, 175, 55, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.header-title {
    font-size: 1.8em;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: #d4af37;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.header-balance {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.balance-label {
    font-size: 0.9em;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.balance-amount {
    font-size: 1.4em;
    font-weight: 700;
    color: #4ade80;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

/* ---------- Main Game Area ---------- */
#game-area {
    width: 100%;
    max-width: 60em;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1em 1.5em 2em;
    gap: 1em;
}

/* ---------- Dealer Area ---------- */
#dealer-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
    padding: 1em 0;
}

.area-label {
    display: flex;
    align-items: center;
    gap: 0.75em;
    font-size: 1em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.7);
}

.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2em;
    padding: 0.2em 0.6em;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 1em;
    font-size: 0.95em;
    font-weight: 700;
    color: #fff;
}

.card-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5em;
    min-height: 7.5em;
    padding: 0.5em;
}

/* ---------- Table Divider ---------- */
.table-divider {
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.4), transparent);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shoe-counter {
    position: absolute;
    background: #1b4332;
    padding: 0.15em 1em;
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
}

/* ---------- Player Area ---------- */
#player-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
    padding: 1em 0;
}

.hands-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5em;
    width: 100%;
}

/* Individual hand slot */
.hand-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
    padding: 0.75em;
    border-radius: 0.75em;
    border: 2px solid transparent;
    background: rgba(0, 0, 0, 0.15);
    position: relative;
    transition: all 0.3s ease;
    min-width: 12em;
}

.hand-slot.active-hand {
    border-color: rgba(212, 175, 55, 0.7);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.35), 0 0 30px rgba(212, 175, 55, 0.15);
    background: rgba(0, 0, 0, 0.25);
}

.hand-slot.completed-hand {
    opacity: 0.6;
}

.hand-header {
    display: flex;
    align-items: center;
    gap: 0.75em;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hand-header .hand-label {
    font-weight: 700;
}

.hand-header .hand-score {
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.15em 0.5em;
    border-radius: 0.75em;
    font-size: 0.95em;
}

.hand-header .hand-bet {
    color: #d4af37;
    font-weight: 600;
}

.hand-cards {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4em;
    min-height: 7.5em;
    padding: 0.25em;
}

/* ---------- Result Badge ---------- */
.result-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.5em 1.5em;
    border-radius: 0.5em;
    font-size: 1.3em;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 5;
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.result-badge.win {
    background: rgba(46, 204, 113, 0.9);
    color: #fff;
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.5);
}

.result-badge.lose {
    background: rgba(231, 76, 60, 0.9);
    color: #fff;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.result-badge.push {
    background: rgba(241, 196, 15, 0.9);
    color: #1a1a1a;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.5);
}

.result-badge.blackjack {
    background: linear-gradient(135deg, #d4af37, #f1c40f);
    color: #1a1a1a;
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.6);
    font-size: 1.4em;
}

/* ---------- Message Area ---------- */
#message-area {
    width: 100%;
    text-align: center;
    padding: 0.5em 1em;
}

#game-message {
    font-size: 1.15em;
    color: #f0f0f0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    min-height: 1.5em;
    line-height: 1.5;
}

/* ---------- Round Results Summary ---------- */
.round-results {
    width: 100%;
    max-width: 30em;
    text-align: center;
    padding: 0.75em 1em;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.5em;
}

.round-results p {
    font-size: 0.95em;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}

/* ---------- Action Bar ---------- */
#action-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75em;
    padding: 0.5em;
    width: 100%;
}

/* ---------- Buttons ---------- */
.action-btn {
    padding: 0.7em 1.8em;
    border: none;
    border-radius: 2em;
    font-size: 1em;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    outline: none;
    position: relative;
    overflow: hidden;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

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

.btn-positive {
    background: linear-gradient(180deg, #2ecc71, #27ae60);
    color: #fff;
}

.btn-positive:hover:not(:disabled) {
    background: linear-gradient(180deg, #3ddc84, #2ecc71);
}

.btn-neutral {
    background: linear-gradient(180deg, #5a6e8a, #4a5c72);
    color: #fff;
}

.btn-neutral:hover:not(:disabled) {
    background: linear-gradient(180deg, #6a7e9a, #5a6e8a);
}

.btn-warning {
    background: linear-gradient(180deg, #f39c12, #e67e22);
    color: #fff;
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(180deg, #f5b041, #f39c12);
}

.btn-danger {
    background: linear-gradient(180deg, #e74c3c, #c0392b);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(180deg, #ec7063, #e74c3c);
}

.btn-large {
    padding: 0.9em 3em;
    font-size: 1.15em;
}

/* ---------- Betting Tray ---------- */
#betting-tray {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
    padding: 1em;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75em;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.bet-display {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.bet-label {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bet-amount {
    font-size: 1.5em;
    font-weight: 700;
    color: #d4af37;
    text-shadow: 0 0 6px rgba(212, 175, 55, 0.3);
}

.chip-rack {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75em;
}

.betting-actions {
    display: flex;
    gap: 0.75em;
}

/* ---------- New Round Section ---------- */
#new-round-section {
    padding: 0.5em;
}

/* ---------- Insurance Modal ---------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: linear-gradient(160deg, #2c3e50, #1a252f);
    padding: 2em 2.5em;
    border-radius: 1em;
    border: 2px solid rgba(212, 175, 55, 0.5);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 25em;
    width: 90%;
}

.modal-title {
    font-size: 1.6em;
    font-weight: 800;
    color: #d4af37;
    margin-bottom: 0.5em;
    letter-spacing: 0.05em;
}

.modal-text {
    font-size: 1em;
    color: #ddd;
    margin-bottom: 0.5em;
    line-height: 1.5;
}

.modal-subtext {
    font-size: 0.85em;
    color: #999;
    margin-bottom: 1.5em;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1em;
}

/* ---------- Utility ---------- */
.hidden {
    display: none !important;
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .header-title {
        font-size: 1.5em;
    }

    #game-area {
        padding: 0.75em 1em 1.5em;
    }

    .hand-slot {
        min-width: 10em;
        padding: 0.5em;
    }

    .hands-container {
        gap: 1em;
    }

    .action-btn {
        padding: 0.6em 1.4em;
        font-size: 0.9em;
    }
}

/* ---------- Header Right Group ---------- */
.header-right {
    display: flex;
    align-items: center;
    gap: 1em;
}

/* ---------- Settings Button ---------- */
.settings-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 0.3em;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    color: #d4af37;
    background: rgba(255, 255, 255, 0.1);
}

/* ---------- Settings Modal ---------- */
.settings-modal-content {
    max-width: 22em;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1em;
    margin-bottom: 1.5em;
    text-align: left;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
}

.settings-row label {
    font-size: 0.95em;
    color: #ccc;
    white-space: nowrap;
}

.settings-input {
    padding: 0.4em 0.6em;
    border-radius: 0.4em;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.9em;
    min-width: 5em;
}

.settings-input:focus {
    outline: none;
    border-color: #d4af37;
}

.settings-checkbox {
    width: 1.2em;
    height: 1.2em;
    cursor: pointer;
    accent-color: #d4af37;
}

/* ---------- Game Over Modal ---------- */
.gameover-title {
    color: #e74c3c;
}

/* ---------- Round History Section ---------- */
.round-history-section {
    width: 100%;
    max-width: 60em;
    padding: 0 1.5em 1em;
}

.history-toggle-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    padding: 0.5em 1em;
    border-radius: 0.5em;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.history-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.8);
}

.history-toggle-icon {
    font-size: 0.7em;
    transition: transform 0.2s ease;
}

.history-toggle-icon.open {
    transform: rotate(180deg);
}

.history-list {
    margin-top: 0.5em;
    max-height: 20em;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 0.75em;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.4em;
    font-size: 0.85em;
    border-left: 3px solid transparent;
}

.history-entry.result-win {
    border-left-color: #2ecc71;
}

.history-entry.result-lose {
    border-left-color: #e74c3c;
}

.history-entry.result-push {
    border-left-color: #f1c40f;
}

.history-entry.result-blackjack {
    border-left-color: #d4af37;
}

.history-entry.result-surrender {
    border-left-color: #95a5a6;
}

.history-entry-left {
    display: flex;
    align-items: center;
    gap: 0.75em;
}

.history-round {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    min-width: 2em;
}

.history-result {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.history-result.win { color: #2ecc71; }
.history-result.lose { color: #e74c3c; }
.history-result.push { color: #f1c40f; }
.history-result.blackjack { color: #d4af37; }
.history-result.surrender { color: #95a5a6; }
.history-result.busted { color: #e74c3c; }

.history-bet {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9em;
}

.history-payout {
    font-weight: 600;
}

.history-payout.positive { color: #2ecc71; }
.history-payout.negative { color: #e74c3c; }
.history-payout.neutral { color: #f1c40f; }

.history-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: 1em;
    font-size: 0.85em;
    font-style: italic;
}

/* ---------- Responsive: Phone ---------- */
@media (max-width: 480px) {
    html {
        font-size: 12px;
    }

    #header {
        padding: 0.5em 1em;
    }

    .header-title {
        font-size: 1.3em;
        letter-spacing: 0.1em;
    }

    .balance-amount {
        font-size: 1.2em;
    }

    .table-divider {
        width: 95%;
    }

    .hand-slot {
        min-width: 8em;
    }

    .action-btn {
        padding: 0.55em 1.1em;
        font-size: 0.85em;
    }

    .btn-large {
        padding: 0.75em 2em;
        font-size: 1em;
    }

    .modal-content {
        padding: 1.5em;
    }

    .modal-actions {
        flex-direction: column;
        gap: 0.5em;
    }

    .chip-rack {
        gap: 0.5em;
    }

    .round-history-section {
        padding: 0 1em 1em;
    }

    .settings-modal-content {
        max-width: 95%;
    }
}
