@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;900&family=Press+Start+2P&family=Space+Grotesk:wght@500;700&display=swap');

:root {
    --bg-dark: #070a14;
    --bg-card: rgba(14, 20, 38, 0.85);
    --border-glow: rgba(0, 255, 204, 0.25);
    --primary-neon: #00ffcc;
    --accent-pink: #ff007f;
    --accent-gold: #ffe600;
    --text-primary: #f0f4fc;
    --text-secondary: #8ba3c7;
    --font-heading: 'Outfit', sans-serif;
    --font-arcade: 'Press Start 2P', monospace;
    --font-ui: 'Space Grotesk', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 20% 15%, rgba(0, 255, 204, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 85%, rgba(255, 0, 127, 0.08) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    color: var(--text-primary);
    font-family: var(--font-heading);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1.5rem 1rem;
    overflow-x: hidden;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 1.25rem;
    width: 100%;
    max-width: 1050px;
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 12px var(--primary-neon));
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

h1 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--primary-neon) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.arcade-badge,
.python-badge {
    background: rgba(0, 255, 204, 0.12);
    color: var(--primary-neon);
    border: 1px solid rgba(0, 255, 204, 0.3);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.online-snakes-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.35);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
    transition: all 0.3s ease;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 8px #00ff88;
    animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 8px #00ff88;
    }
    50% {
        transform: scale(1.35);
        opacity: 0.6;
        box-shadow: 0 0 16px #00ff88;
    }
}

/* Main Layout */
.game-layout {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    width: 100%;
    max-width: 1050px;
    justify-content: center;
    align-items: flex-start;
}

/* Game Container */
.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glow);
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 255, 204, 0.1);
}

/* HUD Top Bar */
.hud-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(7, 11, 25, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.score-box {
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.8px;
}

.score-val {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    font-family: var(--font-ui);
    line-height: 1.1;
}

.score-val.highlight {
    color: var(--accent-gold);
}

.status-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-pill.live {
    background: rgba(0, 255, 204, 0.15);
    color: var(--primary-neon);
    border: 1px solid var(--primary-neon);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.3);
}

.status-pill.paused {
    background: rgba(255, 230, 0, 0.15);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
}

.status-pill.over {
    background: rgba(255, 0, 127, 0.15);
    color: var(--accent-pink);
    border: 1px solid var(--accent-pink);
}

/* Canvas Area */
.canvas-container {
    position: relative;
    width: 600px;
    height: 600px;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 0 25px rgba(0, 255, 204, 0.15), inset 0 0 15px rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(0, 255, 204, 0.4);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #070b19;
}

/* Game Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-top: 1rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

.btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.55rem 1rem;
    border-radius: 10px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn:hover {
    background: rgba(0, 255, 204, 0.15);
    border-color: var(--primary-neon);
    color: var(--primary-neon);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 204, 0.2);
}

.btn.btn-primary {
    background: linear-gradient(135deg, var(--primary-neon) 0%, #00cc99 100%);
    color: #050d1a;
    font-weight: 700;
    border: none;
}

.btn.btn-primary:hover {
    background: linear-gradient(135deg, #33ffdd 0%, var(--primary-neon) 100%);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.5);
    transform: translateY(-2px);
}

.select-control {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.select-control option {
    background: #0e1426;
    color: #fff;
}

/* Sidebar Leaderboard & Info */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 340px;
    flex-shrink: 0;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glow);
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.5rem;
}

.leaderboard-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(7, 11, 25, 0.5);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
    transition: transform 0.15s ease;
}

.leaderboard-item:hover {
    border-color: rgba(0, 255, 204, 0.3);
    transform: translateX(3px);
}

.rank-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rank-badge {
    font-weight: 700;
    color: var(--accent-gold);
    min-width: 22px;
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.score-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.score-meta .score-val {
    font-size: 0.95rem;
    color: var(--primary-neon);
    font-weight: 700;
}

.diff-tag {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
}

.empty-entry {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 1rem 0;
}

/* Instructions List */
.instructions-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.instructions-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.key-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 2px 8px;
    border-radius: 5px;
    font-family: monospace;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Mobile Virtual D-Pad */
.mobile-dpad {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 1rem;
    width: 100%;
}

.dpad-row {
    display: flex;
    gap: 8px;
}

.dpad-btn {
    width: 64px;
    height: 52px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(0, 255, 204, 0.3);
    color: var(--primary-neon);
    font-size: 1.4rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.dpad-btn:active {
    background: var(--primary-neon);
    color: #000;
    transform: scale(0.95);
}

/* Game Over Modal */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 11, 25, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.25s ease;
}

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

.modal-card {
    background: #0e1428;
    border: 2px solid var(--accent-pink);
    box-shadow: 0 0 35px rgba(255, 0, 127, 0.3);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    width: 90%;
    max-width: 360px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-card h3 {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--accent-pink);
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.modal-score-summary {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.modal-score-summary span {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
}

.input-field {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
    font-family: var(--font-heading);
    outline: none;
}

.input-field:focus {
    border-color: var(--primary-neon);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Footer status */
.app-footer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.dot.online {
    background-color: #00ff66;
    box-shadow: 0 0 8px #00ff66;
}

.dot.offline {
    background-color: #ffaa00;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }
    .sidebar {
        width: 100%;
        max-width: 600px;
    }
    .canvas-container {
        width: 100vw;
        max-width: 500px;
        height: auto;
    }
    .mobile-dpad {
        display: flex;
    }
}

@media (max-width: 540px) {
    h1 {
        font-size: 1.6rem;
    }
    .game-wrapper {
        padding: 0.75rem;
    }
    .hud-bar {
        padding: 0.4rem 0.5rem;
    }
    .score-val {
        font-size: 1.3rem;
    }
    .btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
    }
}
