:root {
    --primary-color: #00ccff;
    --secondary-color: #ff00aa;
    --accent-color: #FFD700;
    --tertiary-color: #00ffaa;
    --dark-bg: #0a0a16;
    --dark-bg-alt: #0f0f22;
    --cyan-glow: 0 0 10px rgba(0, 204, 255, 0.7), 0 0 20px rgba(0, 204, 255, 0.4);
    --magenta-glow: 0 0 10px rgba(255, 0, 170, 0.7), 0 0 20px rgba(255, 0, 170, 0.4);
    --gold-glow: 0 0 10px rgba(255, 215, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.4);
    --green-glow: 0 0 10px rgba(0, 255, 170, 0.7), 0 0 20px rgba(0, 255, 170, 0.4);
}

/* Base Styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.cyber-body {
    background: var(--dark-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Global Background Effects */
.cyber-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.15;
    background-image: 
        linear-gradient(90deg, rgba(0, 204, 255, 0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    perspective: 1000px;
    transform-origin: center bottom;
    transform: rotateX(60deg) translateZ(-100px) scale(2.5);
    animation: gridPulse 20s infinite linear;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.05; }
}

.scan-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0) 100%
    );
    background-size: 100% 4px;
    z-index: 999;
    opacity: 0.3;
}

/* Data Stream Animation */
.data-stream {
    position: fixed;
    width: 2px;
    height: 10px;
    background-color: var(--primary-color);
    opacity: 0;
    z-index: -1;
    animation: data-flow 3s infinite linear;
}

@keyframes data-flow {
    0% {
        height: 10px;
        opacity: 0;
        transform: translateY(-20px);
    }
    20% {
        opacity: 0.5;
    }
    100% {
        height: 50px;
        opacity: 0;
        transform: translateY(100px);
    }
}

.data-stream:nth-child(1) { left: 10%; animation-delay: 0s; }
.data-stream:nth-child(2) { left: 25%; animation-delay: 0.5s; }
.data-stream:nth-child(3) { left: 45%; animation-delay: 1.5s; }
.data-stream:nth-child(4) { left: 75%; animation-delay: 0.3s; }
.data-stream:nth-child(5) { left: 90%; animation-delay: 0.8s; }

/* Cyber Header */
.cyber-header {
    padding: 15px 0;
    text-align: center;
    position: relative;
    border-bottom: 2px solid var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 204, 255, 0.3);
    z-index: 10;
    background: rgba(10, 10, 22, 0.8);
    backdrop-filter: blur(10px);
}

.cyber-logo {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.5rem;
    margin: 0;
    color: var(--primary-color);
    text-shadow: var(--cyan-glow);
    position: relative;
    display: inline-block;
}

.cyber-glitch {
    color: var(--secondary-color);
    animation: glitch-skew 1s infinite alternate-reverse;
    position: relative;
    text-shadow: var(--magenta-glow);
}

@keyframes glitch-skew {
    0%, 100% { transform: skew(0); }
    20% { transform: skew(3deg); }
    40% { transform: skew(-2deg); }
}

.cyber-glitch::before,
.cyber-glitch::after {
    content: '.game';
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.8;
}

.cyber-glitch::before {
    left: 1px;
    text-shadow: -2px 0 var(--accent-color);
    animation: glitch-anim1 2s infinite;
}

.cyber-glitch::after {
    left: -1px;
    text-shadow: 2px 0 var(--tertiary-color);
    animation: glitch-anim2 3s infinite;
}

@keyframes glitch-anim1 {
    0%, 100% { clip-path: inset(20% 0 30% 0); }
    20% { clip-path: inset(60% 0 20% 0); }
    40% { clip-path: inset(10% 0 60% 0); }
    60% { clip-path: inset(40% 0 40% 0); }
    80% { clip-path: inset(30% 0 10% 0); }
}

