:root {
    --fg-color: #00FF41;
    --glow-color: #00FF41;
    --bg-color: #0a0a0a;
    --panel-bg: #111111;
    --border-color: #1a1a1a;
}

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

body {
    background: #050505;
    color: var(--fg-color);
    font-family: 'IBM Plex Mono', monospace;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    overflow-x: hidden;
}

#app {
    max-width: 680px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Header */
header {
    text-align: center;
    padding: 20px 0 8px;
}

header h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 28px;
    color: var(--fg-color);
    text-shadow: 0 0 10px var(--glow-color), 0 0 20px var(--glow-color);
    letter-spacing: 4px;
}

header .subtitle {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: #555;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Controls */
#controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: var(--panel-bg);
    border: 1px solid #222;
    border-radius: 4px;
    width: 100%;
}

.rom-btn {
    position: relative;
    cursor: pointer;
    background: #1a1a1a;
    border: 1px solid var(--fg-color);
    color: var(--fg-color);
    padding: 8px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    border-radius: 3px;
    transition: all 0.15s;
}

.rom-btn:hover {
    background: var(--fg-color);
    color: #000;
    box-shadow: 0 0 8px var(--glow-color);
}

.rom-btn input[type="file"] {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
}

.ctrl-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #aaa;
    padding: 8px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.ctrl-btn:hover {
    border-color: var(--fg-color);
    color: var(--fg-color);
    box-shadow: 0 0 6px var(--glow-color);
}

.ctrl-btn:active {
    background: var(--fg-color);
    color: #000;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #666;
}

.speed-control input[type="range"] {
    width: 80px;
    accent-color: var(--fg-color);
}

.speed-control span {
    color: var(--fg-color);
    min-width: 20px;
    text-align: center;
}

.demo-btns {
    display: flex;
    gap: 6px;
}

.demo-btn {
    background: transparent;
    border: 1px solid #333;
    color: #888;
    padding: 6px 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
}

.demo-btn:hover {
    border-color: var(--fg-color);
    color: var(--fg-color);
}

/* Display */
#display-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

#crt-bezel {
    position: relative;
    border: 3px solid #222;
    border-radius: 12px;
    padding: 8px;
    background: #060606;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.8),
        0 0 15px rgba(0,0,0,0.5),
        0 0 2px var(--glow-color);
    overflow: hidden;
}

#screen {
    display: block;
    border-radius: 4px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 100%;
    max-width: 640px;
    height: auto;
    aspect-ratio: 2/1;
}

#scanlines {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 4px;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    z-index: 2;
}

/* Status Bar */
#status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 16px;
    background: var(--panel-bg);
    border: 1px solid #1a1a1a;
    border-radius: 4px;
    font-size: 11px;
    color: #555;
    width: 100%;
    justify-content: center;
}

#status-bar span {
    white-space: nowrap;
}

.sound-on {
    color: var(--fg-color) !important;
    text-shadow: 0 0 6px var(--glow-color);
    animation: pulse 0.5s infinite alternate;
}

.sound-off {
    color: #333 !important;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* Settings Row */
#settings-row {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 11px;
    color: #666;
    flex-wrap: wrap;
    justify-content: center;
}

#settings-row select {
    background: #1a1a1a;
    border: 1px solid #333;
    color: var(--fg-color);
    padding: 4px 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
}

#settings-row input[type="checkbox"] {
    accent-color: var(--fg-color);
}

/* Keyboard */
#keyboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 360px;
    padding: 12px;
    background: var(--panel-bg);
    border: 1px solid #1a1a1a;
    border-radius: 6px;
}

.key {
    aspect-ratio: 1;
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    background: #1a1a1a;
    border: 2px solid #2a2a2a;
    border-bottom: 3px solid #333;
    color: #777;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.08s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key:hover {
    border-color: var(--fg-color);
    color: var(--fg-color);
    box-shadow: 0 0 8px var(--glow-color);
}

.key.active, .key:active {
    background: var(--fg-color) !important;
    color: #000 !important;
    border-color: var(--fg-color) !important;
    box-shadow: 0 0 15px var(--glow-color), inset 0 0 5px rgba(0,0,0,0.3) !important;
    transform: translateY(1px);
    border-bottom-width: 2px;
}

/* About Section */
#about-section {
    width: 100%;
    font-size: 12px;
    color: #555;
    border: 1px solid #1a1a1a;
    border-radius: 4px;
    padding: 10px 14px;
    background: var(--panel-bg);
}

#about-section summary {
    cursor: pointer;
    color: #777;
    font-weight: 500;
    outline: none;
}

#about-section summary:hover {
    color: var(--fg-color);
}

#about-section p {
    margin-top: 10px;
    line-height: 1.6;
}

/* Footer */
footer {
    padding: 16px 0;
    text-align: center;
}

footer a {
    color: #444;
    text-decoration: none;
    font-size: 11px;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--fg-color);
}

/* Responsive */
@media (max-width: 500px) {
    body {
        padding: 8px;
    }

    header h1 {
        font-size: 20px;
    }

    #controls {
        gap: 6px;
        padding: 8px;
    }

    .ctrl-btn, .rom-btn {
        padding: 6px 10px;
        font-size: 10px;
    }

    .key {
        font-size: 14px;
    }

    #status-bar {
        font-size: 9px;
        gap: 8px;
    }
}