/* ============================================
   BirdPwner - Premium Game Styles
   ============================================ */

:root {
    --bg-dark: #0a0e1a;
    --bg-card: rgba(15, 20, 40, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --accent-primary: #00e5ff;
    --accent-secondary: #7c4dff;
    --accent-warm: #ff6d00;
    --accent-gold: #ffd600;
    --accent-pink: #ff4081;
    --text-primary: #e8eaf6;
    --text-secondary: #9fa8da;
    --text-muted: #5c6bc0;
    --border-glass: rgba(255, 255, 255, 0.08);
    --shadow-glow: 0 0 40px rgba(0, 229, 255, 0.15);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-main: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

#app {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    max-height: 860px;
    overflow: hidden;
    background: linear-gradient(170deg, #0d1127 0%, #0a0e1a 40%, #111833 100%);
    border-radius: 0;
    box-shadow: var(--shadow-card);
}

@media (min-width: 500px) {
    #app {
        border-radius: var(--radius-lg);
        border: 1px solid var(--border-glass);
    }
}

/* ============ Music Toggle ============ */
.music-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-glass);
    background: rgba(15, 20, 40, 0.7);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    padding: 0;
    line-height: 1;
}

.music-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
    transform: scale(1.1);
}

/* ============ Background Particles ============ */
#bg-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: floatUp linear infinite;
    opacity: 0;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-20px) scale(1);
        opacity: 0;
    }
}

/* ============ Screens ============ */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* ============ Loading Screen ============ */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.loading-logo {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -2px;
    line-height: 1;
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {

    0%,
    100% {
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.loading-bar-container {
    width: 220px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.loading-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
    transition: width 0.3s ease;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.loading-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    min-height: 20px;
}

.loading-start-btn {
    padding: 16px 48px;
    font-size: 1.2rem;
    letter-spacing: 2px;
    animation: startBtnAppear 0.6s ease forwards;
}

.loading-start-btn.hidden {
    display: none !important;
}

@keyframes startBtnAppear {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============ Start Screen ============ */
.logo-container {
    position: relative;
    text-align: center;
    margin-bottom: 48px;
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 120px;
    background: radial-gradient(ellipse, rgba(0, 229, 255, 0.2) 0%, transparent 70%);
    filter: blur(30px);
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.15);
    }
}

.game-logo {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -2px;
    position: relative;
    z-index: 1;
    line-height: 1;
}

.logo-bird {
    color: var(--accent-primary);
    text-shadow: 0 0 30px rgba(0, 229, 255, 0.5);
}

.logo-pwner {
    color: var(--accent-warm);
    text-shadow: 0 0 30px rgba(255, 109, 0, 0.5);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 12px;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.start-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 240px;
}

/* ============ Buttons ============ */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

.btn-play {
    background: linear-gradient(135deg, #00c853, #00e676);
    color: #0a0e1a;
    box-shadow: 0 4px 20px rgba(0, 200, 83, 0.35);
}

.btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 200, 83, 0.5);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-submit {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    box-shadow: 0 4px 20px rgba(124, 77, 255, 0.3);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(124, 77, 255, 0.5);
}

.btn-icon {
    font-size: 1.1rem;
}

/* ============ Instructions ============ */
.instructions {
    margin-top: 48px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 40px;
}

/* ============ Game Screen ============ */
#game-screen {
    background: transparent;
    justify-content: flex-start;
    padding: 0;
}

.game-hud {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
    pointer-events: none;
}

.score-display {
    font-family: var(--font-mono);
    font-size: 4rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 229, 255, 0.3);
    line-height: 1;
}

.best-score-display {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============ Ready Overlay ============ */
.ready-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15;
    background: rgba(10, 14, 26, 0.4);
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

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

.ready-text {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent-primary);
    text-shadow: 0 0 30px rgba(0, 229, 255, 0.5);
    animation: readyBounce 1.5s ease-in-out infinite;
}

.ready-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 12px;
}

@keyframes readyBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ============ Game Over ============ */
.gameover-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gameover-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-warm));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
}

.score-summary {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 16px;
}

.final-score-container,
.best-score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.final-score-label,
.best-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.final-score-value {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
    line-height: 1.2;
}

