:root {
    --bg-dark: #0d1117;
    --bg-darker: #010409;
    --bg-card: #161b22;
    --terminal-green: #39d353;
    --terminal-green-dark: #2ea043;
    --warning-orange: #f85149;
    --code-purple: #bc8cff;
    --github-blue: #58a6ff;
    --text-gray: #c9d1d9;
    --text-dim: #8b949e;
    --border-gray: #30363d;
}

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

body {
    background: var(--bg-darker);
    font-family: 'VT323', monospace;
    color: var(--text-gray);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(57, 211, 83, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(57, 211, 83, 0.02) 2px, rgba(57, 211, 83, 0.02) 4px);
    /* Firefox Mobile fixes */
    position: fixed;
    width: 100%;
    height: 100%;
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#gameContainer {
    position: relative;
    max-width: 900px;
    width: 100%;
    padding: 20px;
}

#gameCanvas {
    width: 100%;
    height: 500px;
    background: var(--bg-dark);
    border: 4px solid var(--terminal-green);
    box-shadow: 
        0 0 30px rgba(57, 211, 83, 0.4),
        inset 0 0 80px rgba(57, 211, 83, 0.05),
        0 10px 50px rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    transition: transform 0.1s ease-out;
    /* Firefox Mobile touch fixes */
    touch-action: none;
    -ms-touch-action: none;
}

.scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        transparent 50%,
        rgba(57, 211, 83, 0.03) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    animation: scanline 8s linear infinite;
    z-index: 5;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

.vignette {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.6);
    z-index: 5;
}

/* UI Elements */
#ui {
    position: absolute;
    top: 30px;
    left: 30px;
    right: 30px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
    pointer-events: none;
    z-index: 10;
}

.ui-panel {
    background: rgba(13, 17, 23, 0.95);
    padding: 12px 18px;
    border: 3px solid var(--terminal-green);
    box-shadow: 
        0 0 20px rgba(57, 211, 83, 0.4),
        inset 0 0 20px rgba(57, 211, 83, 0.1);
    position: relative;
    overflow: hidden;
    animation: slideInDown 0.5s ease-out;
}

.ui-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(57, 211, 83, 0.3), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat .label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
}

.stat .value {
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    color: var(--terminal-green);
    text-shadow: 0 0 10px rgba(57, 211, 83, 1);
}

#lives {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
    animation: slideInDown 0.5s ease-out 0.1s backwards;
}

.life {
    font-size: 24px;
    color: var(--warning-orange);
    text-shadow: 0 0 15px rgba(248, 81, 73, 0.8);
    transition: all 0.3s ease;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.life:not(.active) {
    opacity: 0.2;
    text-shadow: none;
    animation: none;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    10% { transform: scale(1.2); }
    20% { transform: scale(1); }
}

/* Power-up Indicator */
#powerupIndicator {
    position: absolute;
    top: 100px;
    right: 30px;
    background: rgba(13, 17, 23, 0.95);
    padding: 15px;
    border: 3px solid var(--code-purple);
    box-shadow: 0 0 20px rgba(188, 140, 255, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10;
    animation: slideInRight 0.3s ease-out;
}

#powerupIndicator.hidden {
    display: none;
}

.powerup-icon {
    width: 32px;
    height: 32px;
    background: var(--code-purple);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.powerup-timer {
    width: 40px;
    height: 6px;
    background: var(--border-gray);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.powerup-timer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: var(--code-purple);
    box-shadow: 0 0 10px var(--code-purple);
    animation: timerDrain 5s linear;
}

@keyframes timerDrain {
    from { width: 100%; }
    to { width: 0%; }
}

/* Combo Indicator */
#comboIndicator {
    position: absolute;
    top: 100px;
    left: 30px;
    background: rgba(13, 17, 23, 0.95);
    padding: 15px 20px;
    border: 3px solid var(--github-blue);
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 10;
    animation: slideInLeft 0.3s ease-out;
}

#comboIndicator.hidden {
    display: none;
}

.combo-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--text-dim);
}

.combo-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: var(--github-blue);
    text-shadow: 0 0 15px rgba(88, 166, 255, 1);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(1, 4, 9, 0.97);
    backdrop-filter: blur(10px);
    z-index: 100;
    animation: fadeIn 0.3s ease-out;
}

.screen.hidden {
    display: none;
}

.screen-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
    animation: scaleIn 0.5s ease-out;
}

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

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

@keyframes slideInDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

/* Title */
.title {
    font-family: 'Press Start 2P', monospace;
    font-size: 48px;
    color: var(--terminal-green);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-shadow: 
        0 0 20px rgba(57, 211, 83, 1),
        0 0 40px rgba(57, 211, 83, 0.5);
}

.title-line {
    display: block;
    animation: glowPulse 2s ease-in-out infinite;
}

.title-line:nth-child(2) {
    animation-delay: 0.1s;
}

