 * {
	 box-sizing: border-box;
}
 body {
	 background-color: #000;
	 color: white;
	 font-family: sans-serif;
	 display: flex;
	 flex-direction: column;
	 padding: 10px;
	 margin: 0;
	 user-select: none;
}
 #editor-container {
	 display: flex;
	 gap: 10px;
	 align-items: flex-start;
}
 .canvas-container {
	 position: relative;
}
 canvas {
	 background-color: #4040E0;
	 border: none;
	 cursor: default;
	 image-rendering: pixelated;
}
 #charSelector {
	 cursor: pointer;
	 background-color: #000;
	 display: block;
	 margin: 0 auto;
}
 .sidebar {
	 display: flex;
	 flex-direction: column;
	 gap: 10px;
	 width: 281px;
}
 .toolbar {
	 display: grid;
	 grid-template-columns: repeat(2, 1fr);
	 gap: 5px;
	 width: max-content;
	 align-content: start;
}
 .toolbar button {
	 width: 37px;
	 height: 37px;
	 font-size: 18px;
	 padding: 0;
	 display: flex;
	 align-items: center;
	 justify-content: center;
}
 button:disabled {
	 opacity: 0.3;
	 cursor: not-allowed;
	 background: #aaa;
}
 .palette {
	 display: grid;
	 grid-template-columns: repeat(8, 1fr);
	 gap: 2px;
}
 .color-swatch {
	 height: 25px;
	 border: 2px solid transparent;
	 cursor: pointer;
}
 .color-swatch.selected {
	 border-color: red;
}
 .controls {
	 display: flex;
	 gap: 5px;
}
 button {
	 padding: 6px 12px;
	 background: #2c2d35;
	 border: 1px solid #4a4a5a;
	 border-radius: 4px;
	 cursor: pointer;
	 font-size: 12px;
	 color: #d1d1d1;
	 font-family: sans-serif;
	 transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
 button:hover:not(:disabled) {
	 background: #3e3f4a;
	 border-color: #6a6a7c;
	 color: #ffffff;
}
 button:active:not(:disabled) {
	 background: #1a1b20;
	 border-color: #333;
}
 button:disabled {
	 opacity: 0.3;
	 cursor: not-allowed;
	 background: #111;
	 border-color: #222;
	 color: #555;
}
 button.active-tool {
	 background-color: #813338;
	 border-color: #c46c71;
	 color: white;
	 box-shadow: 0 0 6px rgba(196, 108, 113, 0.4);
}
 .status {
	 font-family: monospace;
	 margin-top: 5px;
	 font-size: 14px;
}
 #romWarning {
	 color: #ffcccc;
	 font-weight: bold;
	 margin-bottom: 10px;
}
 .hints {
	 color: #ffaaaa;
	 margin-top: 5px;
	 font-size: 12px;
	 line-height: 1.4;
	 background: rgba(0,0,0,0.2);
	 padding: 5px;
	 border-radius: 4px;
}
 .typing-indicator {
	 color: #aaffaa;
	 font-weight: bold;
}
 .dark-panel {
	 background-color: rgba(0, 0, 0, 0.65);
	 padding: 8px;
	 border-radius: 6px;
	 margin-bottom: 5px;
	 box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
 .color-targets {
	 display: flex;
	 gap: 5px;
	 margin-bottom: 5px;
}
 .color-target {
	 flex: 1;
	 background: #333;
	 color: white;
	 border: 1px solid #555;
	 border-bottom-width: 4px;
	 font-size: 11px;
	 padding: 4px 0;
	 text-align: center;
}
 .color-target.active-target {
	 background: #666;
	 font-weight: bold;
	 border-top-color: #fff;
	 border-left-color: #fff;
	 border-right-color: #fff;
}
 .frame-bar {
	 display: flex;
	 align-items: center;
	 gap: 6px;
	 margin-bottom: 10px;
}
 .frame-counter {
	 font-family: monospace;
	 font-size: 16px;
	 font-weight: bold;
	 color: #fff;
	 min-width: 50px;
	 text-align: center;
}
 .thumbnail-container {
	 display: flex;
	 gap: 4px;
	 overflow-x: auto;
	 flex: 1;
	 min-width: 68px; /* one full thumbnail: 64px canvas (border-box) + 4px container padding */
	 padding: 2px;
}
 .thumb-canvas {
	 border: 1px solid transparent;
	 cursor: pointer;
	 background-color: #000;
}
 .thumb-canvas.active-thumb {
	 border-color: red;
}
 .panel {
	 background-color: #171717;
	 padding: 5px;
	 border-radius: 4px;
}
 .color-indicator {
	 width: 14px;
	 height: 14px;
	 display: inline-block;
	 border: 1px solid #777;
	 vertical-align: middle;
	 margin-left: 6px;
	 border-radius: 2px;
}
 .color-btn {
	 display: flex;
	 align-items: center;
	 justify-content: center;
	 padding: 0px 8px;
	 height: 34px 
}
 .popup-palette {
	 position: absolute;
	 top: 110px;
	 right: 5px;
	 background: #2a2a35;
	 padding: 6px;
	 border: 1px solid #555;
	 border-radius: 4px;
	 box-shadow: 0 4px 15px rgba(0,0,0,0.8);
	 z-index: 100;
	 display: none;
	 grid-template-columns: repeat(8, 1fr);
	 gap: 2px;
	 width: max-content;
}
 .popup-palette .color-swatch {
	 width: 30px;
}
 a.linkcolor, a.linkcolor:visited, a.linkcolor:hover, a.linkcolor:active {
	 color: #ffffff;
}
 .h1style {
	 margin: 0;
	 font-size: 22px;
	 font-weight: bold;
}
 .tagline {
	font-size: 14px;
	 color: #ddd;
}
 .has-submenu {
	 position: relative;
}
 .has-submenu::after {
	 content: '';
	 position: absolute;
	 bottom: 2px;
	 right: 2px;
	 border-width: 0 0 6px 6px;
	 border-style: solid;
	 border-color: transparent transparent #88ccff transparent;
}
.submenu-active {
	color: #88ff88 !important;
	font-weight: bold !important;
}
.submenu-active::before {
	content: '✓ ';
}
/* --- CRT Effect Overlay --- */
#crt-overlay {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    border-radius: 3px;
}

#crt-overlay.active {
    display: block;
    animation: crt-flicker 0.12s infinite;
}

/* Scanlines */
#crt-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.13) 0px,
        rgba(0, 0, 0, 0.13) 1px,
        transparent 1px,
        transparent 3px
    );
}

/* Vignette */
#crt-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 55%,
        rgba(0, 0, 0, 0.55) 100%
    );
}

@keyframes crt-flicker {
    0%, 100% { opacity: 1.0; }
    47%       { opacity: 0.988; }
    50%       { opacity: 0.982; }
    53%       { opacity: 0.988; }
}

/* --- VHS Effect Overlay --- */
#vhs-canvas {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 6;
    background: transparent;
    width: 100%;
    height: 100%;
}
#vhs-canvas.active {
    display: block;
}

/* Color grade + chroma approximation when VHS is active */
.vhs-active {
    filter: contrast(0.93) saturate(1.03);
}
.vhs-active::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to right, rgba(210, 0, 90, 0.04) 0%, transparent 14%),
        linear-gradient(to left,  rgba(0, 70, 220, 0.04) 0%, transparent 14%),
        rgba(45, 0, 55, 0.04);
    pointer-events: none;
    z-index: 7;
    mix-blend-mode: screen;
}
