:root {
    --bg-darker: #050508;
    --bg-dark: #12121c;
    --bg-panel: rgba(18, 18, 28, 0.65);
    --border-color: rgba(102, 252, 241, 0.15);
    --text-primary: #a9abc0;
    --text-light: #ffffff;
    
    /* Neon accents */
    --neon-blue: #00f0ff;
    --neon-blue-glow: rgba(0, 240, 255, 0.45);
    --neon-pink: #ff007f;
    --neon-pink-glow: rgba(255, 0, 127, 0.45);
    --neon-green: #39ff14;
    --neon-green-glow: rgba(57, 255, 20, 0.45);
    --neon-yellow: #ffdf00;
    --neon-yellow-glow: rgba(255, 223, 0, 0.45);
    --neon-red: #ff3c3c;
    --neon-red-glow: rgba(255, 60, 60, 0.45);
    --neon-purple: #9d4edd;
    --neon-purple-glow: rgba(157, 78, 221, 0.45);

    --font-heading: 'Orbitron', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --transition-speed: 0.3s;
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 0, 127, 0.04) 0%, transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(0, 240, 255, 0.04) 0%, transparent 45%),
        linear-gradient(rgba(18, 18, 28, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 18, 28, 0.2) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px;
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    max-height: 800px;
    padding: 20px;
}

/* Game Area Viewport */
.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: rgba(5, 5, 8, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(0, 240, 255, 0.03);
    overflow: hidden;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 580px;
    max-height: 580px;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background-color: #050508;
    border-radius: 12px;
    border: 2px solid rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    display: block;
}

/* Sidebar Dashboard Style */
.dashboard {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.dashboard-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.dashboard-title {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.8rem;
    letter-spacing: 2px;
    color: var(--text-light);
    text-shadow: 0 0 12px var(--neon-blue-glow);
}

.game-status-indicator {
    display: flex;
    align-items: center;
    margin-top: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    position: relative;
}

.status-dot.online {
    background-color: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green-glow);
    animation: pulse-dot 1.5s infinite ease-in-out;
}

.status-text {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
}

@keyframes pulse-dot {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

/* Stats Cards */
.stats-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(5, 5, 8, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform var(--transition-speed), border-color var(--transition-speed);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 240, 255, 0.35);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-title {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1.5px;
}

.stat-icon {
    width: 16px;
    height: 16px;
    fill: rgba(255, 255, 255, 0.3);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 1px;
}

.stat-grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-mini {
    background: rgba(5, 5, 8, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-mini-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-mini-value {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
}

/* Neon Text Colors */
.neon-text-blue {
    color: var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue-glow);
}

.neon-text-green {
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green-glow);
}

.neon-text-pink {
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink-glow);
}

.neon-text-yellow {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow-glow);
}

.neon-text-red {
    color: var(--neon-red);
    text-shadow: 0 0 15px var(--neon-red-glow);
}

.neon-text-purple {
    color: var(--neon-purple);
    text-shadow: 0 0 10px var(--neon-purple-glow);
}

/* Controls & Buttons Panel */
.controls-panel {
    margin-bottom: 15px;
}

.audio-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    background: rgba(5, 5, 8, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.btn-icon:hover {
    border-color: var(--neon-blue);
    box-shadow: 0 0 8px var(--neon-blue-glow);
    transform: scale(1.05);
}

.btn-icon .icon {
    width: 20px;
    height: 20px;
    fill: var(--neon-blue);
}

.btn-icon.muted .icon {
    fill: var(--text-primary);
}

.btn {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1.5px;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-speed) cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
    border: none;
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background-color: var(--neon-blue);
    color: #050508;
    box-shadow: 0 0 15px var(--neon-blue-glow);
}

.btn-primary:hover {
    background-color: var(--text-light);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.7);
    transform: scale(1.03);
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    flex-grow: 1;
}

.btn-secondary:hover {
    border-color: var(--text-light);
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.05);
}

.dashboard-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 15px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.4;
    text-align: center;
}

/* Canvas Overlays */
.overlay {
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: rgba(5, 5, 8, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity var(--transition-speed) ease;
    padding: 20px;
}

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

.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 420px;
    width: 100%;
    animation: zoom-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes zoom-in {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.neon-title {
    font-family: var(--font-heading);
    font-size: 2.3rem;
    font-weight: 900;
    color: var(--neon-blue);
    text-shadow: 0 0 15px var(--neon-blue-glow);
    margin-bottom: 2px;
    letter-spacing: 3px;
}

.logo-container {
    position: relative;
    margin-bottom: 12px;
}

.version-tag {
    position: absolute;
    bottom: -8px;
    right: -12px;
    background-color: var(--neon-pink);
    color: var(--text-light);
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 6px var(--neon-pink-glow);
}

.overlay-intro {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Key instructions design */
.instructions-card {
    background: rgba(5, 5, 8, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 16px 20px;
    width: 100%;
    margin-bottom: 24px;
    text-align: left;
}

.instructions-card h3 {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
}

.controls-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.control-action {
    color: rgba(255, 255, 255, 0.5);
}

.control-keys {
    font-family: var(--font-heading);
    color: var(--neon-blue);
    font-size: 0.8rem;
}

.key-cap {
    background: #252538;
    border: 1px solid #44445c;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-light);
    box-shadow: 0 2px 0 #0d0d14;
    display: inline-block;
    margin: 0 2px;
}

/* Overlay Game Over Specifics */
.overlay-subtitle {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    margin-top: 5px;
    margin-bottom: 25px;
}

.stats-summary {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.02);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.summary-item:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-val {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-light);
}

.highscore-badge {
    background-color: var(--neon-pink);
    color: var(--text-light);
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 0.85rem;
    padding: 6px 18px;
    border-radius: 20px;
    letter-spacing: 1.5px;
    box-shadow: 0 0 15px var(--neon-pink-glow);
    margin-bottom: 25px;
    animation: bounce 1.2s infinite ease-in-out;
}

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

.restart-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 20px;
}

/* Pulse animation for buttons */
.animate-pulse {
    animation: pulse-button 1.8s infinite;
}

@keyframes pulse-button {
    0% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(0, 240, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

/* Responsive CSS - Adapt layout for smaller screens / portrait orientation */
@media (max-width: 900px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
        align-items: flex-start;
        padding: 10px 0;
    }

    .app-container {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        width: 100%;
        max-width: 600px;
        padding: 10px;
        gap: 15px;
    }

    .game-container {
        aspect-ratio: 1 / 1;
        width: 100%;
    }

    .canvas-wrapper {
        max-width: 100%;
        max-height: 100%;
    }

    .dashboard {
        order: -1; /* Display dashboard at the top */
        padding: 15px;
        gap: 12px;
        height: auto;
    }

    .dashboard-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .dashboard-title {
        font-size: 1.4rem;
    }

    .game-status-indicator {
        margin-top: 0;
    }

    .stats-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 8px;
    }

    .stat-card {
        padding: 8px 12px;
        gap: 2px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-grid-row {
        grid-column: span 2;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-mini {
        padding: 6px 10px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .stat-mini-label {
        margin-bottom: 0;
    }

    .stat-mini-value {
        font-size: 0.95rem;
    }

    .controls-panel {
        margin-bottom: 0;
    }

    .audio-control {
        justify-content: center;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.75rem;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .btn-icon .icon {
        width: 16px;
        height: 16px;
    }

    .dashboard-footer {
        display: none;
    }
}
