body {
    font-family: "nyt-franklin", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background-color: #e2e0dd;
    color: rgb(22, 21, 21);
}


#game-container {
    display: flex;
    position: relative;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4.5px;
    transform: translateX(0px);
}

.tile {
    width: 46.80px;
    height: 47.25px;
    border-radius: 5px;
    border: 1.8px solid #3a3a3c;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    font-weight: bold;
    transition: transform 0.2s ease;
}
@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}
.present {
    background-color: grey;
}
.pop {
    transform: scale(1.2);
}

#result-boxes {
    position: absolute;
    left: calc(5 * 57px + 135px); /* Calculate position dynamically */
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    50% {
        transform: translateX(5px);
    }
    75% {
        transform: translateX(-5px);
    }
}

.shake {
    animation: shake 0.4s ease;
}

#error-popup.visible {
    opacity: 1;
}

#error-popup.hidden {
    opacity: 0;
}


.result-row {
    display: flex;
    gap: 5px;
}

.result-box {
    width: 46.80px;
    height: 47.25px;
    border: 0px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    background-color: transparent;
    color: rgb(8, 8, 8);
    font-size: 1.2em;
    font-weight: bold;
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    transform-style: preserve-3d;
}
#keyboard {
    display: flex;
    flex-direction: column;
    gap: 2.7px;
    margin-top: 10px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 2.7px;
}

.key {
    font-size: 1.15em;
    font-weight: bold;
    background-color: #646667;
    color: white;
    text-align: center;
    border: 0;
    border-radius: 4px;
    width: 41.6px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key.wide {
    flex: 1.5;
}

.key.used {
    background-color: #b2b2b4;
    color: #fff;
}

.correct {
    background-color: #516aa3; /* blue for bulls */
}

.present {
    background-color: #b55e3b; /* orange for cows */
}

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

.flip {
    animation: flip 0.5s ease-in-out forwards;
}
.dark-grey {
    background-color: #727272; /* Dark grey */
    color: #fff; /* White text for better contrast */
}
#result-labels {
    position: absolute;
    left: calc(5 * 57px + 135px); /* Match result-boxes' left position */
    top: -51.75px; /* Place 4.5px above result-boxes */
    display: flex;
    flex-direction: row;
    gap: 5px;
}

.label-box {
    width: 46.80px; /* Match result-box size */
    height: 47.25px; /* Match result-box size */
    border: 0px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    background-color: transparent;
    color: rgb(8, 8, 8);
    font-size: 1.2em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
#error-message {
    color: rgb(170, 52, 34);
    font-weight: bold;
    font-family: 'Inter', 'Roboto', 'Helvetica', sans-serif;
    font-size: 0.9em;
    display: none;
    position: relative;
    top: -5px; /* Moves it higher */
    background-color: rgba(147, 142, 142, 0.6); /* Semi-transparent black */
    padding: 8px 12px;
    border-radius: 5px;
    text-align: center;
    width: fit-content;
    max-width: 80%;
    margin: 0 auto;
}
@media (max-width: 900px) {
    #game-container {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100vw;
    }
    #game-board {
        grid-template-columns: repeat(5, 1fr);
        gap: 2.5vw;
        width: 95vw;
        max-width: 380px;
        margin: 0 auto;
    }
    .tile {
        width: 14vw;
        height: 14vw;
        max-width: 55px;
        max-height: 55px;
        font-size: 6vw;
    }
    #result-labels {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        width: 95vw;
        gap: 22vw;
        margin: 12px auto 0 auto;
    }
    .label-box {
        text-align: center;
        width: 14vw !important;
        font-size: 5vw;
        min-width: 36px;
        background: transparent;
    }
    #result-boxes {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
        width: 95vw;
        gap: 22vw;
        margin: 2vw auto 3vw auto;
    }
    .result-row {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
        width: 95vw;
        gap: 22vw;
    }
    .result-box {
        width: 14vw !important;
        height: 9vw !important;
        min-width: 32px;
        min-height: 22px;
        max-width: 46px;
        max-height: 36px;
        font-size: 6vw;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    #keyboard {
        gap: 2vw;
        width: 98vw;
        max-width: 400px;
        margin: 0 auto;
    }
    .keyboard-row {
        gap: 2vw;
    }
    .key {
        width: 11vw;
        height: 11vw;
        max-width: 48px;
        max-height: 48px;
        font-size: 5vw;
    }
    .key.wide {
        flex: 1.5;
        min-width: 50px;
        max-width: 100px;
        font-size: 4.7vw;
    }
    #game-over-message, #more-attempts-popup {
        width: 88vw;
        max-width: 340px;
        font-size: 1.1em;
        padding: 12px 6px;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }
}

/* Even smaller screens (e.g., older mobiles) */
@media (max-width: 500px) {
    #result-labels,
    #result-boxes,
    .result-row {
        gap: 24vw !important;
    }
    .tile,
    .result-box,
    .label-box {
        width: 17vw !important;
        height: 17vw !important;
        font-size: 7vw;
    }
    .result-box, .label-box {
        min-width: 24px;
        min-height: 24px;
    }
    .key {
        width: 14vw;
        height: 14vw;
        font-size: 6vw;
        min-width: 34px;
        min-height: 34px;
    }
}
