/* ========================================
   BIKE KART RACING — Styles
   ======================================== */
:root {
    --bg-dark: #0a0a1a;
    --bg-card: #12122a;
    --primary: #00e5ff;
    --secondary: #ff3d71;
    --accent: #f5a623;
    --green: #00e676;
    --purple: #b388ff;
    --text: #e8eaf6;
    --text-dim: #7986cb;
    --glow-primary: 0 0 20px rgba(0, 229, 255, 0.4);
    --glow-secondary: 0 0 20px rgba(255, 61, 113, 0.4);
    --radius: 12px;
    --font-display: 'Press Start 2P', monospace;
    --font-body: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ---- Screens ---- */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.screen.active {
    display: flex;
}

/* ---- Main Menu ---- */
.menu-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0a0a2e 0%, #1a0a3e 40%, #0a1a3e 100%);
    z-index: 0;
}

.menu-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(0, 229, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 61, 113, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(179, 136, 255, 0.1) 0%, transparent 60%);
    animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.menu-content {
    position: relative;
    z-index: 2;
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-title {
    font-family: var(--font-display);
    font-size: 3rem;
    line-height: 1.4;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.title-bike {
    color: var(--primary);
    text-shadow: 0 0 30px rgba(0, 229, 255, 0.6), 0 0 60px rgba(0, 229, 255, 0.3);
    animation: glowPulse 2s ease-in-out infinite alternate;
}

.title-kart {
    color: var(--secondary);
    text-shadow: 0 0 30px rgba(255, 61, 113, 0.6), 0 0 60px rgba(255, 61, 113, 0.3);
    animation: glowPulse 2s ease-in-out infinite alternate 0.5s;
    font-size: 4.5rem;
}

.title-racing {
    color: var(--accent);
    text-shadow: 0 0 30px rgba(245, 166, 35, 0.6), 0 0 60px rgba(245, 166, 35, 0.3);
    animation: glowPulse 2s ease-in-out infinite alternate 1s;
}

@keyframes glowPulse {
    from {
        filter: brightness(1);
    }

    to {
        filter: brightness(1.3);
    }
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

/* ---- Buttons ---- */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.menu-btn {
    font-family: var(--font-display);
    font-size: 0.9rem;
    border: none;
    padding: 18px 48px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.menu-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.menu-btn:hover::before {
    transform: translateX(100%);
}

.menu-btn.primary {
    background: linear-gradient(135deg, var(--primary), #0091ea);
    color: #000;
    box-shadow: var(--glow-primary);
}

.menu-btn.primary:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.6);
}

.menu-btn.secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 2px solid rgba(0, 229, 255, 0.3);
}

.menu-btn.secondary:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--glow-primary);
}

.btn-icon {
    font-size: 1.2rem;
    font-family: sans-serif;
}

/* ---- Screen Header ---- */
.screen-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 5;
}

.screen-header h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--primary);
    text-shadow: var(--glow-primary);
}

.back-btn {
    font-family: var(--font-display);
    font-size: 0.7rem;
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: var(--primary);
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(0, 229, 255, 0.2);
    box-shadow: var(--glow-primary);
}

/* ---- Track Select ---- */
#track-screen {
    background: var(--bg-dark);
    flex-direction: column;
}

.track-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 100px 40px 40px;
    max-width: 1000px;
    width: 100%;
}

.track-card {
    background: var(--bg-card);
    border: 2px solid rgba(0, 229, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.track-card:hover {
    border-color: var(--primary);
    transform: translateY(-6px);
    box-shadow: var(--glow-primary);
}

.track-card .track-emoji {
    font-size: 3rem;
    margin-bottom: 12px;
}

.track-card .track-name {
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--text);
    margin-bottom: 8px;
}

.track-card .track-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* ---- How To Play ---- */
#how-screen {
    background: var(--bg-dark);
    flex-direction: column;
}

.controls-info {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    padding: 100px 40px 20px;
    max-width: 800px;
}

.control-item {
    background: var(--bg-card);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: var(--radius);
    padding: 20px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 200px;
}

.key-group {
    display: flex;
    gap: 4px;
}

