/* ===== GLOBAL STYLES ===== */
:root {
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --accent: #a78bfa;
  --bg: #0f0f1a;
  --card: rgba(30, 30, 50, 0.6);
  --text: #e0e0ff;
  --gray: #9ca3af;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --white-piece: #fff;
  --black-piece: #222;
  --gold: #ffd700;
  --success: #4caf50;
  --warning: #ffc107;
  --danger: #f44336;
}

* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, #0f0f1a, #1a0033);
  color: var(--text);
  min-height: 100vh;
  padding: 1.5rem;
  background-attachment: fixed;
}

/* ===== INDEX PAGE STYLES ===== */
.container {
  max-width: 960px;
  margin: 0 auto;
  background: var(--card);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  border: 1px solid rgba(124,58,237,0.15);
  padding: 3rem 2rem;
  box-shadow: 0 30px 70px rgba(0,0,0,0.7);
}

h1 {
  font-size: 3.8rem;
  text-align: center;
  margin-bottom: 0.8rem;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.subtitle {
  text-align: center;
  color: var(--gray);
  font-size: 1.3rem;
  margin-bottom: 3rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 2rem;
}

.card {
  background: rgba(30,30,50,0.5);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
}

.card:hover {
  transform: translateY(-12px) scale(1.03);
  border-color: var(--primary);
  box-shadow: 0 25px 50px rgba(124,58,237,0.25);
}

.card i {
  font-size: 4.2rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
  transition: transform 0.4s;
}

.card:hover i { 
  transform: rotate(10deg) scale(1.1); 
}

.card h3 { 
  font-size: 1.8rem; 
  margin-bottom: 1rem; 
}

.card p { 
  color: var(--gray); 
  line-height: 1.6; 
  margin-bottom: 1.5rem; 
}

/* Inputs and Buttons */
input[type="text"] {
  width: 100%;
  padding: 1rem 1.4rem;
  margin: 1.2rem 0;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: white;
  font-size: 1.15rem;
  transition: all 0.3s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}

.btn {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  padding: 1rem 2.5rem;
  border-radius: 12px;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px rgba(124,58,237,0.35);
}

.btn-danger {
  background: linear-gradient(90deg, #dc3545, #c82333);
}

.btn-success {
  background: linear-gradient(90deg, var(--success), #2e7d32);
}

/* Rules Section */
.rules {
  margin-top: 3.5rem;
  padding: 2rem;
  background: rgba(0,0,0,0.25);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
}

.rules h3 { 
  color: var(--accent); 
  margin-bottom: 1.2rem; 
  font-size: 1.5rem; 
}

.rules ul { 
  list-style: none; 
}

.rules li {
  padding: 0.8rem 0;
  padding-left: 2rem;
  position: relative;
  color: #d1d5ff;
}

.rules li:before {
  content: "★";
  position: absolute;
  left: 0.5rem;
  color: var(--primary);
}

/* ===== PLAY PAGE STYLES ===== */
.game-container {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 350px;
  grid-template-rows: auto 1fr;
  gap: 20px;
  padding: 20px;
}

.game-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: rgba(30,30,50,0.6);
  border-radius: 15px;
  border: 1px solid var(--primary);
}

.player-info {
  display: flex;
  gap: 30px;
}

.player-card {
  padding: 15px 25px;
  border-radius: 12px;
  min-width: 250px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.player-you { 
  background: rgba(124,58,237,0.2);
  border: 2px solid var(--primary);
}

.player-opponent { 
  background: rgba(30,30,50,0.4);
  border: 1px solid #444;
}

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.avatar-white { background: white; color: #333; }
.avatar-black { background: #333; color: white; }

.player-details h3 {
  margin-bottom: 5px;
  font-size: 1.2rem;
}

.player-color {
  font-size: 0.9rem;
  opacity: 0.8;
}

.game-code-display {
  background: rgba(0,0,0,0.3);
  padding: 10px 20px;
  border-radius: 8px;
  font-family: monospace;
  letter-spacing: 2px;
}

/* Board Section */
.board-section {
  position: relative;
  padding: 20px;
  background: rgba(20,20,40,0.5);
  border-radius: 15px;
}

.board-with-coords {
  position: relative;
  width: 640px;
  height: 640px;
  margin: 0 auto;
}

.board-grid {
  position: absolute;
  top: 40px;
  left: 40px;
  width: 560px;
  height: 560px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 4px solid #2a2a4a;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.7);
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.square.light { background: var(--board-light); }
.square.dark { background: var(--board-dark); }
.square.highlight { background: rgba(0,255,0,0.3) !important; }
.square.selected { 
  box-shadow: inset 0 0 0 4px var(--gold);
  z-index: 2;
}

.piece {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  z-index: 3;
}

.piece.white { 
  background: radial-gradient(circle at 30% 30%, #fff, #e0e0e0);
  border: 2px solid #ccc;
}

.piece.black { 
  background: radial-gradient(circle at 30% 30%, #333, #000);
  border: 2px solid #111;
}

.piece.king::after {
  content: "♔";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: var(--gold);
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Board Coordinates */
.coords-vertical {
  position: absolute;
  left: 0;
  top: 40px;
  width: 40px;
  height: 560px;
  display: flex;
  flex-direction: column;
}

.coords-horizontal {
  position: absolute;
  top: 0;
  left: 40px;
  width: 560px;
  height: 40px;
  display: flex;
}

.coord-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #aaa;
  user-select: none;
}

.coord-vertical {
  flex: 1;
  font-size: 18px;
}

.coord-horizontal {
  flex: 1;
  font-size: 18px;
}

/* Game Status */
.game-status {
  padding: 20px;
  text-align: center;
  border-radius: 12px;
  margin-top: 20px;
  font-size: 1.3rem;
  font-weight: bold;
}

.status-waiting { background: rgba(255,193,7,0.2); color: #ffc107; }
.status-your-turn { background: rgba(76,175,80,0.2); color: #4caf50; }
.status-opponent-turn { background: rgba(244,67,54,0.2); color: #f44336; }
.status-finished { background: rgba(156,39,176,0.2); color: #9c27b6; }

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-panel, .moves-panel, .chat-panel {
  background: rgba(30,30,50,0.6);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid rgba(124,58,237,0.2);
}

.panel-title {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 1.2rem;
  color: var(--accent);
}

.moves-list {
  max-height: 300px;
  overflow-y: auto;
}

.move-item {
  padding: 8px 12px;
  margin-bottom: 5px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  font-family: monospace;
  display: flex;
  justify-content: space-between;
}

.game-controls {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* Chat Styles */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 15px;
  max-height: 300px;
}

.message {
  background: white;
  padding: 10px 15px;
  border-radius: 10px;
  margin-bottom: 10px;
  max-width: 80%;
}

.message.you {
  margin-left: auto;
  background: #e3f2fd;
}

.chat-input {
  display: flex;
  gap: 10px;
}

#chatInput {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
}

.chat-input button {
  background: #667eea;
  color: white;
  border: none;
  width: 45px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
}

/* ===== RESPONSIVE STYLES ===== */
@media (max-width: 1200px) {
  .game-container {
    grid-template-columns: 1fr;
  }
  
  .board-with-coords {
    width: 90vw;
    height: 90vw;
    max-width: 500px;
    max-height: 500px;
  }
  
  .board-grid {
    width: calc(100% - 80px);
    height: calc(100% - 80px);
    top: 40px;
    left: 40px;
  }
  
  .piece {
    width: 70%;
    height: 70%;
  }
}

@media (max-width: 768px) {
  .container { 
    padding: 2rem 1.2rem; 
  }
  
  h1 { 
    font-size: 2.8rem; 
  }
  
  .cards { 
    grid-template-columns: 1fr; 
  }
  
  .board-with-coords {
    width: 95vw;
    height: 95vw;
  }
  
  .game-header {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }
  
  .player-info {
    flex-direction: column;
    gap: 10px;
  }
  
  .player-card {
    min-width: auto;
    width: 100%;
  }
}