/* === Jump Dash — Neon Auto-Scroll Runner === */

:root {
    --jd-bg: hsl(260, 60%, 4%);
    --jd-cyan: hsl(185, 100%, 55%);
    --jd-magenta: hsl(320, 100%, 60%);
    --jd-lime: hsl(140, 90%, 52%);
    --jd-gold: hsl(45, 100%, 55%);
    --jd-grid: hsl(185, 80%, 30%);
    --jd-city: hsl(260, 40%, 12%);

    --jd-glass: rgba(10, 3, 24, 0.72);
    --jd-glass-border: rgba(185, 255, 255, 0.12);
    --jd-shadow: 0 0 20px rgba(0, 242, 255, 0.25);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at 50% 0%, hsl(260, 50%, 10%) 0%, var(--jd-bg) 70%);
    color: #f8fafc;
    min-height: 100vh;
    overflow-x: hidden;
}

.jump-dash-container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

.jump-dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 8px;
}

.jump-dash-header h1 {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.game-title-neon {
    color: var(--jd-cyan);
    text-shadow:
        0 0 6px rgba(0, 242, 255, 0.6),
        0 0 18px rgba(0, 242, 255, 0.4);
}

.jump-dash-back-btn {
    padding: 10px 20px;
    background: var(--jd-glass);
    border: 1px solid var(--jd-glass-border);
    border-radius: 12px;
    color: #f8fafc;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.jump-dash-back-btn:hover {
    background: rgba(0, 242, 255, 0.12);
    border-color: var(--jd-cyan);
}

/* Game screen + letterbox canvas */
.jump-dash-screen {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(0, 242, 255, 0.25);
    box-shadow: var(--jd-shadow), 0 20px 60px rgba(0, 0, 0, 0.6);
}

#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: auto;
    display: block;
    background: var(--jd-bg);
    touch-action: none;
    image-rendering: pixelated;
}

/* HUD */
.jump-dash-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    z-index: 10;
    font-family: 'Orbitron', sans-serif;
}

.hud-left,
.hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.hud-left {
    color: var(--jd-lime);
}

#starText {
    color: var(--jd-gold);
}

.hud-center {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: min(40%, 280px);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--jd-cyan), var(--jd-magenta));
    box-shadow: 0 0 10px var(--jd-cyan);
    transition: width 0.1s linear;
}

.progress-fill.milestone-25 {
    box-shadow: 0 0 14px var(--jd-cyan);
}

.progress-fill.milestone-50 {
    box-shadow: 0 0 16px var(--jd-lime);
}

.progress-fill.milestone-75,
.progress-fill.milestone-100 {
    animation: pulse-bar 0.6s ease-in-out infinite alternate;
}

.progress-fill.milestone-75 {
    box-shadow: 0 0 18px var(--jd-gold);
}

.progress-fill.milestone-100 {
    box-shadow: 0 0 22px var(--jd-magenta);
}

@keyframes pulse-bar {
    from { opacity: 1; }
    to { opacity: 0.65; }
}

.hud-level {
    display: block;
    color: var(--jd-cyan);
    font-size: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    line-height: 1;
    margin-bottom: 4px;
}

.dash-pips {
    display: flex;
    gap: 4px;
}

.dash-pip {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dash-pip.active {
    background: var(--jd-cyan);
    box-shadow: 0 0 8px var(--jd-cyan);
}

/* Overlays */
.jump-dash-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    background: rgba(5, 2, 12, 0.82);
    backdrop-filter: blur(4px);
    padding: 20px;
    transition: opacity 0.2s ease;
}

.jump-dash-overlay.hidden {
    display: none;
}

.overlay-panel {
    width: min(420px, 100%);
    background: var(--jd-glass);
    border: 1px solid var(--jd-glass-border);
    border-radius: 20px;
    padding: 28px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.overlay-panel.wide {
    width: min(680px, 100%);
}

.overlay-panel h2 {
    margin: 0 0 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6rem;
    color: var(--jd-cyan);
    text-shadow: 0 0 12px rgba(0, 242, 255, 0.5);
}

.overlay-panel p {
    margin: 0 0 24px;
    color: rgba(248, 250, 252, 0.7);
}

.jump-dash-btn {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    color: #050505;
    background: linear-gradient(135deg, var(--jd-cyan), var(--jd-lime));
    box-shadow: 0 0 16px rgba(0, 242, 255, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
}

.jump-dash-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 24px rgba(0, 242, 255, 0.55);
}

.jump-dash-btn.ghost {
    background: transparent;
    color: #f8fafc;
    border: 1px solid var(--jd-glass-border);
    box-shadow: none;
}

.jump-dash-btn.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--jd-cyan);
}

