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

:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --border-color: rgba(255, 255, 255, 0.2);
    --cell-bg: rgba(255, 255, 255, 0.05);
    --cell-border: rgba(255, 255, 255, 0.3);
    --correct-color: #6aaa64;
    --wrong-color: #c9b458;
    --error-color: #787c7e;
    --gold-color: #f7da21;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    border-radius: 16px;
}

/* Header */
.header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-color);
    text-align: center;
}

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

.level-info {
    width: 100%;
    display: flex;
    justify-content: center;
}

.lives-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.lives-label {
    color: var(--text-color);
}

.lives-container {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.heart {
    font-size: 1.2rem;
    display: inline-block;
    transition: all 0.3s ease;
}

#level-select {
    background: var(--cell-bg);
    border: 2px solid var(--cell-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    cursor: not-allowed;
    outline: none;
    appearance: none;
    transition: all 0.2s ease;
}

#level-select:focus {
    border-color: rgba(255, 255, 255, 0.5);
}

/* Game Status */
.game-status {
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
    min-height: 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    transition: opacity 0.2s ease;
}

/* Action Buttons Container */
.action-buttons {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Grid Container */
.grid-container {
    display: grid;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1;
    padding: 0.75rem;
    border-radius: 16px;
}

/* Grid Cells */
.grid-cell {
    aspect-ratio: 1;
    background-color: var(--cell-bg);
    border: 2px solid var(--cell-border);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.grid-cell:hover:not(.revealed) {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.02);
}

.grid-cell:active:not(.revealed) {
    transform: scale(0.98);
}

/* Revealed State */
.grid-cell.revealed {
    cursor: default;
    pointer-events: none; 
    animation: flip 0.4s ease-in-out;
}

@keyframes flip {
    0% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(90deg) scale(0.95);
    }
    100% {
        transform: rotateY(0deg) scale(1);
    }
}

/* Ball Found - Green (like Wordle correct) */
.grid-cell[data-ball="true"] {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
    color: white;
    border-radius: 12px;
    animation: flip 0.4s ease-in-out, bounce 0.5s ease 0.4s;
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Wrong Cell - Gray (like Wordle absent) */
.grid-cell[data-wrong="true"] {
    background-color: var(--error-color);
    border-color: var(--error-color);
    color: white;
    border-radius: 12px;
    animation: flip 0.4s ease-in-out;
}

/* Restart Button */
.restart-button {
    background-color: var(--correct-color);
    border: 2px solid var(--correct-color);
    border-radius: 12px;
    padding: 0.75rem 2rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(106, 170, 100, 0.3);
}

.restart-button:hover {
    background-color: #5a9a54;
    border-color: #5a9a54;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 170, 100, 0.4);
}

.restart-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(106, 170, 100, 0.3);
}

/* Retry Button */
.retry-button {
    background-color: var(--error-color);
    border: 2px solid var(--error-color);
    border-radius: 12px;
    padding: 0.75rem 2rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(120, 124, 126, 0.3);
}

.retry-button:hover {
    background-color: #5a5d5f;
    border-color: #5a5d5f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(120, 124, 126, 0.4);
}

.retry-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(120, 124, 126, 0.3);
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        gap: 1.5rem;
        padding: 0.5rem;
    }
    
    .auth-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .header-info {
        gap: 0.75rem;
    }
    
    .lives-display {
        font-size: 0.85rem;
    }
    
    .heart {
        font-size: 1rem;
    }
    
    .grid-container {
        gap: 0.4rem;
        padding: 0.4rem;
    }
    
    .grid-cell {
        font-size: 1.5rem;
    }
    
    .game-status {
        font-size: 0.9rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .restart-button,
    .retry-button {
        width: 100%;
    }
    
    .auth-form h2 {
        font-size: 1.25rem;
    }
    
    .user-info {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .logout-button {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .grid-cell {
        font-size: 1.2rem;
    }
}

/* Smooth transitions for all interactive elements */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fade in animation for restart button */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auth Container */
.auth-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.auth-tab:hover {
    color: rgba(255, 255, 255, 0.8);
}

.auth-tab.active {
    border-bottom-color: var(--correct-color);
    color: var(--correct-color);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--cell-bg);
    border: 2px solid var(--cell-border);
    border-radius: 8px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus {
    border-color: var(--correct-color);
    background: rgba(255, 255, 255, 0.08);
}

.error-message {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    min-height: 1.2rem;
    text-align: center;
}

.auth-button {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--correct-color);
    border: 2px solid var(--correct-color);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.auth-button:hover {
    background: #5a9a54;
    border-color: #5a9a54;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 170, 100, 0.4);
}

.auth-button:active {
    transform: translateY(0);
}

/* User Info */
.user-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

#username-display {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

.logout-button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 2px solid var(--error-color);
    border-radius: 8px;
    color: var(--error-color);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.logout-button:hover {
    background: var(--error-color);
    color: white;
    transform: translateY(-2px);
}

.logout-button:active {
    transform: translateY(0);
}
