* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #fff;
  font-family: monospace;
  font-size: 1rem;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  padding: 0.5rem; /* Reduziert von 1rem */
  gap: 0.5rem; /* Reduziert von 1rem */
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

canvas {
  display: block;
  max-width: 100%;
  margin-bottom: 0.5rem; /* Reduziert von 1rem */
}

.control-container {
  font-size: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px; /* Einheitlicher Abstand zwischen allen Elementen */
  /* Breite wird dynamisch per JavaScript gesetzt */
}

.editor-sidebar {
  font-size: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.3rem; /* Reduziert von 1rem */
  width: 200px;
  min-width: 180px;
}

label {
  flex: 1 1 45%;
  max-width: 50%;
  line-height: 2;
}

input[type="text"],
select,
textarea {
  font-size: inherit;
}

select {
  flex: 1 1 45%;
  max-width: 50%;
  padding: 0.1rem; /* Neu hinzugefügt, um vertikalen Platz zu reduzieren */
  height: 1.4rem; /* Definierte Höhe für alle Dropdowns */
}

textarea {
  font: inherit;
  padding: 0.25rem;
}

button {
  font-size: inherit;
  font: inherit;
  padding: 0.2rem 0.8rem; /* Reduziert von 0.5rem 1rem */
  width: 100%;
  cursor: pointer;
  margin-bottom: 2px;
}

.text-output {
  font: inherit;
  padding: 0.5rem;
  width: 100%;
  resize: vertical;
  height: 10rem;
  font-size: 0.85rem; /* Kleinere Schriftgröße für das Nachrichtenfenster */
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem; /* Reduziert von 0.25rem */
  align-items: center;
  margin-bottom: 0.2rem; /* Reduziert von 0.3rem */
}

.editor-section {
  border: 2px solid #ccc;
  border-radius: 8px;
  padding: 5px; /* Reduziert von 10px */
  background-color: #f9f9f9;
}

.editor-section h3 {
  margin-top: 0.4rem;
  margin-bottom: 0.2rem;
  font-size: 0.9rem; /* Reduziert, falls nicht schon klein genug */
  color: #333;
}

.figuren-palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px; /* Reduziert von 6px */
  margin: 4px 0; /* Reduziert von 8px */
  padding: 4px; /* Reduziert von 8px */
  background-color: #ffffff;
  border-radius: 5px;
  border: 1px solid #ddd;
}

.figuren-button {
  padding: 5px 3px; /* Reduziert von 10px 6px */
  border: 1px solid #ccc;
  background-color: white;
  cursor: pointer;
  border-radius: 3px;
  text-align: center;
  font-size: 2.2em;
  min-height: 40px; /* Reduziert von 50px */
  display: flex;
  align-items: center;
  justify-content: center;
}

.figuren-button:hover {
  background-color: #e0e0e0;
}

.figuren-button:active,
.figuren-button.selected {
  background-color: #d0d0d0;
  border-color: #999;
}

.editor-controls {
  display: flex;
  flex-direction: column;
  gap: 3px; /* Reduziert von 6px */
  margin-top: 5px; /* Reduziert von 10px */
}

.editor-controls button {
  padding: 4px; /* Reduziert von 8px */
  font-size: 0.85em;
}

/* KI-Controls ohne speziellen Hintergrund */
.ki-controls {
  display: flex;
  gap: 5px;
  margin: 1px 0; /* Reduziert */
  padding: 0; /* Entfernt das Padding */
  background-color: transparent; /* Entfernt den Hintergrund */
  border: none; /* Entfernt den Rahmen */
  border-radius: 0;
}

.ki-controls .control-button {
  flex: 1;
  min-width: 120px;
}

/* Einheitliche Abstände für alle Button-Gruppen */
.nav-container,
.ki-controls,
.form-row,
button {
  margin-bottom: 2px;
}

/* Entfernung von Margin unten beim letzten Button vor einem neuen Container */
.nav-container button:last-child,
.ki-controls button:last-child {
  margin-bottom: 0;
}

/* Spiel zurücksetzen Button - wie die anderen Buttons */
.zuruecksetzen-button {
  margin-bottom: 2px;
}

.fen-buttons-container {
  display: flex;
  width: 100%;
  gap: 0;
}

.fen-buttons-container .control-button {
  flex: 1;
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    align-items: center;
  }
  
  .control-container,
  .editor-sidebar {
    width: 100%;
    max-width: 400px;
  }
}