@keyframes glitch-anim2 {
    0%, 100% { clip-path: inset(40% 0 30% 0); }
    20% { clip-path: inset(10% 0 50% 0); }
    40% { clip-path: inset(70% 0 10% 0); }
    60% { clip-path: inset(20% 0 60% 0); }
    80% { clip-path: inset(50% 0 30% 0); }
}

/* Game Arena */
.game-arena {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Cyber Game Container */
.cyber-game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: linear-gradient(135deg, rgba(15, 15, 34, 0.9), rgba(25, 25, 50, 0.85));
    border: 2px solid var(--primary-color);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 40px;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.cyber-game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(rgba(0, 204, 255, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 0;
    pointer-events: none;
}

/* Cyber HUD */
.cyber-hud {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin-bottom: 15px;
}

.hud-stat {
    position: relative;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    padding: 8px 12px;
    margin: 5px;
    box-shadow: 0 0 8px rgba(0, 204, 255, 0.3);
    min-width: 80px;
    transition: all 0.3s ease;
}

/* Create a cool hover effect */
.hud-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--primary-color);
}

.hud-stat::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(0, 204, 255, 0),
        rgba(0, 204, 255, 0.1),
        rgba(0, 204, 255, 0)
    );
    transform: rotate(45deg);
    animation: scan 3s infinite;
}

@keyframes scan {
    0% {
        left: -200%;
        opacity: 0;
    }
    20% {
        left: -100%;
        opacity: 0;
    }
    40% {
        left: 0%;
        opacity: 0.5;
    }
    60% {
        left: 100%;
        opacity: 0;
    }
    100% {
        left: 200%;
        opacity: 0;
    }
}

/* Stats Label */
.stat-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #8ff7ff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 3px;
    text-shadow: 0 0 5px rgba(143, 247, 255, 0.7);
}
  
/* Stats Value */
.stat-value {
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    color: white;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* Cyber Canvas Container */
.cyber-canvas-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1;
    margin: 0 auto;
    z-index: 5;
}

.neon-frame {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 10px;
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color), var(--tertiary-color), var (--secondary-color));
    background-size: 400% 400%;
    z-index: -1;
    filter: blur(5px);
    animation: neon-glow 6s ease infinite;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.5);
}

@keyframes neon-glow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.cyber-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    z-index: 2;
}

.top-left {
    top: -2px;
    left: -2px;
    border-top: 3px solid var(--primary-color);
    border-left: 3px solid var(--primary-color);
    border-top-left-radius: 8px;
}

.top-right {
    top: -2px;
    right: -2px;
    border-top: 3px solid var(--primary-color);
    border-right: 3px solid var(--primary-color);
    border-top-right-radius: 8px;
}

.bottom-left {
    bottom: -2px;
    left: -2px;
    border-bottom: 3px solid var(--primary-color);
    border-left: 3px solid var(--primary-color);
    border-bottom-left-radius: 8px;
}

.bottom-right {
    bottom: -2px;
    right: -2px;
    border-bottom: 3px solid var(--primary-color);
    border-right: 3px solid var(--primary-color);
    border-bottom-right-radius: 8px;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 5% 5%;
    pointer-events: none;
    opacity: 0.7;
    z-index: 1;
}

/* Special styling for the BEST score */
#best.stat-value {
    color: #ffcc00;
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.8);
    animation: pulse-best 2s infinite alternate;
}
  
/* Pulse animation for the best score */
@keyframes pulse-best {
    0% { text-shadow: 0 0 5px rgba(255, 204, 0, 0.5); }
    100% { text-shadow: 0 0 12px rgba(255, 204, 0, 0.9); }
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7) !important; /* Ensure consistent background */
    border-radius: 8px;
    position: relative;
    z-index: 1;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
}

/* Power Up Indicators */
.power-up-indicators {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 15px;
}

/* Cyber Control Panel */
.cyber-control-panel {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    margin-bottom: 15px;
    width: 100%;
}

/* Cyber Buttons */
.cyber-button {
    position: relative;
    padding: 12px 24px;
    background: #000;
    border: 2px solid;
    border-radius: 5px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.75rem;
    color: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 140px;
}

