@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

/* CSS Variables */
:root {
    --primary-color: #00ffff;
    --secondary-color: #ff00ff;
    --accent-color: #ffd700;
    --success-color: #00ff88;
    --danger-color: #ff0066;
    --bg-dark: #0a0a0a;
    --text-light: #ffffff;
    --text-dim: #666666;
    
    /* Safe area support */
    --sat: env(safe-area-inset-top, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
}

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

body {
    background: var(--bg-dark);
    font-family: 'Orbitron', monospace;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    padding: var(--sat) var(--sar) var(--sab) var(--sal);
}

/* Game Container */
#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

#gameCanvas {
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    box-shadow: 0 0 100px rgba(0, 255, 255, 0.3);
    touch-action: none;
    display: block;
    position: relative;
}

/* Canvas wrapper for positioning panels */
#canvas-wrapper {
    position: relative;
    display: inline-block;
    z-index: 1;
}

/* UI Overlay */
#uiOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 10px;
    overflow: visible; /* Allow elements to overflow */
}

.ui-element {
    position: absolute;
    color: white;
    text-shadow: 0 0 10px currentColor;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

/* Score Display */
#score {
    position: absolute;
    top: 80px;
    left: 20px;
    transform: none;
    font-size: 48px;
    font-weight: 900;
    color: var(--text-light);
    text-align: left;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    width: auto;
    display: block;
    z-index: 10;
    white-space: nowrap;
}

#bestScore {
    position: absolute;
    top: 130px;
    left: 20px;
    transform: none;
    font-size: 14px;
    color: var(--accent-color);
    opacity: 0.9;
    text-align: left;
    white-space: nowrap;
    z-index: 10;
}

/* Compact Stats Panel - Top Left */
#leftPanel {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 12px;
    color: var(--primary-color);
    background: rgba(0, 0, 0, 0.6);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    width: auto;
    display: flex;
    gap: 24px;
    align-items: center;
    z-index: 10;
}

/* Right Panel - Hidden by default, will be used for radar */
#rightPanel {
    display: none;
}

#leftPanel .stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 0 10px currentColor;
    line-height: 1;
}

.stat-label {
    font-size: 10px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 400;
    margin-bottom: 2px;
}

.speed-bar {
    display: none; /* Hide speed bar in new layout */
}

.speed-fill {
    display: none;
}

.pattern-display {
    display: none; /* Hide pattern display in new layout */
}

/* Streak Bar */
#streakBar {
    position: absolute;
    top: 155px;
    left: 20px;
    transform: none;
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
}

#streakFill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--success-color) 100%);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px currentColor;
}

/* Power-up Pills */
.powerup-pill {
    position: absolute;
    top: 40%;
    right: 5%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid currentColor;
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Game Overlay - Fullscreen */
#gameOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95); /* Dark background with slight transparency */
    display: none; /* Hidden by default to prevent flash on load */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    opacity: 1;
    pointer-events: all;
}

/* Modern minimal menu container - Now just content without card */
#menuContainer {
    text-align: center;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Removed card effects for fullscreen design */

.game-title {
    font-size: 64px;
    font-weight: 200;
    color: #ffffff;
    margin: 0 0 20px 0;
    padding: 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 8px;
    position: relative;
    opacity: 0.95;
}

.game-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

@keyframes glow-pulse {
    0%, 100% { 
        text-shadow: 0 0 20px var(--primary-color);
        opacity: 0.9;
    }
    50% { 
        text-shadow: 0 0 40px var(--primary-color), 0 0 60px var(--primary-color);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.05);
        filter: brightness(1.2);
    }
}


/* Modern minimal subtitle */
.subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 60px;
    position: relative;
    font-weight: 400;
}


/* Modern minimal Play Button */
.play-button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    padding: 18px 56px;
    font-size: 16px;
    font-weight: 300;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    font-family: 'Orbitron', monospace;
    pointer-events: all;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 4px;
    overflow: hidden;
    z-index: 10; /* Ensure it's above other elements */
}

.play-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.08);
    transition: width 0.3s ease;
}

.play-button:hover::before {
    width: 100%;
}

.play-button:hover {
    /* Removed transform to prevent movement */
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
    opacity: 1 !important; /* Ensure button stays visible */
    transform: none !important; /* Prevent any transform */
}

.play-button:active {
    /* Removed transform to prevent movement */
    background: rgba(255, 255, 255, 0.05);
    opacity: 1 !important; /* Ensure button stays visible */
    transform: none !important; /* Prevent any transform */
}

/* Stats Display */
#gameStats {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.final-score {
    font-size: 36px;
    color: var(--primary-color);
    margin: 20px 0 10px 0;
    text-align: center;
}

.best-score-display {
    font-size: 24px;
    color: var(--accent-color);
    margin: 0 0 20px 0;
    text-align: center;
    opacity: 0.9;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 20px 0;
    text-align: center;
}

.stats-grid .stat-item {
    color: var(--accent-color);
    text-align: center;
    display: block;
    align-items: center;
}

.stat-label {
    font-size: 12px;
    opacity: 0.7;
    text-align: center;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
}

/* Touch Indicator */
#touchIndicator {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 3px solid rgba(0, 255, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#touchIndicator.active {
    animation: touchPulse 0.6s ease-out;
}

