:root {
    --primary: #00ff9d;
    --secondary: #00d4ff;
    --tertiary: #ff006e;
    --bg-dark: #0a0e27;
    --bg-darker: #050810;
    --text: #e0e6f5;
    --text-dim: #8892b0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-darker);
    color: var(--text);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Neural Network Background */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.3;
}

/* Game Container */
.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    z-index: 10;
    display: none; /* Hidden by default, shown only with ?game=true */
}

.game-canvas-wrapper {
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 250px;
    background: linear-gradient(135deg, rgba(0, 255, 157, 0.03) 0%, rgba(0, 212, 255, 0.03) 100%);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 12px;
    display: block;
    box-shadow: 0 0 30px rgba(0, 255, 157, 0.1);
}

.game-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 11;
    width: 90%;
    max-width: 600px;
}

.game-overlay.has-background {
    background: rgba(10, 14, 39, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 2rem 1rem;
    border: 1px solid rgba(0, 255, 157, 0.3);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    max-height: 90%;
    overflow-y: auto;
}

.game-overlay.has-background::-webkit-scrollbar {
    width: 6px;
}

.game-overlay.has-background::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.game-overlay.has-background::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.game-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 20px var(--primary);
    letter-spacing: 0.3em;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.game-instructions {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    padding: 0 20px;
}

.game-start {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    color: var(--secondary);
    animation: pulse 2s ease-in-out infinite;
    margin-top: 1rem;
}

.new-high-score {
    font-size: 1rem;
    color: var(--primary);
    margin: 1rem 0;
    animation: celebration 0.6s ease-in-out infinite alternate;
    line-height: 1.4;
}

.game-score {
    font-family: 'JetBrains Mono', monospace;
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 0.9rem;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary);
    z-index: 12;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes celebration {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* Leaderboard Styles */
.leaderboard-submit {
    margin: 1.5rem auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-width: 300px;
    pointer-events: all;
}

.leaderboard-submit input {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.3s ease;
}

.leaderboard-submit input:focus {
    outline: none;
    border-color: var(--secondary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.leaderboard-submit input::placeholder {
    color: var(--text-dim);
}

.leaderboard-submit button {
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    pointer-events: all;
}

.leaderboard-submit button:hover:not(:disabled) {
    background: var(--primary);
    color: var(--bg-darker);
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.4);
    transform: translateY(-2px);
}

.leaderboard-submit button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.leaderboard-submit button:nth-child(3) {
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
}

.leaderboard-submit button:nth-child(3):hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.leaderboard-list {
    max-width: 400px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 40px 1fr 60px;
    gap: 1rem;
    align-items: center;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 255, 157, 0.05);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.3s ease;
}

.leaderboard-entry .player-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow: hidden;
}

.leaderboard-entry:hover {
    background: rgba(0, 255, 157, 0.1);
    border-color: rgba(0, 255, 157, 0.4);
    transform: translateX(5px);
}

.leaderboard-entry:nth-child(1) {
    border-color: gold;
    background: rgba(255, 215, 0, 0.1);
}

.leaderboard-entry:nth-child(2) {
    border-color: silver;
    background: rgba(192, 192, 192, 0.1);
}

.leaderboard-entry:nth-child(3) {
    border-color: #cd7f32;
    background: rgba(205, 127, 50, 0.1);
}

.leaderboard-entry .rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

.leaderboard-entry:nth-child(1) .rank {
    color: gold;
}

.leaderboard-entry:nth-child(2) .rank {
    color: silver;
}

.leaderboard-entry:nth-child(3) .rank {
    color: #cd7f32;
}

.leaderboard-entry .player-name {
    color: var(--text);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.95rem;
}

.leaderboard-entry .player-date {
    color: var(--text-dim);
    font-size: 0.75rem;
    opacity: 0.7;
}

.leaderboard-entry .score {
    font-weight: 700;
    color: var(--secondary);
    text-align: right;
}

/* Leaderboard Sidebar */
.leaderboard-sidebar {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 15px auto 0;
    background: rgba(10, 14, 39, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 10px;
    padding: 1rem;
    z-index: 11;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.leaderboard-sidebar:hover {
    border-color: rgba(0, 255, 157, 0.4);
    box-shadow: 0 8px 32px rgba(0, 255, 157, 0.2);
}

.sidebar-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 0.75rem;
    text-shadow: 0 0 10px var(--primary);
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sidebar-title::after {
    content: '▼';
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

.leaderboard-sidebar.collapsed .sidebar-title::after {
    transform: rotate(-90deg);
}

.sidebar-leaderboard {
    max-height: 180px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.leaderboard-sidebar.collapsed .sidebar-leaderboard {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

.leaderboard-sidebar.collapsed .sidebar-title {
    margin-bottom: 0;
}

.leaderboard-sidebar.collapsed {
    padding: 0.8rem 1rem;
}

.sidebar-leaderboard::-webkit-scrollbar {
    width: 6px;
}

.sidebar-leaderboard::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.sidebar-leaderboard::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.sidebar-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 1.5rem 0.5rem;
}

.sidebar-entry {
    display: grid;
    grid-template-columns: 24px 1fr 45px;
    gap: 0.6rem;
    align-items: center;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.3rem;
    background: rgba(0, 255, 157, 0.05);
    border: 1px solid rgba(0, 255, 157, 0.15);
    border-radius: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow: hidden;
}

.sidebar-entry:hover {
    background: rgba(0, 255, 157, 0.1);
    border-color: rgba(0, 255, 157, 0.3);
    transform: translateX(-2px);
}

.sidebar-entry:nth-child(1) {
    border-color: gold;
    background: rgba(255, 215, 0, 0.08);
}

.sidebar-entry:nth-child(2) {
    border-color: silver;
    background: rgba(192, 192, 192, 0.08);
}

.sidebar-entry:nth-child(3) {
    border-color: #cd7f32;
    background: rgba(205, 127, 50, 0.08);
}

.sidebar-entry .rank {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

.sidebar-entry:nth-child(1) .rank {
    color: gold;
}

.sidebar-entry:nth-child(2) .rank {
    color: silver;
}

.sidebar-entry:nth-child(3) .rank {
    color: #cd7f32;
}

.sidebar-entry .player-name {
    color: var(--text);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.8rem;
}

.sidebar-entry .player-date {
    color: var(--text-dim);
    font-size: 0.65rem;
    opacity: 0.7;
}

.sidebar-entry .score {
    font-weight: 700;
    color: var(--secondary);
    text-align: right;
    font-size: 0.85rem;
}

.sidebar-entry.highlight-player {
    animation: highlightPulse 1s ease-in-out 3;
    border-color: var(--primary);
    background: rgba(0, 255, 157, 0.15);
}

@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 0 0 rgba(0, 255, 157, 0.4);
        transform: translateX(0);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 255, 157, 0.6);
        transform: translateX(-3px);
    }
}

/* Main Content */
main {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem;
    z-index: 5;
}

.content {
    text-align: center;
    max-width: 800px;
}

.name-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--tertiary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(0, 255, 157, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 40px rgba(0, 255, 157, 0.8)) drop-shadow(0 0 60px rgba(0, 212, 255, 0.5));
    }
}

.neural-line {
    width: 60%;
    height: 2px;
    margin: 1rem auto;
    background: linear-gradient(90deg, transparent, var(--primary), var(--secondary), transparent);
    position: relative;
    overflow: hidden;
}

.neural-line::before {
    content: '';
    position: absolute;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: scan 3s linear infinite;
}

@keyframes scan {
    0% { left: -30%; }
    100% { left: 130%; }
}

.title {
    font-size: 1.5rem;
    color: var(--text-dim);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    font-weight: 300;
}

.tech-badge {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.badge-item {
    font-family: 'JetBrains Mono', monospace;
    padding: 0.5rem 1.5rem;
    border: 1px solid var(--primary);
    border-radius: 20px;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    background: rgba(0, 255, 157, 0.05);
    color: var(--primary);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.badge-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 157, 0.2), transparent);
    transition: left 0.5s ease;
}