.cyber-button.primary {
    border-color: var(--primary-color);
}

.cyber-button.primary:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: var(--cyan-glow);
}

.cyber-button.secondary {
    border-color: var(--tertiary-color);
}

.cyber-button.secondary:hover {
    background: var(--tertiary-color);
    color: #000;
    box-shadow: var(--green-glow);
}

.cyber-button.tertiary {
    border-color: var(--accent-color);
}

.cyber-button.tertiary:hover {
    background: var(--accent-color);
    color: #000;
    box-shadow: var(--gold-glow);
}

.button-decor {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    animation: button-scan 2s infinite;
}

@keyframes button-scan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Mobile Controls */
.cyber-mobile-controls {
    display: none;
    margin-top: 20px;
    width: 100%;
    max-width: 300px;
}

@media (max-width: 768px) {
    .cyber-mobile-controls {
        display: block;
    }
}

body {
    overflow-x: hidden; /* Only prevent horizontal scroll */
    width: 100%;
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
}

/* Game Container - Enhanced positioning */
.game-container {
    background: url('https://www.transparenttextures.com/patterns/asfalt-light.png') repeat, #228B22;
    background-size: 100px 100px;
    width: 100%;
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Canvas Container - Improved responsive design */
.canvas-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Canvas styling for optimal viewing */
#gameCanvas {
    display: block;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
    image-rendering: pixelated; /* Keep pixel art crisp */
    width: 100%;
    height: auto;
    max-width: 480px; /* Optimal size for gameplay */
    aspect-ratio: 1 / 1; /* Maintain square aspect ratio */
}

/* For older browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
    #gameCanvas {
        height: 0;
        padding-bottom: 100%; /* Creates square aspect ratio */
    }
}

/* Game Stats */
.game-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: min(600px, 90vw);
    position: relative;
    z-index: 2;
}

/* Control Buttons */
.control-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.control-button {
    padding: 10px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    transition: background 0.3s ease;
}

.control-button:hover {
    background: #45a049;
}

/* Mobile Controls - Enhanced positioning */
#mobileControls {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 320px; /* Match canvas max-width on mobile */
    margin: 15px auto 0;
    display: none; /* Hidden by default, shown on mobile */
}

#mobileControls .control-button {
    width: 60px;
    height: 60px;
    font-size: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

#mobileControls .control-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}

/* Updated mobile controls layout */
#mobileControls .grid-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 240px;
    margin: 0 auto;
}

/* Game Content Section */
.game-content {
    background: linear-gradient(135deg, #1a472a, #2a623d);
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem auto;
    width: 100%;
    max-width: 800px;
    color: #fff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.game-content h2 {
    font-family: 'Press Start 2P', cursive;
    color: #FFD700;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.3);
}

.game-content p, .game-content li {
    line-height: 1.8;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Modal Styles */
.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.modal-button {
    padding: 10px 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

/* Retro Header Styling */
.text-shadow-retro {
    text-shadow: 
        2px 2px 0 #000,
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000;
    font-family: 'Press Start 2P', cursive !important;
    letter-spacing: 2px;
    color: #FFD700;
}

/* Make sure font is loaded */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* Responsive Design */
@media (max-width: 640px) {
    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .game-stats {
        font-size: 12px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .control-button {
        padding: 8px 16px;
        font-size: 12px;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #gameCanvas {
        max-width: 400px; /* Slightly smaller on tablets */
    }
}

@media (max-width: 500px) {
    #gameCanvas {
        max-width: 320px; /* Much smaller on phones */
    }
    
    .game-stats {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}

/* Add styles for the new game features */

.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}

.ghost-walls {
    box-shadow: 0 0 20px 10px rgba(106, 13, 173, 0.7);
    animation: ghost-pulse 2s infinite;
}

@keyframes ghost-pulse {
    0% { box-shadow: 0 0 20px 8px rgba(106, 13, 173, 0.7); }
    50% { box-shadow: 0 0 30px 15px rgba(106, 13, 173, 0.5); }
    100% { box-shadow: 0 0 20px 8px rgba(106, 13, 173, 0.7); }
}

/* IMPROVED: Enhanced powerup notification styles */
.powerup-notification {
    position: fixed;
    top: 100px; /* Position below header elements */
    left: 10px; /* Position on left side, outside of game area */
    right: auto;
    transform: none; /* Remove the horizontal centering transform */
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    z-index: 50;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.5s, transform 0.5s;
    animation: notification-side-pulse 2s infinite;
    max-width: 220px; /* Keep it compact */
    backdrop-filter: blur(2px);
    opacity: 0.95;
    cursor: pointer; /* Indicate it's clickable */
    border-left: 4px solid white; /* Add a highlight border */
}

/* Update animation for side position */
@keyframes notification-side-pulse {
    0% { box-shadow: 0 0 8px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); }
    100% { box-shadow: 0 0 8px rgba(0, 0, 0, 0.3); }
}

/* Update fade-out animation for side position */
.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

.powerup-notification .powerup-symbol {
    font-size: 24px; /* Slightly smaller */
    margin-right: 12px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.7));
}

