html, body {
  margin: 0;
  padding: 0;
  background-color: #000;
  font-family: 'Courier';
  color: #FFF;
  font-size: 8pt;
  line-height: 10pt;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-x: auto;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  font-size: 13pt;
  width: 100%;
  box-sizing: border-box;
  max-width: 680px;
}

#controls-toggle {
  cursor: pointer;
  font-size: 12pt;
  color: #aaa;
  list-style: none;
  padding: 6px 10px;
  border: 1px solid #444;
  border-radius: 4px;
  display: inline-block;
  user-select: none;
}

#controls-toggle::-webkit-details-marker { display: none; }

#controls[open] #controls-toggle {
  color: #fff;
  border-color: #888;
  margin-bottom: 8px;
}

.ctrl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}

#controls button {
  cursor: pointer;
  font-size: 13pt;
  padding: 8px 16px;
  min-height: 40px;
}

#controls select {
  font-size: 13pt;
  padding: 4px 8px;
  min-height: 40px;
}

#controls input[type="text"] {
  font-size: 13pt;
  padding: 4px 6px;
  width: 60px;
  min-height: 40px;
}

#controls input[type="range"] {
  width: 160px;
  height: 8px;
  accent-color: #fff;
  cursor: pointer;
}

#controls input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: #fff;
}

#controls input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 2px;
  border: 1px solid #555;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

#camera-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 10px 0;
}

#capture-btn,
#flip-btn {
  font-size: 28pt;
  cursor: pointer;
  margin: 0;
  padding: 10px 18px;
  background-color: #515151;
  border: 3px solid rgb(150, 150, 150);
  border-radius: 6px;
  line-height: 1;
  min-width: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* ── Mobile layout ── */
@media (max-width: 540px) {
  #controls {
    font-size: 11pt;
    gap: 8px;
    padding: 10px 12px;
  }

  #controls select,
  #controls button {
    font-size: 11pt;
    min-height: 36px;
  }

  #controls input[type="range"] {
    width: 120px;
  }

  .ctrl-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .ctrl {
    white-space: normal;
    width: 100%;
  }

  .ctrl select {
    flex: 1;
    min-width: 0;
  }
}

canvas {
  display: block;
}

#ascii-window {
  position: relative;
  display: inline-block;
  margin: 16px 0 0;
  border: 2px solid #444;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  box-shadow: 0 0 24px rgba(255,255,255,0.07), 0 4px 32px rgba(0,0,0,0.7);
  transition: border-color 0.2s;
}

#ascii-window:hover {
  border-color: #888;
}

/* Fullscreen state — browser handles positioning; we just clean up styling */
#ascii-window.is-fullscreen,
#ascii-window:fullscreen {
  margin: 0;
  border: none;
  border-radius: 0;
  overflow: auto;
  cursor: default;
  box-shadow: none;
}

/* Overlay camera/flip buttons — hidden normally, shown in fullscreen */
#ascii-overlay-controls {
  display: none;
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: row;
  gap: 10px;
  z-index: 11;
}

#ascii-overlay-controls button {
  font-size: 18pt;
  padding: 6px 14px;
  background: rgba(60, 60, 60, 0.85);
  border: 2px solid rgb(150, 150, 150);
  border-radius: 6px;
  cursor: pointer;
  color: #fff;
  min-width: 50px;
  min-height: 50px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#ascii-window.is-fullscreen #ascii-overlay-controls,
#ascii-window:fullscreen #ascii-overlay-controls {
  display: flex;
}

#ascii-fullscreen-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
  background: rgba(0,0,0,0.6);
  color: #ccc;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 14pt;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: auto;
}

#ascii-window:hover #ascii-fullscreen-btn,
#ascii-window.is-fullscreen #ascii-fullscreen-btn {
  opacity: 1;
}

table {
  color: #FF0011;
  table-layout: fixed;
  /*width: 2400px;*/
  /*border: 1px solid red;*/
}
tr {
  height: 8px;
  width: 8px;
  white-space: nowrap;
  overflow: hidden;
  /*border: 1px solid blue;*/
  /*text-overflow: ellipsis;*/
}

td {
  height: 8px;
  width: 8px;
  white-space: nowrap;
  overflow: hidden;
  /*border: 1px solid blue;*/
  /*text-overflow: ellipsis;*/
}

/* ── Debug panel ── */
#debug-panel {
  font-family: 'Lucida Console', monospace;
  font-size: 10pt;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 10px 16px;
  margin: 8px 0;
  width: 100%;
  max-width: 680px;
  box-sizing: border-box;
}

#debug-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: auto;
}

#debug-table tr {
  height: auto;
  width: auto;
}

#debug-table td {
  height: auto;
  width: auto;
  padding: 2px 10px 2px 0;
  white-space: nowrap;
  overflow: visible;
  color: inherit;
}

#debug-table td:first-child {
  color: #555;
  width: 1%;
}

#debug-table td:nth-child(2) {
  color: #0f0;
  text-align: right;
  padding-right: 4px;
  font-weight: bold;
  min-width: 56px;
}

#debug-table td:nth-child(3) {
  color: #444;
  font-size: 8pt;
}