* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

:root {
    --color-correct: #6aaa64;
    --color-present: #c9b458;
    --color-absent: #787c7e;
    --color-background: #ffffff;
    --color-keyboard: #d3d6da;
    --tile-size: 62px;
    --keyboard-height: 200px;
    --leaderboard-width: 350px;
}

body {
    background-color: var(--color-background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

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

header {
    text-align: center;
    padding: 10px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 0.2rem;
}

#help-button {
    position: absolute;
    right: 0;
    padding: 8px 12px;
    background-color: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

#help-button:hover {
    background-color: #f0f0f0;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: calc(100vh - 320px);
    min-height: 500px;
}

#board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    padding: 10px;
    box-sizing: border-box;
    width: calc(5 * var(--tile-size) + 20px);
    margin-bottom: 30px;
}

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

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    border: 2px solid #d3d6da;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    user-select: none;
    transition: transform 0.2s;
}

.tile.filled {
    border-color: #878a8c;
}

.tile.flip {
    transform: rotateX(90deg);
    transition: transform 0.5s;
}

.tile.flip-back {
    transform: rotateX(0deg);
    transition: transform 0.5s;
}

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

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

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

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    10% { transform: translateX(-5px); }
    30% { transform: translateX(5px); }
    50% { transform: translateX(-5px); }
    70% { transform: translateX(5px); }
    90% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.bounce {
    animation: bounce 0.5s;
}

@keyframes bounce {
    0%, 20% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    50% {
        transform: translateY(5px);
    }
    60% {
        transform: translateY(-15px);
    }
    80% {
        transform: translateY(2px);
    }
    100% {
        transform: translateY(0);
    }
}

#keyboard {
    margin-top: auto;
    width: 100%;
    max-width: 500px;
    height: var(--keyboard-height);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

#keyboard button {
    height: 58px;
    flex: 1;
    border-radius: 4px;
    border: none;
    background-color: var(--color-keyboard);
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    color: black;
    transition: background-color 0.3s ease;
}

#keyboard button:hover {
    opacity: 0.9;
}

#keyboard button:active {
    opacity: 0.7;
}

#keyboard button.wide-button {
    flex: 1.5;
    font-size: 0.8rem;
}

.spacer {
    flex: 0.5;
}

#keyboard button.correct {
    background-color: var(--color-correct);
    color: white;
}

#keyboard button.present {
    background-color: var(--color-present);
    color: white;
}

#keyboard button.absent {
    background-color: var(--color-absent);
    color: white;
}

#message {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    z-index: 100;
    animation: fadeOut 1.5s forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

.hidden {
    display: none !important;
}

#game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 23px 0 rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 200;
}

#game-over h2 {
    font-size: 24px;
    margin-bottom: 15px;
}

#game-over p {
    font-size: 18px;
    margin-bottom: 20px;
}

#play-again {
    background-color: var(--color-correct);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#play-again:hover {
    background-color: #5a9955;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 23px 0 rgba(0, 0, 0, 0.2);
}

.close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #777;
}

.close-button:hover {
    color: #333;
}

.instructions {
    display: none;
}

.examples {
    margin-top: 15px;
}

.example {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.example .tile {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    margin-right: 15px;
}

.leaderboard-toggle {
    position: fixed;
    left: 20px;
    top: 20px;
    width: 40px;
    height: 40px;
    background-color: var(--color-correct);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 150;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.leaderboard-toggle:hover {
    transform: scale(1.1);
}

.leaderboard-panel {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--leaderboard-width);
    background-color: white;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 250;
    padding: 20px;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.leaderboard-panel.hidden {
    transform: translateX(-100%);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.close-leaderboard {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #555;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-box {
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 12px 10px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
    background-color: #f0f0f0;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--color-correct);
}

.stat-label {
    font-size: 12px;
    color: #555;
}

.guess-distribution {
    margin-bottom: 30px;
}

.guess-distribution h3 {
    margin-bottom: 15px;
    font-size: 16px;
}

.graph-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    padding: 10px;
    background-color: #f8f8f8;
    border-radius: 8px;
}

.graph-row {
    display: flex;
    align-items: center;
    height: 24px;
}

.graph-label {
    width: 25px;
    font-weight: bold;
    margin-right: 10px;
}

.graph-bar {
    height: 100%;
    background-color: var(--color-absent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: 12px;
    border-radius: 4px;
    transition: width 0.5s ease, background-color 0.3s ease;
}

.graph-bar.highlight {
    background-color: var(--color-correct);
}

.last-played {
    font-size: 14px;
    color: #555;
    margin-top: 20px;
}

.advanced-stats {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.advanced-stats h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #555;
}

.advanced-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.advanced-stat-label {
    color: #555;
}

.advanced-stat-value {
    font-weight: bold;
    color: #333;
}

@media (max-width: 600px) {
    :root {
        --tile-size: 52px;
        --leaderboard-width: 300px;
    }
    
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 28px;
    }
    
    #board {
        width: calc(5 * var(--tile-size) + 20px);
        margin-bottom: 20px;
    }
    
    #keyboard {
        height: auto;
    }
    
    #keyboard button {
        height: 50px;
        font-size: 0.9rem;
    }
    
    #help-button {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .example .tile {
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
    }
    
    .leaderboard-toggle {
        width: 35px;
        height: 35px;
        left: 10px;
        top: 10px;
    }
    
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-value {
        font-size: 22px;
    }
}