:root {
    --phosphor: #00ff41;
    --phosphor-dim: #00aa2a;
    --phosphor-bg: rgba(0,255,65,0.05);
    --bg: #0a0a0a;
    --panel-bg: #111111;
    --border: #222;
    --glow: 0 0 8px rgba(0,255,65,0.3);
}

.amber {
    --phosphor: #ffb000;
    --phosphor-dim: #aa7500;
    --phosphor-bg: rgba(255,176,0,0.05);
    --glow: 0 0 8px rgba(255,176,0,0.3);
}

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

body {
    background: var(--bg);
    color: var(--phosphor);
    font-family: 'VT323', monospace;
    overflow-x: hidden;
    min-height: 100vh;
}

/* CRT Scanline overlay */
.crt-overlay {
    pointer-events: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.08) 2px,
        rgba(0,0,0,0.08) 4px
    );
}

.crt-screen {
    border-radius: 12px;
    box-shadow: inset 0 0 80px rgba(0,0,0,0.4), var(--glow);
}

/* Boot animation */
@keyframes bootFlicker {
    0%, 5% { opacity: 0; }
    6% { opacity: 1; }
    7% { opacity: 0.3; }
    8%, 100% { opacity: 1; }
}

@keyframes bootCursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.boot-text { animation: bootFlicker 0.5s ease-out; }
.boot-cursor { animation: bootCursor 0.5s infinite; }

/* Key styles */
.oric-key {
    background: linear-gradient(180deg, #d4d4d4 0%, #b8b8b8 80%, #999 100%);
    border: 1px solid #666;
    border-radius: 4px;
    box-shadow: 0 3px 0 #777, 0 4px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
    color: #222;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 14px;
    padding: 6px 4px;
    min-width: 36px;
    text-align: center;
    transition: all 0.08s ease;
    user-select: none;
    position: relative;
    transform: translateY(0);
}

.oric-key:hover {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #777, 0 3px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.5);
}

.oric-key:active, .oric-key.pressed {
    transform: translateY(3px);
    box-shadow: 0 0px 0 #777, 0 1px 2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
    background: linear-gradient(180deg, #bbb 0%, #aaa 80%, #888 100%);
}

.oric-key.active-scan {
    box-shadow: 0 0 12px var(--phosphor), 0 3px 0 #777;
    border-color: var(--phosphor);
}

.oric-key.key-flash {
    background: linear-gradient(180deg, #aaff88 0%, #66dd44 80%, #44aa22 100%);
    box-shadow: 0 0 16px rgba(0,255,65,0.6), 0 3px 0 #4a4;
}

/* Matrix cell */
.matrix-cell {
    border: 1px solid #333;
    padding: 2px 4px;
    font-size: 11px;
    text-align: center;
    transition: all 0.15s ease;
    cursor: pointer;
    min-width: 44px;
}

.matrix-cell:hover {
    border-color: var(--phosphor);
    background: var(--phosphor-bg);
}

.matrix-cell.col-highlight {
    background: rgba(255,102,0,0.15);
    border-color: #ff6600;
}

.matrix-cell.row-highlight {
    background: rgba(0,170,255,0.15);
    border-color: #00aaff;
}

.matrix-cell.cell-active {
    background: rgba(0,255,65,0.3) !important;
    border-color: var(--phosphor) !important;
    box-shadow: 0 0 8px rgba(0,255,65,0.5);
    color: #fff;
}

.matrix-cell.scanning {
    background: rgba(255,255,0,0.1);
    border-color: #ff0;
}

/* Chip box */
.chip-box {
    border: 2px solid #555;
    border-radius: 6px;
    padding: 8px;
    background: #1a1a1a;
    position: relative;
    min-width: 140px;
}

.chip-box .chip-label {
    position: absolute;
    top: -10px;
    left: 8px;
    background: #1a1a1a;
    padding: 0 6px;
    font-size: 12px;
    color: var(--phosphor);
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
}

/* Data flow lines */
@keyframes flowRight {
    0% { background-position: 0 0; }
    100% { background-position: 20px 0; }
}

@keyframes flowDown {
    0% { background-position: 0 0; }
    100% { background-position: 0 20px; }
}

.flow-line-h {
    height: 3px;
    background: repeating-linear-gradient(90deg, transparent, transparent 4px, #ff6600 4px, #ff6600 10px);
    background-size: 20px 3px;
    animation: flowRight 0.4s linear infinite;
}

.flow-line-h.blue {
    background: repeating-linear-gradient(90deg, transparent, transparent 4px, #00aaff 4px, #00aaff 10px);
    animation: flowRight 0.4s linear infinite;
}

.flow-line-h.green {
    background: repeating-linear-gradient(90deg, transparent, transparent 4px, #00ff41 4px, #00ff41 10px);
    animation: flowRight 0.4s linear infinite;
}

.flow-line-inactive { opacity: 0.15; animation: none !important; }

/* Memory map segment */
.mem-segment {
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border-left: 3px solid transparent;
}

.mem-segment:hover {
    border-left-color: var(--phosphor);
    background: var(--phosphor-bg);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--phosphor-dim); }

/* Scan log */
.scan-log {
    font-family: 'VT323', monospace;
    font-size: 14px;
    line-height: 1.4;
    max-height: 160px;
    overflow-y: auto;
    background: #050505;
    border: 1px solid #222;
    padding: 8px;
    border-radius: 4px;
}

.scan-log .log-scan { color: #ff6600; }
.scan-log .log-key { color: #00ff41; }
.scan-log .log-via { color: #00aaff; }

/* Panel */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--glow);
    padding: 12px;
    overflow: hidden;
}

/* Character ROM grid */
.char-grid-cell {
    width: 24px;
    height: 24px;
    border: 1px solid #222;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-grid-cell:hover {
    border-color: var(--phosphor);
    background: var(--phosphor-bg);
}

/* Tooltip */
.tooltip-content {
    position: absolute;
    z-index: 100;
    background: #1a1a1a;
    border: 1px solid var(--phosphor);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    max-width: 280px;
    box-shadow: 0 0 12px rgba(0,0,0,0.8);
    pointer-events: none;
}

/* Dropzone */
.rom-dropzone {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.rom-dropzone:hover, .rom-dropzone.drag-over {
    border-color: var(--phosphor);
    background: var(--phosphor-bg);
}

/* Speed slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    height: 4px;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--phosphor);
    cursor: pointer;
}

/* Pulse animation for ROM loaded */
@keyframes romPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.rom-loaded-pulse {
    animation: romPulse 1.5s ease-in-out 3;
}

/* Tab button */
.tab-btn {
    padding: 6px 14px;
    border: 1px solid #333;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: #111;
    color: #666;
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 15px;
    transition: all 0.15s;
}

.tab-btn.active {
    background: var(--panel-bg);
    color: var(--phosphor);
    border-color: var(--phosphor-dim);
}

.tab-btn:hover:not(.active) {
    color: var(--phosphor-dim);
    border-color: #444;
}

/* How it works expandable */
.how-it-works {
    border: 1px solid #333;
    border-radius: 6px;
    margin-top: 8px;
}

.how-it-works summary {
    cursor: pointer;
    padding: 8px 12px;
    color: var(--phosphor);
    font-size: 15px;
}

.how-it-works summary:hover {
    background: var(--phosphor-bg);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .oric-key { min-width: 28px; font-size: 12px; padding: 4px 2px; }
}

@media (max-width: 768px) {
    .oric-key { min-width: 24px; font-size: 11px; padding: 3px 1px; }
    .matrix-cell { font-size: 9px; min-width: 32px; padding: 1px 2px; }
}