/* ===== RESET & OSNOVA ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --gold: #d4af37;
  --gold-light: #f0d878;
  --gold-dark: #a8862a;
  --black: #0a0a0a;
  --black-soft: #1a1a1a;
  --white: #ffffff;
  --bg: #141414;
  --board-light: #d4af37;
  --board-dark: #1a1a1a;
}

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: radial-gradient(circle at top, #1f1f1f 0%, #0a0a0a 100%);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 12px;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  padding: 8px 0;
}

.logo {
  font-size: clamp(28px, 8vw, 44px);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.logo-x {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
}

.logo-chess {
  color: var(--white);
}

/* ===== KONTROLE ===== */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 10px;
  padding: 10px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-group label {
  font-size: 13px;
  color: #ddd;
}

select, button {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--gold-dark);
  background: var(--black-soft);
  color: var(--white);
  cursor: pointer;
  transition: all 0.2s;
}

select:hover, button:hover {
  background: var(--gold-dark);
  color: var(--black);
}

button:active {
  transform: scale(0.96);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== STATUS ===== */
.status {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--white);
  transition: all 0.3s;
}

.status.check {
  background: rgba(220, 53, 69, 0.2);
  border-color: #dc3545;
}

.status.win {
  background: rgba(40, 167, 69, 0.2);
  border-color: #28a745;
}

/* ===== TABLA ===== */
.board-wrapper {
  display: flex;
  justify-content: center;
  padding: 4px;
}

.board {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid var(--gold);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.25), inset 0 0 20px rgba(0,0,0,0.5);
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.square.light { background: var(--board-light); }
.square.dark  { background: var(--board-dark); }

.square.selected {
  box-shadow: inset 0 0 0 3px #ffffff, inset 0 0 15px rgba(255,255,255,0.6);
}

.square.valid-move::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.square.valid-capture::after {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  background: transparent;
  pointer-events: none;
}

.square.last-move {
  box-shadow: inset 0 0 0 3px rgba(255, 215, 0, 0.7);
}

.square.check {
  background: radial-gradient(circle, #ff4444 0%, transparent 70%) !important;
}

/* ===== FIGURE ===== */
.piece {
  font-size: clamp(24px, 8vw, 46px);
  line-height: 1;
  pointer-events: none;
  transition: transform 0.1s;
  position: relative;
  z-index: 2;
}

.piece.gold {
  color: var(--gold-light);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0 0 6px rgba(212, 175, 55, 0.8);
}

.piece.black {
  color: #0a0a0a;
  text-shadow:
    -1px -1px 0 var(--gold-light),
     1px -1px 0 var(--gold-light),
    -1px  1px 0 var(--gold-light),
     1px  1px 0 var(--gold-light),
     0 0 4px rgba(212, 175, 55, 0.5);
}

.square:active .piece {
  transform: scale(0.9);
}

/* ===== GAME OVER ===== */
.game-over {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, var(--black-soft), var(--black));
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 24px 32px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  box-shadow: 0 0 40px rgba(212, 175, 55, 0.5);
  z-index: 100;
  max-width: 90vw;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .controls {
    padding: 8px 6px;
  }
  select, button {
    font-size: 12px;
    padding: 5px 8px;
  }
  .status {
    font-size: 13px;
  }
}

@media (min-width: 700px) {
  #app {
    max-width: 640px;
  }
  .board {
    max-width: 580px;
  }
}