@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(50, 50, 60, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(60, 60, 70, 0.1) 0%, transparent 50%);
  z-index: -1;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #333;
}

.title {
  font-size: 2.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
}

.title span {
  color: #64b5f6;
}

.game-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 800px;
  margin: 0 auto;
}

.status-text {
  font-size: 1.3rem;
  font-weight: 500;
  color: #bbbbbb;
}

.status-indicators {
  display: flex;
  gap: 20px;
}

.indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #999;
  font-size: 0.95rem;
}

.indicator i {
  color: #64b5f6;
}

/* Main Layout */
.main-content {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 30px;
  min-height: 70vh;
}

@media (max-width: 1400px) {
  .main-content {
    grid-template-columns: 250px 1fr 280px;
  }
}

@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr 350px;
  }
  .left-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
  }
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
  .right-panel {
    grid-column: 1 / -1;
  }
}

/* Panels */
.left-panel, .right-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.center-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Info Cards */
.info-card {
  background: #252525;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.info-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}

.info-header i {
  color: #64b5f6;
  font-size: 1.2rem;
}

.info-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.move-count {
  margin-left: auto;
  font-size: 0.9rem;
  color: #888;
}

/* Turn Display */
.turn-display {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.turn-color {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #2a2a2a;
  border-radius: 8px;
  border-left: 4px solid #64b5f6;
}

.color-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #444;
}

.color-circle.white {
  background: #f0f0f0;
}

.color-circle.black {
  background: #222;
}

.check-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #2a2a2a;
  border-radius: 8px;
  font-size: 0.95rem;
}

.check-status span {
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.check-status .in-check {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.check-status .no-check {
  color: #4CAF50;
  background: rgba(76, 175, 80, 0.1);
}

/* Settings */
.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #333;
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-row label {
  color: #999;
  font-size: 0.95rem;
}

.settings-btn {
  width: 100%;
  margin-top: 10px;
}

/* Chess Board */
.board-container {
  position: relative;
  margin: 0 auto 30px;
  padding: 10px;
  background: #2a2a2a;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.coordinates {
  position: absolute;
  color: #888;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Roboto Mono', monospace;
  user-select: none;
}

.coordinates.horizontal {
  display: flex;
  justify-content: space-around;
  width: 100%;
  left: 0;
}

.coordinates.horizontal.top {
  top: -20px;
}

.coordinates.horizontal.bottom {
  bottom: -20px;
}

.coordinates.vertical {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 100%;
  top: 0;
}

.coordinates.vertical.left {
  left: -20px;
  text-align: right;
}

.coordinates.vertical.right {
  right: -20px;
  text-align: left;
}

#chessBoard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(70vmin, 600px);
  aspect-ratio: 1;
  border: 2px solid #444;
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  background: #f0f0f0;
}

.cell {
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1;
  font-size: min(4.5vmin, 40px);
  cursor: pointer;
  position: relative;
  transition: background-color 0.1s ease;
}

/* Black and white chess pieces */
.cell.black-piece { 
  color: #222; 
  text-shadow: 0 1px 2px rgba(255,255,255,0.3); 
}

.cell.white-piece { 
  color: #f0f0f0; 
  text-shadow: 0 1px 2px rgba(0,0,0,0.5); 
}

/* Board colors - 2D clean look */
.cell.light {
  background-color: #f0d9b5;
}

.cell.dark {
  background-color: #b58863;
}

/* Hover effects */
.cell:hover {
  filter: brightness(0.95);
}

/* Selection and moves */
.cell.selected {
  background-color: #ffd54f !important;
}

.cell.highlight {
  background-color: rgba(76, 175, 80, 0.6) !important;
}

.cell.possible-move::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24%;
  height: 24%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  pointer-events: none;
}

.cell.possible-capture {
  position: relative;
}

.cell.possible-capture::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 3px solid rgba(244, 67, 54, 0.7);
  border-radius: 2px;
  pointer-events: none;
}

/* Captured Pieces */
.captured-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.captured-section {
  background: #2a2a2a;
  border-radius: 8px;
  padding: 12px;
}