.powerup-notification h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: bold;
}

.powerup-notification p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

.powerup-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    z-index: 50;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.5s, transform 0.5s;
    animation: notification-pulse 2s infinite;
}

@keyframes notification-pulse {
    0%, 100% { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4); }
}

.powerup-notification .powerup-symbol {
    font-size: 28px;
    margin-right: 15px;
    animation: symbol-bounce 1s ease infinite;
}

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

.powerup-notification h3 {
    margin: 0 0 3px 0;
    font-size: 18px;
    font-weight: bold;
}

.powerup-notification p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* Modal button styles */
.modal-button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    margin: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-button:active {
    transform: translateY(0);
}

/* Snake Icon Styling */
.snake-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
}

.snake-icon {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    animation: snake-sway 4s ease-in-out infinite;
}

@keyframes snake-sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

.snake-logo-small {
    display: flex;
    justify-content: center;
    margin: 0 auto;
}

/* Game Stats Enhancement */
.stats-container {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 15px;
}

/* Add this for mobile controls if needed */
#mobileControls {
    display: none;
}

@media (max-width: 768px) {
    #mobileControls {
        display: block;
    }
}

/* Modal Content Readability Enhancements */
.modal-content {
    max-width: 90%;
    width: 500px;
    background: linear-gradient(to bottom, #ffffff, #f5f5f5);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #333; /* Ensure base text color has contrast */
}

/* Improve contrast for all modal text */
.modal-content p, 
.modal-content span {
    color: #333; /* Default dark color for better contrast */
}

/* Ensure powerup descriptions are visible against their backgrounds */
.bg-purple-100 span:last-child { color: #4b0082; }
.bg-blue-100 span:last-child { color: #00008b; }
.bg-yellow-100 span:last-child { color: #8b4000; }
.bg-red-100 span:last-child { color: #8b0000; }

/* Enhanced Game UI Elements */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 90;
}

.countdown {
    font-size: 80px;
    font-family: 'Press Start 2P', cursive;
    color: white;
    animation: countdown-pulse 0.7s infinite alternate;
}

@keyframes countdown-pulse {
    from { transform: scale(1); text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); }
    to { transform: scale(1.1); text-shadow: 0 0 20px rgba(255, 255, 255, 1); }
}

/* IMPROVED: Enhanced pause overlay styling */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 80;
    backdrop-filter: blur(5px);
    cursor: pointer; /* Show clickable cursor */
}

.pause-content {
    background: rgba(10, 10, 22, 0.8);
    border: 2px solid var(--primary-color);
    border-radius: 15px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.3);
    animation: pause-pulse 2s infinite alternate;
    cursor: default; /* Reset cursor for content */
}

@keyframes pause-pulse {
    0% { box-shadow: 0 0 20px rgba(0, 204, 255, 0.2); }
    100% { box-shadow: 0 0 40px rgba(0, 204, 255, 0.4); }
}

.pause-text {
    font-size: 48px;
    font-family: 'Press Start 2P', cursive;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    animation: pause-blink 1.5s infinite alternate;
    margin-bottom: 30px;
    letter-spacing: 3px;
}

@keyframes pause-blink {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

#resumeBtn {
    margin-top: 20px;
    min-width: 200px;
}

.card-icon {
    height: 36px;
    width: 30px;
    margin-right: 15px;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
    animation: card-float 3s ease-in-out infinite;
}

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

.card-mini {
    height: 50px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    transition: transform 0.3s;
}

.card-mini:hover {
    transform: translateY(-5px);
}

.game-button {
    padding: 12px 24px;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.primary-button {
    background: linear-gradient(to bottom, #4CAF50, #3e8e41);
    color: white;
}

.primary-button:hover {
    background: linear-gradient(to bottom, #5ac561, #4CAF50);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.2);
}

.secondary-button {
    background: linear-gradient(to bottom, #2196F3, #0b7dda);
    color: white;
}

.secondary-button:hover {
    background: linear-gradient(to bottom, #42a5f5, #2196F3);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.2);
}

.game-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

/* Card-themed powerup indicators */
.powerup-item {
    background: rgba(255,255,255,0.9);
    border-radius: 8px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.powerup-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.powerup-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

/* Show mobile controls on small screens */
@media (max-width: 768px) {
    #mobileControls {
        display: block;
    }
}

/* Overlay for fullscreen mode */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a472a, #2a623d);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fullscreen-overlay #gameCanvas {
    max-width: min(90vmin, 600px); /* Optimal size for fullscreen */
}

.fullscreen-overlay .game-stats {
    max-width: min(90vmin, 600px);
    margin: 0 auto 20px;
}

/* Button to toggle fullscreen mode */
#fullScreenBtn {
    position: absolute;
    right: 20px;
    top: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.3s;
    z-index: 5;
}

#fullScreenBtn:hover {
    background: rgba(0, 0, 0, 0.6);
}

/* Game area border for better visibility */
.game-area-border {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    pointer-events: none;
    z-index: 1;
}

/* Visual guide for game boundaries */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 5% 5%; /* 20x20 grid cells */
    pointer-events: none;
    opacity: 0.5;
    z-index: 0;
}

/* Mobile Direction Controls */
.mobile-control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
}

.cyber-direction-button {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cyber-direction-button:active,
.cyber-direction-button:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: var(--cyan-glow);
}

.center-dot {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    margin: auto;
    opacity: 0.7;
}

/* Terminal Section Styles */
.cyber-terminal-section {
    width: 100%;
    max-width: 800px;
    margin: 40px auto 0;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 204, 255, 0.3);
}

