* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #121213;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
}

.container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    text-align: center;
}

header {
    flex-shrink: 0;
    margin-bottom: 10px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
    border-bottom: 1px solid #3a3a3c;
    padding-bottom: 5px;
}

header p {
    color: #818384;
    margin-bottom: 10px;
    font-size: 14px;
}

.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-bottom: 15px;
    padding: 0 20px;
    flex-shrink: 0;
}

.main-content {
    display: flex;
    flex: 1;
    gap: 20px;
    min-height: 0; /* Important for flex children */
}

.left-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    align-items: center;
    position: relative;
}



.attempts {
    font-size: 1rem;
    font-weight: bold;
}

#new-game-btn {
    background-color: #538d4e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

#new-game-btn:hover {
    background-color: #6aac5a;
}

.game-board {
    margin-bottom: 10px;
    padding: 10px 0;
    flex-shrink: 0;
}

.word-grid {
    position: relative;
    display: inline-block;
    margin: 0 auto;
    padding: 15px;
    min-height: 300px;
    width: 360px;
}

.vertical-word {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    z-index: 1;
}

.horizontal-word {
    display: flex;
    flex-direction: row;
    position: absolute;
    top: 128px; /* Precisely align with center cell (64px * 2) */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.letter-cell {
    width: 60px;
    height: 60px;
    border: 2px solid #3a3a3c;
    margin: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
    background-color: #121213;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.letter-cell:hover {
    border-color: #565758;
    background-color: #1a1a1b;
}

.letter-cell.selected {
    border-color: #538d4e;
    background-color: #262629;
}

.center-cell {
    border-color: #565758;
    background-color: #1a1a1b;
    position: relative;
    z-index: 3;
}

/* Hide the horizontal word's center cell to avoid overlap */
.horizontal-word .center-cell {
    background-color: transparent;
    border-color: transparent;
    z-index: 1;
}

/* Color states for letter feedback */
.correct {
    background-color: #538d4e;
    border-color: #538d4e;
    color: white;
}

.present {
    background-color: #b59f3b;
    border-color: #b59f3b;
    color: white;
}

.absent {
    background-color: #3a3a3c;
    border-color: #3a3a3c;
    color: white;
}

.input-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
    margin-top: 20px;
    flex-shrink: 0;
}

.section-divider {
    width: 100%;
    max-width: 500px;
    height: 1px;
    background-color: #3a3a3c;
    margin: 20px auto;
    flex-shrink: 0;
}

#submit-guess, #clear-btn {
    background-color: #818384;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

#submit-guess:hover, #clear-btn:hover {
    background-color: #565758;
}

#submit-guess:disabled, #clear-btn:disabled {
    background-color: #3a3a3c;
    cursor: not-allowed;
}

#clear-btn {
    background-color: #b59f3b;
}

#clear-btn:hover {
    background-color: #c5af4b;
}

/* Keyboard Styles */
.keyboard-container {
    position: absolute;
    top: 102px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    width: 100%;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 450px;
}

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

.key {
    background-color: #818384;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 12px 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.1s ease;
    min-width: 38px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

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

.key:active {
    background-color: #3a3a3c;
}

.key-wide {
    min-width: 55px;
    font-size: 10px;
}

/* Keyboard color states */
.key.correct {
    background-color: #538d4e !important;
}

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

.key.absent {
    background-color: #3a3a3c !important;
}

.key.correct:hover {
    background-color: #6aac5a !important;
}

.key.present:hover {
    background-color: #c5af4b !important;
}

.key.absent:hover {
    background-color: #4a4a4c !important;
}

.message {
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: bold;
    min-height: 20px;
    flex-shrink: 0;
}

.message.success {
    color: #538d4e;
}

.message.error {
    color: #f5793a;
}

.message.info {
    color: #85c0f9;
}

.guess-history {
    flex: 1;
    text-align: center;
    overflow-y: auto;
    padding: 0 10px;
    margin-top: 10px;
}

.guess-history h3 {
    margin-bottom: 10px;
    text-align: center;
    color: #818384;
    font-size: 1rem;
}

.history-item {
    background-color: #1a1a1b;
    border: 1px solid #3a3a3c;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.history-number {
    font-size: 14px;
    font-weight: bold;
    color: #818384;
    min-width: 20px;
    text-align: right;
}

.history-words {
    display: flex;
    gap: 20px;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.history-word {
    font-family: monospace;
    font-size: 12px;
    display: flex;
    gap: 2px;
}

.history-letter {
    width: 20px;
    height: 20px;
    border: 1px solid #3a3a3c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border-radius: 2px;
}

.history-letter.correct {
    background-color: #538d4e;
    border-color: #538d4e;
    color: white;
}

.history-letter.present {
    background-color: #b59f3b;
    border-color: #b59f3b;
    color: white;
}

.history-letter.absent {
    background-color: #3a3a3c;
    border-color: #3a3a3c;
    color: white;
}

/* Responsive design */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .left-column, .right-column {
        flex: none;
    }
    
    .guess-history {
        max-height: 150px;
    }
    
    body {
        overflow-y: auto;
    }
    
    .container {
        height: auto;
        min-height: 100vh;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 5px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .letter-cell {
        width: 54px;
        height: 54px;
        font-size: 1.3rem;
    }
    
    .horizontal-word {
        top: 116px; /* Adjusted for mobile: 58px * 2 */
    }
    
    .word-grid {
        padding: 10px;
        min-height: 260px;
        width: 320px;
    }
    
    .keyboard-container {
        top: 89px; /* Centered on horizontal grid line for mobile */
    }
    
    .keyboard {
        max-width: 100%;
        padding: 0 5px;
    }
    
    .key {
        min-width: 32px;
        min-height: 45px;
        padding: 10px 4px;
        font-size: 11px;
    }
    
    .key-wide {
        min-width: 50px;
        font-size: 9px;
    }
    
    .input-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    #submit-guess, #clear-btn {
        width: 130px;
        margin: 0 auto;
    }
}

/* Animation for revealing letters */
@keyframes flipIn {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(-90deg);
    }
    100% {
        transform: rotateY(0deg);
    }
}

.letter-cell.animate {
    animation: flipIn 0.6s ease-in-out;
} 