:root {
    --primary-bg-color: #f0f0f0;
    --secondary-bg-color: #cccccc;
    --primary-text-color: #333;
    --button-color: #333;
    --button-hover-color: #555;
    --button-active-color: #111;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --hangman-primary: #000000;
    --hangman-secondary: #f50057;
}

[data-theme="dark"] {
    --primary-bg-color: #1a1a1a;
    --secondary-bg-color: #2d2d2d;
    --primary-text-color: #ffffff;
    --card-bg: #333333;
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    --hangman-primary: #ffffff;
    --hangman-secondary: #ff4081;
}

.theme-toggle, .difficulty-toggle {
    color: white;
    background-color: var(--button-color);
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    will-change: transform, background-color;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

.difficulty-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
}

.theme-toggle:hover, .difficulty-toggle:hover {
    background-color: var(--button-hover-color);
    transform: translateY(-3px);
}

.theme-toggle:active, .difficulty-toggle:active {
    background-color: var(--button-active-color);
    transform: translateY(0);
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    background: linear-gradient(to bottom right, var(--primary-bg-color), var(--secondary-bg-color));
    font-family: 'Roboto', sans-serif;
    color: var(--primary-text-color);
    transition: background-color 0.3s ease;
    min-height: 100vh;
    overflow: hidden;
    margin: 0;
}

.container {
    max-width: 1000px;
    margin: 0.25rem auto;
    padding: 0 0.5rem;
    height: calc(100vh - 0.5rem);
    display: flex;
    flex-direction: column;
}

h1 {
    color: var(--hangman-primary);
    font-size: clamp(1.2rem, 3vw, 2rem);
    text-align: center;
    margin: 0;
}

.subtitle {
    color: var(--primary-text-color);
    text-align: center;
    margin: 0.25rem 0;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
}

.game-container {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    padding: 0.75rem;
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
    max-height: calc(80vh - 8rem);
}

.game-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.hangman-svg {
    width: 100%;
    max-width: 250px;
    height: auto;
    max-height: 28vh;
}

.word-display {
    font-size: clamp(1.5rem, 3.5vw, 2.5rem);
    font-family: 'Courier New', monospace;
    letter-spacing: 4px;
    margin: 0.5rem 0;
    min-height: 30px;
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 0.25rem;
    margin: 0.3rem 0;
}

.key {
    color: white;
    background-color: var(--button-color);
    border: none;
    padding: 8px;
    font-size: 0.9rem;
    min-width: 28px;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.key:hover {
    background-color: var(--button-hover-color);
    transform: translateY(-3px);
}

.key:active {
    background-color: var(--button-active-color);
    transform: translateY(0);
}

.key:disabled {
    background-color: #000000;
    transform: none;
    cursor: not-allowed;
    opacity: 0.7;
}

.guessed-letters {
    margin: 0.15rem 0;
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    color: var(--primary-text-color);
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin: 0.15rem 0;
    font-size: clamp(0.8rem, 2vw, 1.1rem);
}

.message {
    min-height: 20px;
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    margin: 0.15rem 0;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

footer {
    position: fixed;
    bottom: 15px;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 100;
    padding: 5px;
}

footer a {
    color: var(--primary-text-color);
    text-decoration: underline;
    font-size: 0.9rem;
}

footer a:hover {
    color: var(--button-hover-color);
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
        padding: 10px 5px;
    }

    .container {
        height: auto;
        min-height: calc(100vh - 2rem);
        margin-bottom: 50px;
    }

    .game-container {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
        max-height: none;
        height: auto;
        margin-bottom: 3rem;
    }

    .hangman-svg {
        max-height: 20vh;
        margin: 0 auto;
    }

    .theme-toggle, .difficulty-toggle {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .keyboard {
        grid-template-columns: repeat(9, 1fr);
        gap: 0.15rem;
    }

    .key {
        padding: 10px;
        font-size: 1rem;
    }

    .word-display {
        font-size: clamp(1.2rem, 4vw, 1.8rem);
    }

    h1 {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
        margin-top: 2.5rem;
    }

    footer {
        position: static;
        margin-top: 20px;
        padding: 10px;
    }

    .game-container {
        margin-bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .keyboard {
        grid-template-columns: repeat(7, 1fr);
    }

    .key {
        padding: 8px;
        font-size: 0.9rem;
    }

    .game-info, .guessed-letters, .message {
        font-size: 0.8rem;
    }
}

@media (min-width: 1200px) {
    .game-container {
        max-width: 1100px;
        margin: 0 auto;
    }

    .key {
        padding: 10px;
        font-size: 1rem;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .game-container {
        grid-template-columns: 0.6fr 1.4fr;
    }

    .hangman-svg {
        max-height: 18vh;
    }

    .keyboard {
        grid-template-columns: repeat(13, 1fr);
        gap: 0.1rem;
    }

    .key {
        padding: 4px;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .hangman-svg {
        max-height: 25vh;
    }
}

#restartButton {
    padding: 6px;
    margin-top: 0.1rem;
    width: auto !important;
    min-width: 100px;
    align-self: center;
    font-size: 0.75rem;
}
