/* Chess Game Styles */
:root {
  --primary-blue: #2563eb;
  --secondary-teal: #0891b2;
  --accent-orange: #ea580c;
  --success-green: #059669;
  --error-red: #dc2626;
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #111827;
  --neutral-200: #e5e7eb;
  --square-size: 60px;
  --board-border: 2px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #dc2626 0%, #1e40af 100%);
  min-height: 100vh;
  color: var(--neutral-700);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.game-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 16px 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  color: var(--primary-blue);
  text-decoration: none;
  font-weight: 500;
}

.game-header h1 {
  color: var(--neutral-800);
  font-size: 1.5rem;
}

.game-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.lang-btn, #newGameBtn {
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

/* Game Main */
.game-main {
  padding: 20px 0;
}

.game-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px;
}

.game-info {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.game-info > div {
  font-weight: 500;
}

.game-info span:last-child {
  font-weight: 700;
  color: var(--primary-blue);
}

/* Chess Container */
.chess-container {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 32px;
  margin-bottom: 20px;
}

.chess-board {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  grid-template-rows: repeat(8, var(--square-size));
  gap: 0;
  justify-content: center;
  border: var(--board-border) solid #8b5cf6;
}

.chess-square {
  width: var(--square-size);
  height: var(--square-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  user-select: none;
  touch-action: manipulation;
  min-width: 44px;
  min-height: 44px;
}

.chess-square.light {
  background: #f0d9b5;
}

.chess-square.dark {
  background: #b58863;
}

.chess-square:hover {
  background: rgba(37, 99, 235, 0.3);
}

/* Touch-specific styles */
@media (pointer: coarse) {
  .chess-square:active {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px var(--primary-blue);
  }
  
  .chess-piece {
    font-size: 24px;
    padding: 4px;
  }
}

.chess-square.selected {
  background: rgba(234, 88, 12, 0.6) !important;
  box-shadow: inset 0 0 0 3px var(--accent-orange);
}

.chess-square.valid-move {
  background: rgba(5, 150, 105, 0.4) !important;
}

.chess-square.valid-move::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--success-green);
  border-radius: 50%;
  opacity: 0.7;
}

.chess-square.capture-move {
  background: rgba(220, 38, 38, 0.4) !important;
}

.chess-square.capture-move::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border: 3px solid var(--error-red);
  border-radius: 4px;
}

/* Chess Pieces */
.chess-piece {
  font-size: 32px;
  cursor: pointer;
  transition: transform 0.2s;
  z-index: 10;
}

.chess-piece:hover {
  transform: scale(1.1);
}

.chess-piece.dragging {
  opacity: 0.7;
  transform: scale(1.2);
  z-index: 1000;
}

/* Sidebar */
.game-sidebar {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 20px;
  height: fit-content;
}

.captured-pieces h3,
.move-history h3 {
  color: var(--neutral-800);
  margin-bottom: 12px;
  font-size: 1rem;
}

.captured-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  min-height: 40px;
  padding: 8px;
  background: var(--neutral-50);
  border-radius: 6px;
}

.captured-piece {
  font-size: 20px;
  opacity: 0.7;
}

.move-list {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.875rem;
  background: var(--neutral-50);
  padding: 8px;
  border-radius: 6px;
}

.move-item {
  padding: 4px 0;
  border-bottom: 1px solid var(--neutral-200);
}

.move-item:last-child {
  border-bottom: none;
}

/* Game Actions */
.game-actions {
  text-align: center;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.game-actions button {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.game-actions button:hover:not(:disabled) {
  background: white;
  transform: translateY(-2px);
}

.game-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#resignBtn {
  background: var(--error-red);
  color: white;
}

#resignBtn:hover {
  background: #b91c1c;
}

/* Game Instructions */
.game-instructions {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 24px;
  margin-top: 20px;
}

.game-instructions h3 {
  color: var(--neutral-800);
  margin-bottom: 16px;
  text-align: center;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.instruction-item {
  background: var(--neutral-50);
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}

.instruction-item h4 {
  color: var(--primary-blue);
  margin-bottom: 8px;
  font-size: 1rem;
}

.instruction-item p {
  color: var(--neutral-900);
  font-size: 0.875rem;
}

.game-rules {
  background: var(--neutral-50);
  padding: 16px;
  border-radius: 8px;
}

.game-rules h4 {
  color: var(--neutral-800);
  margin-bottom: 12px;
}

.game-rules ul {
  list-style-type: disc;
  padding-left: 20px;
}

.game-rules li {
  color: var(--neutral-900);
  margin-bottom: 8px;
  font-size: 0.875rem;
}

/* Fixed Privacy Controls */
.fixed-privacy-controls {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}

.privacy-choices-btn {
  background: var(--neutral-800);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive Design */
@media (max-width: 768px) {
  .chess-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .game-sidebar {
    order: -1;
  }
  
  :root {
    --square-size: 45px;
  }
  
  .chess-piece {
    font-size: 24px;
  }
  
  .captured-piece {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  :root {
    --square-size: 35px;
  }
  
  .chess-piece {
    font-size: 20px;
  }
  
  .chess-board {
    padding: 16px;
  }
  
  .game-actions {
    flex-wrap: wrap;
  }
  
  .game-actions button {
    padding: 10px 16px;
    font-size: 0.875rem;
  }
}

/* Accessibility */
.chess-square:focus {
  outline: 3px solid var(--accent-orange);
  outline-offset: 2px;
}

.chess-piece:focus {
  outline: 3px solid var(--accent-orange);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .chess-piece,
  .chess-square {
    transition: none;
  }
}

/* Check and Checkmate indicators */
.chess-square.in-check {
  background: rgba(220, 38, 38, 0.6) !important;
  animation: check-pulse 1s ease-in-out infinite alternate;
}

@keyframes check-pulse {
  from { box-shadow: inset 0 0 0 2px var(--error-red); }
  to { box-shadow: inset 0 0 0 4px var(--error-red); }
}