:root {
    --bg: #f2f2f2;
    --fg: #000;
    --tile-bg: #ffffff;
    --tile-border: #ccc;
    --key-bg: #ddd;
    --key-bg-active: #bbb;
}

.dark {
    --bg: #121213;
    --fg: #ffffff;
    --tile-bg: #121213;
    --tile-border: #3a3a3c;
    --key-bg: #3a3a3c;
    --key-bg-active: #565758;
}

/* Base layout */
body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

h1 {
    margin-top: 20px;
    font-size: clamp(22px, 6vw, 36px);
}

#stats {
    margin-top: 10px;
    font-size: clamp(12px, 3.5vw, 16px);
}

#board, #keyboard, h1, #stats, #message {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Burger menu */
#menuContainer {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 44px;
    height: 44px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#burger {
    font-size: 28px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--tile-bg);
    border: 2px solid var(--tile-border);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#menuPanel {
    display: none;
    flex-direction: column;
    background: var(--tile-bg);
    border: 2px solid var(--tile-border);
    padding: 10px;
    margin-top: 8px;
    border-radius: 6px;
    min-width: 160px;
}

#menuPanel button {
    margin: 6px 0;
    font-size: 14px;
    padding: 8px 12px;
}

/* Board */
#board {
    margin-top: 20px;
    width: 100%;
    max-width: 350px;
}

.row {
    display: flex;
    justify-content: center;
    margin: 6px 0;
}

.tile {
    width: clamp(40px, 12vw, 55px);
    height: clamp(40px, 12vw, 55px);
    border: 2px solid var(--tile-border);
    margin: 4px;
    font-size: clamp(20px, 6vw, 28px);
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    background: var(--tile-bg);
    transition: background 0.3s, transform 0.2s, border-color 0.3s;
}

/* Flip animation */
.flip {
    animation: flip 0.5s ease forwards;
}

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

/* Tile colors */
.correct { background: #6aaa64 !important; color: white; border-color: #6aaa64; }
.present { background: #c9b458 !important; color: white; border-color: #c9b458; }
.absent { background: #787c7e !important; color: white; border-color: #787c7e; }

/* Keyboard */
#keyboard {
    width: 100%;
    max-width: 500px;
    margin: 20px auto 0 auto;
    padding: 0 8px;
    box-sizing: border-box;
}

.key-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 6px 0;
}

/* All letter keys same size */
.key {
    flex: 1 1 0;
    max-width: 36px;
    min-width: 26px;
    height: 42px;
    background: var(--key-bg);
    border-radius: 6px;
    font-weight: bold;
    color: var(--fg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(14px, 4vw, 18px);
    user-select: none;
    cursor: pointer;
}

.key:active {
    background: var(--key-bg-active);
}

/* ENTER and DEL wider */
.key.special {
    flex: 1.8 1 0;
    max-width: 70px;
}

/* Message & buttons */
#message {
    margin-top: 15px;
    font-size: clamp(14px, 4vw, 18px);
    min-height: 24px;
}

#replayBtn, #shareBtn {
    margin-top: 10px;
    padding: 8px 16px;
    font-size: clamp(12px, 3.5vw, 16px);
}

/* Word info */
#wordInfo {
    margin-top: 20px;
    font-size: clamp(14px, 4vw, 18px);
    padding: 10px;
    line-height: 1.4;
    max-width: 600px;
}

/* Small screens */
@media (max-width: 430px) {
    #keyboard {
        padding-left: 4px;
        padding-right: 4px;
    }
}

/* Laptop / desktop refinement */
@media (min-width: 900px) {
    #keyboard {
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }

    .key {
        max-width: 36px;
        min-width: 36px;
        height: 42px;
        font-size: 16px;
    }

    .key.special {
        max-width: 60px;
        min-width: 60px;
    }
}