.key {
    font-family: var(--font-display);
    font-size: 0.6rem;
    background: linear-gradient(180deg, #2a2a4a, #1a1a3a);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--primary);
    min-width: 36px;
    text-align: center;
    box-shadow: 0 3px 0 #0a0a2a;
}

.control-label {
    font-size: 0.95rem;
    color: var(--text);
}

.controls-divider {
    width: 100%;
    text-align: center;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-size: 0.55rem;
    padding: 8px 0;
    letter-spacing: 2px;
}

.mouse-key {
    background: linear-gradient(180deg, #2a1a4a, #1a1a3a);
    border-color: rgba(179, 136, 255, 0.3);
    color: var(--purple);
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
}

.powerup-list {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid rgba(255, 61, 113, 0.2);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 10px;
}

.powerup-list h3 {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--secondary);
    margin-bottom: 16px;
    text-shadow: var(--glow-secondary);
}

.pu-item {
    padding: 8px 0;
    color: var(--text-dim);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pu-icon {
    font-size: 1.3rem;
}

/* ---- Game Screen ---- */
#game-screen {
    background: #000;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: none;
}

/* ---- HUD ---- */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 20;
}

.hud-left,
.hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-position {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(245, 166, 35, 0.5);
}

.hud-lap {
    font-family: var(--font-display);
    font-size: 0.6rem;
    color: var(--text-dim);
}

.hud-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-countdown {
    font-family: var(--font-display);
    font-size: 4rem;
    color: var(--secondary);
    text-shadow: 0 0 40px rgba(255, 61, 113, 0.8);
    animation: countPulse 0.5s ease-out;
}

@keyframes countPulse {
    from {
        transform: scale(2);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.hud-right {
    align-items: flex-end;
}

.hud-speed {
    font-family: var(--font-display);
    font-size: 0.65rem;
    color: var(--green);
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
}

.powerup-slot {
    width: 60px;
    height: 60px;
    background: rgba(18, 18, 42, 0.8);
    border: 2px solid rgba(0, 229, 255, 0.3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.powerup-slot.has-item {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(245, 166, 35, 0.4);
    animation: itemBounce 0.5s ease-out;
}

@keyframes itemBounce {
    0% {
        transform: scale(0.5) rotate(-20deg);
    }

    60% {
        transform: scale(1.2) rotate(5deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* ---- Minimap ---- */
.minimap {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 160px;
    height: 160px;
    border-radius: 12px;
    border: 2px solid rgba(0, 229, 255, 0.3);
    background: rgba(10, 10, 26, 0.7);
    backdrop-filter: blur(5px);
    z-index: 20;
    pointer-events: none;
}

/* ---- Results ---- */
#results-screen {
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
}

.results-content {
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
    max-width: 500px;
    width: 100%;
    padding: 20px;
}

.results-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: 30px;
    text-shadow: 0 0 30px rgba(245, 166, 35, 0.5);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 30px;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.result-row.player {
    border-color: var(--primary);
    box-shadow: var(--glow-primary);
}

.result-pos {
    font-family: var(--font-display);
    font-size: 0.9rem;
    min-width: 50px;
    text-align: left;
}

.result-pos.gold {
    color: #ffd700;
}

.result-pos.silver {
    color: #c0c0c0;
}

.result-pos.bronze {
    color: #cd7f32;
}

.result-name {
    flex: 1;
    text-align: left;
    padding-left: 12px;
    font-weight: 600;
}

.result-time {
    font-family: var(--font-display);
    font-size: 0.6rem;
    color: var(--text-dim);
}

.results-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.results-buttons .menu-btn {
    font-size: 0.7rem;
    padding: 14px 32px;
    min-width: auto;
}

/* ---- Animations ---- */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.8rem;
    }

    .title-kart {
        font-size: 2.8rem;
    }

    .track-grid {
        grid-template-columns: 1fr;
        padding: 90px 20px 20px;
    }

    .controls-info {
        padding: 90px 20px 20px;
    }

    .menu-btn {
        min-width: 240px;
        font-size: 0.75rem;
    }
}