/* Modern CSS Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Variables */
    --primary-bg: #1a1a1a;
    --secondary-bg: #2c3e50;
    --tile-bg: #34495e;
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --correct-color: #27ae60;
    --present-color: #f39c12;
    --absent-color: #e74c3c;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    
    /* Animation Timings */
    --flip-duration: 0.6s;
    --shake-duration: 0.6s;
    --pop-duration: 0.1s;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    background-color: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Container with Glass Morphism */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(44, 62, 80, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Enhanced Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.game-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--accent-color), var(--correct-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.username {
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

/* Game Board Enhancements */
.game-container {
    background-color: var(--secondary-bg);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.game-board {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 2rem auto;
    max-width: 350px;
}

.row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Enhanced Tile Animations */
.tile {
    width: 62px;
    height: 62px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    border-radius: 8px;
    background-color: var(--tile-bg);
    color: var(--text-primary);
    transition: transform var(--pop-duration) ease;
    backface-visibility: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
}

/* Tile States with 3D Flip Animation */
.tile.correct {
    background-color: var(--correct-color);
    animation: flipIn var(--flip-duration) ease forwards;
    border-color: rgba(255, 255, 255, 0.2);
}

.tile.present {
    background-color: var(--present-color);
    animation: flipIn var(--flip-duration) ease forwards;
    border-color: rgba(255, 255, 255, 0.2);
}

.tile.absent {
    background-color: var(--absent-color);
    animation: flipIn var(--flip-duration) ease forwards;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Virtual Keyboard Styling */
.keyboard {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key {
    min-width: 40px;
    height: 58px;
    border: none;
    border-radius: 6px;
    background-color: var(--tile-bg);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    padding: 0 8px;
}

.key:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.key:active {
    transform: translateY(0);
}

.key.correct { background-color: var(--correct-color); }
.key.present { background-color: var(--present-color); }
.key.absent { background-color: var(--absent-color); }

/* Enhanced Input Form */
.guess-form {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.guess-input {
    width: 200px;
    padding: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 1.25rem;
    text-transform: uppercase;
    text-align: center;
    background-color: rgba(52, 73, 94, 0.5);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.guess-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.2);
    background-color: rgba(52, 73, 94, 0.8);
}

/* Modern Button Styles */
.btn {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background-color: rgba(149, 165, 166, 0.8);
    color: white;
}

.btn-secondary:hover {
    background-color: rgba(127, 140, 141, 0.9);
    transform: translateY(-2px);
}

/* Game Over Screen Enhancement */
.game-over {
    text-align: center;
    margin-top: 2rem;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease;
}

.game-over p {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-bottom: 2rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Animations */
@keyframes flipIn {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Toast Messages */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
    z-index: 1000;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .keyboard {
        padding: 0.5rem;
    }

    .key {
        min-width: 32px;
        height: 48px;
        font-size: 0.875rem;
    }

    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        flex-direction: column;
        width: 100%;
    }

    .guess-form {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-bg: #121212;
        --secondary-bg: #1e1e1e;
        --tile-bg: #2d2d2d;
    }
}