/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Helvetica', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

/* Screen Management */
.screen {
    display: none;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    text-align: center;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
h1 {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 10px;
}

h2 {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 20px;
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 30px;
}

/* Buttons */
.btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

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

/* How to Play Screen */
.instructions {
    text-align: left;
    max-width: 600px;
    margin: 0 auto 30px;
    line-height: 1.8;
}

.instructions p {
    margin-bottom: 15px;
}

.instructions ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

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

/* Countdown Screen */
.countdown-display {
    font-size: 8rem;
    font-weight: bold;
    color: #667eea;
    animation: pulse 1s ease-in-out;
}

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

/* Game Screen Layout */
#game-screen {
    max-width: 900px;
}

.target-section {
    margin-bottom: 20px;
}

.target-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap;
}

.target-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.target-label {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 10px;
}

.target-display {
    font-size: 4rem;
    font-weight: bold;
    color: #667eea;
    background: #f0f0f0;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 10px;
    min-width: 120px;
    text-align: center;
}

/* Timer */
.timer-section {
    margin-bottom: 20px;
}

.timer-label {
    font-size: 1rem;
    color: #666;
    margin-bottom: 5px;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: bold;
    color: #764ba2;
    background: #fff3e0;
    border-radius: 10px;
    padding: 10px 20px;
    display: inline-block;
}

