body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
    color: #333;
}

.game-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    text-align: center;
    width: 90%;
    max-width: 500px;
    position: relative;
}

header {
    position: relative;
    padding-bottom: 10px;
    display: flex; /* Flex para alinhar título e botões */
    justify-content: space-between; /* Título à esquerda, botões à direita */
    align-items: center; /* Alinhar verticalmente */
    margin-bottom: 10px;
    width: 100%;
}

header h1 {
    color: #5a5a5a;
    margin: 0;
    font-size: 1.8em;
    text-align: left;
    flex-grow: 1; /* Ocupa espaço disponível, empurrando botões se necessário */
}

.header-buttons {
    display: flex; /* Flex para os botões dentro do contêiner de botões */
    gap: 10px;
    /* margin-left: auto; /* Removido pois space-between no header deve cuidar disso */
}

#help-button, #stats-button {
    padding: 8px 12px;
    font-size: 0.9em;
    color: white;
    background-color: #787c7e;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

#help-button:hover, #stats-button:hover {
    background-color: #686c6e;
}

#game-board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    margin-bottom: 20px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

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

.tile {
    width: 50px;
    height: 50px;
    border: 2px solid #d3d6da;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    background-color: #fff;
    color: #000;
}

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

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

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

#keyboard-area {
    margin-top: 20px;
}

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

.key {
    font-family: inherit;
    font-weight: bold;
    border: 0;
    padding: 0;
    margin: 0 3px;
    height: 50px;
    min-width: 30px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    background-color: #d3d6da;
    color: #000;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    -webkit-tap-highlight-color: rgba(0,0,0,.3);
}

.key.large {
    min-width: 50px;
}

.key.correct {
    background-color: #6aaa64;
    color: white;
}

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

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

#message-area {
    min-height: 24px;
    margin-bottom: 10px;
    font-size: 1.2em;
    color: #888;
}

#new-game-button {
    padding: 10px 20px;
    font-size: 1em;
    color: white;
    background-color: #6aaa64;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 20px;
}

#new-game-button:hover {
    background-color: #5a9a54;
}

.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; /* Mantido alto, mas sem !important */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.6); 
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 90%; 
    max-width: 500px; 
    border-radius: 8px;
    text-align: left;
    position: relative; 
}

.close-button {
    color: #aaa;
    position: absolute; 
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    line-height: 1; 
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-content h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px; 
    color: #333;
}

.modal-content p, .modal-content ul {
    font-size: 1em;
    line-height: 1.6;
    color: #555;
}

.modal-content ul {
    list-style-type: none;
    padding-left: 0;
}

.modal-content li {
    margin-bottom: 10px;
}

.tile-example {
    display: inline-block;
    width: 20px; 
    height: 20px;
    line-height: 20px; 
    text-align: center;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    border: 1px solid #ccc;
    margin-right: 5px;
    vertical-align: middle;
    padding: 2px; 
}

/* Estilos para o Modal de Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    text-align: center;
}

.stat-item .stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #333;
}

.stat-item .stat-label {
    font-size: 0.8em;
    color: #777;
}

.modal-content h3 {
    text-align: center;
    margin-top: 25px;
    margin-bottom: 10px;
    color: #444;
    font-size: 1.2em;
}

.distribution-graph {
    width: 100%;
}

.graph-bar-container {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.graph-label {
    width: 20px; 
    text-align: right;
    margin-right: 5px;
    color: #555;
}

.graph-bar {
    background-color: #6aaa64;
    color: white;
    padding: 3px 5px;
    border-radius: 3px;
    min-width: 20px; 
    text-align: left; 
    transition: width 0.5s ease-in-out;
}

.graph-bar .bar-value {
    font-weight: bold;
}


@media (max-width: 400px) {
    .tile {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    .key {
        height: 40px;
    }
    .key.large {
        min-width: 40px;
    }
    .modal-content {
        margin: 15% auto; 
        width: 90%;
    }
    header h1 {
        font-size: 1.5em;
    }
    #help-button, #stats-button {
        padding: 6px 10px;
        font-size: 0.8em;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr); 
    }
    .stat-item .stat-value {
        font-size: 1.8em;
    }
}

