/* ==========================================================================
   OTB Chess — Styles
   Uses Bauhaus theme CSS variables for native look.
   ========================================================================== */

/* ---------- Pre-game screen ---------- */

.otb-pregame {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--gap, 24px) 0;
}

.otb-settings-section {
  margin-bottom: var(--content-gap, 20px);
  padding: var(--content-gap, 20px);
  background: var(--entry);
  border: var(--border-weight, 3px) solid var(--border);
}

.otb-settings-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin: 0 0 12px 0;
}

.otb-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--secondary);
  margin-bottom: 8px;
}

.otb-input {
  background: var(--theme);
  color: var(--primary);
  border: var(--border-weight, 3px) solid var(--border);
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  width: 80px;
  border-radius: 0;
}

.otb-input:focus {
  border-color: var(--primary);
  outline: none;
}

.otb-input-hex {
  width: 90px;
  font-family: monospace;
}

/* Time control presets */

.otb-time-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.otb-time-preset {
  background: var(--theme);
  color: var(--primary);
  border: var(--border-weight, 3px) solid var(--border);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 0;
}

.otb-time-preset:hover {
  background: var(--red, #D03020);
  border-color: var(--red, #D03020);
  color: #fff;
}

.otb-time-preset.active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}

.otb-time-custom {
  display: flex;
  gap: 16px;
}

/* Piece set grid */

.otb-piece-set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.otb-piece-set-option {
  background: var(--theme);
  border: var(--border-weight, 3px) solid var(--border);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.otb-piece-set-option:hover {
  border-color: var(--red, #D03020);
}

.otb-piece-set-option.active {
  border-color: var(--ink);
  background: var(--entry);
}

.otb-piece-set-option img {
  width: 36px;
  height: 36px;
  display: block;
  margin: 0 auto 4px;
}

.otb-piece-set-option span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--secondary);
}

/* Board color presets */

.otb-board-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.otb-board-preset {
  width: 48px;
  height: 48px;
  border: var(--border-weight, 3px) solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.otb-board-preset:hover {
  border-color: var(--red, #D03020);
}

.otb-board-preset.active {
  border-color: var(--ink);
}

.otb-board-preset-light,
.otb-board-preset-dark {
  position: absolute;
  width: 50%;
  height: 100%;
  top: 0;
}

.otb-board-preset-light {
  left: 0;
}

.otb-board-preset-dark {
  right: 0;
}

.otb-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.otb-color-picker {
  width: 36px;
  height: 36px;
  border: var(--border-weight, 3px) solid var(--border);
  padding: 0;
  cursor: pointer;
  background: none;
  border-radius: 0;
}

/* Primary button */

.otb-btn {
  background: var(--theme);
  color: var(--primary);
  border: var(--border-weight, 3px) solid var(--ink);
  padding: 8px 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 0;
  font-family: inherit;
}

.otb-btn:hover {
  background: var(--red, #D03020);
  border-color: var(--red, #D03020);
  color: #fff;
}

.otb-btn:active {
  transform: scale(0.96);
}

.otb-btn-primary {
  background: var(--ink);
  color: var(--white);
}

/* ---------- Game screen (fullscreen) ---------- */

.otb-game {
  position: fixed;
  inset: 0;
  background: var(--theme);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 8px;
  gap: 6px;
  overflow: hidden;
}

/* Player panels */

.otb-player-panel {
  width: 100%;
  max-width: calc(100vw - 16px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--entry);
  border: var(--border-weight, 3px) solid var(--border);
  box-sizing: border-box;
}

.otb-player-panel.otb-active {
  border-color: var(--red, #D03020);
}

.otb-panel-rotated {
  transform: rotate(180deg);
}

.otb-panel-clock {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  min-width: 80px;
}

.otb-panel-clock.otb-clock-low {
  color: var(--red, #D03020);
}

.otb-panel-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--secondary);
}

.otb-panel-captured {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}

.otb-panel-captured img {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.otb-panel-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.otb-btn-action {
  background: var(--theme);
  color: var(--secondary);
  border: 2px solid var(--border);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 0;
  padding: 0;
  font-family: inherit;
}

.otb-btn-action:hover {
  color: var(--red, #D03020);
  border-color: var(--red, #D03020);
}

.otb-btn-action.otb-confirm {
  color: var(--red, #D03020);
  border-color: var(--red, #D03020);
  font-size: 10px;
  font-weight: 700;
}

.otb-btn-action:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

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

.otb-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.otb-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.otb-square img {
  width: 90%;
  height: 90%;
  pointer-events: none;
}

.otb-square img.otb-piece-black {
  transform: rotate(180deg);
}

/* Square highlights */

.otb-square.otb-selected {
  outline: 3px solid var(--red, #D03020);
  outline-offset: -3px;
  z-index: 1;
}

.otb-square.otb-legal::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.otb-square.otb-capture::after {
  content: '';
  position: absolute;
  width: 85%;
  height: 85%;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.2);
  background: transparent;
  pointer-events: none;
  box-sizing: border-box;
}

.otb-square.otb-last-move {
  background-color: rgba(255, 255, 0, 0.3) !important;
}

.otb-square.otb-in-check {
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0.6) 0%, rgba(255, 0, 0, 0.2) 60%, transparent 80%) !important;
}

/* Dragging piece */

.otb-drag-piece {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -90%);
}

.otb-drag-piece.otb-piece-black {
  transform: translate(-50%, -90%) rotate(180deg);
}

/* ---------- Promotion overlay ---------- */

.otb-promotion {
  position: absolute;
  z-index: 10001;
  display: flex;
  background: var(--entry);
  border: var(--border-weight, 3px) solid var(--ink);
}

.otb-promotion.otb-promotion-rotated {
  transform: rotate(180deg);
}

.otb-promotion-piece {
  cursor: pointer;
  padding: 4px;
  transition: background 0.15s ease;
}

.otb-promotion-piece:hover {
  background: var(--concrete);
}

.otb-promotion-piece img {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Game over overlay ---------- */

.otb-gameover {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
}

.otb-gameover-content {
  background: var(--entry);
  border: var(--border-weight, 3px) solid var(--ink);
  padding: 24px 32px;
  text-align: center;
}

.otb-gameover-result {
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 16px;
}

/* ---------- Draw offer overlay ---------- */

.otb-draw-offer {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
}

.otb-draw-offer-content {
  background: var(--entry);
  border: var(--border-weight, 3px) solid var(--ink);
  padding: 20px 28px;
  text-align: center;
}

.otb-draw-offer-content.otb-panel-rotated {
  transform: rotate(180deg);
}

.otb-draw-offer-text {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 12px;
}

.otb-draw-offer-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ---------- Board sizing ---------- */

.otb-game {
  --panel-height: 52px;
  --board-size: min(calc(100vw - 16px), calc(100vh - var(--panel-height) * 2 - 40px));
}

.otb-board {
  width: var(--board-size);
  height: var(--board-size);
}

/* ---------- Coordinate labels ---------- */

.otb-coord-file,
.otb-coord-rank {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.6;
}

.otb-coord-file {
  bottom: 1px;
  right: 3px;
}

.otb-coord-rank {
  top: 1px;
  left: 3px;
}

/* Coordinate on dark squares gets light color and vice versa */
.otb-square-light .otb-coord-file,
.otb-square-light .otb-coord-rank {
  color: var(--otb-dark, #b58863);
}

.otb-square-dark .otb-coord-file,
.otb-square-dark .otb-coord-rank {
  color: var(--otb-light, #f0d9b5);
}
