/* ================= GLOBAL RESETS & VARS ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #1e1e1e; 
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 15px;
  background-color: #252526;
  border-bottom: 1px solid #333333;
}

header h1 {
  color: #00bcd4;
  font-size: 1.8rem;
}

footer {
  text-align: center;
  padding: 15px;
  margin-top: auto;
  font-size: 0.9rem;
  background-color: #252526;
  border-top: 1px solid #333333;
  color: #888888;
}

/* ================= MAIN CONTAINER (RESPONSIVE GRID) ================= */
.game-container {
  display: grid;
  grid-template-columns: 1fr; /* Mobil: Alles sauber untereinander */
  gap: 20px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 15px;
}

/* Landscape / Desktop Monitore (Rechte Spalte für Steuerung und Infos) */
@media (min-width: 850px) and (orientation: landscape) {
  .game-container {
    grid-template-columns: 1.2fr 1fr; /* Links Brett (breiter), rechts Sidebar */
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
  }

  .board-wrapper {
    grid-column: 1;
    grid-row: 1 / 5; /* Das Brett nutzt links die volle verfügbare Höhe */
  }

  .top-bar, .game-info, .captured-pieces, .move-history {
    grid-column: 2; /* Alle Info-Boxen rutschen nach rechts */
  }
}

/* ================= dunkle BOX-DESIGNS (COMMON STYLES) ================= */
.top-bar, .game-info, .captured-pieces, .move-history {
  background-color: #252526; /* Dunkle Container-Boxen */
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #333333;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 600px;
  margin: auto;
}

/* ================= 1. TOPBAR & CONTROLS ================= */
.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* Dunkle Buttons und Dropdowns */
.controls select, .controls button {
  padding: 8px 14px;
  font-size: 1.3rem;
  border: 1px solid #444444;
  border-radius: 6px;
  background-color: #333333;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.controls select:focus, .controls button:hover {
    background-color: #444444;
    border-color: #555555;
}

#restart-btn {
  padding: 8px 14px;
  font-size: 1.3rem;
  border: 1px solid #444444;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

button#new-game-btn, #restart-btn {
    background-color: #00bcd4 !important;
}

#new-game-btn:hover, #restart-btn:hover {
    background-color: #0097a7 !important;
}

/* ================= 2. GAME INFO & STATUS ================= */
.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 1.05rem;
  width: 100%;
  max-width: 600px;
  margin: auto;
}

/* Status-Farben aus der JS-Logik */
.player-mode {
  color: #4caf50; 
}

.ai-mode {
  color: #f44336; 
}

.hidden {
  display: none !important;
}

/* ================= 3. SCHACHBRETT & FIGUREN ================= */
.board-wrapper {
  width: 100%;
  max-width: 600px; 
  margin: 0 auto;
}

#chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1; 
  border: 6px solid #111111;
  border-radius: 4px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  transition: transform 0.5s ease;
}

/* Brett-Rotation über den Flip-Button */
#chessboard.flipped {
  transform: rotate(180deg);
}

#chessboard.flipped .piece {
  transform: rotate(180deg); /* Verhindert, dass Figuren auf dem Kopf stehen */
}

/* Die Einzelfelder */
.square {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.6rem, 6vw, 3.2rem); /* Skaliert die Text-Figuren flüssig */
  user-select: none;
  cursor: pointer;
}

/* DEINE ORIGINAL-BOARD-FARBEN */
.light-square {
  background-color: #f0d9b5; 
  color: #222222; /* Kontrastfarbe für Text-Figuren auf hell */
}

.dark-square {
  background-color: #b58863;
  color: #ffffff; /* Kontrastfarbe für Text-Figuren auf dunkel */
}

/* Figuren-Farbzuweisungen falls im JS genutzt */
.white-piece {
  color: #ffffff;
  text-shadow: 0 0 4px rgba(0,0,0,0.6);
}

.black-piece {
  color: #000000;
  text-shadow: 0 0 4px rgba(255,255,255,0.2);
}

/* Selektions- und Schach-Zustände */
.selected {
  outline: 4px solid #3a86ff !important;
  outline-offset: -4px;
}

.check-king {
  background-color: #cc3333 !important; /* Warn-Rot bei Schach */
}

.piece {
  transition: transform 0.15s ease-out;
}

/* ================= 4. CAPTURED PIECES ================= */
.captured-pieces h2, .move-history h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: #aaaaaa;
  border-bottom: 1px solid #333333;
  padding-bottom: 5px;
}

#white-captured, #black-captured {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 35px;
  font-size: 1.6rem;
}

.captured-item {
  display: inline-block;
  line-height: 1;
}

/* ================= 5. MOVE HISTORY ================= */
#move-list {
  max-height: 160px;
  overflow-y: auto;
  padding-right: 5px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
}

/* Scrollbar-Styling für den Dark-Mode */
#move-list::-webkit-scrollbar {
  width: 6px;
}
#move-list::-webkit-scrollbar-track {
  background: #1e1e1e;
}
#move-list::-webkit-scrollbar-thumb {
  background: #444444;
  border-radius: 3px;
}

.move-row {
  display: grid;
  grid-template-columns: 0.6fr 1fr 1fr;
  padding: 5px 0;
  border-bottom: 1px solid #2d2d30;
}

.move-number {
  color: #666666;
}

.move-text {
  color: #e0e0e0;
}

/* ================= OVERLAYS (GAME OVER) ================= */
#game-over-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay-content {
  background: #252526;
  border: 1px solid #444444;
  padding: 30px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

#game-message {
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 20px;
  color: #ffffff;
}
