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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Courier New', monospace;
    background: #000;
    color: #00ff00;
    display: flex;
    flex-direction: column;
}

#emulator-container {
    flex: 1;
    width: 100%;
    height: 100vh;
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Debug page has controls bar, so needs different height */
body.debug-page #emulator-container {
    height: calc(100vh - 60px);
}

/* Dev page layout: emulator left, editor panel right */
body.dev-page {
    flex-direction: row;
}

body.dev-page #emulator-container {
    height: 100vh;
    flex: 1;
}

.dev-panel {
    width: 440px;
    height: 100vh;
    flex-shrink: 0;
    border-left: 2px solid #00ff00;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
}

.dev-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-bottom: 2px solid #00ff00;
}

.dev-panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dev-modes {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn.btn-mode {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 4px;
    background: rgba(0, 255, 0, 0.15);
    color: #00ff00;
    border: 1px solid rgba(0, 255, 0, 0.55);
}

.btn.btn-mode:hover {
    background: rgba(0, 255, 0, 0.25);
    box-shadow: none;
}

.btn.btn-mode.is-active {
    background: #00ff00;
    color: #000;
    border-color: #00ff00;
}

.dev-title {
    font-weight: bold;
    letter-spacing: 1px;
}

.dev-meta {
    margin-top: 2px;
    font-size: 12px;
    color: rgba(0, 255, 0, 0.75);
}

.dev-meta #build-sha {
    color: #ffaa00;
}

.dev-status {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 255, 0, 0.35);
    color: #00cc00;
    min-height: 20px;
}

.dev-status.is-warn { color: #ffaa00; }
.dev-status.is-err { color: #ff5555; }

.editor-wrap {
    position: relative;
    flex: 1;
    min-height: 0; /* allow flex child to shrink */
    padding: 12px;
    --editor-inset: 12px;
    --gutter-w: 52px;
}

.editor-layer {
    position: absolute;
    inset: 0;
    display: none;
}

.editor-layer.is-active {
    display: block;
}

.basic-highlight,
#basic-editor {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    tab-size: 4;
    white-space: pre;
}

.basic-highlight {
    position: absolute;
    top: var(--editor-inset);
    right: var(--editor-inset);
    bottom: var(--editor-inset);
    left: calc(var(--editor-inset) + var(--gutter-w));
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(0, 255, 0, 0.65);
    overflow: auto;
    pointer-events: none;
    color: #00ff00;
    background: rgba(0, 0, 0, 0.2);
}

#basic-editor {
    position: absolute;
    top: var(--editor-inset);
    right: var(--editor-inset);
    bottom: var(--editor-inset);
    left: calc(var(--editor-inset) + var(--gutter-w));
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(0, 255, 0, 0.65);
    background: transparent;
    resize: none;
    overflow: auto;
    outline: none;
    color: transparent; /* text is rendered by highlight layer */
    caret-color: #00ff00;
}

.asm-highlight,
#asm-editor {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    tab-size: 4;
    white-space: pre;
}

.asm-highlight {
    position: absolute;
    top: var(--editor-inset);
    right: var(--editor-inset);
    bottom: var(--editor-inset);
    left: calc(var(--editor-inset) + var(--gutter-w));
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(0, 255, 0, 0.65);
    overflow: auto;
    pointer-events: none;
    color: #00ff00;
    background: rgba(0, 0, 0, 0.2);
}

#asm-editor {
    position: absolute;
    top: var(--editor-inset);
    right: var(--editor-inset);
    bottom: var(--editor-inset);
    left: calc(var(--editor-inset) + var(--gutter-w));
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(0, 255, 0, 0.65);
    background: transparent;
    resize: none;
    overflow: auto;
    outline: none;
    color: transparent;
    caret-color: #00ff00;
}

.dev-hint {
    padding: 10px 12px;
    border-top: 2px solid #00ff00;
    color: rgba(0, 255, 0, 0.75);
    font-size: 12px;
}