.terminal-header {
    background: #0a0a16;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0, 204, 255, 0.3);
}

.terminal-controls {
    display: flex;
    gap: 8px;
    margin-right: 20px;
}

.control-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.control-dot.red { background: #ff5f56; }
.control-dot.yellow { background: #ffbd2e; }
.control-dot.green { background: #27c93f; }

.terminal-title {
    color: var(--primary-color);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    flex-grow: 1;
    text-align: center;
}

.terminal-content {
    padding: 20px;
    color: #e4e4e4;
    font-family: 'Roboto', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
}

.terminal-section-title {
    color: var(--primary-color);
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    margin: 1.5rem 0 1rem;
    text-shadow: var(--cyan-glow);
}

.terminal-section-title:first-child {
    margin-top: 0;
}

.terminal-subsection {
    color: var(--secondary-color);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    margin: 1.2rem 0 0.8rem;
    text-shadow: var(--magenta-glow);
}

.terminal-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.terminal-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 0.5rem;
}

.terminal-list li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--accent-color);
}

.command {
    color: var(--tertiary-color);
    font-weight: bold;
    margin-right: 5px;
}

.terminal-signature {
    margin-top: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    border-top: 1px dashed rgba(0, 204, 255, 0.3);
    padding-top: 1rem;
}

/* Cyber Modal */
.cyber-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.cyber-modal.hidden {
    display: none;
}

