/**
 * WDC's Daily Word - Game Styling
 */

/* Prevent zoom on mobile when tapping buttons */
button, .key, input, select, textarea {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Ensure no double-tap zoom */
* {
    -webkit-touch-callout: none;
}

#game-container {
    -webkit-text-size-adjust: 100%;
}

/* Board and Tile Styling */
.board-row {
    display: flex;
    justify-content: center;
    margin: 5px 0;
    gap: 5px;
}

.tile {
    width: 60px;
    height: 60px;
    border: 2px solid #d3d6da;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: bold;
    color: #000;
    background: #fff;
    text-transform: uppercase;
    user-select: none;
    transition: border-color 0.1s;
}

.tile.filled {
    border-color: #878a8c;
    animation: pop 0.1s;
}

/* Tile States (after evaluation) */
.tile.correct {
    background: #6aaa64;
    border-color: #6aaa64;
    color: white;
}

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

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

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

.tile.flip {
    animation: flip 0.5s;
}

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

.tile.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); }
}

/* On-Screen Keyboard */
#keyboard {
    margin: 20px auto;
}

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

.key {
    min-width: 40px;
    height: 55px;
    padding: 0 10px;
    border: none;
    border-radius: 4px;
    background: #d3d6da;
    color: #000;
    font-weight: bold;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
}

.key:hover {
    background: #bbb;
}

.key:active {
    transform: scale(0.95);
}

.key-large {
    min-width: 65px;
    font-size: 0.9em;
    background: #8b8d8f;
    color: white;
    font-weight: bold;
}

.key-large:hover {
    background: #6e7072;
}

/* Make backspace icon bigger */
.key[data-key="Backspace"] {
    font-size: 1.8em;
    line-height: 1;
}

/* Key States (after use) */
.key.correct {
    background: #6aaa64;
    color: white;
}

.key.present {
    background: #c9b458;
    color: white;
}

.key.absent {
    background: #787c7e;
    color: white;
}

/* Keep large keys distinct even when marked absent */
.key-large.absent {
    background: #6e7072;
}

/* Message Display */
#message {
    transition: opacity 0.3s;
}

/* Modal Overlay */
#stats-modal {
    animation: fadeIn 0.3s;
    z-index: 2147483647;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    
    /* Reduce overall padding on mobile */
    #game-board {
        margin: 15px auto !important;
    }
    
    .tile {
        width: 56px;
        height: 56px;
        font-size: 1.8em;
        border-width: 2px;
    }
    
    .board-row {
        gap: 5px;
        margin: 5px 0;
    }
    
    .key {
        min-width: 36px;
        height: 52px;
        padding: 0 8px;
        font-size: 1.05em;
        border-radius: 5px;
    }
    
    .key-large {
        min-width: 60px;
        font-size: 0.85em;
        padding: 0 8px;
    }
    
    /* Make action buttons more prominent on mobile */
    .key-large {
        background: #8b8d8f;
        height: 54px;
    }
    
    /* Bigger backspace on mobile */
    .key[data-key="Backspace"] {
        font-size: 2em;
    }
    
    .keyboard-row {
        gap: 4px;
        margin: 4px 0;
    }
    
    /* Make message more visible on mobile */
    #message {
        font-size: 1em !important;
        min-height: 25px !important;
    }
}

@media (max-width: 400px) {
    .tile {
        width: 48px;
        height: 48px;
        font-size: 1.5em;
        border-width: 1.5px;
    }
    
    .board-row {
        gap: 4px;
        margin: 4px 0;
    }
    
    .key {
        min-width: 30px;
        height: 46px;
        padding: 0 5px;
        font-size: 0.95em;
    }
    
    .key-large {
        min-width: 52px;
        font-size: 0.75em;
        padding: 0 6px;
        height: 48px;
    }
    
    /* Even bigger backspace on small phones */
    .key[data-key="Backspace"] {
        font-weight: bold;
        font-size: 1.5em;
    }
    .key[data-key="Enter"] {
        font-weight: bold;
        font-size: 1.0em;
    }
    
    .keyboard-row {
        gap: 3px;
    }
}

/* Larger phones */
@media (min-width: 400px) and (max-width: 600px) {
    .tile {
        width: 58px;
        height: 58px;
    }
    
    .key {
        min-width: 38px;
        height: 54px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .tile.flip,
    .tile.shake,
    .tile.filled {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .tile {
        border-width: 3px;
    }
    
    .tile.correct {
        background: #0a0;
    }
    
    .tile.present {
        background: #dd0;
        color: #000;
    }
    
    .tile.absent {
        background: #333;
    }
}


