/* Dark Mode Styles */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .header-button img,
body.dark-mode .close-button {
    filter: invert(1);
}

body.dark-mode .popup-content {
    background-color: #333;
    color: #e0e0e0;
}

body.dark-mode .cell {
    background-color: #1e1e1e;
    border: 2px solid #555;
    color: #e0e0e0;
}

body.dark-mode .cell.correct {
    background-color: #6aaa64;
}

body.dark-mode .cell.present {
    background-color: #c9b458;
}

body.dark-mode .cell.absent {
    background-color: #787c7e;
}

body.dark-mode .key {
    background-color: #333;
    color: #e0e0e0;
}

body.dark-mode .key.correct {
    background-color: #6aaa64;
    color: #e0e0e0;
}

body.dark-mode .key.present {
    background-color: #c9b458;
    color: #e0e0e0;
}

body.dark-mode .key.absent {
    background-color: #787c7e;
    color: #e0e0e0;
}

body.dark-mode #popup,
body.dark-mode #how-to-play-popup,
body.dark-mode #settings-popup {
    background-color: rgba(0, 0, 0, 0.8);
}

body.dark-mode .button {
    background-color: #6aaa64;
}

body.dark-mode .button:hover {
    background-color: #5c9a54;
}

body.dark-mode .feedback-link {
    color: #e0e0e0;
}

body.dark-mode .gender {
    background-color: #3c376a; 
}

body {
    font-family: monospace, Helvetica Neue, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background-color: #ffff;
    margin: 0;
}

#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    gap: 20px;
}

h1 {
    margin: 0;
    font-size: 20px;
}

#header-buttons {
    display: flex;
    justify-content: end;
}

#how-to-play-button {
    text-align: left;
}

.header-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.header-button img {
    width: 30px;
    height: 30px;
}

#header-button-invisible {
    width: 30px;
    height: 30px;
}

#left-header-buttons {
    align-items: flex-start;
    justify-content: center;
    display: flex;
}

#grid {
    display: grid;
    grid-template-columns: repeat(5, 53px); /* Default to 5 columns, will be dynamically updated */
    grid-gap: 5px;
    margin: 15px 0;
    justify-content: center;
}

.cell {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #ccc;
    font-size: 24px;
    font-weight:bold;
    background-color:white;
    text-transform: uppercase;
}

.correct {
    background-color: #6aaa64;
    color: white;
}

.present {
    background-color: #c9b458;
    color: white;
}

.absent {
    background-color: #787c7e;
    color: white;
}

#keyboard {
    display: flex;
    flex-direction: column;
}

.row {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 3px;
}

.key {
    background-color: #d3d6da;
    border: none;
    cursor: pointer;
    flex: 1;
    font-size: 18px;
    font-weight: bold;
    border: 0;
    padding: 14px;
    height: 50px;
    border-radius: 4px;
    text-transform: uppercase;
}

.key.large-key {
    flex: 1.5;
}

.key.correct {
    background-color: #6aaa64;
    color: white;
}

.key.present {
    background-color: #c9b458;
    color: white;
}

.key.absent {
    background-color: #787c7e;
    color: white;
}

/* Responsive styles for mobile and iPad */
@media (max-width: 768px) {

    #grid {
        grid-template-columns: repeat(5, 1fr);
        grid-gap: 5px;
    }

    .cell {
        position: relative;
        font-size: 20px; 
    }

    .cell::after {
        content: '';
        display: block;
        padding-bottom: 100%;
    }

    .key {
        font-size: 20px; 
    }

    @media (max-width: 440px) {
        h1 {
            font-size: 18px;
        }
        .header-button img {
            width: 20px;
        }
        
        .key {
            font-size: 14px;
            padding: 10px;
        }
        #gender-message {
            width: 320px;
        }

        #keyboard-placeholder {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #keyboard {
            position: fixed;
            bottom: 20px;
            width: 95%;
        }
    
    }

    @media (max-width: 350px) {
        .cell {
            height: 35px;
        }

        .key {
            padding: 7.5px;
        }

        #keyboard {
            margin-bottom: 0px;
        }

        #gender-message {
            font-size: 14px;
        }
    }
}

#message {
    margin-top: 10px;
    font-size: 18px;
    color: red;
}

#message-container {
    position: relative;
    width: 100%;
    text-align: center;
    height: 0;
}

#error-message {
    position: absolute;
    top: -30px; /* Position above the grid */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0);
    color: white;
    padding: 15px 10px;
    border-radius: 5px;
    display: none;
    font-size: 14px;
    font-weight: 700;
    z-index: 10;
}

.popup {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgb(0,0,0);
    background-color: rgba(0,0,0,0.4);
    padding-top: 60px;
}

.popup-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    padding-bottom: 40px;
    border: 1px solid #888;
    width: 80%;
    max-width: 400px;
    text-align: center;
    border-radius: 10px;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#stats-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-bottom: 20px;
    margin-top: 20px;
}

#stats div {
    text-align: center;
}

#stats span {
    font-size: 2em;
    font-weight: bold;
}

#guess-distribution {
    width: 100%;
}

.distribution-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.distribution-row span {
    width: 20px;
    text-align: center;
}

.bar {
    height: 20px;
    background-color: #cacaca;
    margin-left: 10px;
    border-radius: 5px;
    padding-left: 3px;
    padding-right: 3px;
}

.button {
    background-color: #6aaa64;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 5px;
    cursor: pointer;
}

.button:hover {
    background-color: #5c9a54;
}

#share-button {
    margin-top: 20px;
    margin-bottom: 20px;
}

#already-played {
    align-items: center;
    display: flex;
    flex-direction: column;
    text-align: center;
    width: 350px;
}

/* How to Play Popup Styling */
.example-correct {
    background-color: green;
    color: white;
    padding: 0 5px;
}

.example-present {
    background-color: yellow;
    color: black;
    padding: 0 5px;
}

.example-incorrect {
    background-color: gray;
    color: white;
    padding: 0 5px;
}


#how-to-play-popup-content {
    text-align: left;
}

li {
    margin-top: 10px;
    margin-bottom: 10px;
}

.feedback-button {
    margin-top: 10px;
    margin-bottom: 10px;
    width: 100%;
    text-align: center; 
}

.feedback-link {
    color: black;
}

.stat {
    width: 80px;
    text-align: center;
}

.setting-option {
    margin-bottom: 20px;
}

.gender {
    background-color: yellow; 
    padding: 5px 2px; 
    border-radius: 5px;
}

#gender-message {
    max-width: 500px;
    text-align: center;
}

#gender-message-container {
    display: flex;
    justify-content: center;
    text-align: center;
}


/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
    margin-bottom: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

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

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

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