/* The canvas is always a dark rendered scene, so the whole demo commits to a
   single dark "inspector panel" in both themes rather than scattering dark
   widgets across a light page. All chrome text is therefore explicitly light
   (never the theme-driven --text, which would go dark-on-dark in light mode). */
:root {
    --panel: #171b21;
    --panel-line: #2a2f39;
    --surface: #1c2028;
    --surface-hover: #242a34;
    --console: #0c0e12;
    --line: #333a46;
    --ink: #d6d7d9;
    --ink-dim: #8b909b;
    --accent: #3a5fd0;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    user-select: none;
}

/* One cohesive panel: tabs, viewport, toolbar and console read as a single
   instrument regardless of the page theme behind the iframe. */
#app {
    max-width: 720px;
    margin: 12px auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--panel-line);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .18);
    box-sizing: border-box;
}

/* Mode switch as a segmented control rather than three loose pills. */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--console);
    border-radius: 9px;
}

.tabs button {
    flex: 1;
    background: transparent;
    color: var(--ink-dim);
    border: 1px solid transparent;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s ease, color .15s ease;
}

.tabs button:hover {
    background: var(--surface);
    color: var(--ink);
}

.tabs button.active {
    background: var(--surface);
    border-color: var(--line);
    color: #fff;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #161a21;
    border: 1px solid var(--panel-line);
    border-radius: 8px;
    touch-action: none;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    min-height: 28px;
    flex-wrap: wrap;
}

.controls[hidden] {
    display: none;
}

.controls label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.controls button {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s ease;
}

.controls button:hover {
    background: var(--surface-hover);
}

.controls input[type=range] {
    flex: 1;
    min-width: 120px;
}

/* Themed sliders and checkboxes so the accent matches the active tab. */
.controls input {
    accent-color: var(--accent);
}

:where(.tabs, .controls) button:focus-visible,
.controls input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.note {
    color: var(--ink-dim);
    font-size: 12px;
}

/* Console footer: readout of the current DDA / column / sprite state. */
#readout {
    background: var(--console);
    color: var(--ink);
    border: 1px solid var(--panel-line);
    border-radius: 8px;
    padding: 10px 12px;
    font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
    min-height: 72px;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
}
