:root {
    --primary-color: #3a3a3c;
    --secondary-color: #818384;
    --correct-color: #538d4e;
    --present-color: #b59f3b;
    --absent-color: #3a3a3c;
    --background-color: #121213;
    --text-color: #ffffff;
    --border-color: #3a3a3c;
    --tile-size: 62px;
    --key-height: 58px;
    --key-gap: 6px;
    --tile-gap: 6px;
    --flash-color: #ffcc00;
    --shift-duration: 0.5s;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2ecc71;
    transition: color 0.3s;
}

.timer.warning {
    color: #e74c3c;
    animation: pulse 1s infinite;
}

.timer.critical {
    color: #ff0000;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.message {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 5px;
    min-height: 2.5rem;
}

.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: var(--tile-gap);
    width: calc(5 * var(--tile-size) + 4 * var(--tile-gap));
    height: calc(6 * var(--tile-size) + 5 * var(--tile-gap));
    margin: 0 auto 1rem;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--tile-gap);
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    background-color: #f8f9fa;
    border: 2px solid #d3d6da;
    border-radius: 5px;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.tile.correct {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
}

.tile.present {
    background-color: var(--present-color);
    border-color: var(--present-color);
    color: white;
}

.tile.absent {
    background-color: var(--absent-color);
    border-color: var(--absent-color);
    color: white;
}

.word-change-flash {
    animation: flash var(--shift-duration) ease 2;
}

@keyframes flash {
    0%, 100% { background-color: transparent; }
    50% { background-color: var(--flash-color); }
}

.tile.shifting {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

.word-change-message {
    animation: pulse 1.5s ease infinite;
    font-weight: bold;
    color: #e74c3c;
}

.keyboard {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: var(--key-gap);
}

.key {
    height: var(--key-height);
    min-width: 2rem;
    font-size: 1rem;
    font-weight: bold;
    background-color: #d3d6da;
    color: #1a1a1a;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 0.5rem;
}

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

.key[data-key="ENTER"],
.key[data-key="BACKSPACE"] {
    padding: 0 0.5rem;
    font-size: 0.9rem;
    min-width: 3.5rem;
}

.key[data-key="ENTER"] {
    background-color: var(--correct-color);
    color: white;
}

.key[data-key="BACKSPACE"] {
    background-color: var(--absent-color);
    color: white;
}

.key.correct {
    background-color: var(--correct-color) !important;
    color: white !important;
}

.key.present {
    background-color: var(--present-color) !important;
    color: white !important;
}

.key.absent {
    background-color: var(--absent-color) !important;
    color: white !important;
}

.rules {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.rules h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.rules ul {
    list-style-type: none;
}

.rules li {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

button {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

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

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.modal p {
    margin-bottom: 20px;
}

.word-change-notice {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 100;
    animation: fadeInOut 2.5s ease;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.word-change-icon {
    font-size: 2rem;
    animation: spin 1s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rules-list {
    text-align: left;
    margin: 20px 0;
}

.rules-list h3 {
    color: #2c3e50;
    margin: 15px 0 10px;
    font-size: 1.2rem;
}

.rules-list ul {
    list-style-type: none;
    padding-left: 20px;
}

.rules-list li {
    margin: 8px 0;
    position: relative;
    padding-left: 25px;
}

.rules-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #2c3e50;
}

#start-game-from-rules {
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

#start-game-from-rules:hover {
    background-color: #27ae60;
}

@media (max-width: 600px) {
    :root {
        --tile-size: 50px;
        --key-height: 46px;
    }

    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .tile {
        font-size: 1.5rem;
    }

    .game-info {
        flex-direction: column;
        gap: 1rem;
    }

    .stats {
        width: 100%;
        justify-content: space-around;
    }

    .key {
        padding: 0 0.3rem;
        min-width: 1.5rem;
        font-size: 0.9rem;
        height: var(--key-height);
    }
    
    .key[data-key="ENTER"],
    .key[data-key="BACKSPACE"] {
        padding: 0 0.3rem;
        font-size: 0.8rem;
        min-width: 2.5rem;
    }
}