@keyframes glowPulse {
    0%, 100% { 
        text-shadow: 
            0 0 20px rgba(57, 211, 83, 1),
            0 0 40px rgba(57, 211, 83, 0.5);
    }
    50% { 
        text-shadow: 
            0 0 30px rgba(57, 211, 83, 1),
            0 0 60px rgba(57, 211, 83, 0.8);
    }
}

.game-over-title {
    color: var(--warning-orange);
    text-shadow: 
        0 0 20px rgba(248, 81, 73, 1),
        0 0 40px rgba(248, 81, 73, 0.5);
}

.screen-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 28px;
    color: var(--terminal-green);
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(57, 211, 83, 1);
}

.subtitle {
    font-family: 'Space Mono', monospace;
    font-size: 18px;
    color: var(--text-gray);
    margin-bottom: 40px;
    letter-spacing: 3px;
}

/* Controls */
.controls-section {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 30px 0;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.key-icon {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--terminal-green);
    padding: 12px 16px;
    border: 3px solid var(--terminal-green);
    box-shadow: 
        0 0 15px rgba(57, 211, 83, 0.3),
        0 4px 0 var(--terminal-green-dark);
    transition: all 0.1s;
    display: inline-block;
}

.control-label {
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: var(--text-dim);
}

/* Buttons */
button {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    padding: 15px 30px;
    margin: 10px;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-primary {
    background: var(--terminal-green);
    color: var(--bg-darker);
    box-shadow: 
        0 0 20px rgba(57, 211, 83, 0.5),
        0 6px 0 var(--terminal-green-dark);
    overflow: hidden;
}

.btn-primary:hover {
    background: #4ae168;
    transform: translateY(-2px);
    box-shadow: 
        0 0 30px rgba(57, 211, 83, 0.7),
        0 8px 0 var(--terminal-green-dark);
}

.btn-primary:active {
    transform: translateY(4px);
    box-shadow: 
        0 0 20px rgba(57, 211, 83, 0.5),
        0 2px 0 var(--terminal-green-dark);
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: btnGlow 3s infinite;
}

@keyframes btnGlow {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--terminal-green);
    border: 3px solid var(--terminal-green);
    box-shadow: 0 0 15px rgba(57, 211, 83, 0.3);
}

.btn-secondary:hover {
    background: var(--terminal-green);
    color: var(--bg-darker);
    box-shadow: 0 0 25px rgba(57, 211, 83, 0.5);
}

.btn-danger {
    background: var(--warning-orange);
    color: var(--bg-darker);
    box-shadow: 0 6px 0 #d73a49;
}

.btn-danger:hover {
    background: #ff6b6b;
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #d73a49;
}

.btn-danger:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #d73a49;
}

/* Features */
.features {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: var(--text-dim);
}

.feature-icon {
    font-size: 32px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 30px 0;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border: 3px solid var(--terminal-green);
    box-shadow: 0 0 20px rgba(57, 211, 83, 0.3);
}

.stat-label {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.stat-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: var(--terminal-green);
    text-shadow: 0 0 10px rgba(57, 211, 83, 1);
}

/* Achievements */
.achievements-unlocked {
    margin: 30px 0;
    padding: 20px;
    background: var(--bg-card);
    border: 3px solid var(--github-blue);
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.3);
    animation: slideInDown 0.5s ease-out;
}

.achievement-header {
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    color: var(--github-blue);
    margin-bottom: 15px;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.achievement-item {
    background: var(--bg-card);
    padding: 15px;
    border: 3px solid var(--border-gray);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s;
}

.achievement-item.unlocked {
    border-color: var(--terminal-green);
    box-shadow: 0 0 15px rgba(57, 211, 83, 0.3);
}

.achievement-item:not(.unlocked) {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 32px;
    text-align: center;
}

.achievement-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--terminal-green);
    text-align: center;
}

.achievement-desc {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: var(--text-dim);
    text-align: center;
}

/* Settings */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-card);
    border: 3px solid var(--border-gray);
}

.setting-item label {
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    color: var(--text-gray);
    letter-spacing: 2px;
}

.setting-item input[type="checkbox"] {
    width: 50px;
    height: 25px;
    appearance: none;
    background: var(--border-gray);
    border: 3px solid var(--terminal-green);
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.setting-item input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: var(--terminal-green);
    left: 2px;
    top: 2px;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(57, 211, 83, 0.5);
}

.setting-item input[type="checkbox"]:checked {
    background: var(--terminal-green);
}

.setting-item input[type="checkbox"]:checked::before {
    left: 25px;
    background: var(--bg-darker);
}

/* Pause Overlay */
#pauseOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(1, 4, 9, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#pauseOverlay.hidden {
    display: none;
}

.pause-content {
    text-align: center;
    padding: 40px;
}

.pause-content h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 36px;
    color: var(--github-blue);
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(88, 166, 255, 1);
}

