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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.back-link {
    align-self: flex-start;
    color: #4ecca3;
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.back-link:hover {
    text-decoration: underline;
}

h1 {
    color: #4ecca3;
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.game-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Game Board */
#game-board {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 1rem 0;
}

.row {
    display: flex;
    gap: 5px;
}

.tile {
    width: 58px;
    height: 58px;
    border: 2px solid #3a3a5c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    background: transparent;
    transition: transform 0.1s;
}

.tile.filled {
    border-color: #5a5a7c;
    animation: pop 0.1s ease;
}

.tile.flip {
    animation: flip 0.5s ease forwards;
}

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

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

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

@keyframes pop {
    50% { transform: scale(1.1); }
}

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

.row.shake {
    animation: shake 0.5s ease;
}

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

/* Message */
#message {
    min-height: 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: #4ecca3;
    opacity: 0;
    transition: opacity 0.3s;
}

#message.show {
    opacity: 1;
}

/* Keyboard */
#keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
    padding-bottom: 1rem;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.key {
    min-width: 30px;
    height: 50px;
    padding: 0 8px;
    border: none;
    border-radius: 4px;
    background: #818384;
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
    text-transform: uppercase;
}

.key:hover {
    background: #a0a0a0;
}

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

.key.wide {
    min-width: 55px;
    font-size: 0.75rem;
}

.key.ready {
    background: #4ecca3;
    color: #1a1a2e;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 10px #4ecca3; }
}

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

.key.present {
    background: #b59f3b;
}

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

/* Game Buttons */
.game-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

#new-game-btn,
.share-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s, transform 0.1s;
}

#new-game-btn:hover,
.share-btn:hover {
    background: #3db892;
}

#new-game-btn:active,
.share-btn:active {
    transform: scale(0.98);
}

.share-btn {
    background: #2a9d8f;
}

.share-btn:hover {
    background: #248c7f;
}

.share-btn.hidden {
    display: none;
}

/* Content section */
.content {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 1rem 2rem;
    line-height: 1.7;
}

.content h2 {
    color: #4ecca3;
    margin: 1.5rem 0 0.75rem;
    font-size: 1.3rem;
}

.content p {
    margin-bottom: 1rem;
    color: #c0c0c0;
}

.content ul {
    margin: 0.5rem 0 1rem 1.5rem;
    color: #c0c0c0;
}

.content li {
    margin-bottom: 0.3rem;
}

.color-example {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 5px;
}

.color-example.green { background: #538d4e; }
.color-example.yellow { background: #b59f3b; }
.color-example.gray { background: #3a3a4c; }

/* Related games */
.related-games {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #3a3a5c;
}

.related-games h3 {
    color: #4ecca3;
    margin-bottom: 1rem;
}

.game-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.game-links a {
    padding: 0.5rem 1rem;
    background: #2a2a4a;
    color: #4ecca3;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s;
}

.game-links a:hover {
    background: #3a3a5a;
}

/* Mobile adjustments */
@media (max-width: 400px) {
    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }

    .key {
        min-width: 26px;
        height: 45px;
        padding: 0 5px;
        font-size: 0.8rem;
    }

    .key.wide {
        min-width: 45px;
        font-size: 0.65rem;
    }
}

@media (max-width: 350px) {
    .tile {
        width: 44px;
        height: 44px;
        font-size: 1.4rem;
    }
}
