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

body {
    background: #000000;
    color: #00ff00;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    position: relative;
    height: 100vh;
    text-transform: uppercase;
}

/* Custom matrix cursor */
body::after {
    content: '';
    position: fixed;
    width: 0;
    height: 0;
    border-left: 12px solid #00ff00;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    pointer-events: none;
    z-index: 9999;
    transform: translate(0, -50%);
    left: var(--cursor-x, 50%);
    top: var(--cursor-y, 50%);
    filter: drop-shadow(0 0 5px #00ff00);
    display: none; /* Hide by default */
}

/* Matrix cursor trail effect */
body::before {
    content: '';
    position: fixed;
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.2;
    filter: blur(1px);
    transform: translate(-50%, -50%);
    left: var(--cursor-x, 50%);
    top: var(--cursor-y, 50%);
    animation: cursorTrail 0.3s infinite;
    display: none; /* Hide by default */
}

/* Show cursor only when mouse is within window */
body.cursor-visible::after,
body.cursor-visible::before {
    display: block;
}

/* Hide cursor on touch devices */
@media (hover: none) {
    body::after,
    body::before {
        display: none !important;
    }
}

@keyframes cursorTrail {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.2; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

/* CRT Monitor Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Scanlines */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.03) 2px,
        rgba(0, 255, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 3;
    animation: scanlines 8s linear infinite;
}

@keyframes scanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

/* Flicker effect */
.flicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 255, 0, 0.01);
    pointer-events: none;
    z-index: 4;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.97; }
    10% { opacity: 0.98; }
    20% { opacity: 0.97; }
    30% { opacity: 0.99; }
    40% { opacity: 0.98; }
    50% { opacity: 0.96; }
    60% { opacity: 0.99; }
    70% { opacity: 0.98; }
    80% { opacity: 0.97; }
    90% { opacity: 0.99; }
    100% { opacity: 0.97; }
}