.captured-label {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
}

.captured-piece {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #333;
  border-radius: 4px;
  font-size: 20px;
  color: #bbb;
}

/* Move List */
.move-list-container {
  background: #2a2a2a;
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #333;
}

.move-row {
  display: grid;
  grid-template-columns: 50px 1fr 1fr;
  gap: 10px;
  padding: 10px 15px;
  border-bottom: 1px solid #333;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.95rem;
  transition: background-color 0.2s ease;
}

.move-row:last-child {
  border-bottom: none;
}

.move-row:hover {
  background-color: #333;
}

.move-row.current {
  background-color: rgba(100, 181, 246, 0.1);
  border-left: 3px solid #64b5f6;
}

.move-number {
  color: #888;
  font-weight: 500;
  text-align: right;
}

.move-white, .move-black {
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: 500;
}

.move-white {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.move-black {
  color: #bbb;
  background: rgba(255, 255, 255, 0.03);
}

/* Scrollbar */
.move-list-container::-webkit-scrollbar {
  width: 6px;
}

.move-list-container::-webkit-scrollbar-track {
  background: #2a2a2a;
}

.move-list-container::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

.move-list-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.control-btn {
  padding: 12px 24px;
}

.control-btn.primary {
  background: #64b5f6;
  color: white;
}

.control-btn.primary:hover {
  background: #42a5f5;
  transform: translateY(-2px);
}

.control-btn.secondary {
  background: #555;
  color: #ddd;
  border: 1px solid #666;
}

.control-btn.secondary:hover {
  background: #666;
  border-color: #777;
}

.control-btn.hint {
  background: linear-gradient(135deg, #FFB74D, #FF9800);
  color: white;
}

.control-btn.hint:hover {
  background: linear-gradient(135deg, #FF9800, #F57C00);
}

.small-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  background: #444;
  color: #bbb;
  border: 1px solid #555;
}

.small-btn:hover {
  background: #555;
  color: #ddd;
}

.settings-btn {
  background: #424242;
  color: #ddd;
  border: 1px solid #555;
}

.settings-btn:hover {
  background: #4a4a4a;
}

/* Controls Layout */
.controls {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.primary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.secondary-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* Settings Modal */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.settings-content {
  background: #252525;
  border-radius: 16px;
  padding: 30px;
  width: 90%;
  max-width: 500px;
  border: 1px solid #444;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.settings-content h3 {
  color: #64b5f6;
  margin-bottom: 25px;
  font-size: 1.5rem;
  text-align: center;
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  color: #bbb;
  margin-bottom: 8px;
  font-weight: 500;
}

.setting-group select {
  width: 100%;
  padding: 12px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
}

.setting-group select:focus {
  outline: none;
  border-color: #64b5f6;
}

.setting-buttons {
  display: flex;
  gap: 12px;
  margin-top: 30px;
}

.setting-buttons button {
  flex: 1;
  padding: 12px;
  font-weight: 600;
}

.setting-buttons button:first-child {
  background: #64b5f6;
  color: white;
}

.setting-buttons button:first-child:hover {
  background: #42a5f5;
}

.setting-buttons button:last-child {
  background: #555;
  color: #ddd;
}

.setting-buttons button:last-child:hover {
  background: #666;
}

/* Hint Tooltip */
.hint-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1000;
  pointer-events: none;
  border: 1px solid #64b5f6;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.hint-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #64b5f6 transparent transparent transparent;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }
  
  .title {
    font-size: 2.2rem;
  }
  
  .game-status {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }
  
  .status-indicators {
    gap: 15px;
  }
  
  #chessBoard {
    width: 85vmin;
  }
  
  .primary-controls {
    gap: 8px;
  }
  
  .control-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  
  .move-row {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 1.8rem;
  }
  
  .main-content {
    gap: 20px;
  }
  
  #chessBoard {
    width: 90vmin;
  }
  
  .cell {
    font-size: 5vmin;
  }
  
  .primary-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-btn {
    width: 100%;
  }
}