/* ============================================
   Main Layout & Container Styles
   ============================================ */

#board.centered-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    margin: 0 auto;
    gap: 1px;
}

.tile-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 1px;
}

.tiles-container {
    display: flex;
    gap: 1px;
}

#keyboard {
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
}

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

/* ============================================
   Tile Styles & States
   ============================================ */

.tile {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
    margin: 1px;
    border-radius: 10px;
    font-size: 24px;
    box-sizing: border-box;
    color: #333;
    background-color: #fff;
    border: 2px solid #999;
    cursor: pointer;
}

.tile.empty {
    border: 3px solid #457b9d;
    background-image: radial-gradient(#a8dadc, #f1faee);
    background-size: cover;
    color: transparent;
}

.tile.correct {
    background-color: #6aaa64;
    color: #fff;
    border-color: #6aaa64;
}

.tile.present {
    background-color: #c9b458;
    color: #fff;
    border-color: #c9b458;
}

.tile.absent {
    background-color: #787c7e;
    color: #fff;
    border-color: #787c7e;
}

.tile.selected,
.current-input {
    border-color: #6adb75 !important;
    box-shadow: 0 0 5px #6adb75;
}

/* ============================================
   Keyboard Key Styles
   ============================================ */

.key-tile,
.enter-key-tile,
.backspace-key-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 8px;
    margin: 1px;
    border-radius: 5px;
    background-color: #eee;
    font-size: 14px;
    cursor: pointer;
    box-sizing: border-box;
    color: #333;
    touch-action: none;
}

.key-tile.correct,
.enter-key-tile.correct,
.backspace-key-tile.correct {
    background-color: #6aaa64;
    color: #fff;
}

.key-tile.present,
.enter-key-tile.present,
.backspace-key-tile.present {
    background-color: #c9b458;
    color: #fff;
}

.key-tile.absent,
.enter-key-tile.absent,
.backspace-key-tile.absent {
    background-color: #787c7e;
    color: #fff;
}

.floating-key {
    position: absolute;
    z-index: 1000;
    width: 35px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    pointer-events: none;
    background-color: #eee;
    border-radius: 5px;
    font-size: 14px;
    color: #333;
    touch-action: none;
}

/* ============================================
   Header & Navigation Styles
   ============================================ */

.logo-style {
    font-weight: bold;
    text-align: center;
    font-size: 2rem;
}

/* ============================================
   Modal & Dialog Styles
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    display: none;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    max-width: 500px;
    width: 80%;
    border-radius: 10px;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

/* ============================================
   Info Button Styles
   ============================================ */

.info-button {
    visibility: hidden;
    width: 30px;
    font-size: 24px;
    text-align: center;
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
}

.info-button.visible {
    visibility: visible;
}

.info-button i {
    color: #333;
}

/* ============================================
   How to Play Section Styles - Improved
   ============================================ */

.how-to-play-button {
    transition: all 0.3s ease;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.how-to-play-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

#guidelines-body {
    max-width: 400px;
    margin: 1rem auto 0;
    overflow: hidden;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    border-top: 2px solid #dee2e6;
    transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in-out;
}

.guidelines-content {
    font-size: 16px;
    line-height: 1.5;
}

.guidelines-content h3 {
    margin-top: 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

.guidelines-content ul {
    margin-bottom: 12px;
}

.guidelines-content li {
    margin-bottom: 4px;
}

#guidelines-body:not(.hidden) {
    max-height: 2000px;
    opacity: 1;
}

.rotate-180 {
    transform: rotate(180deg);
}

.tile.example {
    width: 40px;
    height: 40px;
    font-size: 20px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Animation Styles
   ============================================ */

.invalid-word {
    animation: shake 0.6s;
    border-color: #ff4d4d;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablet and smaller screens */
@media (max-width: 600px) {

    .game-container {
        padding: 10px;
        width: 100%;
        margin: 0 auto;
    }

    #board.centered-board {
        max-width: 90%;
    }

    .tile {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .key-tile {
        width: 28px;
        padding: 6px;
        font-size: 12px;
    }

    .enter-key-tile,
    .backspace-key-tile {
        width: 45px;
        padding: 6px;
        font-size: 12px;
    }

    .keyboard-row {
        margin-bottom: 2px;
    }

    .logo-style {
        font-size: 1.5rem;
    }

    .btn-how-to-play {
        font-size: 14px;
        padding: 10px 15px;
    }

    #how-to-play-container {
        max-width: 100%;
    }

    .how-to-play-button {
        max-width: 100%;
        font-size: 14px;
    }

    #guidelines-body {
        max-width: 100%;
    }

    .guidelines-content {
        font-size: 14px;
    }

    .guidelines-content h3 {
        font-size: 16px;
    }

    .tile.example {
        width: 35px;
        height: 35px;
        font-size: 18px;
        min-width: 35px;
    }
}

/* Mobile screens */
@media (max-width: 400px) {

    .tile {
        width: 40px;
        height: 40px;
        font-size: 16px;
        margin: 0.5px;
    }

    .key-tile {
        width: 24px;
        padding: 4px;
        font-size: 10px;
        margin: 0.5px;
    }

    .enter-key-tile,
    .backspace-key-tile {
        width: 40px;
        padding: 4px;
        font-size: 10px;
        margin: 0.5px;
    }

    .logo-style {
        font-size: 1.2rem;
    }

    .guidelines-content {
        font-size: 13px;
    }

    .guidelines-content h3 {
        font-size: 15px;
    }

    .tile.example {
        width: 30px;
        height: 30px;
        font-size: 16px;
        min-width: 30px;
    }

    #guidelines-body .p-4 {
        padding: 12px 10px;
    }
    .guidelines-content ul {
        padding-left: 16px;
    }

    .guidelines-content .space-y-2 {
        margin-top: 8px;
    }
}