/* WMG Chess — tournament-terminal styling, scoped to #wmg-game-root */

#wmg-game-root .ch-wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 8px 0 16px;
  color: #fff;
}

/* ---------- control bar ---------- */

#wmg-game-root .ch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

#wmg-game-root .ch-btn,
#wmg-game-root .ch-select {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0;
  color: #fff;
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 10px;
  cursor: pointer;
}

#wmg-game-root .ch-select {
  appearance: none;
  -webkit-appearance: none;
}

#wmg-game-root .ch-select option {
  background: #1a1a1a;
  color: #fff;
}

#wmg-game-root .ch-btn-led {
  border-color: var(--led, #ff3b30);
  color: var(--led, #ff3b30);
}

#wmg-game-root .ch-btn:hover:not(:disabled),
#wmg-game-root .ch-select:hover {
  border-color: rgba(255, 255, 255, 0.6);
}

#wmg-game-root .ch-btn-led:hover:not(:disabled) {
  border-color: var(--led, #ff3b30);
  background: rgba(255, 59, 48, 0.12);
}

#wmg-game-root .ch-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

#wmg-game-root .ch-btn:focus-visible,
#wmg-game-root .ch-select:focus-visible,
#wmg-game-root .ch-sq:focus-visible,
#wmg-game-root .ch-promo-btn:focus-visible {
  outline: 2px solid var(--led, #ff3b30);
  outline-offset: 1px;
}

/* ---------- status line ---------- */

#wmg-game-root .ch-status {
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  margin-bottom: 12px;
  min-height: 16px;
}

/* ---------- layout ---------- */

#wmg-game-root .ch-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

#wmg-game-root .ch-board-zone {
  position: relative;
  flex: 0 1 480px;
  min-width: 0;
  width: 100%;
  max-width: 480px;
}

#wmg-game-root .ch-side {
  flex: 1 1 150px;
  min-width: 140px;
}

@media (max-width: 600px) {
  #wmg-game-root .ch-main {
    flex-direction: column;
  }
  #wmg-game-root .ch-board-zone {
    flex-basis: auto;
    max-width: 480px;
    margin: 0 auto;
  }
  #wmg-game-root .ch-side {
    width: 100%;
  }
}

/* ---------- board ---------- */

#wmg-game-root .ch-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#wmg-game-root .ch-sq {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wmg-game-root .ch-sq.light { background: #2c2c29; }
#wmg-game-root .ch-sq.dark { background: #20201e; }

#wmg-game-root .ch-pc {
  font-size: clamp(22px, 9.5vmin, 42px);
  pointer-events: none;
}

#wmg-game-root .ch-pc.pw { color: #f4f4f2; }
#wmg-game-root .ch-pc.pb { color: #757572; }

/* last-move + check tints (placed after light/dark so they win) */
#wmg-game-root .ch-sq.last { background: #36342a; }
#wmg-game-root .ch-sq.chk { background: rgba(255, 59, 48, 0.35); }

#wmg-game-root .ch-sq.sel {
  outline: 2px solid var(--led, #ff3b30);
  outline-offset: -2px;
}

/* legal-move markers: small sharp square; hollow frame on captures */
#wmg-game-root .ch-sq.tgt::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18%;
  height: 18%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.4);
}

#wmg-game-root .ch-sq.tgt.occ::after {
  width: 86%;
  height: 86%;
  background: transparent;
  border: 2px solid rgba(255, 59, 48, 0.7);
  box-sizing: border-box;
}

/* coordinates */
#wmg-game-root .ch-crd {
  position: absolute;
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 8px;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

#wmg-game-root .ch-crd-f { right: 3px; bottom: 2px; }
#wmg-game-root .ch-crd-r { left: 3px; top: 2px; }

/* ---------- promotion dialog ---------- */

#wmg-game-root .ch-promo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 26, 0.88);
}

#wmg-game-root .ch-promo[hidden] { display: none; }

#wmg-game-root .ch-promo-box {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #1a1a1a;
  padding: 14px;
  text-align: center;
}

#wmg-game-root .ch-promo-row {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  justify-content: center;
}

#wmg-game-root .ch-promo-btn {
  background: #242421;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0;
  font-size: 30px;
  line-height: 1;
  width: 52px;
  height: 52px;
  cursor: pointer;
}

#wmg-game-root .ch-promo-btn.pw { color: #f4f4f2; }
#wmg-game-root .ch-promo-btn.pb { color: #9b9b97; }

#wmg-game-root .ch-promo-btn:hover {
  border-color: var(--led, #ff3b30);
}

/* ---------- side panel ---------- */

#wmg-game-root .ch-label {
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 6px;
}

#wmg-game-root .ch-tally {
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.1em;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 7px 9px;
  margin-bottom: 8px;
}

#wmg-game-root .ch-cap {
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 9px;
  margin-bottom: 8px;
  min-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#wmg-game-root .ch-moves {
  font-family: var(--mono, 'Martian Mono', monospace);
  font-size: 11px;
  line-height: 1.7;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  max-height: 300px;
  overflow-y: auto;
}

#wmg-game-root .ch-mrow {
  display: flex;
  gap: 8px;
}

#wmg-game-root .ch-mno {
  color: rgba(255, 255, 255, 0.4);
  flex: 0 0 26px;
}

#wmg-game-root .ch-msan {
  flex: 1 1 0;
  color: #fff;
}