.best-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1.4;
}

.new-best-badge {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 16px;
    animation: badgePulse 1s ease-in-out infinite;
}

.new-best-badge.hidden {
    display: none;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.medal-container {
    margin-bottom: 20px;
}

.medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 2rem;
    animation: medalShine 2s ease-in-out infinite;
}

.medal.hidden {
    display: none;
}

.medal.gold {
    background: linear-gradient(135deg, #ffd600, #ffab00);
    box-shadow: 0 0 25px rgba(255, 214, 0, 0.5);
}

.medal.silver {
    background: linear-gradient(135deg, #cfd8dc, #90a4ae);
    box-shadow: 0 0 25px rgba(207, 216, 220, 0.4);
}

.medal.bronze {
    background: linear-gradient(135deg, #d84315, #ff5722);
    box-shadow: 0 0 25px rgba(255, 87, 34, 0.4);
}

@keyframes medalShine {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }
}

/* ============ Submit Score ============ */
.submit-score-section {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.player-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.player-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.15);
}

.player-input::placeholder {
    color: var(--text-muted);
}

.gameover-actions {
    display: flex;
    gap: 10px;
}

.gameover-actions .btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.9rem;
}

/* ============ Leaderboard ============ */
.leaderboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    width: 90%;
    max-width: 400px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
    animation: slideUp 0.5s ease;
}

.leaderboard-title {
    font-size: 1.6rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 24px;
    color: var(--accent-gold);
}

.leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.leaderboard-list::-webkit-scrollbar {
    width: 4px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: transparent;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.lb-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    background: var(--bg-glass);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.lb-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-glass);
}

.lb-row.top-1 {
    background: rgba(255, 214, 0, 0.08);
    border-color: rgba(255, 214, 0, 0.2);
}

.lb-row.top-2 {
    background: rgba(176, 190, 197, 0.06);
    border-color: rgba(176, 190, 197, 0.15);
}

.lb-row.top-3 {
    background: rgba(255, 87, 34, 0.06);
    border-color: rgba(255, 87, 34, 0.15);
}

.lb-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    margin-right: 14px;
    flex-shrink: 0;
}

.lb-rank.r1 {
    background: linear-gradient(135deg, #ffd600, #ffab00);
    color: #1a1a1a;
}

.lb-rank.r2 {
    background: linear-gradient(135deg, #cfd8dc, #90a4ae);
    color: #1a1a1a;
}

.lb-rank.r3 {
    background: linear-gradient(135deg, #d84315, #ff5722);
    color: #fff;
}

.lb-rank.rn {
    background: var(--bg-glass);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
}

.lb-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.lb-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 1rem;
}

.lb-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 12px;
    flex-shrink: 0;
}

.leaderboard-loading,
.leaderboard-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 0;
    font-size: 0.95rem;
}

.leaderboard-card .btn-secondary {
    width: 100%;
}

/* ============ About ============ */
.about-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
    animation: slideUp 0.5s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.about-card::-webkit-scrollbar {
    width: 4px;
}

.about-card::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.about-title {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.about-creator {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.7;
}

.creator-name {
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.team-name {
    font-weight: 700;
    color: var(--accent-warm);
    text-shadow: 0 0 15px rgba(255, 109, 0, 0.3);
}

.credits-section {
    margin-bottom: 24px;
}

.credits-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 14px;
}

.credits-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.credits-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.credits-list li:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-glass);
}

.credit-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.credit-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: right;
}

.credits-footer {
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.about-card .btn-secondary {
    width: 100%;
    margin-top: 4px;
}

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

/* ============ Responsive ============ */
@media (max-height: 700px) {
    .logo-container {
        margin-bottom: 32px;
    }

    .game-logo {
        font-size: 2.8rem;
    }

    .instructions {
        margin-top: 32px;
    }
}

@media (max-height: 600px) {
    .gameover-card {
        padding: 20px 20px;
    }

    .final-score-value {
        font-size: 2.2rem;
    }

    .medal {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
    }
}

/* Mobile improvements for music toggle */
@media (max-width: 480px) {
    .music-toggle {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
        background: rgba(15, 20, 40, 0.85);
        border-width: 2px;
    }
}