.cyber-modal-content {
    width: 90%;
    max-width: 500px;
    background: rgba(15, 15, 34, 0.95);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 0 30px rgba(0, 204, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.cyber-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, rgba(0, 204, 255, 0.07) 1px, transparent 1px),
        linear-gradient(rgba(0, 204, 255, 0.07) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: -1;
}

.modal-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-family: 'Press Start 2P', cursive;
    color: var(--secondary-color);
    font-size: 1.2rem;
    text-align: center;
    text-shadow: var(--magenta-glow);
    flex-grow: 1;
}

.modal-decor {
    height: 2px;
    background: var(--secondary-color);
    width: 40px;
    box-shadow: 0 0 10px var(--secondary-color);
}

.stats-terminal {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    overflow: hidden;
    margin: 20px 0;
}

.stats-terminal .terminal-header {
    padding: 5px 10px;
    background: #0e0e1c;
    border-bottom: 1px solid var(--primary-color);
}

.stats-terminal .terminal-header span {
    color: var(--primary-color);
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
}

.stats-terminal .terminal-content {
    padding: 15px;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.stat-name {
    color: var(--tertiary-color);
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
}

.terminal-cursor {
    color: var(--primary-color);
    animation: blink-cursor 1s infinite;
    margin-top: 5px;
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
}

@keyframes blink-cursor {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Responsive adjustments for terminal content */
@media (max-width: 768px) {
    .cyber-terminal-section {
        margin-top: 30px;
    }
    
    .terminal-section-title {
        font-size: 0.8rem;
    }
    
    .terminal-subsection {
        font-size: 0.7rem;
    }
    
    .terminal-content {
        font-size: 0.85rem;
    }
}

/* Accessibility Enhancements */
.cyber-button:focus,
.cyber-button-circle:focus,
.cyber-direction-button:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 3px;
}

/* Button press effect */
.cyber-button:active,
.cyber-button-circle:active {
    transform: translateY(2px);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Add a scanline effect to each stat box */
.hud-stat::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
      to bottom,
      transparent 0%,
      rgba(32, 255, 255, 0.05) 50%,
      transparent 100%
    );
    pointer-events: none;
    animation: scan-stat 2s linear infinite;
  }
  
  @keyframes scan-stat {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
  }

/* Start Screen Enhanced Styling */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    transition: opacity 0.5s;
}

.game-modal.fade-out {
    opacity: 0;
}

.cyber-modal-content.start-modal {
    background: linear-gradient(135deg, rgba(15, 15, 34, 0.95), rgba(25, 25, 50, 0.9));
    border: 2px solid var(--primary-color);
    max-width: 550px;
    width: 90%;
    position: relative;
    padding: 25px;
    overflow: visible;
}

.title-accent {
    color: var(--tertiary-color);
    text-shadow: var(--green-glow);
}

.cyber-grid-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 0;
}

