/* Import a visually appealing modern font */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;800&display=swap');

:root {
    --primary-color: #0ea5e9; /* Light blue */
    --secondary-color: #0284c7; /* Darker blue */
    --accent-color: #f59e0b; /* Amber/Orange */
    --text-light: #f8fafc;
    --text-dark: #0f172a;
    --glass-bg: rgba(15, 23, 42, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

body {
    background-color: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* Prevent scrolling */
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 400px; /* Mobile-like aspect ratio */
    height: 100%;
    max-height: 700px;
    background: linear-gradient(180deg, #0284c7 0%, #0ea5e9 40%, #bae6fd 100%);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: background 1s ease; /* Smooth background transitions */
}

/* Character Themes */
#game-container.bg-fugu {
    background: linear-gradient(180deg, #0284c7 0%, #0ea5e9 40%, #bae6fd 100%); /* Ocean */
}
#game-container.bg-astronaut {
    background: linear-gradient(180deg, #050511 0%, #170d42 50%, #3a1586 100%); /* Deep Space */
}
#game-container.bg-jedi {
    background: linear-gradient(180deg, #451a03 0%, #b45309 50%, #fcd34d 100%); /* Tatooine Sunset */
}
#game-container.bg-unicorn {
    background: linear-gradient(180deg, #fda4af 0%, #f472b6 40%, #c084fc 100%); /* Rainbow Pastel */
}
#game-container.bg-diablo {
    background: linear-gradient(180deg, #7f1d1d 0%, #b91c1c 40%, #ea580c 100%); /* Hellfire */
}
#game-container.bg-abeille {
    background: linear-gradient(180deg, #b45309 0%, #d97706 40%, #fcd34d 100%); /* Honeycomb Yellow/Orange */
}
#game-container.bg-dragonball {
    background: radial-gradient(circle at center, #fef08a 0%, #f59e0b 40%, #172554 100%); /* Super Saiyan Golden Aura */
}

@media (min-width: 480px) {
    #game-container {
        border-radius: 24px;
        height: 85vh;
    }
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* Pixel art rendering if needed */
    image-rendering: auto;
}

/* UI Layer positioning */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas when playing */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Score Display */
#score-display {
    position: absolute;
    top: 40px;
    font-size: 3.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 20px rgba(14, 165, 233, 0.8);
    z-index: 10;
    transition: opacity 0.3s ease;
}

#score-display.hidden {
    opacity: 0;
}

/* Character Display */
#character-name-display {
    position: absolute;
    top: 110px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
    transition: opacity 0.5s ease;
}

#character-name-display.hidden {
    opacity: 0;
}

/* Flash effect for switching */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* Pixel art rendering if needed */
    image-rendering: auto;
    transition: filter 0.3s ease;
}

.flash-transition {
    filter: brightness(2) contrast(1.2) sepia(0.5);
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    text-align: center;
    width: 85%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    pointer-events: auto; /* Re-enable clicks inside panels */
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
}

.glass-panel.active {
    transform: scale(1);
    opacity: 1;
}

.glass-panel.hidden {
    display: none;
}

h1, h2, h3 {
    color: white;
    font-weight: 800;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

h1 { font-size: 2.2rem; background: linear-gradient(to right, #fff, #bae6fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 2.5rem; color: #fdf2f8; margin-bottom: 0.5rem; }
h3 { font-size: 1.2rem; color: #f59e0b; margin-top: 1rem; margin-bottom: 0.5rem; }

p {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.5;
    opacity: 0.9;
}

.score-board {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.score-board p {
    margin: 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-board span {
    color: var(--accent-color);
    font-size: 1.8rem;
}

/* Leaderboard */
#leaderboard-section, #home-leaderboard-section {
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

#leaderboard-list, #home-leaderboard-list {
    list-style: none;
    text-align: left;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 5px;
}

#leaderboard-list::-webkit-scrollbar, #home-leaderboard-list::-webkit-scrollbar {
    width: 6px;
}
#leaderboard-list::-webkit-scrollbar-track, #home-leaderboard-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2); 
    border-radius: 4px;
}
#leaderboard-list::-webkit-scrollbar-thumb, #home-leaderboard-list::-webkit-scrollbar-thumb {
    background: var(--accent-color); 
    border-radius: 4px;
}

#leaderboard-list li, #home-leaderboard-list li {
    display: flex;
    justify-content: space-between;
    color: white;
    font-size: 1.1rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-family: monospace;
    font-weight: bold;
}

#leaderboard-list li:last-child, #home-leaderboard-list li:last-child {
    border-bottom: none;
}

#leaderboard-list li .name, #home-leaderboard-list li .name {
    color: #bae6fd;
    text-transform: uppercase;
}

#leaderboard-list li .sc, #home-leaderboard-list li .sc {
    color: var(--accent-color);
}

/* New High Score Input Section */
#new-highscore-section {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#new-highscore-section.hidden {
    display: none;
}

#player-name {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 2px solid var(--accent-color);
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    font-family: monospace;
}

#player-name::placeholder {
    color: rgba(255,255,255,0.3);
}

/* Stats Screen */
#stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

#stats-grid::-webkit-scrollbar {
    width: 4px;
}

#stats-grid::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem;
    text-align: center;
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-color);
}

.stat-card .stat-label {
    font-size: 0.7rem;
    color: #bae6fd;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
    font-weight: 700;
}

.stat-card .stat-value {
    font-size: 1.1rem;
    color: white;
    font-weight: 800;
}

.stat-card .stat-sub {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.2rem;
}

.stat-card.wide {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(0,0,0,0.3) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.stat-card i {
    font-style: normal;
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

/* Premium Buttons */
.premium-btn {
    appearance: none;
    background: linear-gradient(135deg, var(--accent-color) 0%, #fbbf24 100%);
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 1rem 2.5rem;
    cursor: pointer;
    box-shadow: 0 5px 15px -5px var(--accent-color), inset 0 -3px 0 rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
    width: 100%;
}

.premium-btn.small-btn {
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
}

.premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -10px var(--accent-color), inset 0 -3px 0 rgba(0,0,0,0.2);
    filter: brightness(1.1);
}

.premium-btn:active {
    transform: translateY(2px);
    box-shadow: 0 5px 10px -5px var(--accent-color), inset 0 -1px 0 rgba(0,0,0,0.2);
}

#game-version {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    z-index: 1000;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.5px;
}

/* Release Notes Modal */
#release-notes-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 2100;
    width: 90%;
    max-width: 500px;
    padding: 30px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#release-notes-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

#release-notes-modal .modal-content {
    display: flex;
    flex-direction: column;
}

#release-notes-modal h2 {
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 1.8rem;
    text-align: center;
}

#rn-list {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 10px;
}

#rn-list::-webkit-scrollbar {
    width: 4px;
}

#rn-list::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

.rn-version-block {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rn-version-block:last-child {
    border-bottom: none;
}

.rn-version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.rn-version-tag {
    background: var(--accent-color);
    color: #000;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 900;
    font-size: 0.85rem;
    font-family: monospace;
}

.rn-date {
    font-size: 0.8rem;
    opacity: 0.5;
}

.rn-item {
    margin-bottom: 10px;
    font-size: 0.95rem;
    line-height: 1.4;
    display: flex;
    gap: 12px;
}

.rn-item::before {
    content: '→';
    color: var(--accent-color);
    font-weight: bold;
}