.matrix-container {
    width: 100%;
    height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Header with ASCII art - Fixed at top */
.matrix-header {
    flex-shrink: 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #00ff00;
    padding-bottom: 5px;
}

.ascii-art {
    color: #00ff00;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    white-space: pre;
    overflow: hidden;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00, 0 0 30px #00ff00; }
    to { text-shadow: 0 0 20px #00ff00, 0 0 30px #00ff00, 0 0 40px #00ff00; }
}

/* Main content area - Scrollable middle section */
.matrix-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px;
}

.terminal-output {
    margin-bottom: 30px;
}

.system-message {
    color: #00ff00;
    margin-bottom: 5px;
    animation: typeIn 0.5s ease-out;
}

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

/* Menu items */
.matrix-menu {
    margin-bottom: 30px;
}

.menu-item {
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #00ff00;
    background: rgba(0, 255, 0, 0.05);
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-item:hover,
.menu-item.active {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.menu-number {
    color: #00ff00;
    font-weight: bold;
    min-width: 30px;
}

.menu-text {
    flex: 1;
    color: #00ff00;
}

.menu-status {
    color: rgba(0, 255, 0, 0.6);
    font-size: 12px;
}

/* Command line - Fixed above footer */
.command-line {
    display: flex;
    align-items: center;
    border: 1px solid #00ff00;
    border-bottom: none;
    padding: 10px 20px;
    background: rgba(0, 255, 0, 0.05);
    flex-shrink: 0;
    width: 100%;
}

.prompt {
    color: #00ff00;
    margin-right: 10px;
    animation: blink 1s infinite;
}

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

.command-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #00ff00;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    text-transform: uppercase;
}

.command-input::placeholder {
    color: rgba(0, 255, 0, 0.4);
}

/* Footer status bar - Fixed at bottom */
.matrix-footer {
    flex-shrink: 0;
    border-top: 1px solid #00ff00;
    padding-top: 10px;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border: 1px solid #00ff00;
    background: rgba(0, 255, 0, 0.05);
    font-size: 12px;
}

.status-item {
    color: rgba(0, 255, 0, 0.8);
}

/* Mobile touch indicator */
.touch-indicator {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid #00ff00;
    padding: 10px 20px;
    font-size: 12px;
    color: #00ff00;
    text-align: center;
    z-index: 10;
    display: none;
}

.touch-indicator.show {
    display: block;
    animation: fadeInOut 3s ease-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* Mobile controls overlay */
.mobile-controls {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 10px;
    z-index: 10;
}

.mobile-controls.active {
    display: flex;
}

.control-button {
    width: 60px;
    height: 60px;
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #00ff00;
    color: #00ff00;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-button:active {
    background: rgba(0, 255, 0, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        font-size: 12px;
        -webkit-text-size-adjust: 100%;
        touch-action: manipulation;
    }
    
    .matrix-container {
        padding: 10px;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    .matrix-header {
        margin-bottom: 5px;
        padding-bottom: 3px;
    }
    
    .ascii-art {
        font-size: 10px;
    }
    
    .matrix-content {
        padding-right: 5px;
    }
    
    .menu-item {
        padding: 12px;
        margin-bottom: 8px;
        min-height: 60px;
        touch-action: manipulation;
    }
    
    .menu-number {
        font-size: 14px;
        min-width: 25px;
    }
    
    .menu-text {
        font-size: 13px;
    }
    
    .menu-status {
        font-size: 11px;
    }
    
    .command-line {
        padding: 8px 15px;
    }
    
    .command-input {
        font-size: 12px;
    }
    
    .status-bar {
        flex-wrap: wrap;
        gap: 5px;
        padding: 8px;
        font-size: 10px;
    }
    
    .status-item {
        flex: 1 1 auto;
        min-width: 80px;
        text-align: center;
    }
    
    /* Hide scrollbar on mobile for cleaner look */
    .matrix-content::-webkit-scrollbar {
        width: 0;
        display: none;
    }
    
    /* Game specific mobile adjustments */
    .game-option {
        font-size: 12px;
        padding: 10px;
        min-height: 50px;
    }
    
    .game-canvas {
        min-height: 300px;
        padding: 10px;
    }
    
    .retro-game-canvas {
        max-width: calc(100vw - 40px);
        height: auto;
        touch-action: none;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .ascii-art {
        font-size: 8px;
        line-height: 0.9;
    }
    
    .menu-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        padding: 10px;
    }
    
    .menu-text {
        font-size: 12px;
    }
    
    .status-bar {
        font-size: 9px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .matrix-header {
        display: none;
    }
    
    .matrix-content {
        margin-top: 10px;
    }
    
    .matrix-footer {
        padding-top: 5px;
    }
    
    .status-bar {
        padding: 5px;
        min-height: auto;
    }
}

/* Matrix Exit Sequence */
.matrix-exit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    font-family: 'Courier New', monospace;
    color: #00ff00;
}

.matrix-exit-overlay.active {
    display: flex;
}

.exit-content {
    text-align: center;
    opacity: 0;
    animation: matrixFadeIn 1s ease-in-out forwards;
}

.exit-content h2 {
    font-size: 24px;
    font-weight: normal;
    margin-bottom: 20px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px #00ff00;
}

.exit-content p {
    font-size: 14px;
    margin-bottom: 30px;
    opacity: 0.8;
    letter-spacing: 1px;
}

.matrix-loading {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin: 20px 0;
}

.matrix-dot {
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    animation: matrixPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px #00ff00;
}

.matrix-dot:nth-child(2) {
    animation-delay: 0.3s;
}

.matrix-dot:nth-child(3) {
    animation-delay: 0.6s;
}

.matrix-code-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.matrix-column {
    position: absolute;
    top: -100%;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #00ff00;
    animation: matrixFall 3s linear infinite;
    opacity: 0.3;
}

@keyframes matrixFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes matrixPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes matrixFall {
    0% {
        top: -100%;
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Glitch effect for exit */
.matrix-glitch {
    animation: matrixGlitch 0.3s ease-in-out infinite;
}

@keyframes matrixGlitch {
    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);
    }
}

/* Mobile adjustments for exit sequence */
@media (max-width: 768px) {
    .exit-content h2 {
        font-size: 18px;
    }
    
    .exit-content p {
        font-size: 12px;
    }
    
    .matrix-column {
        font-size: 10px;
    }
}

/* Text selection */
::selection {
    background: #00ff00;
    color: #000000;
}

::-moz-selection {
    background: #00ff00;
    color: #000000;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #000000;
    border: 1px solid #00ff00;
}

::-webkit-scrollbar-thumb {
    background: #00ff00;
}

::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

/* Game Menu Styles */
.game-menu {
    margin-top: 20px;
}

.game-option {
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #00ff00;
    background: rgba(0, 255, 0, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 20px;
}

.game-option:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transform: translateX(5px);
}

.game-number {
    color: #00ff00;
    font-weight: bold;
    min-width: 30px;
}

.game-name {
    flex: 1;
    color: #00ff00;
    font-weight: bold;
}

.game-desc {
    color: rgba(0, 255, 0, 0.6);
    font-size: 12px;
}

/* Game Canvas */
.game-canvas {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.game-canvas.hidden {
    display: none;
}

.retro-game-canvas {
    border: 2px solid #00ff00;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Game-specific animations */
@keyframes gameGlow {
    0% { box-shadow: 0 0 20px rgba(0, 255, 0, 0.5); }
    50% { box-shadow: 0 0 40px rgba(0, 255, 0, 0.8); }
    100% { box-shadow: 0 0 20px rgba(0, 255, 0, 0.5); }
}

.retro-game-canvas:focus {
    outline: none;
    animation: gameGlow 2s infinite;
}

/* Game-specific mobile styles */
.game-controls-mobile {
    position: fixed;
    bottom: 10px;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px 10px 10px 10px;
    z-index: 15;
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid #00ff00;
}

.game-controls-mobile.active {
    display: flex;
}

/* Hide command line and footer when mobile game is active */
body.mobile-game-active .command-line,
body.mobile-game-active .matrix-footer {
    display: none;
}

/* Adjust matrix content when mobile game controls are active */
body.mobile-game-active .matrix-content {
    padding-bottom: 160px; /* Make room for mobile controls */
    max-height: calc(100vh - 160px); /* Ensure content fits above controls */
    overflow-y: auto;
}

/* Ensure game canvas doesn't overflow on mobile */
@media (max-width: 768px) {
    body.mobile-game-active .game-canvas {
        max-height: calc(100vh - 240px); /* Header + controls + padding */
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: 10px;
    }
}

.game-control-group {
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
}

.game-control-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.game-control-btn {
    width: 50px;
    height: 50px;
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #00ff00;
    color: #00ff00;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: 5px;
}

.game-control-btn:active {
    background: rgba(0, 255, 0, 0.3);
    transform: scale(0.95);
}

.game-control-btn.large {
    width: 80px;
    height: 50px;
    font-size: 11px;
}

.game-control-btn.exit {
    background: rgba(255, 0, 0, 0.1);
    border-color: #ff0000;
    color: #ff0000;
    font-size: 11px;
    width: 60px;
    height: 40px;
}

.game-control-btn.exit:active {
    background: rgba(255, 0, 0, 0.3);
}

/* Swipe indicator */
.swipe-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 255, 0, 0.6);
    font-size: 14px;
    text-align: center;
    pointer-events: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Text selection cursor */
input,
textarea,
[contenteditable="true"] {
    cursor: none;
}

input::selection,
textarea::selection,
[contenteditable="true"]::selection {
    background: #00ff00;
    color: #000000;
}

/* Interactive element cursor */
a,
button,
[role="button"],
[type="button"],
[type="submit"] {
    cursor: none;
}

/* Custom text selection cursor */
.text-select-cursor {
    display: none;
    position: fixed;
    width: 2px;
    height: 20px;
    background: #00ff00;
    box-shadow: 0 0 5px #00ff00;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    left: var(--cursor-x, 50%);
    top: var(--cursor-y, 50%);
}

input:focus ~ .text-select-cursor,
textarea:focus ~ .text-select-cursor,
[contenteditable="true"]:focus ~ .text-select-cursor {
    display: block;
}

/* Custom pointer cursor for interactive elements */
.pointer-cursor {
    display: none;
    position: fixed;
    width: 0;
    height: 0;
    border-left: 12px solid #00ff00;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    pointer-events: none;
    z-index: 9999;
    transform: translate(0, -50%) scale(1.2);
    left: var(--cursor-x, 50%);
    top: var(--cursor-y, 50%);
    filter: drop-shadow(0 0 8px #00ff00);
}

a:hover ~ .pointer-cursor,
button:hover ~ .pointer-cursor,
[role="button"]:hover ~ .pointer-cursor,
[type="button"]:hover ~ .pointer-cursor,
[type="submit"]:hover ~ .pointer-cursor {
    display: block;
}