/**
 * Enhanced High-Score System Styles
 * Modern, production-ready UI with smooth animations
 */

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Enhanced Scoreboard Overlay */
.enhanced-scoreboard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15000; /* Increased z-index to prevent conflicts */
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: visible; /* Ensure visibility */
}

.enhanced-scoreboard-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    visibility: hidden; /* Ensure it's truly hidden */
}

/* Main Modal */
.enhanced-scoreboard-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border: 2px solid #4a9eff;
    border-radius: 20px;
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    height: 600px; /* Fixed height to prevent resizing */
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.5),
        0 0 50px rgba(74, 158, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.enhanced-scoreboard-overlay.hidden .enhanced-scoreboard-modal {
    transform: translateY(-50px);
}

/* Header */
.enhanced-scoreboard-header {
    background: 
        linear-gradient(135deg, rgba(74, 158, 255, 0.8) 0%, rgba(107, 115, 255, 0.8) 100%),
        url('../assets/pixelpanda/highscore-panda.png?v=1') right center/80% no-repeat;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.enhanced-scoreboard-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.scoreboard-title {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.7),
        0 0 10px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(74, 158, 255, 0.3);
    position: relative;
    z-index: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.close-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.1);
}

/* Header Content Layout */
.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

/* High Score Panda Icon - Hidden since using background image */
.highscore-panda-icon {
    display: none;
}

/* Game Selector Dropdown */
.game-selector {
    padding: 1.5rem 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(74, 158, 255, 0.3);
}

.game-selector-dropdown {
    position: relative;
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
}

.current-game-btn {
    width: 100%;
    background: rgba(74, 158, 255, 0.1);
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    color: #d0d8ff;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.current-game-btn:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}

.current-game-btn.active {
    border-color: #4a9eff;
    background: rgba(74, 158, 255, 0.2);
}

.current-game-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    color: #4a9eff;
}

.game-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border: 2px solid rgba(74, 158, 255, 0.3);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.game-options.hidden {
    display: none;
}

.game-option {
    width: 100%;
    background: transparent;
    border: none;
    color: #b0b8ff;
    padding: 12px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(74, 158, 255, 0.1);
}

.game-option:last-child {
    border-bottom: none;
}

.game-option:hover {
    background: rgba(74, 158, 255, 0.1);
    color: #d0d8ff;
}

.game-option.active {
    background: rgba(74, 158, 255, 0.2);
    color: #4a9eff;
}