.badge-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 255, 157, 0.3);
}

.badge-item:hover::before {
    left: 100%;
}

/* Footer */
footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    padding: 2rem;
    z-index: 10;
    background: linear-gradient(to top, var(--bg-darker) 0%, transparent 100%);
}

.social-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.social-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.social-link:hover::before {
    left: 100%;
}

.social-link:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 5px 20px rgba(0, 255, 157, 0.2);
    background: rgba(0, 255, 157, 0.05);
}

.social-link[data-social="twitter"]:hover {
    border-color: var(--secondary);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.2);
}

.social-link[data-social="github"]:hover {
    border-color: var(--tertiary);
    box-shadow: 0 5px 20px rgba(255, 0, 110, 0.2);
}

.social-link svg {
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .leaderboard-sidebar {
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .leaderboard-sidebar {
        position: fixed;
        bottom: -100%;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 40px);
        max-width: 400px;
        margin: 0;
        transition: bottom 0.3s ease, padding 0.3s ease;
        z-index: 101;
    }
    
    .leaderboard-sidebar.mobile-visible {
        bottom: 140px;
    }
    
    .leaderboard-sidebar.collapsed.mobile-visible {
        padding: 0.8rem 1rem;
    }
    
    body.game-enabled .leaderboard-toggle {
        display: flex !important;
        position: fixed;
        bottom: 80px;
        right: 20px;
        z-index: 100;
        background: rgba(10, 14, 39, 0.9);
        backdrop-filter: blur(10px);
        border: 2px solid var(--primary);
        border-radius: 50%;
        width: 56px;
        height: 56px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 20px rgba(0, 255, 157, 0.4);
        font-size: 1.5rem;
    }
    
    .leaderboard-toggle:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 30px rgba(0, 255, 157, 0.6);
    }
    
    .leaderboard-toggle:active {
        transform: scale(0.95);
    }
}

