:root {
  color-scheme: dark;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: #161616;
  color: #ededed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, #202020 0%, #111 48%, #252525 100%);
}

button {
  font: inherit;
}

input,
select {
  font: inherit;
}

.c64-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  gap: 24px;
  padding: 24px;
  align-items: stretch;
}

.screen-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
}

#screen {
  width: min(100%, calc((100vh - 48px) * 1.6));
  aspect-ratio: 1.6;
  image-rendering: pixelated;
  border: 18px solid #8d8d8d;
  border-radius: 8px;
  outline: 4px solid #3d3d3d;
  background: #40318d;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  background: #242424;
  border-left: 1px solid #4d4d4d;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4343;
  box-shadow: 0 0 14px #ef4343;
}

.controls button,
.file-actions button,
.bind-button {
  min-height: 42px;
  border: 1px solid #737373;
  border-radius: 6px;
  color: #f7f7f7;
  background: #3a3a3a;
  cursor: pointer;
}

.controls button:hover,
.file-actions button:hover,
.bind-button:hover {
  background: #464646;
}

.config-panel {
  display: grid;
  gap: 8px;
}

.config-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #e5e5e5;
  font-weight: 700;
}

.accordion-block {
  border: 1px solid #555;
  border-radius: 6px;
  background: #1c1c1c;
  overflow: hidden;
}

.accordion-block summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: #f1f1f1;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.accordion-block summary::-webkit-details-marker {
  display: none;
}

.accordion-block summary::after {
  content: "+";
  color: #a7f0c0;
  font-family: Consolas, "Courier New", monospace;
}

.accordion-block[open] summary {
  border-bottom: 1px solid #444;
}

.accordion-block[open] summary::after {
  content: "-";
}

.accordion-content {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.controls.accordion-content,
.file-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.controls #soundButton {
  grid-column: 1 / -1;
}

#cpuSpeedValue {
  color: #a7f0c0;
  font-family: Consolas, "Courier New", monospace;
}

#cpuSpeedSlider {
  width: 100%;
  accent-color: #75cec8;
}

#joystickPortSelect {
  min-height: 34px;
  border: 1px solid #666;
  border-radius: 6px;
  color: #f7f7f7;
  background: #2d2d2d;
}

.file-actions {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.drive-load-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #4f4f4f;
  border-radius: 8px;
  background: #151515;
}

.drive-load-mode-text {
  display: grid;
  gap: 3px;
}

.drive-load-mode-title {
  color: #d4d4d4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.drive-load-mode-value {
  color: #a7f0c0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.switch-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 58px;
  height: 30px;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border: 1px solid #737373;
  border-radius: 999px;
  background: #303030;
  transition: background 140ms ease, border-color 140ms ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ededed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 140ms ease;
}

.switch-toggle input:checked + .switch-slider {
  border-color: #a7f0c0;
  background: #2e5940;
}

.switch-toggle input:checked + .switch-slider::before {
  transform: translateX(28px);
}

.switch-toggle input:focus-visible + .switch-slider {
  outline: 2px solid #75cec8;
  outline-offset: 3px;
}

.hidden-file {
  display: none;
}

.ai-prompt {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 8px;
  color: #f7f7f7;
  background: #111;
}

.ai-target-label {
  color: #d8d8d8;
  font-size: 12px;
}

.ai-target {
  width: 100%;
  min-height: 36px;
  border: 1px solid #666;
  border-radius: 6px;
  padding: 6px 8px;
  color: #f7f7f7;
  background: #111;
}

.ai-output {
  min-height: 56px;
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border: 1px solid #444;
  border-radius: 6px;
  color: #a7f0c0;
  background: #101010;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.ai-run-button {
  min-height: 42px;
  border: 1px solid #737373;
  border-radius: 6px;
  color: #f7f7f7;
  background: #3a3a3a;
  cursor: pointer;
}

.ai-run-button:hover {
  background: #464646;
}

.joystick-bindings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bind-button {
  min-height: 36px;
  text-align: left;
  padding: 0 10px;
  font-size: 13px;
}

.bind-button[data-joy-action="fire"] {
  grid-column: 1 / -1;
}

.bind-button.is-listening {
  border-color: #a7f0c0;
  color: #a7f0c0;
}

.input-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d4d4d4;
}

.input-toggle input {
  accent-color: #75cec8;
}

.rom-note {
  margin: 0;
  color: #d4d4d4;
  line-height: 1.4;
}

.machine-status {
  min-height: 28px;
  margin: 0;
  color: #a7f0c0;
  font-family: Consolas, "Courier New", monospace;
}

.machine-status-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.fps-status {
    white-space: nowrap;
    opacity: 0.85;
    font-variant-numeric: tabular-nums;
}


@media (max-width: 900px) {
  .c64-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .side-panel {
    min-height: 420px;
    border-left: 0;
    border-top: 1px solid #4d4d4d;
  }
}
