* {
  box-sizing: border-box;
  font-family: Inter, system-ui, Segoe UI, Arial, sans-serif;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #f9fafb;
  color: #111827;
  padding: 20px;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

header h1 {
  font-size: 24px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

button,
select,
input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  background: #d1d5db;
  color: #111827;
  cursor: pointer;
}

input {
  width: 140px;
}

.game-area {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-left: 200px;
}

.board {
  width: 500px;
  height: 500px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 12px;
  overflow: hidden;
  border: 4px solid #9ca3af;
  margin-left: 70px;
}

.cell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cell[data-color="light"] {
  background: linear-gradient(180deg, #f0d9b5, #e9d8b7);
}

.cell[data-color="dark"] {
  background: linear-gradient(180deg, #b58863, #a56f47);
  cursor: pointer;
}

.piece {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  user-select: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.piece.red {
  background: linear-gradient(180deg, #ff6b6b, #c53030);
  color: #fff;
}

.piece.white {
  background: linear-gradient(180deg, #fff, #dcdcdc);
  color: #111;
}

.piece.king::after {
  content: "\2605";
  position: absolute;
  top: 6%;
  right: 6%;
  font-size: 0.9rem;
}

.cell.highlight {
  outline: 4px solid rgba(96, 165, 250, 0.6);
  z-index: 2;
}

.cell.capture {
  outline: 4px solid rgba(239, 68, 68, 0.6);
}

.info {
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.status {
  background: #e5e7eb;
  padding: 12px;
  border-radius: 10px;
  text-align: center;
}

.board-footer {
  margin-top: 12px;
}

#popupInstrucoes,
#convitePop {
  position: fixed;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.4);
  z-index: 10;
}

#popupInstrucoes .conteudo,
#convitePop {
  background: #e5e7eb;
  padding: 18px;
  border-radius: 10px;
  max-width: 640px;
  text-align: center;
}

#statusBar {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: rgba(107, 114, 128, 0.6);
  color: #111;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

#chat {
  position: relative;
  top: 30px;
  margin-left: 5%;
  width: 250px;
  height: 480px;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #1e2329;
  display: flex;
  flex-direction: column;
}

#chatMensagens {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
  color: white;
}

#chatInput {
  display: flex;
}

#chatInput input {
  flex: 1;
  padding: 3px;
}

#chatInput button {
  padding: 5px;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #111827;
    color: #e6edf3;
  }

  button,
  select,
  input {
    background: #1f2937;
    color: #e6edf3;
  }

  .board {
    border: 4px solid #0b1220;
  }

  .status,
  #popupInstrucoes .conteudo,
  #convitePop {
    background: #0f1724;
    color: #e6edf3;
  }

  #statusBar {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
  }

  #chatMensagens {
    color: white;
  }
}

@media (max-width: 1440px) {
  .game-area {
    gap: 16px;
  }

  .board {
    width: 450px;
    height: 450px;
  }

  #chat {
    width: 230px;
    height: 450px;
  }

  input {
    width: 120px;
  }
}

@media (max-width: 1024px) {
  .container {
    gap: 16px;
    padding: 15px;
  }

  .game-area {
    gap: 12px;
  }

  .board {
    width: 400px;
    height: 400px;
  }

  #chat {
    width: 200px;
    height: 400px;
  }

  input {
    width: 100px;
  }
}

@media (max-width: 780px) {
  body {
    flex-direction: column;
    padding: 10px;
  }

  .game-area {
    flex-direction: column;
    margin-left: 0;
    align-items: center;
    gap: 12px;
  }

  .board {
    width: 350px;
    height: 350px;
  }

  #chat {
    width: 100%;
    height: 300px;
    margin-left: 0;
    margin-top: 12px;
  }

  input {
    width: 90px;
  }
}

@media (max-width: 480px) {
  .board {
    width: 280px;
    height: 280px;
  }

  .game-area {
    gap: 8px;
  }

  .controls {
    flex-direction: column;
    gap: 6px;
  }

  input {
    width: 70px;
  }

  #chat {
    width: 100%;
    height: 250px;
    margin-left: 0;
    margin-top: 12px;
  }

  header h1 {
    font-size: 20px;
  }
}
