:root {
  --bg: #060906;
  --panel: #0a0e0a;
  --phosphor: #33ff66;
  --amber: #ffb000;
  --green-dim: #1f6b3a;
  --border: #143a20;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

#root { height: 100%; }

.crt-root {
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(51,255,102,0.06), transparent 60%),
    linear-gradient(180deg, #060906 0%, #040604 100%);
  color: var(--phosphor);
}

/* ---- header ---- */
.c4-header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0c130c, #070a07);
  text-shadow: 0 0 6px rgba(51,255,102,0.4);
}

.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { opacity: 0; } }

/* ---- controls ---- */
.c4-controls {
  border-bottom: 1px solid var(--border);
  background: #080b08;
}

.c4-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #0d160d;
  color: var(--phosphor);
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.12s ease;
  text-shadow: 0 0 4px rgba(51,255,102,0.3);
}
.c4-btn:hover {
  background: #123018;
  box-shadow: 0 0 10px rgba(51,255,102,0.35);
  transform: translateY(-1px);
}
.c4-btn:active { transform: translateY(0); }
.c4-btn.run { border-color: #2fae5a; color: #7dff9e; }
.c4-btn.compile { border-color: #a77a1a; color: var(--amber); }
.c4-btn.clear:hover, .c4-btn.reset:hover { box-shadow: 0 0 10px rgba(255,176,0,0.25); }

.c4-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--green-dim);
  cursor: pointer;
  user-select: none;
}
.c4-check input { accent-color: var(--phosphor); }

.c4-select {
  font-family: inherit;
  font-size: 11px;
  background: #0d160d;
  color: var(--phosphor);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
}

/* ---- file explorer ---- */
.c4-explorer {
  width: 190px;
  min-width: 150px;
  border-right: 1px solid var(--border);
  background: #060c07;
}
.c4-explorer-head {
  padding: 7px 10px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--green-dim);
  border-bottom: 1px solid var(--border);
  text-shadow: 0 0 4px rgba(51,255,102,0.25);
}
.c4-newfile {
  font-family: inherit;
  background: #0d160d;
  color: var(--phosphor);
  border: 1px solid var(--border);
  border-radius: 3px;
  width: 20px; height: 20px;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
}
.c4-newfile:hover { background: #123018; box-shadow: 0 0 8px rgba(51,255,102,0.3); }
.c4-filelist { overflow-y: auto; padding: 4px 0; }
.c4-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: #8ad6a2;
  cursor: pointer;
  border-left: 2px solid transparent;
  white-space: nowrap;
}
.c4-file:hover { background: #0c160d; }
.c4-file.active {
  background: #0f1e12;
  border-left-color: var(--phosphor);
  color: var(--phosphor);
  text-shadow: 0 0 5px rgba(51,255,102,0.4);
}
.c4-file.header { color: #c79a3a; }
.c4-file.header.active { color: var(--amber); border-left-color: var(--amber); }
.c4-file-icon { opacity: 0.7; font-size: 11px; }
.c4-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.c4-file-del {
  background: none; border: none; color: #5a4a2a;
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px;
  opacity: 0; transition: opacity 0.1s;
}
.c4-file:hover .c4-file-del { opacity: 1; }
.c4-file-del:hover { color: #ff6b6b; }
.c4-explorer-foot {
  padding: 6px 10px;
  font-size: 9px;
  color: #2c5c3d;
  border-top: 1px solid var(--border);
  letter-spacing: 0.5px;
}

/* ---- tab bar ---- */
.c4-tabbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: #070d08;
  border-bottom: 1px solid var(--border);
  min-height: 28px;
}
.c4-tab {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px 3px 0 0;
  color: var(--phosphor);
}
.c4-tab.active {
  background: #0f1e12;
  border: 1px solid var(--border);
  border-bottom: none;
  text-shadow: 0 0 4px rgba(51,255,102,0.3);
}
.c4-tab-hint {
  font-size: 10px;
  color: #2c5c3d;
  font-style: italic;
  margin-left: auto;
}

/* ---- editor ---- */
.c4-editor-wrap {
  border-right: 1px solid var(--border);
  min-height: 220px;
  background: #08120a;
}

.c4-gutter {
  margin: 0;
  padding: 12px 8px 12px 12px;
  text-align: right;
  color: #1a4a2b;
  font-size: 13px;
  line-height: 1.5;
  user-select: none;
  overflow: hidden;
  background: #060c07;
  border-right: 1px solid var(--border);
  min-width: 42px;
  white-space: pre;
}

.c4-editor {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: #b7ffca;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  caret-color: var(--phosphor);
  text-shadow: 0 0 3px rgba(51,255,102,0.25);
  tab-size: 2;
}
.c4-editor::selection { background: #1f6b3a; }

/* ---- console ---- */
.c4-console-wrap {
  min-height: 220px;
  background: #030503;
}

.c4-console {
  padding: 12px;
  font-size: 13px;
  line-height: 1.45;
  overflow-y: auto;
  text-shadow: 0 0 5px rgba(51,255,102,0.35);
}

.scanlines {
  position: relative;
}
.scanlines::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0) 4px
  );
  z-index: 5;
}

.c4-statusbar {
  border-top: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--amber);
  background: #070a07;
  text-shadow: 0 0 4px rgba(255,176,0,0.3);
}

/* ---- footer ---- */
.c4-footer {
  border-top: 1px solid var(--border);
  background: #060906;
}

/* scrollbars */
.c4-console::-webkit-scrollbar, .c4-editor::-webkit-scrollbar { width: 10px; }
.c4-console::-webkit-scrollbar-thumb, .c4-editor::-webkit-scrollbar-thumb {
  background: #143a20; border-radius: 5px;
}
.c4-console::-webkit-scrollbar-track, .c4-editor::-webkit-scrollbar-track { background: #060906; }

/* subtle CRT flicker */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.985; }
}
.crt-root { animation: flicker 6s infinite; }

@media (max-width: 767px) {
  .c4-editor-wrap { border-right: none; border-bottom: 1px solid var(--border); }
  .c4-header span { text-shadow: none; }
  .c4-explorer {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .c4-filelist { display: flex; overflow-x: auto; overflow-y: hidden; padding: 4px; }
  .c4-file { border-left: none; border-bottom: 2px solid transparent; }
  .c4-file.active { border-left: none; border-bottom-color: var(--phosphor); }
  .c4-file.header.active { border-bottom-color: var(--amber); }
  .c4-explorer-foot { display: none; }
  .c4-tab-hint { display: none; }
}