.pause-content p {
    font-family: 'VT323', monospace;
    font-size: 20px;
    color: var(--text-gray);
    margin-bottom: 30px;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
    #gameContainer {
        padding: 10px;
    }

    #gameCanvas {
        height: 400px;
    }

    .title {
        font-size: 32px;
    }

    #ui {
        top: 20px;
        left: 20px;
        right: 20px;
        gap: 10px;
    }

    .ui-panel {
        padding: 8px 12px;
    }

    .stat .value {
        font-size: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .features {
        flex-direction: column;
        gap: 15px;
    }

    .controls-section {
        flex-direction: column;
        gap: 20px;
    }

    button {
        font-size: 12px;
        padding: 12px 20px;
    }
}

/* Custom Scrollbar */
.achievements-grid::-webkit-scrollbar {
    width: 10px;
}

.achievements-grid::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border: 2px solid var(--border-gray);
}

.achievements-grid::-webkit-scrollbar-thumb {
    background: var(--terminal-green);
    border: 2px solid var(--bg-dark);
}

.achievements-grid::-webkit-scrollbar-thumb:hover {
    background: #4ae168;
}

/* Mobile Touch Controls */
.mobile-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 50;
    pointer-events: none;
}

.mobile-controls.hidden {
    display: none;
}

.touch-button {
    pointer-events: auto;
    width: 80px;
    height: 80px;
    background: rgba(13, 17, 23, 0.9);
    border: 3px solid var(--terminal-green);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 
        0 0 20px rgba(57, 211, 83, 0.4),
        inset 0 0 20px rgba(57, 211, 83, 0.1);
    transition: all 0.1s;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Firefox Mobile touch fixes */
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    -moz-user-select: none;
    -webkit-user-select: none;
}

.touch-button:active {
    transform: scale(0.9);
    background: var(--terminal-green);
    box-shadow: 
        0 0 30px rgba(57, 211, 83, 0.8),
        inset 0 0 30px rgba(57, 211, 83, 0.3);
}

.touch-button:active .button-icon,
.touch-button:active .button-label {
    color: var(--bg-darker);
}

.button-icon {
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: var(--terminal-green);
    text-shadow: 0 0 10px rgba(57, 211, 83, 1);
}

.button-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: var(--terminal-green);
    letter-spacing: 1px;
}

.jump-button {
    margin-right: auto;
}

.slide-button {
    margin-left: auto;
}

/* Touch Gesture Zones */
.touch-zones {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    pointer-events: none;
}

.touch-zones.hidden {
    display: none;
}

.touch-zone-left,
.touch-zone-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    pointer-events: auto;
}

.touch-zone-left {
    left: 0;
}

.touch-zone-right {
    right: 0;
}

/* Mobile Instructions */
.mobile-instructions {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(1, 4, 9, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    animation: fadeIn 0.3s ease-out;
}

.mobile-instructions.hidden {
    display: none;
}

.instruction-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
}

.instruction-content h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: var(--terminal-green);
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(57, 211, 83, 1);
}

.instruction-methods {
    display: flex;
    gap: 30px;
    margin: 30px 0;
    justify-content: center;
}

.method {
    flex: 1;
    background: var(--bg-card);
    padding: 20px;
    border: 3px solid var(--terminal-green);
    box-shadow: 0 0 20px rgba(57, 211, 83, 0.3);
}

.method-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: var(--github-blue);
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(88, 166, 255, 1);
}

.method p {
    font-family: 'VT323', monospace;
    font-size: 18px;
    color: var(--text-gray);
    margin: 10px 0;
}

/* Vibration Feedback Indicator */
.vibration-pulse {
    animation: vibrationPulse 0.3s ease-out;
}

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

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
    }

    #ui {
        top: 15px;
        left: 15px;
        right: 15px;
        gap: 8px;
    }

    .ui-panel {
        padding: 8px 12px;
    }

    .stat .label {
        font-size: 8px;
    }

    .stat .value {
        font-size: 14px;
    }

    #lives {
        top: 15px;
    }

    .life {
        font-size: 20px;
    }

    #powerupIndicator {
        top: 80px;
        right: 15px;
        padding: 10px;
    }

    #comboIndicator {
        top: 80px;
        left: 15px;
        padding: 10px 15px;
    }

    .combo-value {
        font-size: 20px;
    }

    .instruction-methods {
        flex-direction: column;
        gap: 20px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    .mobile-controls {
        bottom: 20px;
        padding: 0 20px;
    }

    .touch-button {
        width: 60px;
        height: 60px;
    }

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

    .button-label {
        font-size: 6px;
    }

    #ui {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    #lives {
        top: 10px;
    }
}

/* Touch-friendly button sizing */
@media (hover: none) and (pointer: coarse) {
    button {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 18px 35px;
        font-size: 12px;
    }
}