.game-option .game-icon {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.game-option .game-name {
    flex: 1;
    text-align: left;
}

/* Combined Scores Layout */
.combined-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-entry.combined-score {
    display: grid;
    grid-template-columns: 50px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border-left: 3px solid #4a9eff;
}

.score-entry.combined-score:hover {
    background: rgba(255, 255, 255, 0.08);
}

.score-rank {
    font-weight: bold;
    color: #4a9eff;
    font-size: 0.9rem;
}

.score-game {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-game .game-icon {
    font-size: 1.1rem;
}

.score-game .game-name {
    font-size: 0.9rem;
    color: #b0b8ff;
}

.score-value {
    font-weight: bold;
    color: #e0e0ff;
    font-size: 0.9rem;
}

.score-date {
    font-size: 0.8rem;
    color: #8090ff;
}

.scores-header {
    text-align: center;
    margin-bottom: 20px;
}

.scores-header h3 {
    margin: 0 0 8px 0;
    color: #4a9eff;
    font-size: 1.1rem;
}

.scores-subtitle {
    margin: 0;
    color: #8090ff;
    font-size: 0.9rem;
}

/* Main Content */
.scores-container {
    padding: 2rem;
    flex: 1; /* Take up remaining space */
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Reduce top padding when showing all games view */
.scores-container.all-games-view {
    padding-top: 1rem;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #b0b8ff;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(74, 158, 255, 0.3);
    border-top: 3px solid #4a9eff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    color: #b0b8ff;
    padding: 3rem 1rem;
}

.empty-state p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.sub-text {
    opacity: 0.7;
    font-size: 0.9rem !important;
}

/* Scores List */
.scores-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.score-entry {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.1) 0%, rgba(107, 115, 255, 0.1) 100%);
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.score-entry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(74, 158, 255, 0.05) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.score-entry:hover::before {
    opacity: 1;
}

.score-entry.best-score {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.rank {
    font-size: 1rem;
    font-weight: 700;
    color: #4a9eff;
    min-width: 40px;
}

.best-score .rank {
    color: #ffd700;
}

.score {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    font-family: 'Courier New', monospace;
}

.date {
    font-size: 0.85rem;
    color: #b0b8ff;
    opacity: 0.8;
}

.crown {
    font-size: 1.5rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Footer */
.scoreboard-footer {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem 2rem;
    border-top: 1px solid rgba(74, 158, 255, 0.3);
    text-align: center;
}

.stats-summary {
    color: #b0b8ff;
    font-size: 0.9rem;
    margin: 0;
    opacity: 0.8;
}

/* Celebration Overlay */
.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, rgba(0, 0, 0, 0.8) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15000;
    opacity: 1;
    transition: all 0.5s ease;
}

.celebration-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.celebration-content {
    text-align: center;
    color: white;
    position: relative;
    animation: celebrationEntry 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes celebrationEntry {
    0% {
        transform: scale(0.3) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(-90deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.celebration-title {
    font-size: 3rem;
    font-weight: 800;
    margin: 0 0 1.5rem 0;
    text-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 4px 8px rgba(0, 0, 0, 0.5);
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 4px 8px rgba(0, 0, 0, 0.5); }
    100% { text-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 4px 8px rgba(0, 0, 0, 0.5); }
}

.celebration-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.game-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: #4a9eff;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.score-rank {
    font-size: 1.2rem;
    color: #b0b8ff;
}

/* Celebration Effects */
.celebration-effects {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200%;
    height: 200%;
    pointer-events: none;
}

.confetti,
.sparkles {
    position: absolute;
    width: 100%;
    height: 100%;
}

.confetti::before,
.confetti::after,
.sparkles::before,
.sparkles::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd700;
    border-radius: 2px;
    animation: confettiFall 3s linear infinite;
}

.confetti::before { left: 10%; animation-delay: -0.5s; background: #4a9eff; }
.confetti::after { left: 20%; animation-delay: -1s; background: #ff6b6b; }
.sparkles::before { left: 70%; animation-delay: -1.5s; background: #4ecdc4; }
.sparkles::after { left: 80%; animation-delay: -2s; background: #45b7d1; }

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 1440px) and (max-height: 900px) {
    /* 13" laptop optimization */
    .enhanced-scoreboard-modal {
        width: 700px;
        max-height: 75vh;
    }
    
    .scoreboard-title {
        font-size: 1.6rem;
    }
    
    .scores-container {
        max-height: 350px;
        padding: 1.5rem;
    }
    
    .score-entry {
        padding: 0.8rem 1.2rem;
        gap: 0.8rem;
    }
    
    .rank {
        font-size: 1.1rem;
    }
    
    .score {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .enhanced-scoreboard-modal {
        width: 95vw;
        max-height: 95vh;
        margin: 1rem;
    }
    
    .scoreboard-title {
        font-size: 1.5rem;
    }
    
    .highscore-panda-icon {
        width: 45px;
        height: 45px;
    }
    
    .header-content {
        gap: 0.75rem;
    }

    /* Game Selector Mobile Adjustments */
    .game-selector {
        padding: 1rem 1.5rem;
    }
    
    .game-selector-dropdown {
        max-width: 100%;
    }

    .current-game-btn {
        font-size: 0.9rem;
        padding: 12px 16px;
    }

    .game-option {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .game-option .game-icon {
        font-size: 1rem;
        min-width: 20px;
    }

    /* Combined Scores Mobile Layout */
    .score-entry.combined-score {
        grid-template-columns: 40px 1fr auto;
        gap: 8px;
        padding: 10px;
        font-size: 0.85rem;
    }

    .score-date {
        grid-column: 2 / 4;
        justify-self: end;
        font-size: 0.75rem;
    }
    
    .game-tab {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }
    
    .scores-container {
        padding: 1rem;
        max-height: 300px;
    }
    
    .score-entry {
        padding: 0.75rem 1rem;
        grid-template-columns: auto 1fr auto;
        gap: 0.75rem;
    }
    
    .crown {
        display: none;
    }
    
    .celebration-title {
        font-size: 2rem;
    }
    
    .score-value {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .enhanced-scoreboard-header {
        padding: 1rem 1.5rem;
    }
    
    .highscore-panda-icon {
        width: 35px;
        height: 35px;
    }
    
    .header-content {
        gap: 0.5rem;
    }
    
    .scoreboard-title {
        font-size: 1.25rem;
    }
    
    .game-tabs {
        padding: 0 1rem;
    }
    
    .game-tab {
        padding: 0.5rem 0.75rem;
    }
    
    .celebration-title {
        font-size: 1.5rem;
    }
    
    .score-value {
        font-size: 1.5rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for keyboard navigation */
.game-tab:focus,
.close-btn:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

.enhanced-scoreboard-modal:focus {
    outline: none;
}

/* Game Controls CSS */
.game-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.control-btn {
    background: linear-gradient(135deg, #4a9eff 0%, #6b73ff 100%);
    border: 2px solid rgba(74, 158, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 80px;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.2);
}

.control-btn:hover {
    background: linear-gradient(135deg, #5aa3ff 0%, #7b83ff 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.control-btn:active {
    transform: translateY(0);
}

.pause-btn.paused {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-color: rgba(40, 167, 69, 0.3);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.pause-btn.paused:hover {
    background: linear-gradient(135deg, #34ce57 0%, #2dd4aa 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.restart-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    border-color: rgba(255, 107, 107, 0.3);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.2);
}

.restart-btn:hover {
    background: linear-gradient(135deg, #ff7b7b 0%, #f66a62 100%);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

/* Resume Game Button in Scoreboard */
.resume-game-container {
    display: none !important; /* Hidden per user request */
    margin-bottom: 1rem;
}

.resume-game-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: 2px solid rgba(40, 167, 69, 0.3);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
}

.resume-game-btn:hover {
    background: linear-gradient(135deg, #34ce57 0%, #2dd4aa 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.resume-game-btn:active {
    transform: translateY(0);
}

.resume-icon,
.pause-icon,
.resume-icon,
.restart-icon {
    font-size: 1.1em;
}

/* Responsive adjustments for game controls */
@media (max-width: 768px) {
    .game-controls {
        gap: 0.3rem;
    }
    
    .control-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 70px;
    }
    
    .resume-game-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .control-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-width: 60px;
        gap: 0.2rem;
    }
    
    .control-btn .pause-text,
    .control-btn .restart-text,
    .control-btn .resume-text {
        display: none;
    }
    
    .resume-game-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}