/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto Mono', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Game container */
#game {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 1200px;
    width: 95%;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Game title */
.game-title {
    color: white;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Word container */
#word-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    width: 100%;
    height: 300px;
    margin: 2rem auto;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Score and stats display */
.game-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 1rem;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    width: 100%;
    position: relative;
}

/* Ensure left/center/right alignment regardless of content width */
.game-stats .stat-item:nth-child(1) {
    justify-self: start;
}

/* True centering: lock the middle stat to the exact horizontal center */
.game-stats .stat-item:nth-child(2) {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    /* Visually center the label + value so the number sits under the title */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Make the label and value stack cleanly */
.game-stats .stat-item:nth-child(2) span {
    display: block;
}

.game-stats .stat-item:nth-child(3) {
    justify-self: end;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-variant-numeric: tabular-nums;
}

/* Player input display */
#player-input {
    color: #4ecdc4;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem 2rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(78, 205, 196, 0.5);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    margin: 1rem auto;
    display: inline-block;
    min-width: 200px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Word styling */
.word {
    position: absolute;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.word:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* Letter styling within words */
.word span {
    display: inline-block;
    transition: all 0.2s ease;
}

/* Correct letter styling */
.correct {
    color: #4ecdc4;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.8);
    animation: correctPulse 0.3s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Incorrect letter styling */
.incorrect {
    color: #ff6b6b;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
    animation: incorrectShake 0.3s ease;
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* Game over overlay */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.game-over-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    color: white;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.game-over h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #ff6b6b;
}

.game-over p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.restart-btn {
    background: linear-gradient(45deg, #4ecdc4, #45b7d1);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Roboto Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* Particle effects */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #4ecdc4;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    #game {
        padding: 1rem;
        margin: 1rem;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    #word-container {
        height: 250px;
    }
    
    .game-stats {
        grid-template-columns: 1fr;
        justify-items: stretch;
        gap: 0.5rem;
    }

    .game-stats .stat-item:nth-child(1),
    .game-stats .stat-item:nth-child(2),
    .game-stats .stat-item:nth-child(3) {
        position: static;
        transform: none;
        justify-self: stretch;
        text-align: center;
    }
    
    #player-input {
        font-size: 1.2rem;
        padding: 0.8rem 1.5rem;
    }
}

/* Background animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Instructions styling */
.instructions {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-top: 1rem;
    line-height: 1.6;
}

.instructions kbd {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    color: #4ecdc4;
}

/* Word class styling for Word.js */
.word {
    position: absolute;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
}
  