/**
 * WDC Word Chain - Tile and keyboard based styling
 * Uses common game tile/keyboard system
 */

/* Prevent zoom on mobile */
button, input, select, textarea, .game-key {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

* {
    -webkit-touch-callout: none;
}

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

/* Tile Rows */
.wc-tile-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin: 2px 0;
}

/* Tiles (4 letters) */
.wc-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: all 0.2s;
    font-family: monospace;
}

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

/* Active tile indicator - highlight next empty tile */
.wc-tile.wc-active {
    border-color: #2196F3;
    border-width: 3px;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
}

/* Tile States */
.wc-tile.wc-start {
    background: #e8f5e9;
    border-color: #4CAF50;
    color: #2e7d32;
}

.wc-tile.wc-target {
    background: #fafafa;
    border-color: #ccc;
    color: #999;
}

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

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

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

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

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

/* Keyboard (from games.inc) */
.game-keyboard {
    margin: 20px auto;
    max-width: 500px;
}

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

.game-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;
}

.game-key:hover {
    background: #bbb;
}

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

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

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

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

/* Edit button */
.wc-edit-indicator {
    font-size: 0.85em;
    padding: 4px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
    font-weight: bold;
}

.wc-edit-indicator:hover {
    background: #1976D2;
    transform: scale(1.05);
}

.wc-edit-indicator:active {
    transform: scale(0.95);
}

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

/* Stats Modal */
.game-stats-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2147483647;
    animation: fadeIn 0.3s;
}

.game-stats-content {
    position: relative;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.game-stats-grid {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
}

.game-stat-box {
    flex: 1;
    text-align: center;
}

.game-stat-value {
    font-size: 2em;
    font-weight: bold;
}

.game-stat-label {
    font-size: 0.9em;
    color: #666;
}

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

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .wc-tile {
        width: 56px;
        height: 56px;
        font-size: 1.8em;
        border-width: 2px;
    }
    
    .wc-tile-row {
        gap: 5px;
        margin: 5px 0;
    }
    
    .game-key {
        min-width: 36px;
        height: 52px;
        padding: 0 8px;
        font-size: 1.05em;
    }
    
    .game-key-large {
        min-width: 60px;
        font-size: 0.85em;
        padding: 0 8px;
        background: #8b8d8f;
        height: 54px;
    }
    
    .game-key[data-key="Backspace"] {
        font-size: 2em;
    }
    
    .game-keyboard-row {
        gap: 4px;
        margin: 4px 0;
    }
    
    #wc-message {
        font-size: 1em !important;
        min-height: 25px !important;
    }
}

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

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