/* TurtleNES style sheet
   Deliberately old: table layouts, small pixel fonts, beveled borders,
   flat grey panels. No CSS frameworks, no flexbox-as-a-look, no
   glassmorphism, no rounded corners on functional chrome. */

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 8px;
  background: #3a6ea5 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><rect width="4" height="4" fill="%233a6ea5"/><rect width="2" height="2" fill="%23336394"/><rect x="2" y="2" width="2" height="2" fill="%23336394"/></svg>');
  font-family: Tahoma, "MS Sans Serif", Geneva, Arial, sans-serif;
  font-size: 11px;
  color: #000000;
}

#app-window {
  max-width: 820px;
  margin: 0 auto;
  background: #d4d0c8;
  border: 2px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  box-shadow: 2px 2px 0 #808080;
}

/* Title bar */
.titlebar {
  width: 100%;
  background: linear-gradient(to right, #0a246a, #3a6ea5 60%, #a6caf0);
  color: #ffffff;
  font-weight: bold;
  height: 22px;
}
.titlebar-icon { width: 20px; text-align: center; }
.titlebar-icon img { vertical-align: middle; }
.titlebar-text { padding-left: 2px; font-size: 12px; letter-spacing: 0.2px; }
.titlebar-btns { text-align: right; white-space: nowrap; padding-right: 3px; }
.tbtn {
  display: inline-block;
  width: 18px; height: 16px;
  background: #d4d0c8;
  color: #000;
  border: 1px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  text-align: center;
  font-size: 10px;
  line-height: 16px;
  margin-left: 2px;
  cursor: default;
  font-family: Marlett, Tahoma, sans-serif;
}
.tbtn:active { border-color: #404040 #ffffff #ffffff #404040; }
.tbtn-close:hover { background: #c04040; color: #fff; }

/* Menu bar */
.menubar {
  width: 100%;
  background: #d4d0c8;
  border-bottom: 1px solid #808080;
}
.menu-item {
  padding: 3px 9px;
  cursor: default;
  font-size: 11px;
}
.menu-item:hover, .menu-item.open {
  background: #0a246a;
  color: #ffffff;
}

.dropdown {
  display: none;
  position: absolute;
  background: #d4d0c8;
  border: 1px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  box-shadow: 2px 2px 3px rgba(0,0,0,0.4);
  z-index: 100000;
  min-width: 190px;
  padding: 2px 0;
}
.dropdown.visible { display: block; }
.dropdown-item {
  padding: 3px 10px 3px 22px;
  cursor: default;
  white-space: nowrap;
  position: relative;
  font-size: 11px;
}
.dropdown-item:hover { background: #0a246a; color: #fff; }
.dropdown-item.disabled { color: #888; }
.dropdown-item.disabled:hover { background: none; color: #888; }
.dropdown-sep { border-top: 1px solid #808080; border-bottom: 1px solid #fff; margin: 3px 2px; }
.shortcut { position: absolute; right: 10px; color: #666; font-size: 10px; }
.dropdown-item:hover .shortcut { color: #ddd; }
.dropdown-item.checkbox .chk { position: absolute; left: 6px; }
.dropdown-item.novolume { padding-left: 10px; cursor: default; }

/* Toolbar */
.toolbar {
  width: 100%;
  background: #d4d0c8;
  border-bottom: 1px solid #808080;
  padding: 2px;
}
.toolbar td { padding: 1px; }
.tool-btn {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  background: #d4d0c8;
  border: 1px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  padding: 2px 8px;
  cursor: default;
  min-width: 26px;
}
.tool-btn:active { border-color: #404040 #ffffff #ffffff #404040; }
.toolbar-sep { width: 2px; border-left: 1px solid #808080; border-right: 1px solid #fff; }

/* Viewport */
#viewport-area {
  background: #000000;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px inset #808080;
  margin: 4px;
  padding: 8px;
}
#no-rom-screen {
  text-align: center;
  color: #b8d8f0;
}
#drop-hint {
  font-size: 12px;
  margin: 10px 0;
  color: #a0c4e0;
}
#btn-open-rom-big {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  background: #d4d0c8;
  color: #000;
  border: 1px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  padding: 4px 14px;
  cursor: default;
}
#screen-wrap {
  background: #000;
  padding: 0;
  line-height: 0;
}
#screen {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: #000;
  display: block;
}

/* Status bar */
.statusbar {
  width: 100%;
  border-top: 1px solid #808080;
}
.statusbar td {
  border: 1px inset #808080;
  padding: 2px 6px;
  font-size: 10px;
  color: #202020;
}
#status-rom { width: 45%; }
#status-mapper { width: 15%; }
#status-region { width: 10%; }
#status-fps { width: 15%; }
#status-speed { width: 15%; }

/* Generic dialog windows */
.win-dialog {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #d4d0c8;
  border: 2px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  box-shadow: 3px 3px 6px rgba(0,0,0,0.5);
  z-index: 2000;
  min-width: 300px;
}
.dialog-titlebar {
  width: 100%;
  background: linear-gradient(to right, #0a246a, #3a6ea5 60%, #a6caf0);
  color: #fff;
  font-weight: bold;
  height: 20px;
}
.dialog-title { padding-left: 5px; font-size: 11px; }
.dialog-close {
  width: 18px;
  text-align: center;
  background: #d4d0c8;
  color: #000;
  border: 1px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  cursor: default;
  margin-right: 2px;
  font-size: 10px;
}
.dialog-body { padding: 10px; font-size: 11px; }
.dialog-buttons { text-align: right; margin-top: 10px; }
.dialog-buttons button, .mem-controls button, #dbg-step, #dbg-run, #dbg-break, #dbg-reset {
  font-family: Tahoma, sans-serif;
  font-size: 11px;
  background: #d4d0c8;
  border: 1px solid #ffffff;
  border-right-color: #404040;
  border-bottom-color: #404040;
  padding: 3px 12px;
  margin-left: 6px;
  cursor: default;
}

.info-table { border-collapse: collapse; }
.info-table td { padding: 2px 6px; font-size: 11px; }
.info-label { font-weight: bold; text-align: right; width: 100px; }

.about-body { display: flex; gap: 12px; align-items: flex-start; }
.about-body p { margin: 3px 0; }

.error-body { display: flex; align-items: center; gap: 10px; }
.error-icon {
  width: 28px; height: 28px;
  background: #ffcc00;
  border: 2px solid #806000;
  border-radius: 50%;
  text-align: center;
  line-height: 26px;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}
#error-message { font-family: Tahoma, sans-serif; font-size: 11px; white-space: pre-wrap; margin: 0; }

.input-hint { font-size: 10px; color: #444; margin-top: 8px; }

/* Debugger */
.debugger-dialog { min-width: 560px; }
.debugger-layout { width: 100%; }
.debugger-disasm {
  width: 60%;
  vertical-align: top;
  border: 1px inset #808080;
  background: #fff;
  padding: 4px;
}
.debugger-regs { width: 40%; vertical-align: top; padding-left: 8px; }
.panel-label { font-weight: bold; font-size: 10px; margin: 4px 0 2px 0; color: #000; }
.disasm-list {
  font-family: "Courier New", monospace;
  font-size: 11px;
  height: 220px;
  overflow-y: auto;
  white-space: pre;
}
.disasm-line { padding: 1px 3px; }
.disasm-line.current { background: #000080; color: #fff; }
.reg-table { border-collapse: collapse; font-family: "Courier New", monospace; font-size: 11px; margin-bottom: 6px; }
.reg-table td { border: 1px solid #a0a0a0; padding: 1px 6px; background: #fff; }
.reg-table td:first-child { background: #e8e4dc; font-family: Tahoma, sans-serif; }
.flags-row { font-family: "Courier New", monospace; font-size: 11px; margin-bottom: 6px; }
.flag-chip {
  display: inline-block; width: 16px; text-align: center;
  border: 1px solid #a0a0a0; margin-right: 1px; background: #fff;
}
.flag-chip.set { background: #000080; color: #fff; }
.debugger-toolbar { width: 100%; margin-top: 8px; }
.debugger-toolbar td { padding-right: 4px; }
.dbg-cycles { font-family: "Courier New", monospace; font-size: 11px; padding-left: 10px; }

/* Memory viewer */
.mem-controls { margin-bottom: 6px; font-size: 11px; }
.mem-controls input { font-family: "Courier New", monospace; }
.mem-view {
  font-family: "Courier New", monospace;
  font-size: 11px;
  background: #fff;
  border: 1px inset #808080;
  padding: 4px;
  margin: 0;
  width: 480px;
  height: 260px;
  overflow-y: auto;
}

#pt-canvas-0, #pt-canvas-1, #nt-canvas {
  image-rendering: pixelated;
  border: 1px inset #808080;
  background: #000;
}
#pt-palette-select { margin-top: 6px; }
.pal-swatch {
  display: inline-block;
  width: 18px; height: 18px;
  border: 1px solid #404040;
  margin-right: 2px;
  cursor: default;
}
.pal-swatch.selected { outline: 2px solid #ff0000; }

/* ---- v1.1 additions ---- */

.dropdown-item.has-sub .arrow { position: absolute; right: 8px; }
.dropdown-item .chk {
  position: absolute; left: 7px; top: 50%;
  width: 8px; height: 8px; margin-top: -5px;
}
.dropdown-item.check .chk.on::before {
  content: ""; position: absolute; left: 1px; top: -1px;
  width: 3px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(40deg);
}
.dropdown-item.radio .chk.on::before {
  content: ""; position: absolute; left: 1px; top: 1px;
  width: 6px; height: 6px; background: currentColor; border-radius: 50%;
}
.dropdown-item.recent-item { padding-right: 14px; }
.recent-meta { color: #666; font-size: 10px; margin-left: 10px; }
.dropdown-item:hover .recent-meta { color: #ddd; }

#screen-wrap { position: relative; }
#screen-stage { position: relative; line-height: 0; background: #000; }
#screen-stage canvas { width: 100%; height: 100%; display: block; background: #000; }
#screen-stage[data-filter="nearest"] canvas,
#screen-stage[data-filter="scanlines"] canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
#screen-stage[data-filter="linear"] canvas { image-rendering: auto; }
#screen-stage[data-filter="crt"] canvas {
  image-rendering: auto;
  filter: contrast(1.08) saturate(1.15) brightness(1.04);
}
#screen-fx { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; display: none; }
#screen-stage[data-filter="scanlines"] #screen-fx,
#screen-stage[data-filter="crt"] #screen-fx {
  display: block;
  background-image: linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 55%, rgba(0,0,0,0.30) 55%, rgba(0,0,0,0.30) 100%);
  background-size: 100% var(--row, 3px);
}
#screen-stage[data-filter="crt"] #screen-fx {
  background-image:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 62%, rgba(0,0,0,0.38) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 60%, rgba(0,0,0,0.22) 60%, rgba(0,0,0,0.22) 100%);
  background-size: 100% 100%, 100% var(--row, 3px);
}

#screen-toast {
  position: absolute; left: 6px; top: 6px;
  background: #ffffe1; color: #000; border: 1px solid #000;
  font-size: 11px; padding: 2px 6px; display: none; line-height: normal;
  pointer-events: none;
}

#screen-wrap:fullscreen, #screen-wrap:-webkit-full-screen {
  width: 100vw; height: 100vh; background: #000;
  display: flex; align-items: center; justify-content: center;
}

#status-msg {
  border: 1px inset #808080; margin: 0 0 2px 0; padding: 2px 6px;
  font-size: 10px; min-height: 16px; color: #000080;
}
.statusbar td { white-space: nowrap; }
#status-rom { width: auto; }
#status-mapper, #status-region, #status-fps, #status-speed, #status-audio, #status-state { width: 1%; }

.info-icon {
  width: 28px; height: 28px; background: #3a6ea5; border: 2px solid #0a246a; color: #fff;
  border-radius: 50%; text-align: center; line-height: 26px; font-weight: bold;
  font-family: "Times New Roman", serif; font-size: 16px; flex-shrink: 0;
}
#msg-text { font-family: Tahoma, sans-serif; font-size: 11px; white-space: pre-wrap; margin: 0; max-width: 340px; }
.help-text { font-size: 10px; color: #333; max-width: 360px; margin: 6px 0; }
.group-box { border: 2px groove #ffffff; margin: 0 0 6px 0; padding: 6px 10px; }
.group-box legend { padding: 0 4px; }
.radio-line { display: block; margin: 3px 0; }

.tab-row { margin-bottom: 6px; }
.tab-btn {
  font-family: Tahoma, sans-serif; font-size: 11px; background: #d4d0c8;
  border: 1px solid #ffffff; border-right-color: #404040; border-bottom-color: #404040;
  padding: 3px 12px; margin-right: 2px; cursor: default;
}
.tab-btn.active { border-color: #404040 #ffffff #ffffff #404040; font-weight: bold; }
#input-config-table button {
  font-family: Tahoma, sans-serif; font-size: 11px; background: #d4d0c8;
  border: 1px solid #ffffff; border-right-color: #404040; border-bottom-color: #404040;
  padding: 2px 10px; min-width: 130px; text-align: left; cursor: default;
}
#input-config-table button.waiting { background: #ffffe1; border-color: #404040 #ffffff #ffffff #404040; }
#input-config-table td.bound-keys { min-width: 170px; }

.cheat-list { border: 1px inset #808080; background: #fff; height: 120px; overflow-y: auto; margin-bottom: 6px; min-width: 430px; }
.cheat-row { padding: 2px 4px; border-bottom: 1px solid #e8e4dc; font-size: 11px; }
.cheat-row.off { color: #808080; }
.cheat-row code { font-family: "Courier New", monospace; margin: 0 8px; }
.cheat-row button { font-size: 10px; margin-left: 6px; float: right; }
.cheat-empty { color: #808080; padding: 6px; }
#cheat-error { color: #a00000; min-height: 12px; }
#cheat-add, #rewind-run, #cpu-apply, #speed-apply, #msg-ok, #input-defaults, .cheat-row button {
  font-family: Tahoma, sans-serif; font-size: 11px; background: #d4d0c8;
  border: 1px solid #ffffff; border-right-color: #404040; border-bottom-color: #404040;
  padding: 2px 10px; cursor: default;
}

/* Input display */
#pads-holder { display: flex; gap: 14px; }
.pad-box { border: 2px groove #ffffff; padding: 4px 6px 6px 6px; background: #c0bcb4; }
.pad-title { font-weight: bold; font-size: 10px; margin-bottom: 4px; }
.pad-grid { display: grid; grid-template-columns: repeat(3, 34px) 16px repeat(2, 38px) 10px repeat(2, 34px); grid-auto-rows: 26px; gap: 2px; align-items: stretch; }
.pad-btn {
  background: #d4d0c8; border: 1px solid #ffffff; border-right-color: #404040; border-bottom-color: #404040;
  font-size: 9px; text-align: center; line-height: 12px; padding-top: 2px; color: #000; overflow: hidden;
}
.pad-btn small { display: block; font-size: 8px; color: #555; line-height: 8px; }
.pad-btn.down { background: #000080; color: #fff; border-color: #404040 #ffffff #ffffff #404040; }
.pad-btn.down small { color: #c8d8ff; }
.pad-gap { visibility: hidden; }
