:root {
    --bg-darker: #0b0c10;
    --bg-dark: #1f2833;
    --bg-panel: rgba(31, 40, 51, 0.6);
    --border-color: rgba(102, 252, 241, 0.2);
    --text-primary: #c5c6c7;
    --text-light: #ffffff;
    
    /* Neon accents */
    --neon-blue: #66fcf1;
    --neon-blue-glow: rgba(102, 252, 241, 0.4);
    --neon-pink: #ff007f;
    --neon-pink-glow: rgba(255, 0, 127, 0.4);
    --neon-green: #39ff14;
    --neon-green-glow: rgba(57, 255, 20, 0.4);
    --neon-yellow: #fff01f;
    --neon-yellow-glow: rgba(255, 240, 31, 0.4);
    --neon-red: #ff355e;
    --neon-red-glow: rgba(255, 53, 94, 0.4);

    --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 20% 30%, rgba(102, 252, 241, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 127, 0.05) 0%, transparent 40%),
        linear-gradient(rgba(18, 18, 18, 0.4) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 18, 18, 0.4) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
}

/* 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(11, 12, 16, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(102, 252, 241, 0.05);
    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: #0b0c10;
    border-radius: 8px;
    border: 2px solid rgba(102, 252, 241, 0.3);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.8);
    display: block;
}

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

.dashboard-header {
    border-bottom: 1px solid rgba(197, 198, 199, 0.1);
    padding-bottom: 15px;
    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 10px 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: 600;
    letter-spacing: 1px;
    color: rgba(197, 198, 199, 0.6);
}

@keyframes pulse-dot {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.1); 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(11, 12, 16, 0.6);
    border: 1px solid rgba(197, 198, 199, 0.08);
    border-radius: 8px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform var(--transition-speed), border var(--transition-speed);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(102, 252, 241, 0.3);
}

.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(197, 198, 199, 0.6);
    letter-spacing: 1px;
}

.stat-icon {
    width: 16px;
    height: 16px;
    fill: rgba(197, 198, 199, 0.4);
}

.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(11, 12, 16, 0.6);
    border: 1px solid rgba(197, 198, 199, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

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

/* 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);
}

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

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

.btn-icon {
    background: rgba(11, 12, 16, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    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 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1px;
    padding: 12px 20px;
    border-radius: 8px;
    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: var(--bg-darker);
    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.6);
    transform: scale(1.03);
}

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(197, 198, 199, 0.3);
    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(197, 198, 199, 0.1);
    padding-top: 15px;
    font-size: 0.7rem;
    color: rgba(197, 198, 199, 0.4);
    line-height: 1.4;
    text-align: center;
}

/* Canvas Overlays */
.overlay {
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: rgba(11, 12, 16, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    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: 400px;
    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.5rem;
    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: -10px;
    background-color: var(--neon-pink);
    color: var(--text-light);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 6px var(--neon-pink-glow);
}

.overlay-intro {
    font-size: 0.9rem;
    color: rgba(197, 198, 199, 0.8);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Key instructions design */
.instructions-card {
    background: rgba(11, 12, 16, 0.5);
    border: 1px solid rgba(197, 198, 199, 0.15);
    border-radius: 8px;
    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: 1px;
    margin-bottom: 12px;
    color: rgba(197, 198, 199, 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(197, 198, 199, 0.6);
}

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

.key-cap {
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-light);
    box-shadow: 0 2px 0 #111;
    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(197, 198, 199, 0.6);
    text-transform: uppercase;
    margin-top: 5px;
    margin-bottom: 25px;
}

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

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

.summary-label {
    font-size: 0.7rem;
    color: rgba(197, 198, 199, 0.5);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-val {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    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 16px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 0 12px 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(197, 198, 199, 0.5);
    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(102, 252, 241, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(102, 252, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(102, 252, 241, 0); }
}

/* Mobile Controls Styling */
.mobile-controls {
    display: none; /* Hidden by default on desktop */
}

/* 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; /* Hide footer to save space on mobile */
    }
}

/* Detect Touch Support or Mobile Layout - Display Mobile Controller */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
    .mobile-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 10px;
        width: 100%;
    }

    .d-pad {
        position: relative;
        width: 160px;
        height: 160px;
        background: rgba(11, 12, 16, 0.4);
        border: 2px solid rgba(102, 252, 241, 0.15);
        border-radius: 50%;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    }

    .d-pad-btn {
        position: absolute;
        background: rgba(31, 40, 51, 0.8);
        border: 1px solid rgba(102, 252, 241, 0.25);
        color: var(--neon-blue);
        width: 48px;
        height: 48px;
        border-radius: 12px;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        outline: none;
        transition: background-color 0.1s, transform 0.1s;
    }

    .d-pad-btn:active {
        background-color: var(--neon-blue);
        color: var(--bg-darker);
        transform: scale(0.92);
        box-shadow: 0 0 10px var(--neon-blue-glow);
    }

    .d-pad-btn svg {
        width: 24px;
        height: 24px;
        fill: currentColor;
    }

    .d-pad-btn.up {
        top: 6px;
        left: 56px;
    }

    .d-pad-btn.down {
        bottom: 6px;
        left: 56px;
    }

    .d-pad-btn.left {
        top: 56px;
        left: 6px;
    }

    .d-pad-btn.right {
        top: 56px;
        right: 6px;
    }

    .d-pad-center {
        position: absolute;
        top: 58px;
        left: 58px;
        width: 44px;
        height: 44px;
        background: rgba(11, 12, 16, 0.9);
        border-radius: 50%;
        border: 1px solid rgba(102, 252, 241, 0.1);
    }
}
