body {
  margin: 0;
  padding: 24px;
  background: #323232;
  color: #fff;
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
}
.game { display: flex; gap: 24px; }
.board-wrap { position: relative; }
.captured {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 2px 4px;
  font-family: Arial, sans-serif;
  color: #d8d8d8;
  font-size: 14px;
  font-weight: bold;
}
.cap-group { display: inline-flex; align-items: center; }
.cap-piece {
  width: 22px;
  height: 22px;
  pointer-events: none;
}
.cap-piece + .cap-piece { margin-left: -10px; }
.cap-adv { margin-left: 4px; color: #ffffff; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 80px);
  grid-template-rows: repeat(8, 80px);
  border: 2px solid #1a1a1a;
  user-select: none;
}
.square {
  width: 80px; height: 80px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.square.light { background: #f0d9b5; }
.square.dark  { background: #b58863; }
.square.last-move { background: #bacaa4 !important; }
.square.selected  { background: #f6f682 !important; }
.square.check {
  background: #eb6150 !important;
  box-shadow: inset 0 0 0 5px #dc3232, inset 0 0 0 7px #ff9696;
}
.square img {
  width: 60px; height: 60px;
  pointer-events: none;
}
.square img.pawn { width: 48px; }
.hint {
  position: absolute;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(100,100,100,0.55);
  pointer-events: none;
}
.hint.capture {
  width: 64px; height: 64px;
  background: transparent;
  border: 5px solid rgba(200,50,50,0.7);
  box-sizing: border-box;
}
.coord {
  position: absolute;
  font-size: 12px;
  pointer-events: none;
  font-weight: bold;
}
.coord.file { right: 4px; bottom: 2px; }
.coord.rank { left: 4px; top: 2px; }

.info { width: 280px; }
.info h2 { margin: 0 0 12px; }
.info h3 { margin: 16px 0 6px; }
.info p { margin: 6px 0; }
#history {
  background: #1e1e1e;
  padding: 10px;
  height: 240px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 4px;
  font-family: monospace;
  white-space: pre-wrap;
}
button {
  background: #555; color: #fff; border: 0;
  padding: 8px 14px; margin: 4px 6px 4px 0;
  cursor: pointer; border-radius: 4px;
}
button:hover { background: #777; }
select {
  background: #444; color: #fff;
  border: 1px solid #666; padding: 4px;
}
.promo {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
}
.promo.show { display: flex; }
.promo-box {
  background: #3c3c3c;
  border: 2px solid #c8c8c8;
  padding: 16px;
  border-radius: 6px;
}
.promo-box .options { display: flex; gap: 10px; margin-top: 10px; }
.promo-box .opt {
  width: 60px; height: 60px;
  border: 2px solid #969696;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: #2a2a2a;
}
.promo-box .opt:hover { background: #555; }
.promo-box .opt img { width: 50px; height: 50px; }
.thinking { color: #ffc864; }
.check-text { color: #ff6464; }
.game-over { color: #ff6464; }

.fen-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.fen-modal.show { display: flex; }
.fen-modal-box {
  background: #3c3c3c;
  color: #fff;
  border: 2px solid #c8c8c8;
  border-radius: 6px;
  padding: 20px;
  min-width: 360px;
  max-width: 90vw;
}
.fen-modal-box h3 { margin: 0 0 10px; }
.fen-modal-box textarea {
  width: 100%;
  box-sizing: border-box;
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #666;
  border-radius: 4px;
  padding: 6px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}
.fen-modal-box p { margin: 10px 0 0; }
.fen-error { color: #ff6464; font-size: 12px; min-height: 16px; margin-top: 8px; }

/* --- auth (login.html) --- */
.auth-card {
  width: 320px;
  margin: 60px auto 0;
  background: #3c3c3c;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 28px 28px 24px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 24px; }
.auth-card .tagline { margin: 0 0 20px; color: #969696; font-size: 13px; }
.auth-card label { display: block; margin: 12px 0 4px; font-size: 13px; color: #d8d8d8; }
.auth-card input {
  width: 100%;
  box-sizing: border-box;
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #666;
  border-radius: 4px;
  padding: 9px 10px;
  font-size: 14px;
}
.auth-card input:focus { outline: none; border-color: #8aa6c8; }
.auth-actions { display: flex; gap: 10px; margin-top: 18px; }
.auth-actions button { flex: 1; margin: 0; padding: 10px; }
.auth-actions .primary { background: #3d6098; }
.auth-actions .primary:hover { background: #4a73b5; }
.auth-error { color: #ff6464; font-size: 13px; min-height: 18px; margin-top: 12px; }
.auth-msg { color: #7fc77f; font-size: 13px; min-height: 18px; margin-top: 12px; }

/* user bar on the game/lobby pages */
.userbar { display: flex; align-items: center; gap: 10px; color: #d8d8d8; font-size: 13px; }
.userbar .who { font-weight: bold; color: #fff; }
.userbar button { margin: 0; padding: 4px 10px; font-size: 12px; }

/* --- lobby --- */
.lobby { width: 420px; margin: 48px auto 0; }
.lobby h1 { margin: 8px 0 16px; }
.lobby .conn { font-size: 14px; }
.lobby .muted { color: #969696; font-size: 13px; margin-top: 24px; }
.lobby .play-link {
  display: inline-block;
  margin: 12px 0;
  padding: 12px 18px;
  background: #3d6098;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: bold;
}
.lobby .play-link:hover { background: #4a73b5; }
.conn-dot { font-weight: bold; }
.conn-dot.pending { color: #ffc864; }
.conn-dot.ok { color: #7fc77f; }
.conn-dot.bad { color: #ff6464; }
.lobby-actions { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.lobby-actions .primary { background: #3d6098; }
.lobby-actions .primary:hover { background: #4a73b5; }
.lobby-actions button:disabled { background: #444; color: #888; cursor: default; }
.rejoin-box {
  margin: 14px 0;
  padding: 12px 14px;
  background: #3a3320;
  border: 1px solid #6a5a2a;
  border-radius: 6px;
  color: #ffd98a;
  font-size: 14px;
}
.rejoin-link { color: #ffc864; font-weight: bold; text-decoration: none; margin-left: 6px; }
.rejoin-link:hover { text-decoration: underline; }

/* a small back-link on the game page */
.toplink { font-size: 13px; }
.toplink a { color: #8aa6c8; text-decoration: none; }
.toplink a:hover { text-decoration: underline; }

/* PvP clocks */
#clocks { margin: 6px 0 12px; }
.clock-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 200px;
  padding: 5px 10px;
  margin: 4px 0;
  background: #1e1e1e;
  border-radius: 4px;
}
.clock-who { color: #d8d8d8; font-size: 13px; }
.clock { font-family: monospace; font-weight: bold; font-size: 19px; color: #ddd; }
.clock.active { color: #7fc77f; }       /* side to move */
.clock.low    { color: #ff6464; }       /* under 10s */
.pvp-info { color: #8aa6c8; }

/* history page */
.history-page { width: 760px; max-width: 92vw; margin: 32px auto 0; }
.history-page h1 { margin: 8px 0 16px; }
.nav-link { color: #8aa6c8; text-decoration: none; }
.nav-link:hover { text-decoration: underline; }
.history-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.history-table th, .history-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #444; }
.history-table th { color: #969696; font-weight: normal; font-size: 12px; text-transform: uppercase; }
.history-table tbody tr:hover { background: #2a2a2a; }
.replay-link { color: #8aa6c8; text-decoration: none; white-space: nowrap; }
.replay-link:hover { text-decoration: underline; }
.out-win { color: #7fc77f; font-weight: bold; }
.out-loss { color: #ff6464; }
.out-draw { color: #c8c8c8; }
.out-progress { color: #ffc864; }

/* replay move list (reuses the #history container styling) */
.mv { cursor: pointer; padding: 1px 3px; border-radius: 3px; }
.mv:hover { background: #333; }
.mv.current { background: #3d6098; color: #fff; }
.mv-num { color: #969696; }
#replayControls button { font-size: 16px; padding: 6px 12px; }
