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

body {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background: #121213;
    color: #d7dadc;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.menu {
    text-align: center;
    max-width: 400px;
    width: 100%;
    padding: 40px;
}

.menu h1 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 0.3rem;
    margin-bottom: 10px;
}

.menu p {
    font-size: 16px;
    color: #818384;
    margin-bottom: 40px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    background: #538d4e;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-btn:hover {
    background: #6aaa64;
}

.join-input-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.join-input-container input {
    padding: 12px;
    font-size: 16px;
    background: #3a3a3c;
    border: 2px solid #565758;
    border-radius: 4px;
    color: #d7dadc;
    text-align: center;
    text-transform: uppercase;
}

.join-input-container input:focus {
    outline: none;
    border-color: #818384;
}

.container {
    max-width: 500px;
    width: 100%;
    height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

header {
    text-align: center;
    padding: 10px 0;
    border-bottom: 1px solid #3a3a3c;
    width: 100%;
    flex-shrink: 0;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.leave-btn {
    padding: 6px 12px;
    font-size: 13px;
    background: transparent;
    color: #818384;
    border: 1px solid #3a3a3c;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.leave-btn:hover {
    color: #f44336;
    border-color: #f44336;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.2rem;
    color: #d7dadc;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 350px;
    padding: 8px 0;
    font-size: 12px;
    color: #818384;
    flex-shrink: 0;
}

.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    margin: 5px 0;
    flex-shrink: 0;
}

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

.tile {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    border: 2px solid #3a3a3c;
    background: transparent;
    color: #d7dadc;
    user-select: none;
}

.tile.filled {
    border-color: #565758;
    animation: pop 0.1s;
}

.tile.correct {
    background: #538d4e;
    border-color: #538d4e;
}

.tile.present {
    background: #b59f3b;
    border-color: #b59f3b;
}

.tile.absent {
    background: #3a3a3c;
    border-color: #3a3a3c;
}

@keyframes pop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.message {
    text-align: center;
    font-size: 13px;
    min-height: 20px;
    padding: 5px;
    color: #818384;
    flex-shrink: 0;
}

.message.error {
    color: #f44336;
}

.message.success {
    color: #538d4e;
}

.keyboard {
    width: 100%;
    max-width: 500px;
    margin-top: 5px;
    flex-shrink: 0;
}

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

.key {
    min-width: 40px;
    height: 52px;
    background: #818384;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}

.key:hover {
    background: #9a9b9c;
}

.key:active {
    transform: scale(0.95);
}

.key-large {
    min-width: 60px;
    font-size: 11px;
}

.key.correct {
    background: #538d4e;
}

.key.present {
    background: #b59f3b;
}

.key.absent {
    background: #3a3a3c;
}

.stats-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: #818384;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.stats-btn:hover {
    background: #9a9b9c;
}

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

.modal-content {
    background: #121213;
    border: 1px solid #3a3a3c;
    border-radius: 8px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    position: relative;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

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

.close:hover {
    color: #fff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    text-align: center;
}

.stat-item {
    padding: 10px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #538d4e;
}

.stat-label {
    font-size: 12px;
    color: #818384;
    margin-top: 5px;
}

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

.shake {
    animation: shake 0.5s;
}

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

.flip {
    animation: flip 0.5s;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.bounce {
    animation: bounce 0.3s;
}

@media (max-width: 768px) {
    .tile {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .key {
        min-width: 32px;
        height: 48px;
        font-size: 10px;
    }
    
    .key-large {
        min-width: 50px;
    }
}

.game-over-content {
    background: #121213;
    border: 2px solid #538d4e;
    border-radius: 12px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.game-over-content.lost {
    border-color:  #f44336;
}

.game-over-content.draw {
    border-color: #b59f3b;
}

#game-over-icon {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 4px;
    margin-bottom: 20px;
}

#game-over-message {
    font-size: 16px;
    color: #818384;
    margin-bottom: 30px;
}

.game-over-buttons {
    display: flex;
  gap: 15px;
  justify-content: center;
}

.game-over-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    background: #538d4e;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.game-over-btn:hover {
    background: #6aaa54;
}

.game-over-btn.secondary {
    background: #818384;
}

.game-over-btn.secondary:hover {
    background: #9a9b9c;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.leave-btn {
    padding: 6px 12px;
    font-size: 13px;
    background: transparent;
    color: #818384;
    border: 1px solid #3a3a3c;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.leave-btn:hover {
    color: #f44336;
    border-color: #f44336;
}

.game-over-content.draw {
    border-color: #b59f3b;
}


.sound-toggle-btn {
    position: fixed;
    top: 20px;
    right: 90px;
    padding: 10px 16px;
    background: #3a3a3c;
    color: #d7dadc;
    border: 1px solid #565758;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.sound-toggle-btn:hover {
    background: #565758;
}

.sound-toggle-btn.muted {
    color: #f44336;
    border-color: #f44336;
}


#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px #538d4e;
    }
    50% {
        box-shadow: 0 0 25px #538d4e, 0 0 50px #538d4e;
    }
}

.glow {
    animation: glow 1s ease-in-out 3;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity : 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes tilePopIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    70% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tile-pop {
    animation: tilePopIn 0.3s ease-out;
}