.timer-display.warning {
    color: #ff5722;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Scores */
.scores-section {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.score-item {
    background: #f5f5f5;
    padding: 15px 25px;
    border-radius: 10px;
}

.score-label {
    font-size: 0.9rem;
    color: #666;
    margin-right: 10px;
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

/* Equation Display */
.equation-section {
    margin-bottom: 30px;
}

.equation-label {
    font-size: 1rem;
    color: #666;
    margin-bottom: 10px;
}

.equation-display {
    font-size: 1.8rem;
    font-weight: bold;
    color: #333;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.equation-placeholder {
    color: #999;
    font-size: 1.2rem;
    font-weight: normal;
}

.equation-prime {
    color: #667eea;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.equation-prime:hover {
    background: #e3f2fd;
    transform: scale(1.1);
}

.equation-operator {
    color: #999;
    margin: 0 5px;
}

.equation-equals {
    color: #999;
    margin: 0 10px;
}

.equation-result {
    color: #764ba2;
    font-weight: bold;
}

.equation-target {
    color: #667eea;
    font-weight: bold;
}

/* Prime Buttons */
.primes-section {
    margin-top: 30px;
}

.primes-label {
    font-size: 1rem;
    color: #666;
    margin-bottom: 15px;
}

.prime-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.prime-btn {
    width: 60px;
    height: 60px;
    font-size: 1.3rem;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.prime-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.prime-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Prime Recognition Section */
.prime-recognition-section {
    margin-top: 30px;
    text-align: center;
}

.prime-recognition-label {
    font-size: 1rem;
    color: #666;
    margin-bottom: 10px;
}

.btn-prime-recognition {
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: bold;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(238, 90, 36, 0.3);
}

.btn-prime-recognition:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(238, 90, 36, 0.5);
}

.btn-prime-recognition:active {
    transform: translateY(-1px);
}

/* Mode Selector */
.mode-selector {
    margin: 30px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 15px;
}

.mode-label {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 15px;
    font-weight: bold;
}

.mode-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 25px;
    min-width: 150px;
    background: white;
    border: 2px solid #e0e0e0;
    color: #666;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.mode-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.mode-btn-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.mode-name {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.mode-desc {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Success Animation */
@keyframes success {
    0% {
        transform: scale(1);
        background: white;
    }
    50% {
        transform: scale(1.05);
        background: #c8e6c9;
    }
    100% {
        transform: scale(1);
        background: white;
    }
}

.screen.success-flash {
    animation: success 0.5s ease-in-out;
}

/* Game Over Screen */
.final-scores {
    margin: 30px 0;
}

.final-score-item {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.final-score-label {
    font-size: 1.3rem;
    color: #666;
}

.final-score-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

/* Responsive Design */
@media (max-width: 768px) {
    .screen {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .subtitle {
        font-size: 1rem;
        margin-bottom: 15px;
    }
    
    .target-container {
        gap: 20px;
    }
    
    .target-display {
        font-size: 2.5rem;
        padding: 10px;
        margin-bottom: 10px;
        min-width: 100px;
    }
    
    .target-label {
        font-size: 1rem;
    }
    
    .timer-display {
        font-size: 1.8rem;
        padding: 5px 15px;
    }
    
    .scores-section {
        gap: 15px;
        margin-bottom: 15px;
    }
    
    .score-item {
        padding: 10px 15px;
    }
    
    .score-value {
        font-size: 1.2rem;
    }
    
    .equation-section {
        margin-bottom: 15px;
    }
    
    .equation-display {
        font-size: 1.2rem;
        padding: 15px;
        min-height: 50px;
    }
    
    .primes-section {
        margin-top: 15px;
    }
    
    .prime-buttons {
        gap: 8px;
    }
    
    .prime-btn {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
    
    .prime-recognition-section {
        margin-top: 15px;
    }
    
    .btn-prime-recognition {
        padding: 10px 25px;
        font-size: 1.1rem;
    }
    
    .countdown-display {
        font-size: 4rem;
    }
    
    .mode-selector {
        margin: 15px 0;
        padding: 15px;
    }
    
    .mode-btn {
        min-width: 120px;
        padding: 12px 20px;
    }
}

/* ===== AUTHENTICATION & USER PROFILE ===== */

.user-profile {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.user-photo {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.user-name {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: white;
    color: #444;
    border: 1px solid #ddd;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 10px auto 0 auto; /* Center the button horizontally */
}

.btn-google:hover {
    background: #f8f8f8;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.google-icon {
    width: 18px;
    height: 18px;
}

/* ===== LEADERBOARD ===== */

.leaderboard-tabs {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.tab-btn {
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 600;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
}

/* Active tab - filled purple style */
.tab-btn.tab-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Inactive tab - white with purple border */
.tab-btn:not(.tab-active) {
    background: white;
    color: #667eea;
    border: 3px solid #667eea;
}

.tab-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.your-rank {
    text-align: center;
    margin: 15px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.your-rank p {
    color: white;
    font-size: 1.1rem;
    margin: 0;
}

.rank-highlight {
    color: #ffd700;
    font-weight: 700;
    font-size: 1.3rem;
}

.leaderboard-message {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
}

.leaderboard-list {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
}

.leaderboard-entry.current-user {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.entry-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
    min-width: 40px;
    text-align: center;
}

.entry-rank.top3 {
    font-size: 1.8rem;
}

.entry-photo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
    background: #ddd;
}

.entry-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.entry-name {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

.entry-stats {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.entry-score {
    color: #4ade80;
    font-weight: 600;
}

.entry-undos {
    color: #fbbf24;
}

/* Mobile Responsiveness for Leaderboard */
@media (max-width: 768px) {
    .user-profile {
        top: 10px;
        right: 10px;
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    .user-photo {
        width: 30px;
        height: 30px;
    }
    
    .user-name {
        font-size: 0.85rem;
    }
    
    .btn-small {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .leaderboard-tabs {
        flex-direction: column;
        gap: 8px;
    }
    
    .tab-btn {
        width: 100%;
    }
    
    .leaderboard-entry {
        padding: 12px;
        gap: 10px;
    }
    
    .entry-rank {
        font-size: 1.2rem;
        min-width: 30px;
    }
    
    .entry-photo {
        width: 35px;
        height: 35px;
    }
    
    .entry-name {
        font-size: 1rem;
    }
    
    .entry-stats {
        flex-direction: column;
        gap: 3px;
        font-size: 0.85rem;
    }
}

