
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Montserrat:wght@700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', sans-serif;
    background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
    color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 950px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 20px;
    margin-bottom: 25px;
}

h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.8em;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
}

/* Rule Switch Styles */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.rule-switch-container {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 15px;
    border-radius: 50px;
}

.rule-label {
    font-size: 0.9em;
    font-weight: 500;
    color: #bdc3c7;
    transition: color 0.3s ease;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3498db; /* Stand on Soft 17 color */
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #c0392b; /* Hit on Soft 17 color */
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}


.player-area {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.hand-container {
    border-radius: 10px;
    padding: 15px;
    min-width: 250px; /* Ensure containers have a minimum width */
    border: 1px solid transparent; /* For active state */
}

.hand-container.active {
    border: 1px solid #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

#double-button {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

#double-button:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

#split-button {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

#split-button-mobile:hover {
    background: linear-gradient(135deg, #8e44ad, #8034a0);
}

#double-button-mobile {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

#double-button-mobile:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.credits {
    font-size: 1.5em;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 700;
}

.message-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 2em;
    font-weight: bold;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.message-box.show {
    opacity: 1;
    visibility: visible;
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.dealer-area, .player-area {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 15px;
}

h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6em;
    margin-bottom: 20px;
    color: #a7c0cd;
}

.hand {
    min-height: 160px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.card {
    background-color: #fff;
    color: #333;
    width: 90px;
    height: 130px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5em;
    font-weight: 700;
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.card.hidden {
    background: linear-gradient(135deg, #c0392b, #8e2418); /* Red gradient for card back */
    color: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border: 3px solid white;
}

.card.hidden::after {
    content: '';
    width: 85%;
    height: 90%;
    border: 2px dotted rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    position: absolute;
}

.controls {
    margin-bottom: 30px;
}

.betting-area {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.betting-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.2);
    padding: 10px 15px;
    border-radius: 12px;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 20px; /* Add space below the buttons */
}

#bet-amount {
    width: 90px;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background-color: #2c3e50;
    color: white;
    font-size: 1.1em;
    text-align: center;
}

button {
    font-family: 'Montserrat', sans-serif;
    color: white;
    border: none;
    padding: 15px 35px;
    font-size: 1.1em;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

#deal-button, #new-round-button {
    background: linear-gradient(45deg, #1abc9c, #16a085);
}

#hit-button {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
}

#stand-button {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
}

#split-button {
    background: linear-gradient(45deg, #f39c12, #e67e22);
}

#reset-bet-button {
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
    padding: 12px 20px;
    font-size: 1em;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

button:disabled {
    background: #566573;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.strategy-tip {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 25px;
    text-align: left;
}

.strategy-tip h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6em;
    margin-bottom: 15px;
}

#tip-text {
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 10px;
}

.explanation {
    font-size: 1.05em;
    color: #bdc3c7;
    font-style: italic;
    line-height: 1.5;
}

.chip-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.chip {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #fff;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.1em;
    color: #fff;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    position: relative;
}

.chip::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.5);
}

.chip:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.5);
}

.chip[data-value="10"] { background-color: #c0392b; }
.chip[data-value="20"] { background-color: #2980b9; }
.chip[data-value="50"] { background-color: #8e44ad; }
.chip[data-value="100"] { background-color: #2c3e50; }

.betting-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.action-buttons {
    display: flex;
    gap: 15px;
}

/* --- Responsive Design --- */

/* Hide mobile controls by default on larger screens */
.mobile-controls {
    display: none;
}

/* Media query for tablets and smaller desktops */
@media (max-width: 980px) {
    .game-container {
        padding: 20px;
    }

    .game-area {
        grid-template-columns: 1fr; /* Stack player/dealer areas */
        gap: 25px;
    }

    h1 {
        font-size: 2.2em;
    }

    .credits {
        font-size: 1.2em;
        padding: 8px 15px;
    }
}

/* Media query for mobile phones */
@media (max-width: 768px) {
    body {
        padding: 0;
        min-height: -webkit-fill-available; /* Fix for mobile viewport height */
    }

    .game-container {
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 15px;
        padding-bottom: 120px; /* Add padding to prevent overlap with sticky controls */
    }

    .main-controls {
        display: none; /* Hide desktop controls */
    }

    .mobile-controls {
        display: flex; /* Show mobile controls */
        flex-direction: column;
        gap: 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15, 32, 39, 0.9);
        backdrop-filter: blur(5px);
        padding: 15px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 200;
    }

    header {
        flex-direction: column;
        gap: 15px;
    }

    .header-controls {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    h2 {
        font-size: 1.4em;
    }

    .card {
        width: 70px;
        height: 105px;
        font-size: 1.8em;
    }

    .chip-container-mobile {
        display: flex;
        justify-content: center;
        gap: 10px;
        width: 100%;
        margin-bottom: 10px; /* Add space below the chips */
    }

    .chip-mobile {
        width: 55px; /* Ensure width and height are the same */
        height: 55px;
        font-size: 1em;
        border-radius: 50%; /* This makes it a circle */
        padding: 0; /* Override any inherited padding */
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .chip-mobile[data-value="10"] { background-color: #3498db; }
    .chip-mobile[data-value="20"] { background-color: #9b59b6; }
    .chip-mobile[data-value="50"] { background-color: #e67e22; }
    .chip-mobile[data-value="100"] { background-color: #2c3e50; }

    .betting-controls-mobile {
        display: flex;
        width: 100%;
        gap: 10px;
        justify-content: center;
    }

    .betting-controls-mobile input {
        flex-grow: 1;
        text-align: center; /* Center the bet amount text */
    }

    .action-buttons-mobile {
        display: flex;
        justify-content: space-around;
        width: 100%;
        gap: 10px;
    }

    .action-buttons-mobile button {
        flex-grow: 1; /* Allow buttons to grow and fill space */
        padding: 12px 5px; /* Adjust padding for smaller screens */
    }

    .strategy-tip {
        margin-bottom: 120px; /* Add margin to prevent overlap with sticky controls */
    }

    #split-button-mobile {
        background: linear-gradient(135deg, #9b59b6, #8e44ad);
    }

    #split-button-mobile:hover {
        background: linear-gradient(135deg, #8e44ad, #8034a0);
    }

    #double-button-mobile {
        background: linear-gradient(135deg, #f39c12, #e67e22);
    }

    #double-button-mobile:hover {
        background: linear-gradient(135deg, #e67e22, #d35400);
    }

    #hit-button-mobile {
        background: linear-gradient(45deg, #2ecc71, #27ae60);
    }

    #stand-button-mobile {
        background: linear-gradient(45deg, #e74c3c, #c0392b);
    }

    #deal-button-mobile,
    #new-round-button-mobile {
        background: linear-gradient(45deg, #1abc9c, #16a085);
    }

    #reset-bet-button-mobile {
        background: linear-gradient(45deg, #95a5a6, #7f8c8d);
        padding: 12px 20px;
        font-size: 1em;
    }
}
