body {
    margin: 0;
    padding: 0 0 40px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Jersey 15', sans-serif;
    flex-direction: column;
    box-sizing: border-box;
    --bg-image: url('../images/background-light.png');
    background-image: var(--bg-image);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

.button-group {
    display: flex;
    gap: 15px;
    margin-top: -20px;
    margin-bottom: 30px;
    justify-content: center;
    align-items: center;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    max-width: 350px;
    max-height: 350px;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #fff;
    padding: 0;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: #333;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.cell:hover {
    background-color: #e0e0e0;
    transform: scale(1);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

#game-board {
    background-color: #f4f4f9;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

#game-over-message {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-top: 15px;
    text-align: center;
    display: none;
}

#restart-button,
#reset-score-button {
    width: 144px;
    height: 144px;
    padding-top: 24px;  
    padding-bottom: 24px; 
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s;
    background-color: transparent;
    color: transparent;
    font-size: 0;
}

#restart-button {
    background-image: url('../images/play-again.png');
}

#restart-button:hover,
#reset-score-button:hover {
    transform: scale(1.05);
}

#reset-score-button {
    background-image: url('../images/reset-score.png');
}

#score-board {
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    text-align: center;
    background-color: #e6eef7;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    gap: 20px;
}
#score-board span {
    flex: 1;
    text-align: center;
    color: #007bff;
}

#mode-selection {
    margin-bottom: 15px;
    text-align: center;
    font-size: 18px;
    color: #555;
    background-color: #f0f8ff;
    padding: 0;              
    border-radius: 40px;     
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: center;
    align-items: center;
}

#mode-selection input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #007bff;
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    vertical-align: middle;
}

#mode-selection input[type="radio"]:checked {
    background-color: #007bff;
    border-color: #007bff;
}

#mode-selection label {
    margin-right: 15px;
    cursor: pointer;
    vertical-align: middle;
}


.segmented-slider {
    position: absolute;
    top: 6px;       
    bottom: 6px;
    left: 6px;        
    width: calc(50% - 12px);
    background: #007bff;
    border-radius: 9999px;
    transition: transform 0.3s cubic-bezier(.4,1.4,.6,1), background 0.3s;
    z-index: 1;
    pointer-events: none;
}

.segmented-option {
    flex: 0 1 auto;
    display: inline;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 17px;
    color: #007bff;
    background: transparent;
    position: relative;
    z-index: 2;
    transition: color 0.3s;
    height: 52px;
    user-select: none;
    border-radius: 9999px;
    width: 50%;
    text-align: center;
    white-space: nowrap;   
    box-sizing: border-box;
    padding: 13px 25px;      
}

.segmented-toggle {
    display: flex;
    position: relative;
    background: #e6eef7;
    border-radius: 9999px;
    overflow: hidden;
    box-shadow: 0 1px 5px rgba(0,0,0,0.04);
    width: 450px;         
    max-width: 100%;
    height: 55px;
    margin: 0px auto;
    align-items: center;
    justify-content: center;
    padding-left: 0;      
    padding-right: 0;
}

.segmented-toggle input[type="radio"] {
    display: none;
}

#vsComputer:checked + label,
#vsPlayer:checked + label {
    color: #fff;
}

@media screen and (max-width: 480px) {
    .segmented-toggle {
        width: 98vw;
        min-width: 0;
        height: 42px;
    }
    .segmented-option {
        font-size: 14px;
        height: 42px;
        padding: 0 0;
    }
    .segmented-slider {
        top: 2px;
        bottom: 2px;
        left: 2px;
        width: calc(50% - 4px);
    }
}

@media screen and (max-width: 600px) {
    .board {
        max-width: 90%;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    #game-board {
        padding: 15px;
    }

    #game-over-message {
        font-size: 18px;
    }

    .button-group {
        flex-direction: column;
        gap: 10px;
    }

    #restart-button,
    #reset-score-button {
        font-size: 16px;
        padding: 10px 15px;
    }

    #score-board {
        font-size: 20px;
        padding: 8px 15px;
        gap: 15px;
    }

    #mode-selection {
        font-size: 16px;
        padding: 8px 10px;
    }

    #mode-selection label {
        margin-right: 10px;
    }
}

/* Toggle Switch */
.top-bar {
    position: absolute;
    top: 20px;
    right: 30px;
    z-index: 10;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch .slider{
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
    border: 2px solid #ffff; /*ini ntar diubah sesuain */
    box-sizing: border-box;
    border-radius: 24px;
    background-color: #ffff; /*ini ntar diubah sesuain */
    transition: .4s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10), 0 1.5px 3px rgba(0,0,0,0.08);
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 5px;
    top: 1px;
    background-color: #2196F3;
    border-radius: 50%;
    transition: .4s;
    box-shadow: 0 2px 6px rgba(33,150,243,0.18), 0 1px 2px rgba(0,0,0,0.10);
}
input:checked + .slider {
    background-color: #23272a;
    border: 2px solid #23272a; /*ini ntar diubah sesuain */
}
input:checked + .slider:before {
    transform: translateX(24px);
}
#vsPlayer:checked ~ .segmented-slider {
    transform: translateX(100%);
    width: calc(50% - 6px);
}

#vsComputer:checked ~ .segmented-slider {
    transform: translateX(0%);
    width: calc(50% - 6px);
}
body.dark-mode {
    --bg-image: url('../images/background-dark.png');
    background-color: #181a1b;
    color: #f0f4f8;
}
body.dark-mode #score-board {
    background-color: #23272a;
    color: #f0f4f8;
}
body.dark-mode .board {
    background-color: #23272a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
body.dark-mode .cell {
    background-color: #2c2f34 !important;
    color: #f0f4f8 !important;
    border: 1px solid #444 !important;
}
body.dark-mode .cell:hover {
    background-color: #3a3f44 !important;
}
.cell.winner, .cell.winner:hover{
    background-color: #8bc34a !important;
    color: #fff !important;
    transform: scale(1.08) !important;
    box-shadow: 0 0 12px #8bc34a80;
}
body.dark-mode .cell.winner, body.dark-mode .cell.winner:hover {
    background-color: #4caf50 !important;
    transform: scale(1.08) !important;
    box-shadow: 0 0 12px #8bc34a80;
}
body.dark-mode #game-board {
    background-color: #23272a;
}
body.dark-mode #game-over-message {
    color: #f0f4f8;
}
body.dark-mode #mode-selection {
    background: #23272a;
    color: #f0f4f8;
}
body.dark-mode .segmented-toggle {
    background: #23272a;
}
body.dark-mode .segmented-slider {
    background: #2196F3;
}
body.dark-mode .segmented-option {
    color: #90caf9;
}
body.dark-mode #vsComputer:checked + label,
body.dark-mode #vsPlayer:checked + label {
    color: #fff;
}                            

@keyframes score-bounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.5); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.score-animate {
    animation: score-bounce 0.5s cubic-bezier(.36,1.56,.64,1) both;
}