body {
    background-color: #121213;
    color: white;
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

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

header {
    width: 100%;
    text-align: center;
    border-bottom: 1px solid #3a3a3c;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    background: linear-gradient(135deg, #ffffff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

#board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

#board {
    display: grid;
    grid-template-columns: repeat(5, 62px);
    grid-template-rows: repeat(6, 62px);
    gap: 5px;
    margin-top: 20px;
}

.tile {
    width: 62px;
    height: 62px;
    border: 2px solid #3a3a3c;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
}

/* Mobile Responsive */
@media (max-width: 400px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    #board {
        grid-template-columns: repeat(5, 52px);
        grid-template-rows: repeat(6, 52px);
        gap: 4px;
        margin-top: 15px;
    }

    .tile {
        width: 52px;
        height: 52px;
        font-size: 1.6rem;
    }

    #reset-button {
        padding: 14px 36px;
        font-size: 1rem;
    }
}

@media (max-width: 340px) {
    #board {
        grid-template-columns: repeat(5, 44px);
        grid-template-rows: repeat(6, 44px);
        gap: 3px;
    }

    .tile {
        width: 44px;
        height: 44px;
        font-size: 1.4rem;
    }

    header h1 {
        font-size: 1.5rem;
    }
}
/* Color states for the tiles */
.correct { 
    background-color: #538d4e !important; 
    border-color: #538d4e !important; 
} /* Green */

.present { 
    background-color: #b59f3b !important; 
    border-color: #b59f3b !important; 
} /* Yellow */

.absent { 
    background-color: #3a3a3c !important; 
    border-color: #3a3a3c !important; 
} /* Gray */

/* Animation when typing a letter */
.pop {
    animation: pop 0.1s ease-in-out;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.flip {
    /* This timing function (cubic-bezier) mimics the 'springy' feel of Wordle */
    animation: flip 0.6s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

@keyframes flip {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(90deg);
        /* This prevents the color from leaking early */
    }
    100% {
        transform: rotateX(0);
    }
}

/* Add a transition to the background color so it doesn't just 'pop' in */
.tile {
    /* ... your existing code ... */
    transition: background-color 0.1s ease, border-color 0.1s ease;
}

.tile.active {
    border-color: #565758; /* Lighter border when a letter is inside */
    animation: pop 0.1s ease-in-out;
}

/* Reset / Play Again Button */
#reset-button {
    margin-top: 30px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #121213;
    background: linear-gradient(135deg, #538d4e 0%, #6aaa64 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(83, 141, 78, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#reset-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

#reset-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(83, 141, 78, 0.6);
    background: linear-gradient(135deg, #6aaa64 0%, #7dbd77 100%);
}

#reset-button:hover::before {
    left: 100%;
}

#reset-button:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(83, 141, 78, 0.4);
}

/* Fade-in animation for the button */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#reset-button[style*="block"] {
    animation: fadeInUp 0.4s ease-out;
}

/* Shake animation for invalid words */
.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Toast notification style */
#toast {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

/* On-screen Keyboard */
#keyboard {
    margin-top: 20px;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

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

#keyboard button {
    min-width: 36px;
    height: 52px;
    border: none;
    border-radius: 4px;
    background-color: #818384;
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.1s;
    text-transform: uppercase;
}

#keyboard button:active {
    background-color: #a0a0a0;
}

#keyboard button.wide-key {
    min-width: 60px;
    font-size: 0.75rem;
}

#keyboard button.correct {
    background-color: #538d4e;
}

#keyboard button.present {
    background-color: #b59f3b;
}

#keyboard button.absent {
    background-color: #3a3a3c;
}

@media (max-width: 400px) {
    #keyboard button {
        min-width: 28px;
        height: 48px;
        font-size: 0.8rem;
    }

    #keyboard button.wide-key {
        min-width: 50px;
        font-size: 0.65rem;
    }

    .keyboard-row {
        gap: 4px;
    }
}

@media (max-width: 340px) {
    #keyboard button {
        min-width: 24px;
        height: 42px;
        font-size: 0.7rem;
    }

    #keyboard button.wide-key {
        min-width: 42px;
        font-size: 0.6rem;
    }
}