.editor-gutter {
    position: absolute;
    top: var(--editor-inset);
    bottom: var(--editor-inset);
    left: var(--editor-inset);
    width: var(--gutter-w);
    margin: 0;
    padding: 12px 8px 12px 12px;
    border: 1px solid rgba(0, 255, 0, 0.35);
    border-right: none;
    overflow: auto;
    color: rgba(0, 255, 0, 0.6);
    background: rgba(0, 0, 0, 0.2);
    text-align: right;
    user-select: none;
    pointer-events: none;
    white-space: pre;
}

.editor-gutter {
    scrollbar-width: none;
}
.editor-gutter::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.editor-error-line {
    position: absolute;
    left: calc(var(--editor-inset) + var(--gutter-w));
    right: var(--editor-inset);
    height: calc(1.4em);
    top: var(--editor-inset);
    background: rgba(255, 85, 85, 0.15);
    border: 1px solid rgba(255, 85, 85, 0.25);
    border-left: none;
    border-right: none;
    pointer-events: none;
    display: none;
    z-index: 1;
}

/* BASIC highlight colors */
.bas-ln { color: #ffaa00; }
.bas-kw { color: #33ccff; font-weight: bold; }
.bas-str { color: #ff66ff; }
.bas-com { color: rgba(0, 255, 0, 0.45); }
.bas-num { color: #ffffff; }

/* ASM highlight colors */
.asm-lbl { color: #ffaa00; }
.asm-op { color: #33ccff; font-weight: bold; }
.asm-dir { color: #33ccff; font-weight: bold; }
.asm-str { color: #ff66ff; }
.asm-com { color: rgba(0, 255, 0, 0.45); }
.asm-num { color: #ffffff; }

@media (max-width: 980px) {
    body.dev-page {
        flex-direction: column;
    }
    body.dev-page #emulator-container {
        height: 55vh;
    }
    .dev-panel {
        width: 100%;
        height: 45vh;
        border-left: none;
        border-top: 2px solid #00ff00;
    }
}

/* JSC64 creates multiple canvas elements (Back, Border, Fore) */
/* Canvas scaling is handled by JavaScript in app.js */
#emulator-container canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
}

.controls-bar {
    height: 60px;
    background: rgba(0, 0, 0, 0.9);
    border-top: 2px solid #00ff00;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 0 20px;
    flex-shrink: 0;
}

.btn {
    background: #00ff00;
    color: #000;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn:hover {
    background: #00cc00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.btn:active {
    transform: scale(0.98);
}

.program-info {
    color: #00cc00;
    font-size: 14px;
    text-align: center;
    min-height: 20px;
    flex: 1;
    max-width: 400px;
}

/* Responsive design */
@media (max-width: 768px) {
    .controls-bar {
        flex-wrap: wrap;
        height: auto;
        min-height: 60px;
        padding: 10px;
    }
    
    .program-info {
        width: 100%;
        order: 3;
    }
}

/* VICE.js audio overlay (start muted; user opts in) */
.vice-audio-overlay {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none; /* don't block emulator interaction */
}

.vice-audio-card {
    border: 2px solid #00ff00;
    background: rgba(0, 0, 0, 0.92);
    padding: 16px 18px;
    border-radius: 6px;
    width: min(360px, calc(100vw - 32px));
    text-align: center;
    box-shadow: 0 0 16px rgba(0, 255, 0, 0.18);
    pointer-events: auto;
}

.vice-audio-title {
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: #00ff00;
}

.vice-audio-sub {
    font-size: 13px;
    color: rgba(0, 255, 0, 0.75);
    margin-bottom: 12px;
}

.vice-audio-btn.btn {
    width: 100%;
}

.vice-audio-overlay.is-disabled .vice-audio-card {
    border-color: rgba(0, 255, 0, 0.35);
    box-shadow: none;
}

.vice-audio-overlay.is-disabled .vice-audio-title,
.vice-audio-overlay.is-disabled .vice-audio-sub {
    color: rgba(0, 255, 0, 0.55);
}

.vice-audio-overlay.is-disabled .btn {
    opacity: 0.6;
    cursor: not-allowed;
}