/* Level select grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.level-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    border: 1px solid var(--jd-glass-border);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Orbitron', sans-serif;
}

.level-cell:hover:not(.locked) {
    border-color: var(--jd-cyan);
    box-shadow: 0 0 14px rgba(0, 242, 255, 0.25);
}

.level-cell.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.level-number {
    font-size: 1.4rem;
    font-weight: 700;
}

.level-stars {
    font-size: 0.75rem;
    color: var(--jd-gold);
}

.results-stars {
    font-size: 2rem;
    color: var(--jd-gold);
    margin: 12px 0;
    text-shadow: 0 0 16px rgba(255, 215, 0, 0.4);
}

.overall-progress {
    margin: 0 0 12px;
    color: rgba(248, 250, 252, 0.8);
    font-size: 0.95rem;
}

.transition-panel {
    animation: transition-in 0.4s ease-out;
}

.transition-mechanic {
    margin: 8px 0 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    color: var(--jd-lime);
    text-shadow: 0 0 12px rgba(140, 255, 100, 0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.transition-skip {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(248, 250, 252, 0.55);
}

@keyframes transition-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.level-cell.locked .level-stars {
    font-size: 1rem;
}

#btnMute {
    width: auto;
    min-width: 52px;
    padding: 10px 14px;
    margin-top: 8px;
}

/* Mobile touch controls */
.mobile-controls {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
    z-index: 30;
    pointer-events: none;
}

.touch-btn {
    pointer-events: auto;
    position: relative;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 60px;
    min-height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: #f8fafc;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1px;
    backdrop-filter: blur(4px);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.08s ease, background 0.08s ease;
}

.touch-btn.jump {
    width: 60px;
    height: 60px;
    background: rgba(0, 242, 255, 0.12);
    border-color: rgba(0, 242, 255, 0.45);
    box-shadow: 0 0 14px rgba(0, 242, 255, 0.2);
}

.touch-btn.jump:active {
    transform: scale(0.94);
    background: rgba(0, 242, 255, 0.28);
}

.touch-btn.dash {
    width: 50px;
    height: 50px;
    background: rgba(255, 0, 170, 0.12);
    border-color: rgba(255, 0, 170, 0.45);
    box-shadow: 0 0 14px rgba(255, 0, 170, 0.2);
}

.touch-btn.dash:active {
    transform: scale(0.94);
    background: rgba(255, 0, 170, 0.28);
}

.touch-label {
    line-height: 1;
}

.dash-charges {
    display: flex;
    gap: 2px;
    margin-top: 3px;
}

.dash-charges::before,
.dash-charges::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
}

.touch-btn.dash[data-charges="1"] .dash-charges::before,
.touch-btn.dash[data-charges="2"] .dash-charges::before,
.touch-btn.dash[data-charges="2"] .dash-charges::after,
.touch-btn.dash[data-charges="3"] .dash-charges::before,
.touch-btn.dash[data-charges="3"] .dash-charges::after {
    background: #ffffff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

/* 3rd charge dot rendered via an extra span when charges === 3 */
.dash-charges .extra-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
}

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

/* Responsive */
@media (max-width: 768px) {
    .jump-dash-container {
        padding: 8px;
    }

    .jump-dash-header h1 {
        font-size: 1.25rem;
    }

    .jump-dash-screen {
        border-radius: 12px;
    }

    .mobile-controls {
        display: flex;
    }

    .hud-left,
    .hud-right {
        font-size: 0.85rem;
    }

    .hud-center {
        width: min(50%, 200px);
    }
}

@media (max-width: 480px) {
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .overlay-panel {
        padding: 20px;
    }

    .touch-btn {
        width: 76px;
        height: 76px;
    }
}
