:root {
  --bg: #0b0b0d;
  --chrome: #16161a;
  --line: #2a2a30;
  --text: #9a9aa4;
  --hi: #d8d8e0;
  --accent: #55ffff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  overflow: hidden;
}

#bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
#bar .spacer { flex: 1; }
#status { color: var(--hi); letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leds { display: inline-flex; gap: 4px; }

.led {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #333;
  box-shadow: inset 0 0 2px #000;
  flex: none;
}
.led.small { width: 6px; height: 6px; }
.led.on { background: #3f3; box-shadow: 0 0 6px #3f3; }
.led.wait { background: #fa0; box-shadow: 0 0 6px #fa0; }
.led.err { background: #f33; box-shadow: 0 0 6px #f33; }
.led.small.on { background: #f55; box-shadow: 0 0 4px #f55; }

button, select, input {
  font: inherit;
  color: var(--hi);
  background: #222228;
  border: 1px solid var(--line);
  border-radius: 3px;
}
button { padding: 2px 10px; cursor: pointer; }
button:hover { border-color: #555; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 1px solid var(--accent); }

#stage {
  position: absolute;
  inset: 32px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen {
  position: relative;
  background: #000;
  outline: none;
  touch-action: none;
  cursor: text;
}
#screen canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#screen canvas[hidden] { display: none; }
#term { image-rendering: pixelated; image-rendering: crisp-edges; }

/* Invisible input that receives keystrokes and raises the soft keyboard. */
#kbd {
  position: absolute;
  left: 0; top: 0;
  width: 1px; height: 1px;
  opacity: 0;
  resize: none;
  border: 0;
  padding: 0;
  pointer-events: none;
  font-size: 16px;
}

#carrier {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
}
#carrier[hidden] { display: none; }
#carrier .box {
  text-align: center;
  background: #0000aa;
  color: #fff;
  border: 3px double #aaa;
  padding: 12px 28px 16px;
}
#carrier p { margin: 0 0 10px; font-size: 20px; letter-spacing: 0.2em; }
#carrier button { background: #aaa; color: #000; border: 0; border-radius: 0; padding: 3px 14px; }

#toast {
  position: absolute;
  bottom: 8px; right: 8px;
  background: #aaa; color: #000;
  padding: 2px 8px;
}

#panel {
  position: absolute;
  top: 32px; right: 0; bottom: 0;
  width: 260px;
  max-width: 100%;
  padding: 8px 14px 14px;
  overflow-y: auto;
  background: rgba(22, 22, 26, 0.96);
  border-left: 1px solid var(--line);
  z-index: 2;
}
#panel h2, #panel h3 { color: var(--hi); font-size: 13px; font-weight: normal; letter-spacing: 0.1em; text-transform: uppercase; margin: 12px 0 6px; }
#panel h2 { margin-top: 4px; }
#panel label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 5px 0; }
#panel label.check { justify-content: flex-start; }
#panel .slider { display: block; }
#panel .slider span { display: flex; justify-content: space-between; }
#panel input[type=range] { width: 100%; accent-color: var(--accent); }
#panel .about { font-size: 11px; line-height: 1.5; }
#panel a { color: var(--accent); }
#crtopts.disabled { opacity: 0.4; pointer-events: none; }

#credit {
  position: absolute;
  right: 8px; bottom: 2px;
  font-size: 10px;
  color: #444;
  pointer-events: none;
}

/* Extra keys for touch screens: Esc, Tab, Ctrl, arrows, function keys. */
body.keys #stage { bottom: var(--kb-h); }
body.keys #credit { display: none; }
#keybar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--kb-h);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--chrome);
  border-top: 1px solid var(--line);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#keybar[hidden] { display: none; }
body { --kb-h: 84px; }
#keybar button {
  min-width: 0;
  padding: 0;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
#keybar button:active, #keybar button.down { background: #3a3a44; }
#keybar button.latched { color: #000; background: var(--accent); border-color: var(--accent); }

@media (max-width: 500px) {
  #credit { display: none; }
}

/* Portrait phones: keep the screen above the soft keyboard. */
@media (orientation: portrait) and (max-width: 900px) {
  #stage { align-items: flex-start; padding-top: 8px; }
}