.cyber-grid-corner.top-left {
    top: -10px;
    left: -10px;
    border-top: 3px solid var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.cyber-grid-corner.top-right {
    top: -10px;
    right: -10px;
    border-top: 3px solid var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.cyber-grid-corner.bottom-left {
    bottom: -10px;
    left: -10px;
    border-bottom: 3px solid var(--primary-color);
    border-left: 3px solid var (--primary-color);
}

.cyber-grid-corner.bottom-right {
    bottom: -10px;
    right: -10px;
    border-bottom: 3px solid var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

/* Instruction Terminal Styling */
.instruction-terminal {
    margin: 15px 0;
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 204, 255, 0.2);
}

.instruction-terminal .terminal-header {
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 12px;
    display: flex;
    align-items: center;
}

.instruction-terminal .terminal-controls {
    display: flex;
    gap: 5px;
    margin-right: 15px;
}

.instruction-terminal .terminal-title {
    font-family: 'Press Start 2P', monospace;
    color: var(--primary-color);
    font-size: 0.65rem;
    letter-spacing: 1px;
}

.instruction-terminal .terminal-content {
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    color: #e0e0e0;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.terminal-line {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.terminal-line .command {
    color: var(--tertiary-color);
    margin-right: 10px;
}

.terminal-line .key {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    margin: 0 3px;
    font-size: 0.85rem;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
    color: white;
}

/* PowerUps Grid Styling */
.powerups-title {
    font-family: 'Press Start 2P', cursive;
    color: var(--primary-color);
    font-size: 1rem;
    margin: 20px 0 15px;
    text-align: center;
}

.powerups-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.powerup-item {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var (--powerup-color, var(--primary-color));
    border-radius: 6px;
    padding: 10px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 0 8px rgba(var(--powerup-color, 0, 204, 255), 0.2);
}

.powerup-item:hover {
    box-shadow: 0 0 12px var(--powerup-color, var(--primary-color));
    transform: translateY(-2px);
}

.powerup-symbol-wrapper {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    box-shadow: 0 0 8px rgba(var(--powerup-color, 0, 204, 255), 0.4);
}

.powerup-symbol {
    font-size: 20px;
}

.powerup-desc {
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
}

/* Start Button Animation */
.cyber-button .button-glitch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: -1;
}

.cyber-button:hover .button-glitch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.1) 2px,
        rgba(255, 255, 255, 0.1) 4px
    );
    animation: glitch-animation 0.5s infinite linear alternate-reverse;
    pointer-events: none;
}

@keyframes glitch-animation {
    0% { 
        clip-path: polygon(0 0, 100% 0, 100% 20%, 0 20%);
        transform: translate(-5px);
    }
    20% { 
        clip-path: polygon(0 20%, 100% 20%, 100% 40%, 0 40%);
        transform: translate(5px);
    }
    40% { 
        clip-path: polygon(0 40%, 100% 40%, 100% 60%, 0 60%);
        transform: translate(-5px);
    }
    60% { 
        clip-path: polygon(0 60%, 100% 60%, 100% 80%, 0 80%);
        transform: translate(5px);
    }
    80% { 
        clip-path: polygon(0 80%, 100% 80%, 100% 100%, 0 100%);
        transform: translate(-5px);
    }
    100% { 
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
        transform: translate(0);
    }
}

.cyber-button.clicked {
    animation: button-click 0.5s forwards;
}

@keyframes button-click {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Snake Logo Animation */
.snake-icon {
    filter: drop-shadow(0 0 8px var(--primary-color));
    transition: all 0.3s ease;
}

.snake-logo:hover .snake-icon {
    filter: drop-shadow(0 0 15px var(--primary-color));
}

/* Responsive Adjustments */
@media (max-width: 500px) {
    .powerups-grid {
        grid-template-columns: 1fr;
    }
    
    .powerup-desc {
        font-size: 0.5rem;
    }
    
    .modal-title {
        font-size: 1rem;
    }
}

/* Fade-out animation for modal */
@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.game-modal.fade-out {
    animation: fade-out 0.5s forwards;
}

/* Enhanced glitch effect for title */
.glitch-effect {
    position: relative;
    display: inline-block;
    width: 100%;
}

.glitch-effect .modal-title::before,
.glitch-effect .modal-title::after {
    content: 'SNAKE.EXE';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
    pointer-events: none;
}

.glitch-effect .modal-title::before {
    left: 2px;
    text-shadow: -1px 0 var(--accent-color);
    animation: glitch-title-1 3s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch-effect .modal-title::after {
    left: -2px;
    text-shadow: 2px 0 var(--tertiary-color);
    animation: glitch-title-2 2.5s infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch-title-1 {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

@keyframes glitch-title-2 {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(2px); }
    20%, 40%, 60%, 80% { transform: translateX(-2px); }
}