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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a1a;
    color: #00ff00;
    overflow-x: auto;
}

.container {
    min-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    border: 2px solid #00ff00;
    border-radius: 10px;
    background: rgba(0, 255, 0, 0.05);
}

.header h1 {
    font-size: 2em;
    margin-bottom: 10px;
    text-shadow: 0 0 10px #00ff00;
}

.main-layout {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    margin-bottom: 20px;
}

.left-panel, .right-panel {
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid #00ff00;
    border-radius: 8px;
    padding: 15px;
    height: fit-content;
}

.center-panel {
    text-align: center;
}

.control-section, .memory-section, .demo-section,
.pattern-tables, .palette-section, .nametable-section {
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #004400;
    border-radius: 5px;
    background: rgba(0, 68, 0, 0.1);
}

h3, h4 {
    color: #00ff88;
    margin-bottom: 10px;
    border-bottom: 1px solid #004400;
    padding-bottom: 5px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

button {
    background: #004400;
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

button:hover {
    background: #006600;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

input[type="range"] {
    background: #004400;
    border: 1px solid #00ff00;
    border-radius: 3px;
}

input[type="text"], select {
    background: #002200;
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 5px;
    border-radius: 3px;
    font-family: inherit;
}

.ppu-registers {
    font-size: 0.85em;
}

.register {
    margin-bottom: 10px;
}

.bit-controls {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    margin-top: 5px;
    font-size: 0.7em;
}

.bit-controls span {
    text-align: center;
    color: #888888;
}

.bit-controls input[type="checkbox"] {
    justify-self: center;
    transform: scale(0.8);
}

.ppu-display {
    background: rgba(0, 255, 0, 0.05);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 20px;
}

.canvas-container {
    position: relative;
    display: inline-block;
    border: 2px solid #004400;
    border-radius: 5px;
    background: #000000;
    margin: 10px 0;
}

canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.scanline-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 0, 0, 0.8);
    pointer-events: none;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

.display-info {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    font-size: 0.9em;
}

.pattern-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    text-align: center;
}

.pattern-container canvas {
    border: 1px solid #004400;
    background: #000000;
}

.memory-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.memory-display {
    max-height: 200px;
    overflow-y: auto;
    background: #000000;
    border: 1px solid #004400;
    border-radius: 3px;
    padding: 5px;
    font-size: 0.8em;
}

.memory-grid {
    font-family: 'Courier New', monospace;
}

.memory-row {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

.addr {
    color: #ffff00;
    margin-right: 10px;
    min-width: 50px;
}

.byte {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 2px;
    cursor: pointer;
    border-radius: 2px;
    padding: 1px;
}

.byte:hover {
    background: rgba(0, 255, 0, 0.2);
}

.byte.pattern-0 { background: rgba(255, 0, 0, 0.2); }
.byte.pattern-1 { background: rgba(0, 0, 255, 0.2); }
.byte.nametable { background: rgba(255, 255, 0, 0.2); }
.byte.palette { background: rgba(255, 0, 255, 0.2); }

.palette-grid h4 {
    font-size: 0.9em;
    margin: 10px 0 5px 0;
}

.palette-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}

.color-swatch {
    width: 20px;
    height: 20px;
    border: 1px solid #00ff00;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.color-swatch:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #00ff00;
    padding: 5px;
    border-radius: 3px;
    font-size: 0.7em;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid #00ff00;
}

.demo-section select {
    width: 100%;
    margin-bottom: 10px;
}

.footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #004400;
    color: #888888;
    font-size: 0.9em;
}

.footer a {
    color: #00ff88;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
    text-shadow: 0 0 5px #00ff88;
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #004400;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #006600;
}

/* Mobile responsiveness */
@media (max-width: 1250px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .container {
        min-width: auto;
        padding: 10px;
    }
    
    .pattern-container {
        grid-template-columns: 1fr;
    }
    
    .bit-controls {
        grid-template-columns: repeat(4, 1fr);
        gap: 3px;
    }
    
    canvas {
        max-width: 100%;
        height: auto;
    }
}

/* Fun CRT effect */
@keyframes crt-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.98; }
}

.ppu-display {
    animation: crt-flicker 3s infinite;
}

/* Konami code Easter egg styles */
.konami-active {
    background: linear-gradient(45deg, #ff0000, #00ff00, #0000ff, #ffff00);
    background-size: 400% 400%;
    animation: rainbow 2s ease infinite;
}

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