body {
  font-family: monospace;
  background: #f0f7f0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  box-sizing: border-box;
  color: #346856;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.6); /* o rgba(0,0,0,0.4) para oscurecer */
  z-index: -1;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(20px, 60px));
  grid-template-rows: repeat(8, minmax(20px, 60px));
  gap: 2px;
  max-width: 480px;
}

.cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #ccc;
  cursor: pointer;
}

.palette {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.swatch {
  width: 40px;
  height: 40px;
  cursor: pointer;
  border: solid 2px gray;
  font-weight: 500;
  color: gray;
  font-size: 20px;
  text-align: center;
  line-height: 40px;
}

.swatch.selected {
  border: 2px solid #000;
}

textarea {
  width: 100%;
  height: 200px;
  margin-top: 15px;
  font-family: monospace;
}

textarea:hover {
  border: 2px solid #346856;
  transition: border-color 0.3s ease;
}

#out {
  max-width: 570px;
  padding: 10px;
}

#out:focus {
  border: 2px solid white;
  border-radius: 5px;
}

#out::placeholder {
  padding: 10px;
}

button {
  margin-top: 10px;
  padding: 8px 12px;
  margin-right: 5px;
  background-color: white;
  border: solid 2px #346856;
  cursor: pointer;
  font-weight: 500;
  color: #346856;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #E0F8D0;
}

.swatch:hover {
  border: solid 2px white;
}

#preview {
  margin-top: 15px;
  border: 2px solid #346856;
  image-rendering: pixelated;
  width: min(64px, 20vw);
  height: auto;
}

footer {
  margin-top: 30px;
  padding: 10px;
  text-align: center;
  font-size: 14px;
  color: #346856;
  border-top: 2px solid #346856;
  width: 90%;
  max-width: 600px;
  box-sizing: border-box;
}

@media (max-width: 600px) {
  h2 {
    font-size: 18px;
    text-align: center;
  }

  .swatch {
    width: 35px;
    height: 35px;
    font-size: 16px;
    line-height: 35px;
  }

  button {
    width: 100%;
    margin: 5px 0;
  }

  .board {
    grid-template-columns: repeat(8, minmax(20px, 9vw));
    gap: 2px;
  }
}

.format-container {
  margin: 15px 0 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.format-label {
  font-weight: 900;
  color: #346856;
  font-size: 16px;
}

.name-container {
  margin: 0 0 15px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.name-input {
  width: 230px;
  background-color: white;
  border: solid 2px #346856;
  padding: 6px 10px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  color: #346856;
}

.name-input:focus {
  outline: none;
  background-color: #E0F8D0;
}

.custom-dropdown {
  position: relative;
  width: 250px;
  background-color: white;
  border: solid 2px #346856;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  color: #346856;
  cursor: pointer;
  user-select: none;
}

.dropdown-selected {
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropdown-selected::after {
  content: "▼";
  font-size: 10px;
  margin-left: 10px;
}

.dropdown-options {
  display: none;
  position: absolute;
  top: 100%;
  left: -2px;
  right: -2px;
  background-color: white;
  border: solid 2px #346856;
  border-top: none;
  z-index: 1000;
}

.dropdown-options.show {
  display: block;
}

.dropdown-option {
  padding: 8px 12px;
  border-bottom: 2px solid #E0F8D0;
}

.dropdown-option:last-child {
  border-bottom: none;
}

.dropdown-option:hover {
  background-color: #88C070;
  color: white;
}

.custom-dropdown:hover {
  background-color: #E0F8D0;
}