* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 10px;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.game-container {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

.header {
    text-align: center;
    border-bottom: 2px solid #ddd;
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header h1 {
    font-size: 2.5em;
    color: #667eea;
    font-weight: bold;
    letter-spacing: 2px;
    flex: 1;
    margin: 0;
}

.header-stats {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.stat-display {
    text-align: center;
    min-width: 80px;
}

.stat-display .stat-label {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-display .stat-value {
    font-size: 1.5em;
    color: #667eea;
    font-weight: bold;
}

.game-board {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 20px 0;
}

.row {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.tile {
    width: 62px;
    height: 62px;
    border: 2px solid #d3d6da;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: bold;
    text-transform: uppercase;
    background: white;
    transition: all 0.3s ease;
}

.tile.filled {
    border-color: #878a8c;
    animation: pop 0.1s ease-in-out;
}

.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.flip {
    animation: flip 0.5s ease-in-out;
}

@keyframes pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes flip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(180deg); }
    100% { transform: rotateX(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.key {
    background: #d3d6da;
    border: none;
    border-radius: 4px;
    padding: 15px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    min-width: 43px;
    transition: background 0.2s;
    text-transform: uppercase;
}

.key:hover {
    background: #bbb;
}

.key:active {
    transform: scale(0.95);
}

.key.wide {
    min-width: 65px;
    font-size: 0.8em;
}

.key.correct {
    background: #6aaa64;
    color: white;
}

.key.present {
    background: #c9b458;
    color: white;
}

.key.absent {
    background: #787c7e;
    color: white;
}

.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.instructions-overlay.show {
    display: flex;
}

.instructions-content {
    background: white;
    padding: 20px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.instructions-content h2 {
    color: #667eea;
    margin: 0 0 15px 0;
    font-size: 1.8em;
    text-align: center;
}

.instructions-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.instructions-section:last-of-type {
    border-bottom: none;
}

.instructions-section h3 {
    color: #764ba2;
    margin: 0 0 6px 0;
    font-size: 1em;
}

.instructions-section p {
    margin: 6px 0;
    line-height: 1.4;
    color: #333;
    font-size: 0.95em;
}

.instructions-section ul {
    margin: 6px 0;
    padding-left: 18px;
}

.instructions-section li {
    margin: 4px 0;
    line-height: 1.4;
    color: #333;
    font-size: 0.95em;
}

.tile-correct {
    color: #6aaa64;
    font-size: 1.2em;
    margin-right: 8px;
}

.tile-present {
    color: #c9b458;
    font-size: 1.2em;
    margin-right: 8px;
}

.tile-absent {
    color: #787c7e;
    font-size: 1.2em;
    margin-right: 8px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.play-btn {
    width: 100%;
    background: #667eea;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 12px;
}

.play-btn:hover {
    background: #5568d3;
}

.message {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.message.show {
    opacity: 1;
}

.stats-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.stats-overlay.show {
    display: flex;
}

.stats-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.stats-content h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.button {
    background: #667eea;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

.button:hover {
    background: #5568d3;
}

.answer-reveal {
    margin: 15px 0;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: 1.2em;
}

.answer-word {
    font-weight: bold;
    color: #667eea;
    font-size: 1.5em;
}

@media (max-width: 500px) {
    .game-container {
        padding: 15px;
    }

    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.5em;
    }

    .header h1 {
        font-size: 2em;
    }

    .header-stats {
        gap: 10px;
    }

    .stat-display {
        min-width: 60px;
    }

    .stat-display .stat-label {
        font-size: 0.75em;
    }

    .stat-display .stat-value {
        font-size: 1.2em;
    }

    .keyboard {
        padding: 0 6px;
        gap: 5px;
    }

    .keyboard-row {
        gap: 4px;
    }

    .key {
        padding: 9px;
        font-size: 0.88em;
        min-width: 32px;
    }

    .key.wide {
        min-width: 47px;
        font-size: 0.67em;
    }
}

.hints-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 2px 0;
    min-height: 30px;
}

.hint-label {
    background: #f0f0f0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 500;
    color: #333;
    border-left: 4px solid #667eea;
    visibility: hidden;
    height: 30px;
    display: flex;
    align-items: center;
}

.hint-label.pos-label {
    border-left-color: #667eea;
}

.hint-label.text-label {
    border-left-color: #764ba2;
}

.hint-label.visible {
    visibility: visible;
}

.hint-button-row {
    position: absolute;
    top: 103px;
    right: 20px;
    transform: translateY(-50%);
}

.hint-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.75em;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    text-transform: uppercase;
    white-space: nowrap;
    display: none;
    height: 30px;
    margin-top: 35px;
}

.hint-btn:hover {
    background: #5568d3;
}

.hint-btn:active {
    transform: scale(0.95);
}

.hint-btn.visible {
    display: block;
}