/* Stats Screen */
.stats-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    text-align: center;
    padding: 0;
    z-index: 100;
    border-radius: 20px;
}

.stats-screen .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    flex-shrink: 0;
}

.stats-screen .screen-title {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
}

.stats-screen .header-spacer {
    width: 40px;
}

@media (orientation: landscape) and (max-height: 600px) {
    .stats-screen {
        padding: 0;
    }
    
    .stats-screen .header {
        padding: 10px 15px;
    }
    
    .stats-screen .screen-title {
        font-size: 1.3em;
    }
}

.stats-screen.hidden {
    display: none;
}

.stats-tabs {
    display: flex;
    gap: 10px;
    padding: 0 20px;
    margin-bottom: 15px;
    flex-shrink: 0;
    z-index: 5;
}

.stats-tab {
    padding: 10px 25px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1em;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stats-tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.stats-tab.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.stats-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    z-index: 5;
}

.stats-section {
    display: none;
}

.stats-section.active {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stats-section h3 {
    font-size: 1.3em;
    margin: 0 0 10px 0;
    color: var(--text-color);
}

.stages-stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.stage-stat-item {
    display: grid;
    grid-template-columns: auto 1fr 1fr 1fr;
    gap: 15px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    align-items: center;
}

.stage-stat-item .stage-number {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
}

.stage-stat-item .stage-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stage-stat-item .stage-stat-value {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-color);
}

.stage-stat-item .stage-stat-label {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 600px;
    z-index: 5;
    margin: 0 auto; /* Center the grid */
}

@media (orientation: landscape) and (max-height: 600px) {
    .stats-grid {
        gap: 10px;
    }
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--text-color);
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.next-challenge {
    margin: 10px 0;
    padding: 12px;
    background: rgba(255, 200, 100, 0.2);
    border-radius: 10px;
    z-index: 5;
}

@media (orientation: landscape) and (max-height: 600px) {
    .next-challenge {
        margin: 8px 0;
        padding: 8px;
    }
}

.next-challenge p {
    font-size: 1.1em;
    color: var(--text-color);
    margin: 0;
}

@media (orientation: landscape) and (max-height: 600px) {
    .next-challenge p {
        font-size: 0.95em;
    }
}

/* Daily Complete Screen */
.daily-complete {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    text-align: center;
    border-radius: 20px;
    overflow-y: auto;
}

.daily-complete h2 {
    font-size: 1.8em;
    margin-bottom: 15px;
    z-index: 5;
}

.challenge-results {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 500px;
    z-index: 5;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.result-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--text-color);
}

.share-section {
    margin: 15px 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 5;
}

.emoji-result {
    font-size: 1.5em;
    letter-spacing: 3px;
    margin-bottom: 5px;
}

.share-success {
    color: #28a745;
    font-weight: bold;
    animation: fadeInOut 2s ease;
}

.share-success.hidden {
    display: none;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.next-challenge-timer {
    margin-top: 10px;
    padding: 10px 15px;
    background: rgba(255, 200, 100, 0.2);
    border-radius: 10px;
    z-index: 5;
}

.next-challenge-timer p {
    font-size: 0.95em;
    color: var(--text-secondary);
    margin: 0;
}

.challenge-timer-container.hidden {
    visibility: hidden;
}

.challenge-timer-container.active {
    background: rgba(76, 175, 80, 0.2);
}

.challenge-timer-container.active .challenge-timer-label,
.challenge-timer-container.active p {
    color: #4CAF50;
}

[data-theme="dark"] .challenge-timer-container.active .challenge-timer-label,
[data-theme="dark"] .challenge-timer-container.active p {
    color: #66bb6a;
}

/* Responsive adjustments for stats and daily screens */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stage-stat-item {
        grid-template-columns: auto 1fr;
        gap: 10px;
    }
    
    .stage-stat-item .stage-number {
        grid-column: 1 / -1;
    }
    
    .challenge-results {
        flex-direction: column;
        gap: 15px;
    }
    
    .emoji-result {
        font-size: 1.5em;
        letter-spacing: 3px;
    }
    
    .game-mode-buttons,
    .utility-buttons {
        max-width: 400px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-value {
        font-size: 1.5em;
    }
    
    .result-value {
        font-size: 1.5em;
    }
    
    .daily-complete {
        padding: 15px;
    }
    
    .daily-complete h2 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .challenge-results {
        gap: 15px;
        margin-bottom: 10px;
    }
    
    .game-mode-buttons,
    .utility-buttons {
        flex-direction: column;
        max-width: 300px;
    }
    
    .modal-content {
        padding: 40px 25px 30px;
        max-width: 95%;
    }
    
    .modal-content h2 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
    
    .instruction-item {
        padding: 12px 15px;
        gap: 12px;
    }
    
    .instruction-icon {
        font-size: 1.5em;
        width: 35px;
    }
    
    .instruction-text {
        font-size: 0.95em;
    }
}