@keyframes touchPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #game-container {
        padding: 0; /* No side padding on mobile */
    }
    
    /* Adjust stats panel for mobile */
    #leftPanel {
        top: 10px;
        left: 10px;
        font-size: 11px;
        padding: 8px 12px;
        gap: 16px;
    }
    
    #leftPanel .stat-value {
        font-size: 14px;
    }
    
    #leftPanel .stat-label {
        font-size: 9px;
    }
    
    /* Hide mobile stats since we're using the compact panel */
    #mobileStats {
        display: none !important;
    }
    
    .stat-value {
        font-size: 16px;
    }
    
    .powerup-pill {
        padding: 3px 10px;
        font-size: 10px;
    }
    
    #score {
        font-size: 36px;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
        top: 60px;
        left: 10px;
    }
    
    #bestScore {
        font-size: 12px;
        top: 100px;
        left: 10px;
    }
    
    #streakBar {
        width: 100px;
        top: 120px;
        left: 10px;
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    .game-title {
        font-size: 48px;
    }
    
    .play-button {
        padding: 16px 40px;
        font-size: 18px;
        box-shadow: 0 5px 20px rgba(0, 255, 255, 0.5);
    }
    
    .final-score {
        font-size: 28px;
    }
    
    .ui-element {
        transition: transform 0.1s ease;
    }
    
    #gameOverlay {
        padding: 30px;
        /* Removed width constraints for fullscreen */
    }
}

/* Mobile Stats Display */
#mobileStats {
    display: none; /* Hidden by default, shown on mobile */
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    gap: 30px;
    pointer-events: none;
}

.mobile-stat {
    text-align: center;
}

.mobile-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 10px currentColor;
    font-family: 'Orbitron', monospace;
}

/* Hide scrollbars */
::-webkit-scrollbar {
    display: none;
}

/* Performance indicator */
#perfIndicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 10px;
    color: var(--text-dim);
    font-family: 'Orbitron', monospace;
}

/* Desktop specific adjustments */
@media (min-width: 769px) and (max-width: 1200px) {
    #game-container {
        padding: 0 150px; /* Less padding for medium screens */
    }
}

@media (min-width: 769px) {
    /* Ensure mobile stats stay hidden on desktop */
    #mobileStats {
        display: none !important;
    }
}

/* Countdown Animation */
@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Additional Animations for Enhanced UI */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes flash {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes glitch {
    0%, 100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
    20% {
        transform: translate(-2px, 2px);
        filter: hue-rotate(90deg);
    }
    40% {
        transform: translate(-2px, -2px);
        filter: hue-rotate(180deg);
    }
    60% {
        transform: translate(2px, 2px);
        filter: hue-rotate(270deg);
    }
    80% {
        transform: translate(2px, -2px);
        filter: hue-rotate(360deg);
    }
}

@keyframes neonPulse {
    0%, 100% {
        text-shadow: 
            0 0 10px currentColor,
            0 0 20px currentColor,
            0 0 30px currentColor;
    }
    50% {
        text-shadow: 
            0 0 20px currentColor,
            0 0 30px currentColor,
            0 0 40px currentColor;
    }
}

@keyframes dataStream {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 0 100%;
    }
}

/* Enhanced UI Styles */
.button-glow {
    filter: blur(15px);
}

.button-ripple {
    animation: rippleExpand 0.6s ease-out;
}

@keyframes rippleExpand {
    from {
        width: 0;
        height: 0;
        opacity: 0.4;
    }
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

.power-up-notification {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.notification-icon {
    animation: spin 2s linear infinite;
}

.milestone-flash {
    /* Animation handled by JavaScript for better control */
    pointer-events: none;
}

/* Leaderboard Button Styles */
.leaderboard-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 0 20px rgba(0, 255, 204, 0.5),
        0 5px 20px rgba(0, 255, 204, 0.3);
    background: linear-gradient(135deg, rgba(0, 255, 204, 0.3) 0%, rgba(0, 255, 204, 0.2) 100%);
}

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

/* Mobile adjustments for leaderboard button */
@media (max-width: 768px) {
    .leaderboard-button {
        font-size: 14px !important;
        padding: 10px 20px !important;
        top: 10px !important;
        right: 10px !important;
    }
}

@keyframes milestoneFlash {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.menu-transition-layer {
    will-change: transform;
}

#matrix-rain {
    background: transparent;
}

/* Accessibility Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

@media (prefers-contrast: high) {
    #gameCanvas {
        border-width: 3px;
        filter: contrast(1.2);
    }
    
    .ui-element {
        filter: contrast(1.5);
        font-weight: bold;
    }
    
    .play-button {
        border: 2px solid white;
    }
}

/* Breathing effect */
.breathing {
    animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Holographic effect */
.holographic {
    animation: hologram 5s ease-in-out infinite;
}

@keyframes hologram {
    0%, 100% {
        filter: hue-rotate(0deg) brightness(1);
    }
    25% {
        filter: hue-rotate(90deg) brightness(1.1);
    }
    50% {
        filter: hue-rotate(180deg) brightness(0.9);
    }
    75% {
        filter: hue-rotate(270deg) brightness(1.1);
    }
}