body {
    font-family: 'Roboto', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    background-color: #f8f9fa;
    transition: background-color 0.3s, color 0.3s;
}

header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 20px;
    background-color: #fff;
    transition: background-color 0.3s, color 0.3s;
    position: fixed;
    top: 0;
    z-index: 1000;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

body.dark-mode header {
    background-color: #333;
    color: #f8f9fa;
}

body.dark-mode {
    background-color: #121212;
    color: #f8f9fa;
}

#switchContainer {
    display: flex;
    align-items: center;
    position: absolute;
    right: 40px;
}

.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: #ccc;
    transition: .4s;
    border-radius: 34px;
}

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

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

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

#switchLabel {
    margin-left: 10px;
    font-size: 1.2rem;
}

#game {
    text-align: center;
    margin-top: 140px;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

#inputArea {
    margin: 20px;
}

#message {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #d9534f;
}

body.dark-mode #message {
    color: #f8d7da;
}

#grid {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding-bottom: 20px;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 10px;
}

.cell {
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    background-color: #ffffff;
    border: 2px solid #ced4da;
    transition: background-color 0.5s, border-color 0.5s, transform 0.1s;
    text-transform: uppercase;
}

body.dark-mode .cell {
    background-color: #333;
    border-color: #555;
}

.cell.correct {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: #fff;
}

.cell.present {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #fff;
}

.cell.absent {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff;
}

@keyframes flipIn {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

@keyframes bump {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10%);
    }
    100% {
        transform: translateY(0);
    }
}

.flip {
    animation: flipIn 0.6s ease-in-out forwards;
}

.bump {
    animation: bump 0.2s ease-in-out;
}

#keyboardContainer {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}

#keyboard {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.key {
    width: 40px;
    height: 50px;
    margin: 0 3px;
    font-size: 1rem;
    font-weight: bold;
    background-color: #e9ecef;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000; /* Ensure text color is black */
}

body.dark-mode .key {
    background-color: #555;
    color: #f8f9fa;
}

.key:hover {
    background-color: #dee2e6;
}

body.dark-mode .key:hover {
    background-color: #666;
}

.key.correct {
    background-color: #28a745 !important;
    color: #fff !important;
}

.key.present {
    background-color: #ffc107 !important;
    color: #fff !important;
}

.key.absent {
    background-color: #6c757d !important;
    color: #fff !important;
}

.key.large {
    width: 60px;
    font-size: 0.75rem;
}

.key.large i {
    font-size: 1.2rem;
}

.key:active {
    background-color: #adb5bd;
}

body.dark-mode .key:active {
    background-color: #777;
}

#congratulations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 1000;
}

#congratulations.hidden {
    display: none;
}

.congrats-content {
    background: #333;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.congrats-content h2 {
    margin-bottom: 10px;
}

#game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 1000;
}

#game-over.hidden {
    display: none;
}

.game-over-content {
    background: #333;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.game-over-content h2 {
    margin-bottom: 10px;
}

#notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #d9534f;
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.5s;
}

#notification.show {
    opacity: 1;
}

/* Media queries for mobile devices */
@media (max-width: 600px) {
    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    #game {
        margin-top: 100px;
        padding: 0;
    }

    #grid {
        grid-gap: 5px;
        padding-bottom: 0;
        margin-top: 10px; /* Reduce margin-top for mobile devices */
    }

    .row {
        grid-gap: 5px;
    }

    .cell {
        width: calc((100vw - 70px) / 5);
        height: calc((100vw - 70px) / 5);
    }

    .key {
        width: 32px;
        height: 40px;
        font-size: 0.8rem;
        margin: 0 2px;
    }

    .key.large {
        width: 48px;
    }

    #keyboardContainer {
        padding: 0;
    }
}
