* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #312e2b;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  max-width: 100%;
}

.board-wrapper {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: 1fr 20px;
  gap: 0;
  background: #312e2b;
  padding: 4px;
  border-radius: 4px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(85vw, 85vh, 560px);
  height: min(85vw, 85vh, 560px);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.square {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: calc(min(85vw, 85vh, 560px) / 10);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  transition: background-color 0.1s;
}

.square.light {
  background: #ebecd0;
}

.square.dark {
  background: #779556;
}

.square.selected {
  background: #f5f682 !important;
}

.square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  background: rgba(0,0,0,0.12);
  border-radius: 50%;
}

.square.legal-capture::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border: 5px solid rgba(0,0,0,0.12);
  border-radius: 50%;
  box-sizing: border-box;
}

.square.last-move {
  background: #f5f682 !important;
}

.square.check {
  background: radial-gradient(ellipse at center, #ff0000 0%, #e70000 25%, rgba(169,0,0,0) 89%) !important;
}

.piece {
  font-size: inherit;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.05s;
  pointer-events: none;
}

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

.coordinates {
  display: flex;
  color: #9e9e9e;
  font-size: 11px;
  font-weight: 600;
}

.coordinates.ranks {
  flex-direction: column;
  justify-content: space-around;
  padding-right: 4px;
  text-align: right;
}

.coordinates.files {
  flex-direction: row;
  justify-content: space-around;
  padding-top: 4px;
  grid-column: 2;
}

.controls {
  display: flex;
  gap: 10px;
}

.controls button {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  background: #81b64c;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.controls button:hover {
  background: #6b9b3f;
}

.controls button:active {
  transform: scale(0.98);
}

.status {
  color: #bababa;
  font-size: 16px;
  font-weight: 500;
}

/* Dragging styles */
.dragging {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  font-size: calc(min(85vw, 85vh, 560px) / 9);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .board-wrapper {
    grid-template-columns: 16px 1fr;
    grid-template-rows: 1fr 16px;
  }

  .coordinates {
    font-size: 9px;
  }

  .controls button {
    padding: 12px 16px;
    font-size: 13px;
  }
}

/* Promotion modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.promotion-modal {
  background: #312e2b;
  padding: 10px;
  border-radius: 8px;
  display: flex;
  gap: 5px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.promotion-option {
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 40px;
  background: #ebecd0;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.promotion-option:hover {
  background: #f5f682;
}
