/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --background: #1a1a2e;
    --surface: #16213e;
    --surface-light: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, var(--surface) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== HEADER ==================== */
.game-header {
    text-align: center;
    padding: 40px 20px;
    animation: fadeInDown 0.6s ease;
}

.game-header h1 {
    font-size: 3.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.tagline {
    font-size: 1.2em;
    color: var(--text-secondary);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* ==================== AUTHENTICATION ==================== */
.auth-container {
    max-width: 500px;
    margin: 40px auto;
    animation: fadeIn 0.8s ease;
}

.auth-box {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.auth-box h2 {
    margin-bottom: 30px;
    text-align: center;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--surface-light);
    background: var(--background);
    color: var(--text-primary);
    border-radius: var(--border-radius);
    font-size: 1em;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.error-message {
    color: var(--danger-color);
    font-size: 0.9em;
    margin-top: 10px;
    min-height: 20px;
}

.switch-form {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.switch-form a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

.switch-form a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    margin-top: 10px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--primary-color);
    color: white;
}

.btn-success:hover {
    background: var(--primary-dark);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
    width: auto;
    margin: 0;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==================== FEATURES SECTION ==================== */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 60px;
    animation: fadeIn 1s ease;
}

.feature {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    transition: var(--transition);
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.feature-icon {
    font-size: 3em;
    display: block;
    margin-bottom: 15px;
}

.feature h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.feature p {
    color: var(--text-secondary);
}

/* ==================== GAME PAGE ==================== */
.game-page {
    background: var(--background);
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.game-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--surface);
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.game-header-bar h1 {
    font-size: 2em;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: var(--primary-color);
    font-weight: bold;
}

/* ==================== GAME MAIN LAYOUT ==================== */
.game-main {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    margin-bottom: 30px;
}

/* ==================== GAME SECTION ==================== */
.game-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.game-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.stat-box {
    background: var(--background);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: var(--primary-color);
}

/* ==================== CANVAS ==================== */
.canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#gameCanvas {
    border: 4px solid var(--primary-color);
    border-radius: var(--border-radius);
    background: var(--background);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius);
}

.overlay-content {
    text-align: center;
    padding: 40px;
}

.overlay-content h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: var(--danger-color);
}

.overlay-content p {
    font-size: 1.5em;
    margin-bottom: 30px;
}

#finalScore {
    color: var(--primary-color);
    font-weight: bold;
}

/* ==================== GAME CONTROLS ==================== */
.game-controls {
    text-align: center;
    margin-top: 20px;
}

.game-controls p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.game-controls button {
    margin: 5px;
}

/* ==================== LEADERBOARD SECTION ==================== */
.leaderboard-section {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.leaderboard-section h2 {
    margin-bottom: 20px;
    text-align: center;
}

.leaderboard-refresh {
    text-align: right;
    margin-bottom: 15px;
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: var(--background);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.leaderboard-item.current-user {
    border: 2px solid var(--primary-color);
    background: var(--surface-light);
}

.leaderboard-rank {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    min-width: 40px;
}

.leaderboard-rank.gold {
    color: #FFD700;
}

.leaderboard-rank.silver {
    color: #C0C0C0;
}

.leaderboard-rank.bronze {
    color: #CD7F32;
}

.leaderboard-info {
    flex: 1;
    margin: 0 15px;
}

.leaderboard-name {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.leaderboard-date {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.leaderboard-score {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
}

/* ==================== USER SCORES ==================== */
.user-scores {
    margin-top: 40px;
}

.user-scores h3 {
    margin-bottom: 15px;
    color: var(--secondary-color);
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: var(--background);
    border-radius: var(--border-radius);
}

.score-date {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.score-value {
    font-weight: bold;
    color: var(--primary-color);
}

/* ==================== INSTRUCTIONS ==================== */
.instructions {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.instructions h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.instructions ul {
    list-style-position: inside;
    color: var(--text-secondary);
}

.instructions li {
    margin-bottom: 10px;
}

/* ==================== LOADING ==================== */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-style: italic;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 1024px) {
    .game-main {
        grid-template-columns: 1fr;
    }

    .game-header-bar h1 {
        font-size: 1.5em;
    }
}

@media (max-width: 768px) {
    .game-header h1 {
        font-size: 2.5em;
    }

    .auth-box {
        padding: 30px 20px;
    }

    .features {
        grid-template-columns: 1fr;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .game-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 2em;
    }

    .container,
    .game-container {
        padding: 10px;
    }

    .game-header-bar {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .overlay-content h2 {
        font-size: 1.8em;
    }
}