.leaderboard-toggle {
    display: none; /* Hidden by default, shown only with ?game=true */
}

@media (max-width: 768px) {
    .name {
        font-size: 2.5rem;
        letter-spacing: 0.1em;
    }

    .title {
        font-size: 1.1rem;
        letter-spacing: 0.2em;
    }

    .game-container {
        padding: 15px;
    }

    .game-title {
        font-size: 1.8rem;
        letter-spacing: 0.2em;
        margin-bottom: 1rem;
    }

    .game-instructions {
        font-size: 0.85rem;
        margin-bottom: 1rem;
        padding: 0 10px;
    }

    .game-start {
        font-size: 1rem;
        margin-top: 0.8rem;
    }

    .new-high-score {
        font-size: 0.9rem;
        margin: 0.8rem 0;
    }

    .leaderboard-submit {
        max-width: 250px;
        gap: 0.6rem;
    }

    .leaderboard-submit input,
    .leaderboard-submit button {
        font-size: 0.85rem;
        padding: 0.7rem;
    }

    .leaderboard-list {
        max-width: 350px;
        padding: 0 0.5rem;
    }

    .leaderboard-entry {
        grid-template-columns: 35px 1fr 55px;
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }

    #game-canvas {
        height: 200px;
        border-radius: 8px;
    }

    .game-score {
        font-size: 0.7rem;
        top: 20px;
        right: 20px;
    }

    .social-container {
        gap: 1rem;
    }

    .social-link {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .tech-badge {
        gap: 0.75rem;
    }

    .badge-item {
        padding: 0.4rem 1rem;
        font-size: 0.75rem;
    }

    main {
        min-height: 50vh;
    }
}

@media (max-width: 480px) {
    .name {
        font-size: 2rem;
    }

    .title {
        font-size: 0.9rem;
    }

    .game-container {
        padding: 10px;
    }

    .game-title {
        font-size: 1.4rem;
        letter-spacing: 0.15em;
        margin-bottom: 0.8rem;
    }

    .game-instructions {
        font-size: 0.75rem;
        margin-bottom: 0.8rem;
        padding: 0 5px;
    }

    .game-start {
        font-size: 0.9rem;
        margin-top: 0.6rem;
    }

    .new-high-score {
        font-size: 0.8rem;
        margin: 0.6rem 0;
    }

    #game-canvas {
        height: 180px;
    }

    .game-score {
        font-size: 0.65rem;
        top: 15px;
        right: 15px;
    }

    .social-link span {
        display: none;
    }

    .social-link {
        padding: 0.75rem;
    }

    .badge-item {
        padding: 0.35rem 0.8rem;
        font-size: 0.7rem;
    }

    .leaderboard-submit {
        max-width: 220px;
    }

    .leaderboard-submit input,
    .leaderboard-submit button {
        font-size: 0.8rem;
        padding: 0.6rem;
    }

    .leaderboard-list {
        max-width: 300px;
    }

    .leaderboard-entry {
        grid-template-columns: 30px 1fr 50px;
        padding: 0.5rem 0.6rem;
        font-size: 0.75rem;
    }

    .leaderboard-entry .rank {
        font-size: 1rem;
    }
}
