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

body {
    font-family: 'Trebuchet MS', Verdana, sans-serif;
    background-color: #1b1f27;
    color: #f2ede4;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 600px;
    background-color: #262b36;
    border: 2px solid #3d4453;
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

h1 {
    text-align: center;
    color: #e8b84b;
    font-size: 2rem;
    margin-bottom: 25px;
    letter-spacing: 1px;
}

h2 {
    color: #e8b84b;
    margin-bottom: 15px;
    border-bottom: 1px solid #3d4453;
    padding-bottom: 8px;
}

.record-display {
    font-size: 1rem;
    color: #7dd3fc;
    text-align: center;
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

.game-settings label {
    display: block;
    margin-top: 15px;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: #c9c3b6;
}

#error-message {
    color: #d97757;
    font-weight: bold;
    margin-top: 8px;
    min-height: 20px;
}

.game-settings select,
.game-settings input {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #3d4453;
    background-color: #1b1f27;
    color: #f2ede4;
    font-size: 1rem;
}

.game-settings select:focus,
.game-settings input:focus {
    outline: 2px solid #e8b84b;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 1rem;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

#hint-button {
    padding: 0px 10px;
    margin-top: 10px;
    color: red;
}

#start-game,
#restart-game,
#play-again {
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    background-color: #e8b84b;
    color: #1b1f27;
}

#start-game:hover,
#restart-game:hover,
#play-again:hover {
    background-color: #f5cb6b;
    transform: translateY(-2px);
}

#close-game {
    margin-top: 10px;
    width: 100%;
    padding: 12px;
    background-color: transparent;
    color: #d97757;
    border: 1px solid #d97757;
}

#close-game:hover {
    background-color: #d97757;
    color: #1b1f27;
}

.game-container {
    text-align: center;
}

.hangman-img {
    display: block;
    width: 200px;
    height: 220px;
    margin: 15px auto;
}

/* Wrong letters animation - screen shake effect */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px); }
    20% { transform: translateX(8px); }
    30% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

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

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0); }
    50% { box-shadow: 0 0 20px 8px rgba(217, 119, 87, 0.6); }
}

.hangman-wrong {
    animation: shake 0.5s ease-in-out, pulse-red 0.5s ease-in-out;
    filter: brightness(1.2) saturate(1.3);
}

/*Hangman image pop when stage advances */
@keyframes pop-in {
    0% { transform: scale(1.05) rotate(-3deg);}
    30% { transform: scale(1.1) rotate(3deg);}
    60% { transform: scale(1.2) rotate(-3deg);}
    80% { transform: scale(1.1) rotate(3deg);}
    100% { transform: scale(1) rotate(0deg);}
}
.hangman-pop {
    animation: pop-in 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
/* Correct letter guessed - green glow */
@keyframes glow-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
    50% { box-shadow: 0 0 15px 6px rgba(46, 204, 113, 0.5); }
}

.letter-correct {
    animation: glow-green 0.6s ease-in-out;
}
/* Word display bounce on correct guess */
@keyframes bounce-word {
    0% { transform: scale(1); }
    25% { transform: scale(1.5); }
    50% { transform: scale(1.25); }
    75% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.word-bounce {
    animation: bounce-word 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

}
/* Win animation - confetti celebration*/
@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes win-bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-15px); }
    75% { transform: translateY(-8px); }
}

.confetti-piece {
    position: fixed;
    top: -30px;
    width: 14px;
    height: 14px;
    z-index: 1000;
    pointer-events: none;
    animation: confetti-fall 2.5s ease-in forwards;
}

.win-celebration {
    animation: win-bounce 0.6s ease-in-out 3;
}

/* Lose animation */
@keyframes fade-red {
    0% { background-color: transparent; }
    30% { background-color: rgba(217, 87, 87, 0.3); }
    100% { background-color: transparent; }
}

@keyframes skull-bounce {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.4); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.lose-flash {
    animation: fade-red 1s ease-out;
}

.hangman-dead {
    animation: skull-bounce 0.6s ease-in-out;
}

/* Game message animations */
@keyframes flash-message {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.message-flash {
    animation: flash-message 0.8s ease-in-out 2;
}

/* Letter button press animation */
@keyframes btn-pop {
    0% { transform: scale(1); }
    50% { transform: scale(0.85); }
    100% { transform: scale(1); }
}

.letter-btn:active {
    animation: btn-pop 0.15s ease-in-out;
}

/* Wrong letter buttons turn red */ 
.letter-btn.wrong-guess {
    background-color: #d97757 !important;
    color: #1b1f27 !important;
}

.letter-btn.correct-guess {
    background-color: #2ecc71 !important;
    color: #1b1f27 !important;
}


#word-display {
    font-family: 'Courier New', monospace;
    font-size: 1.8rem;
    letter-spacing: 10px;
    margin: 15px 0;
    color: #f2ede4;
}

#lives-display {
    font-size: 1.1rem;
    color: #e8b84b;
    margin-bottom: 10px;
}

#timer-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e8b84b;
    margin-bottom:10px;}

.timer-urgent {
    color:#d97757 !important;
    animation:pulse-red 0.5s ease-in-out infinite;
}

#wrong-letters {
    color: #d97757;
    font-weight: bold;
}

#game-message {
    min-height: 24px;
    margin: 10px 0;
    font-weight: bold;
    color: #e8b84b;
}

#letter-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 20px 0;
}

#letter-buttons button {
    background-color: #3d4453;
    color: #f2ede4;
}

#letter-buttons button:hover {
    background-color: #e8b84b;
    color: #1b1f27;
}

#letter-buttons button:disabled {
    background-color: #262b36;
    color: #5a6272;
    cursor: not-allowed;
}

.game-over {
    text-align: center;
}

#final-message {
    font-size: 1.2rem;
    margin: 15px 0;
    color: #e8b84b;
}

#letter-buttons {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    gap: 5px;
    margin: 0 auto;
    max-width: 450px;    
}

#letter-buttons button {
    grid-column: span 2;
    padding: 10px 0;
    background-color: #3d4453;
    color: #f2ede4;
    font-size: 18px;
    border-radius: 6px;
    text-transform: uppercase;
}

#letter-buttons button:hover {
    background-color: #e8b84b;
    color: #1b1f27;
    transform: translateY(-2px);
}

#letter-buttons button:disabled {
    background-color: #262b36;
    color: #5a6272;
    transform: none;
    cursor: not-allowed;
}
#letter-buttons .letter-btn:nth-child(11) {
    grid-column: 2 / span 2;
}
#letter-buttons .letter-btn:nth-child(20) {
    grid-column: 4 / span 2;
}
#letter-buttons .letter-btn:nth-child(27) {
    grid-column: 5 / span 2;
}
#letter-buttons .letter-btn:nth-child(33) {
    grid-column: 6 / span 10;
}
