.chess-wrap { max-width: 1040px; padding-top: 24px; padding-bottom: 40px; }
[hidden] { display: none !important; }

/* Menu */
.menu h1 { font-size: clamp(2.2rem, 6vw, 3.2rem); letter-spacing: -0.03em; line-height: 1.1; margin-top: 40px; }
.menu .lede { color: var(--muted); margin: 10px 0 28px; font-size: 1.1rem; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.mode p { margin-bottom: 4px; }
.color-pick { display: flex; gap: 8px; margin-top: 14px; }
.color-pick button { flex: 1; }

button {
  font: inherit; font-weight: 600; font-size: 0.95rem;
  background: var(--accent); color: #0e0f12;
  border: 0; border-radius: 8px; padding: 9px 12px; cursor: pointer;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }

/* Game layout */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.board-col { width: 100%; max-width: min(640px, calc(100vh - 190px)); min-width: 0; justify-self: center; }
@media (max-width: 820px) {
  .game { grid-template-columns: 1fr; gap: 16px; }
  .board-col { max-width: min(560px, 100%); }
  .chess-wrap { padding-left: 12px; padding-right: 12px; padding-top: 12px; }
}

.player { display: flex; align-items: center; gap: 8px; height: 34px; color: var(--muted); font-size: 0.95rem; }
.player .name { white-space: nowrap; }
.player.to-move .name { color: var(--text); font-weight: 600; }
.player .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; }
.player .dot.on { background: #4ade80; }
.player .dot.w { background: #f2f2f2; }
.player .dot.b { background: #111; border: 1px solid #555; }
.player .caps { display: flex; align-items: center; flex-wrap: wrap; overflow: hidden; height: 22px; font-size: 18px; line-height: 22px; }
.player .caps .pc { margin-right: -4px; }
.player .caps em { font-style: normal; font-size: 0.85rem; margin-left: 8px; }

/* Board */
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1; width: 100%;
  border-radius: 6px; overflow: hidden;
  box-shadow: 0 6px 30px rgba(0,0,0,.45);
  touch-action: none; user-select: none; -webkit-user-select: none;
  container-type: inline-size;
  transition: transform 0.5s ease-in-out;
}
.board.turning { transform: rotate(180deg); }
.board.no-anim { transition: none; }
.sq { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq.light { --sqbg: #e9edcc; background: var(--sqbg); }
.sq.dark { --sqbg: #779556; background: var(--sqbg); }
.sq.last.light { background: #f5f682; }
.sq.last.dark { background: #b9ca43; }
.sq.sel { box-shadow: inset 0 0 0 4px rgba(20, 85, 160, .75); }
.sq.check { background: radial-gradient(circle, #ff3b3b 0%, #e02020 35%, rgba(200,0,0,0) 75%), var(--sqbg); }
.sq.target::after {
  content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%;
  background: rgba(0, 0, 0, .18); pointer-events: none;
}
.sq.capture::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, .2); pointer-events: none;
}
.coord { position: absolute; font-size: max(9px, 2.1cqw); font-weight: 700; pointer-events: none; line-height: 1; }
.coord.rank { top: 3px; left: 4px; }
.coord.file { bottom: 3px; right: 4px; }
.sq.light .coord { color: #779556; }
.sq.dark .coord { color: #e9edcc; }

/* Pieces: one filled glyph set for both colours, painted with fill + outline. */
.pc {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", "Apple Symbols", serif;
  font-variant-emoji: text;
  line-height: 1; pointer-events: none;
}
.board .pc { font-size: 10.2cqw; }
.pc.w { color: #fff; -webkit-text-stroke: 1.2px #222; paint-order: stroke fill; text-shadow: 0 2px 2px rgba(0,0,0,.35); }
.pc.b { color: #1d1d1f; -webkit-text-stroke: 0.6px #000; text-shadow: 0 1px 1px rgba(255,255,255,.25); }
.ghost-piece {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 6px 6px rgba(0,0,0,.4));
}

/* Side panel */
.side { display: flex; flex-direction: column; gap: 14px; padding-top: 34px; }
@media (max-width: 820px) { .side { padding-top: 0; } }
.status { font-size: 1.1rem; font-weight: 600; min-height: 1.6em; }
.status.over { color: var(--accent); }
.share, .offer { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 0.95rem; }
.share p, .offer p { color: var(--muted); margin-bottom: 8px; }
.share-row, .row { display: flex; gap: 8px; }
.row button { flex: 1; }
.share-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.85rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.moves {
  list-style: none; counter-reset: mv; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 0;
  font-variant-numeric: tabular-nums; font-size: 0.95rem;
}
.moves:empty { display: none; }
.moves li { counter-increment: mv; display: grid; grid-template-columns: 2.6em 1fr 1fr; padding: 2px 12px; }
.moves li::before { content: counter(mv) "."; color: var(--muted); }
.moves li:nth-child(even) { background: rgba(255,255,255,.03); }
@media (max-width: 820px) { .moves { max-height: 120px; } }
.controls { display: flex; flex-direction: column; gap: 10px; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.95rem; cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.back { color: var(--muted); font-size: 0.9rem; }

/* Promotion picker */
.promo { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.promo-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 340px; }
.promo-box p { width: 100%; text-align: center; color: var(--muted); }
.promo-box button { width: 64px; height: 64px; background: #e9edcc; padding: 0; font-size: 44px; display: flex; align-items: center; justify-content: center; }
