body {
  font-family: monospace, monospace;
  background: #f5f5f5;
  padding: 10px;
  text-align: center;
}
#controlsForm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}
label {
  font-weight: 600;
  margin-right: 5px;
}
input[type="number"] {
  width: 80px;
  padding: 4px 6px;
  font-size: 1em;
  border-radius: 4px;
  border: 1px solid #ccc;
  text-align: right;
  transition: border-color 0.3s ease;
}
input[type="number"]:focus {
  border-color: #0288d1;
  outline: none;
  box-shadow: 0 0 5px rgba(2,136,209,0.5);
}
input[type="number"].invalid {
  border-color: red;
}
#generateBtn {
  padding: 8px 20px;
  background-color: #0288d1;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
#generateBtn:hover:not(:disabled) {
  background-color: #02669d;
}
#generateBtn:disabled {
  background-color: #bbb;
  cursor: not-allowed;
}
#undoBtn, #redoBtn {
  padding: 6px 14px;
  background-color: #555;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s ease;
}
#undoBtn:hover:not(:disabled) {
  background-color: #333;
}
#redoBtn:hover:not(:disabled) {
  background-color: #333;
}
#undoBtn:disabled, #redoBtn:disabled {
  background-color: #999;
  cursor: not-allowed;
}
#gridContainer {
  width: 100%;
  max-width: 1024px;
  height: 513px;
  overflow: auto;
  border: 1px solid #ccc;
  background: white;
  margin: 0 auto 10px;
  user-select: none;
  touch-action: none;
}
table {
  border-collapse: collapse;
  margin: 0 auto;
  user-select: none;
  table-layout: fixed;
}
td {
  width: 8px;
  height: 8px;
  border: 1px solid #444;
  background-color: #070052;
  cursor: pointer;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  transition: background-color 0.2s ease;
}
td.on {
  background-color: #4ff3ff;
}
#codeOutput {
  background: #eeeeee;
  color: #000000;
  padding: 10px;
  font-size: 14px;
  width: 1024px;
  max-width: 100%;
  margin: 0 auto 10px auto;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: 4px;
  max-height: 200px;
  user-select: text;
  text-align: left;
}
#copyBtn {
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid #090;
  background-color: #0a0;
  color: white;
  user-select: none;
  transition: background-color 0.2s ease;
}
#copyBtn:active {
  background-color: #070;
}
#copyBtn:focus {
  outline: 2px solid #070;
}
#dropArea {
  border: 2px dashed #0288d1;
  padding: 15px 10px;
  margin: 10px auto 20px auto;
  max-width: 90%;
  width: 90%;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  color: #0288d1;
  font-weight: bold;
  font-size: 1rem;
  box-sizing: border-box;
  transition: background-color 0.3s ease;
  text-align: center;
}
#dropArea.dragover {
  background-color: #e0f7fa;
}
header p.subtitle {
  font-style: italic;
  color: #555;
  margin-top: 0;
  margin-bottom: 1em;
}
fieldset#outputFormatFieldset {
  display: inline-flex;
  gap: 15px;
  align-items: center;
  border: none;
  margin: 0;
  padding: 0;
  font-weight: 600;
}
fieldset#outputFormatFieldset legend {
  margin-right: 8px;
  font-weight: 600;
}
fieldset#outputFormatFieldset input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
fieldset#outputFormatFieldset label {
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  user-select: none;
  position: relative;
}
fieldset#outputFormatFieldset input[type="radio"]:focus + label {
  outline: 2px solid #0288d1;
  outline-offset: 2px;
}
fieldset#outputFormatFieldset input[type="radio"]:checked + label {
  background-color: #cceeff;
  border: 1px solid #0288d1;
}
@media (max-width: 480px) {
  #dropArea {
    padding: 12px 8px;
    font-size: 0.9rem;
  }
  #controlsForm {
    gap: 10px;
  }
  input[type="number"] {
    width: 60px;
  }
}
/* Toggle and copy button group styling */
#buttonGroup {
  display: inline-flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}
#toggleOutputBtn {
  padding: 8px 20px;
  background-color: #0288d1;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
#toggleOutputBtn:hover {
  background-color: #02669d;
}
