/* =========================================================
   Xadrez — estilos (separados do HTML; segue o modelo dos projetos)
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: #041027;
}

.app-header {
  background-image: url('../img/banner-xadrez.svg');
  background-size: cover;
  background-position: center;
  color: #ffffff;
  padding: 28px 18px;
  text-align: center;
}
.app-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 2px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

#app {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#board {
  width: min(100%, 85vh);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-auto-rows: 1fr;
  max-width: 100vw;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  font-size: calc(1.6vh + 1.6vw);
  cursor: pointer;
}
.cell:focus-visible { outline: 3px solid #1a6ef0; outline-offset: -3px; }

.light {
  background-color: #f1e2ad;
  background-image: url('../img/white.svg');
  background-size: cover;
  background-position: center;
}
.dark {
  background-color: #9e9fa1;
  background-image: url('../img/black.svg');
  background-size: cover;
  background-position: center;
}
.highlight { outline: 3px solid rgba(255, 215, 0, 0.6); }

#panel {
  background: #fafafa;
  border-top: 1px solid #ccc;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
}
.col-history { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.col-controls { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.panel-title { margin: 0; font-size: 1.05rem; }
.controls-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.status-row { text-align: center; }
.panel-top h2 { margin: 0; font-size: 1.05rem; }

#history-box {
  width: 260px;
  max-width: 320px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  overflow-y: auto;
  min-height: 40px;
  max-height: 72px;
  font-family: 'Noto Sans Mono", monospace';
  font-weight: 300;
  font-size: 0.8rem;
  line-height: 1.35;
}

.button {
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: #4a8cf7;
  color: #fff;
  cursor: pointer;
  font: inherit;
}
.button:hover { background: #3a7ce0; }
.button:focus-visible { outline: 3px solid #1a6ef0; outline-offset: 2px; }

#panel select {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font: inherit;
}
#panel select:focus-visible { outline: 3px solid #1a6ef0; outline-offset: 2px; }

#result {
  font-weight: 600;
  color: #0f3460;
  min-height: 1.2em;
  text-align: center;
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.piece { font-size: 2.6rem; line-height: 1; }
.piece.white-piece {
  color: #fafafa;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.piece.black-piece {
  color: #15171c;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

@media (max-width: 800px) {
  #history-box { max-height: calc(4 * 1.08rem + 16px); }
}

/* Telas grandes: tabuleiro e painel (histórico + botões) lado a lado */
@media (min-width: 900px) {
  body {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
  }
  .app-header { width: 100%; }
  #app {
    flex: 1 1 auto;
    width: auto;
    height: calc(100vh - 80px);
  }
  #panel {
    width: 320px;
    border-top: none;
    border-left: 1px solid #ccc;
    flex-direction: column;
    align-items: center;
    height: calc(100vh - 80px);
    overflow-y: auto;
  }
  #history-box { max-height: calc(12 * 1.08rem + 16px); }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 200;
  background: #fff;
  color: #041027;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid #1a6ef0; outline-offset: 2px; }

.ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: auto;
  padding: 16px;
}
.ai-overlay-box {
  background: rgba(255, 255, 255, 0.97);
  border-radius: 12px;
  padding: 24px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.ai-overlay-box h2 { margin: 0 0 12px; font-size: 20px; color: #0f3460; }
.ai-overlay-box p { margin: 0 0 16px; color: #333; font-size: 14px; line-height: 1.5; }
.ai-overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ai-btn { border: none; border-radius: 8px; padding: 10px 18px; font-size: 14px; cursor: pointer; font-weight: 600; }
.ai-btn.agree { background: #4a8cf7; color: #fff; }
.ai-btn.leave { background: #c0392b; color: #fff; }
.ai-classification {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin: 0 0 16px;
  padding: 10px;
  background: #eef3fb;
  border-radius: 10px;
  border: 1px solid #d4e2f7;
  text-align: left;
}
.pegi-badge {
  min-width: 44px;
  width: 44px;
  height: 52px;
  background: #4a8cf7;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.pegi-text { font-size: 13px; color: #333; line-height: 1.4; }
.pegi-text b { font-size: 15px; }
.pegi-text small { display: block; color: #555; font-size: 11px; margin-top: 2px; }

@media (max-width: 480px) {
  .app-header { padding: 18px 12px; }
  #board { width: min(100%, 70vh); }
  .button { padding: 7px 9px; font-size: 0.85rem; }
  #panel { gap: 14px; padding: 10px; }
  #history-box { width: min(260px, 92vw); }
  .ai-overlay-box { padding: 18px; }
  .ai-classification { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .cell, .button, #history-box { transition: none !important; }
}
