* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #262421;
  color: #e8e6e3;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 1.5rem;
  align-items: flex-start;
  justify-content: center;
}

/* Chessground requires explicit dimensions on its wrap element. */
.board-area {
  position: relative;
}

#board {
  width: min(92vw, 560px);
  height: min(92vw, 560px);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: min(92vw, 300px);
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

#status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #33312e;
  font-weight: 500;
}

#status.thinking {
  background: #3b3a2f;
}

#spinner {
  width: 1rem;
  height: 1rem;
  flex: none;
  border: 2px solid #7d7a74;
  border-top-color: #f0d9b5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#level-display {
  padding: 0.75rem;
  border-radius: 10px;
  background: #33312e;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
}

#level-display #level-value {
  color: #f0d9b5;
}

button {
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 6px;
  background: #629924;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #6fae29;
}

button.secondary {
  background: #4a4844;
}

button.secondary:hover {
  background: #57544f;
}

.hint {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: #8f8c86;
}

.hidden {
  display: none !important;
}

/* Game-over overlay covers the board. */
#game-over {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 19, 18, 0.65);
  z-index: 10;
}

.game-over-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  padding: 1.5rem 2rem;
  border-radius: 10px;
  background: #33312e;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

#game-over-text {
  font-size: 1.25rem;
  font-weight: 600;
}
