* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #121213;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.container {
    max-width: 500px;
    width: 100%;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 2rem;
    letter-spacing: 0.2em;
    color: #ffffff;
}

.main-menu {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.menu-section {
    background-color: #1a1a1b;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid #3a3a3c;
}

.menu-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #ffffff;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #d7dadc;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.2rem;
    text-align: center;
    text-transform: uppercase;
    background-color: #121213;
    border: 2px solid #3a3a3c;
    border-radius: 4px;
    color: #ffffff;
    letter-spacing: 0.1em;
}

.input-group input:focus {
    outline: none;
    border-color: #565758;
}

.input-group small {
    display: block;
    margin-top: 0.5rem;
    color: #818384;
    font-size: 0.8rem;
}

button {
    background-color: #6aaa64;
    color: #ffffff;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-transform: uppercase;
}

button:hover {
    background-color: #5a9a54;
}

button:active {
    transform: scale(0.98);
}

.game-info {
    margin-bottom: 2rem;
    color: #d7dadc;
}

.game-info p {
    margin: 0.5rem 0;
}

.game-board {
    margin-bottom: 2rem;
    perspective: 1000px;
}

.row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.row.revealed .tile {
    animation: flip 0.6s ease-in;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.tile.shake {
    animation: shake 0.5s ease-in-out !important;
}

.tile {
    width: 62px;
    height: 62px;
    border: 2px solid #3a3a3c;
    background-color: #121213;
    color: #ffffff;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    transition: all 0.15s ease-in;
    animation: pop 0.1s ease-in;
}

.tile.filled {
    border-color: #565758;
    animation: pop 0.1s ease-in;
}

@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.tile.correct {
    background-color: #6aaa64;
    border-color: #6aaa64;
    color: #ffffff;
    animation: flip 0.6s ease-in;
}

.tile.present {
    background-color: #c9b458;
    border-color: #c9b458;
    color: #ffffff;
    animation: flip 0.6s ease-in;
}

.tile.absent {
    background-color: #787c7e;
    border-color: #787c7e;
    color: #ffffff;
    animation: flip 0.6s ease-in;
}

@keyframes flip {
    0% {
        transform: rotateX(0deg);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

.result-message {
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.result-message.success {
    background-color: #6aaa64;
}

.result-message.error {
    background-color: #c9b458;
}

.result-message h2 {
    margin-bottom: 1rem;
}

.keyboard-container {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 500px;
    overflow-x: hidden;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
    width: 100%;
}

.keyboard-row {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
    flex-wrap: nowrap;
    width: 100%;
}

.key {
    background-color: #818384;
    color: #ffffff;
    border: none;
    padding: 1.1rem 0.5rem;
    font-size: 0.85rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 30px;
    flex: 1 1 0;
    text-transform: uppercase;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key:hover {
    background-color: #6e7072;
}

.key:active {
    transform: scale(0.95);
}

.key.correct {
    background-color: #6aaa64 !important;
    animation: keyUpdate 0.3s ease;
}

.key.present {
    background-color: #c9b458 !important;
    animation: keyUpdate 0.3s ease;
}

.key.absent {
    background-color: #787c7e !important;
    animation: keyUpdate 0.3s ease;
}

@keyframes keyUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.key.special {
    background-color: #565758;
    padding: 1.1rem 0.5rem;
    font-size: 0.75rem;
    flex: 1.5 1 0;
    min-width: 50px;
}

.share-link {
    background-color: #1a1a1b;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #3a3a3c;
}

.share-link p {
    margin-bottom: 0.5rem;
    color: #d7dadc;
}

.share-link input {
    width: 100%;
    padding: 0.5rem;
    background-color: #121213;
    border: 1px solid #3a3a3c;
    border-radius: 4px;
    color: #ffffff;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    -webkit-user-select: text;
    user-select: text;
}

.share-link button {
    background-color: #565758;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.back-link {
    display: inline-block;
    color: #818384;
    text-decoration: none;
    margin-top: 1rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #ffffff;
}

@media (max-width: 600px) {
    body {
        padding: 8px;
        align-items: flex-start;
        min-height: 100vh;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    h1 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }
    
    .game-info {
        margin-bottom: 0.75rem;
        font-size: 0.85rem;
    }
    
    .game-board {
        margin-bottom: 0.75rem;
    }
    
    .row {
        gap: 0.3rem;
        margin-bottom: 0.3rem;
    }
    
    .tile {
        width: calc((100vw - 30px) / var(--word-length, 5) - 0.3rem);
        max-width: 55px;
        min-width: 35px;
        height: calc((100vw - 30px) / var(--word-length, 5) - 0.3rem);
        max-height: 55px;
        min-height: 35px;
        font-size: 1.25rem;
        border-width: 1px;
    }
    
    .keyboard-container {
        margin-bottom: 0.75rem;
        width: calc(100% - 8px);
        padding: 0;
    }
    
    .keyboard {
        gap: 0.3rem;
        width: 100%;
    }
    
    .keyboard-row {
        gap: 0.25rem;
        width: 100%;
    }
    
    .key {
        padding: 0 0.25rem;
        font-size: 0.7rem;
        min-width: 0;
        flex: 1 1 0;
        height: 48px;
        min-height: 48px;
    }
    
    .key.special {
        padding: 0 0.35rem;
        font-size: 0.65rem;
        flex: 1.5 1 0;
        min-width: 0;
    }
    
    .share-link {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .share-link input {
        font-size: 0.75rem;
        padding: 0.4rem;
    }
    
    .share-link button {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .result-message {
        padding: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    .result-message h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 400px) {
    .tile {
        font-size: 1.1rem;
    }
    
    .key {
        padding: 0 0.2rem;
        font-size: 0.65rem;
        height: 44px;
        min-height: 44px;
    }
    
    .key.special {
        padding: 0 0.3rem;
        font-size: 0.6rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .keyboard-row {
        gap: 0.2rem;
    }
}

@media (max-width: 360px) {
    .key {
        font-size: 0.6rem;
        height: 42px;
        min-height: 42px;
    }
    
    .key.special {
        font-size: 0.55rem;
    }
    
    .tile {
        font-size: 1rem;
    }
}

