/** * Complete CSS Example - Chess Board Styling * Use this as a reference for styling the chess game */ /* ==================== GLOBAL STYLES ==================== */ :root { /* Board dimensions */ --board-size: 600px; --square-size: calc(var(--board-size) / 8); /* Colors */ --light-square: #f0d9b5; --dark-square: #b58863; --highlight-selected: rgba(255, 255, 0, 0.4); --highlight-valid-move: rgba(0, 255, 0, 0.3); --highlight-check: rgba(255, 0, 0, 0.5); --highlight-last-move: rgba(255, 255, 0, 0.2); /* Piece colors */ --piece-white: #ffffff; --piece-black: #000000; /* UI colors */ --bg-primary: #2c3e50; --bg-secondary: #34495e; --text-primary: #ecf0f1; --text-secondary: #bdc3c7; --accent: #3498db; /* Spacing */ --spacing-xs: 4px; --spacing-sm: 8px; --spacing-md: 16px; --spacing-lg: 24px; --spacing-xl: 32px; /* Animations */ --transition-fast: 0.15s; --transition-medium: 0.3s; --transition-slow: 0.5s; } /* ==================== LAYOUT ==================== */ * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg-primary); color: var(--text-primary); display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: var(--spacing-lg); } .game-container { display: grid; grid-template-columns: auto 1fr auto; gap: var(--spacing-xl); max-width: 1400px; } /* ==================== CHESS BOARD ==================== */ .board-container { position: relative; } .board { display: grid; grid-template-columns: repeat(8, var(--square-size)); grid-template-rows: repeat(8, var(--square-size)); border: 2px solid var(--text-secondary); box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); } /* ==================== SQUARES ==================== */ .square { width: var(--square-size); height: var(--square-size); display: flex; align-items: center; justify-content: center; position: relative; transition: background-color var(--transition-fast); cursor: pointer; } /* Alternating colors */ .square--light { background-color: var(--light-square); } .square--dark { background-color: var(--dark-square); } /* Square states */ .square--selected { background-color: var(--highlight-selected) !important; box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.8); } .square--valid-move { cursor: pointer; } .square--valid-move::after { content: ''; position: absolute; width: 30%; height: 30%; background-color: var(--highlight-valid-move); border-radius: 50%; pointer-events: none; } /* Valid move on occupied square (capture) */ .square--valid-move.square--occupied::after { width: 90%; height: 90%; background-color: transparent; border: 3px solid rgba(255, 0, 0, 0.5); border-radius: 50%; } .square--check { background-color: var(--highlight-check) !important; animation: pulse-check 1s infinite; } .square--last-move { background-color: var(--highlight-last-move); } /* Hover effects */ .square:hover { filter: brightness(1.1); } /* ==================== COORDINATES ==================== */ .coordinates { position: absolute; font-size: 12px; font-weight: bold; color: var(--text-secondary); user-select: none; } .coordinate--file { bottom: 2px; right: 4px; } .coordinate--rank { top: 2px; left: 4px; } /* ==================== PIECES ==================== */ .piece { font-size: calc(var(--square-size) * 0.7); cursor: grab; user-select: none; transition: transform var(--transition-fast); pointer-events: auto; } .piece:hover { transform: scale(1.1); } .piece:active { cursor: grabbing; } .piece--dragging { opacity: 0.5; cursor: grabbing; } /* Piece colors using filters (if using images) */ .piece--white { filter: brightness(1.2); } .piece--black { filter: brightness(0.3); } /* ==================== GAME INFO ==================== */ .game-info { background: var(--bg-secondary); padding: var(--spacing-lg); border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } .game-info h1 { font-size: 28px; margin-bottom: var(--spacing-md); color: var(--accent); } .turn-indicator { padding: var(--spacing-md); background: var(--bg-primary); border-radius: 4px; text-align: center; margin-bottom: var(--spacing-md); font-weight: bold; font-size: 18px; } .turn-indicator--white { color: #fff; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } .turn-indicator--black { color: #fff; background: linear-gradient(135deg, #434343 0%, #000000 100%); } .status-message { padding: var(--spacing-sm); border-radius: 4px; text-align: center; margin-top: var(--spacing-md); } .status-message--info { background: rgba(52, 152, 219, 0.2); border: 1px solid var(--accent); } .status-message--warning { background: rgba(230, 126, 34, 0.2); border: 1px solid #e67e22; color: #e67e22; } .status-message--error { background: rgba(231, 76, 60, 0.2); border: 1px solid #e74c3c; color: #e74c3c; } .status-message--success { background: rgba(46, 204, 113, 0.2); border: 1px solid #2ecc71; color: #2ecc71; } /* ==================== CONTROLS ==================== */ .game-controls { background: var(--bg-secondary); padding: var(--spacing-lg); border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); display: flex; flex-direction: column; gap: var(--spacing-md); } button { padding: var(--spacing-md); background: var(--accent); color: white; border: none; border-radius: 4px; font-size: 16px; font-weight: bold; cursor: pointer; transition: all var(--transition-fast); } button:hover { background: #2980b9; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } button:active { transform: translateY(0); } button:disabled { opacity: 0.5; cursor: not-allowed; } /* ==================== CAPTURED PIECES ==================== */ .captured-pieces { display: flex; flex-direction: column; gap: var(--spacing-md); } .captured-section { background: var(--bg-primary); padding: var(--spacing-md); border-radius: 4px; } .captured-section h3 { font-size: 14px; margin-bottom: var(--spacing-sm); color: var(--text-secondary); } .captured-list { display: flex; flex-wrap: wrap; gap: var(--spacing-xs); } .captured-piece { font-size: 24px; opacity: 0.6; } /* ==================== ANIMATIONS ==================== */ @keyframes pulse-check { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } } @keyframes piece-move { from { transform: scale(1); } 50% { transform: scale(1.2); } to { transform: scale(1); } } @keyframes piece-capture { from { transform: scale(1) rotate(0deg); opacity: 1; } to { transform: scale(0) rotate(180deg); opacity: 0; } } .piece--moving { animation: piece-move var(--transition-medium) ease; } .piece--captured { animation: piece-capture var(--transition-medium) ease forwards; } /* ==================== RESPONSIVE DESIGN ==================== */ @media (max-width: 1200px) { .game-container { grid-template-columns: 1fr; grid-template-rows: auto auto auto; } :root { --board-size: 480px; } } @media (max-width: 600px) { :root { --board-size: 320px; } body { padding: var(--spacing-sm); } .piece { font-size: calc(var(--square-size) * 0.6); } } /* ==================== MODAL (for pawn promotion) ==================== */ .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; z-index: 1000; } .modal { background: var(--bg-secondary); padding: var(--spacing-xl); border-radius: 8px; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4); } .modal h2 { margin-bottom: var(--spacing-lg); text-align: center; } .promotion-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--spacing-md); } .promotion-choice { padding: var(--spacing-lg); font-size: 48px; background: var(--bg-primary); border: 2px solid transparent; cursor: pointer; transition: all var(--transition-fast); } .promotion-choice:hover { background: var(--accent); border-color: white; transform: scale(1.1); } /* ==================== DRAG AND DROP ==================== */ .square--drag-over { background-color: var(--highlight-valid-move) !important; } .no-select { user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; }