/* CSS Variables for Arcade Neon Design System */
:root {
    --bg-dark: #07070c;
    --card-bg: rgba(16, 16, 30, 0.7);
    --border-neon: rgba(0, 255, 255, 0.25);
    --border-neon-glow: rgba(0, 255, 255, 0.4);
    
    /* Neon Colors */
    --neon-cyan: #00ffff;
    --neon-magenta: #ff007f;
    --neon-yellow: #ffd700;
    --neon-blue: #0055ff;
    --text-color: #e2e8f0;
    
    /* Fonts */
    --font-arcade: 'Press Start 2P', monospace;
    --font-digital: 'Orbitron', sans-serif;
    --font-ui: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-dark);
    background-image: 
        linear-gradient(rgba(0, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

/* Container */
.container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-neon);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(0, 255, 255, 0.1);
    max-width: 1140px;
    width: 100%;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 2px solid rgba(0, 255, 255, 0.1);
    padding-bottom: 15px;
}

h1 {
    font-family: var(--font-arcade);
    font-size: 1.6em;
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px var(--neon-cyan),
        0 0 20px var(--neon-cyan);
    letter-spacing: 2px;
}

/* Mute button */
.mute-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.1);
}

.mute-btn:hover {
    background: rgba(0, 255, 255, 0.15);
    border-color: var(--neon-cyan);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.sound-icon {
    font-size: 20px;
}

/* Game Layout Grid */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 25px;
    margin-bottom: 25px;
}

/* Main Area */
.game-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Game Info HUD */
.game-info {
    display: flex;
    justify-content: space-between;
    padding: 15px 25px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: inset 0 0 15px rgba(0, 255, 255, 0.1);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.label {
    font-family: var(--font-arcade);
    font-size: 0.65em;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
}

.digital-text {
    font-family: var(--font-digital);
    font-size: 1.8em;
    font-weight: 800;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* Canvas styling */
.canvas-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid var(--neon-blue);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.6),
        0 0 25px rgba(0, 85, 255, 0.3);
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #000;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Sidebar Area */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card.panel {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.card.panel h3 {
    font-family: var(--font-arcade);
    font-size: 0.75em;
    color: var(--neon-cyan);
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

/* Button & Selectors */
.button-container {
    display: flex;
    gap: 15px;
}

.mode-selector, .difficulty-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Basic Button Design */
.btn {
    padding: 12px 20px;
    font-family: var(--font-ui);
    font-size: 0.9em;
    font-weight: 700;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
    text-align: center;
    letter-spacing: 0.5px;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--neon-magenta) 0%, #a10052 100%);
    box-shadow: 0 4px 15px rgba(255, 0, 127, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(255, 0, 127, 0.5),
        0 0 10px var(--neon-magenta);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* Mode / Diff Buttons in Sidebar */
.mode-btn, .diff-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 10px;
    font-size: 0.8em;
    font-family: var(--font-arcade);
}

.mode-btn:hover, .diff-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.mode-btn.active {
    background: rgba(0, 85, 255, 0.2);
    border-color: var(--neon-blue);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 85, 255, 0.4);
    text-shadow: 0 0 5px #fff;
}

.diff-btn.active {
    background: rgba(255, 0, 127, 0.15);
    border-color: var(--neon-magenta);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
    text-shadow: 0 0 5px #fff;
}

/* High Scores List */
.high-scores-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.high-scores-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    font-family: var(--font-digital);
    font-size: 1.1em;
    border-left: 3px solid var(--neon-yellow);
}

.high-scores-list li:nth-child(1) { border-left-color: #ffd700; }
.high-scores-list li:nth-child(2) { border-left-color: #c0c0c0; }
.high-scores-list li:nth-child(3) { border-left-color: #cd7f32; }
.high-scores-list li:nth-child(4) { border-left-color: rgba(255, 255, 255, 0.2); }
.high-scores-list li:nth-child(5) { border-left-color: rgba(255, 255, 255, 0.2); }

.rank {
    font-family: var(--font-arcade);
    font-size: 0.6em;
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
}

.score-val {
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
}

/* Rules Section */
.controls {
    margin-top: 30px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.controls h2 {
    font-family: var(--font-arcade);
    font-size: 0.85em;
    color: var(--neon-yellow);
    margin-bottom: 20px;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

.rules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.rule-block h4 {
    color: #fff;
    margin-bottom: 12px;
    font-size: 1.05em;
    font-weight: 600;
}

.rule-block p {
    font-size: 0.9em;
    line-height: 1.6;
    color: #94a3b8;
    margin-bottom: 8px;
}

.rule-block strong {
    color: var(--text-color);
}

kbd {
    background: #1e1e2f;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--neon-cyan);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    font-size: 0.85em;
    margin: 0 2px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.5);
}

/* Game Over Screen */
.game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 7, 12, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-over h2 {
    font-family: var(--font-arcade);
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.4;
}

.game-over p {
    font-size: 1.2em;
    margin-bottom: 30px;
    color: #94a3b8;
    text-align: center;
    max-width: 500px;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Touch controls for Mobile devices */
.touch-controls {
    display: none;
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 65px);
    grid-template-rows: repeat(3, 65px);
    gap: 8px;
}

.dpad-btn {
    background: rgba(16, 16, 30, 0.85);
    border: 1px solid var(--neon-cyan);
    border-radius: 12px;
    color: var(--neon-cyan);
    font-size: 26px;
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(0, 255, 255, 0.1);
    transition: all 0.1s ease;
}

.dpad-btn:active {
    background: var(--neon-cyan);
    color: #000;
    transform: scale(0.92);
    box-shadow: 0 0 20px var(--neon-cyan);
}

.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 3; }

/* Responsive adjustments */
@media (max-width: 992px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
    
    .game-sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .game-sidebar .card.panel:last-child {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        border-radius: 16px;
    }
    
    h1 {
        font-size: 1.1em;
    }
    
    .mute-btn {
        width: 40px;
        height: 40px;
    }
    
    .game-sidebar {
        grid-template-columns: 1fr;
    }
    
    .game-sidebar .card.panel:last-child {
        grid-column: span 1;
    }
    
    .rules-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* Show touch controls on touch-enabled screens only when in portrait or small viewport */
@media (max-width: 860px) and (hover: none) {
    body {
        padding-bottom: 230px; /* Space for D-pad */
    }
    
    .touch-controls {
        display: block;
    }
    
    /* Minimize textual instruction details on mobile screen */
    .controls {
        display: none;
    }
}
