:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101411;
  color: #eef4e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #101411;
}

button {
  border: 1px solid #6f7f6f;
  border-radius: 6px;
  background: #eef4e8;
  color: #111411;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

select {
  width: 100%;
  border: 1px solid #6f7f6f;
  border-radius: 6px;
  background: #0f150f;
  color: #eef4e8;
  padding: 0.45rem 0.55rem;
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 6.25rem 1rem clamp(0.75rem, 2vw, 1.5rem);
  background: #263226;
  border-bottom: 1px solid #3e4b3e;
}

.github-corner {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
}

.github-corner svg {
  fill: #7cff82;
  color: #101411;
}

.github-corner:hover .octo-arm {
  animation: octocat-wave 560ms ease-in-out;
}

@keyframes octocat-wave {
  0%, 100% { transform: rotate(0); }
  20%, 60% { transform: rotate(-25deg); }
  40%, 80% { transform: rotate(10deg); }
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: #afd39f;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.demo-subtitle {
  margin: 0.35rem 0 0;
  color: #dcebd7;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 700;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0;
}

p { line-height: 1.45; }

.status-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-weight: 700;
}

.status-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: #7cff82;
  box-shadow: 0 0 14px #7cff82;
}

.status-dot.bad {
  background: #ff6b4a;
  box-shadow: 0 0 14px #ff6b4a;
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(330px, 0.8fr) minmax(360px, 1.05fr);
  gap: 0.75rem;
  padding: 0.75rem;
  align-items: start;
}

.panel {
  border: 1px solid #3e4b3e;
  border-radius: 8px;
  background: #182018;
  padding: 0.75rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  color: #dcebd7;
}

.panel-head span {
  color: #afd39f;
  font-size: 0.84rem;
  white-space: nowrap;
}

.joystick {
  width: 170px;
  height: 170px;
  display: block;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
}

.joystick rect {
  fill: #0c120c;
  stroke: #83947e;
  stroke-width: 2;
}

.joystick line {
  stroke: #394639;
  stroke-width: 1;
}

.handle {
  fill: #f5d04c;
  stroke: #fff5c4;
  stroke-width: 3;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.readouts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.demo-select {
  margin-bottom: 0.65rem;
}

.logo-demo-note {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.logo-demo-note span {
  border: 1px solid #384638;
  border-radius: 5px;
  background: #0f150f;
  padding: 0.42rem 0.45rem;
}

.source-editor {
  display: grid;
  gap: 0.5rem;
}

.source-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.asm-source {
  width: 100%;
  min-height: 18rem;
  resize: vertical;
  border: 1px solid #384638;
  border-radius: 6px;
  background: #0f150f;
  color: #eef4e8;
  padding: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}

.readouts span,
.control-registers dd,
.register-grid dd,
.register-summary span {
  border: 1px solid #384638;
  border-radius: 5px;
  background: #0f150f;
}

.readouts span {
  padding: 0.42rem 0.25rem;
  text-align: center;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.scope-panel {
  margin-top: 0.55rem;
  border: 1px solid #1f3b1f;
  border-radius: 6px;
  background: #000;
  padding: 0.45rem;
}

.scope-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  color: #afd39f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
}

.scope {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 1px solid #143014;
}

.scope-grid-line {
  stroke: #102610;
  stroke-width: 1;
}

.scope text {
  fill: #8fff8f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
}

.scope-trace {
  fill: none;
  stroke: #39ff14;
  stroke-width: 2;
  stroke-linejoin: miter;
  stroke-linecap: square;
  filter: drop-shadow(0 0 4px rgba(57, 255, 20, 0.85));
}

.x-trace {
  stroke: #39ff14;
}

.y-trace {
  stroke: #39ff14;
}

.tape-trace {
  stroke: #39ff14;
}

.monitor-panel { overflow-x: auto; }

.monitor-bezel {
  display: inline-block;
  padding: 0.65rem;
  border-radius: 8px;
  background: #080908;
  border: 1px solid #4e5a4d;
}

.screen-grid {
  display: grid;
  gap: 1px;
  background: #030303;
  padding: 6px;
  border: 1px solid #171717;
}

.pixel {
  width: 4px;
  height: 16px;
  background: #000;
}

.pixel.on {
  background: #d8d8d8;
  box-shadow: 0 0 3px rgba(216, 216, 216, 0.65);
}

.pixel.on.ball {
  background: #f2f2f2;
  box-shadow: 0 0 8px rgba(242, 242, 242, 0.95);
}

.note {
  margin: 0.55rem 0 0;
  color: #c7d7bf;
  font-size: 0.84rem;
}

.register-panel {
  margin-top: 0.65rem;
  min-width: 0;
}

.register-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.register-summary span {
  min-width: 0;
  padding: 0.28rem 0.35rem;
  overflow-wrap: anywhere;
}

.control-registers,
.register-grid {
  display: grid;
  gap: 0.28rem 0.35rem;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.control-registers {
  grid-template-columns: repeat(2, max-content minmax(0, 1fr));
  margin-bottom: 0.45rem;
}

.register-grid {
  grid-template-columns: repeat(2, max-content minmax(0, 1fr));
}

.control-registers dt,
.register-grid dt {
  color: #afd39f;
  padding-top: 0.22rem;
}

.control-registers dd,
.register-grid dd {
  margin: 0;
  min-width: 0;
  padding: 0.22rem 0.3rem;
  overflow-wrap: anywhere;
  color: #f5f5f5;
}

.control-registers dd.changed-recent,
.register-grid dd.changed-recent {
  color: #fff5f2;
  background: #7d1f1a;
  border-color: #d73a31;
}

.control-registers dd.changed-older,
.register-grid dd.changed-older {
  color: #edf4ff;
  background: #173765;
  border-color: #255fbd;
}

.control-registers dd.changed-stable,
.register-grid dd.changed-stable {
  color: #f5f5f5;
}

.listing-panel {
  min-width: 0;
}

.listing {
  display: grid;
  max-height: calc(100vh - 8.5rem);
  overflow: auto;
  margin: 0;
  padding: 0.55rem;
  border: 1px solid #334133;
  border-radius: 6px;
  background: #0d120d;
  color: #dbe8d5;
  font-size: 0.72rem;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.listing span {
  min-height: 1rem;
  white-space: pre;
  padding: 0 0.2rem;
}

.current-line {
  background: #d73a31;
  color: #fff5f2;
}

.previous-line {
  background: #255fbd;
  color: #edf4ff;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  padding: 0.8rem 1rem 1rem;
  color: #afd39f;
  font-size: 0.82rem;
}

.site-footer a {
  color: #eef4e8;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-sep {
  color: #6f7f6f;
}

@media (max-width: 1100px) {
  .demo-grid {
    grid-template-columns: minmax(300px, 0.8fr) 1fr;
  }

  .listing-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    padding-right: 5.5rem;
  }

  .demo-grid {
    grid-template-columns: 1fr;
  }

  .joystick {
    width: min(170px, 75vw);
    height: min(170px, 75vw);
  }
}
