/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header Styles */
.header {
    background: linear-gradient(90deg, #2c3e50, #34495e);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 50px;
    height: 50px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Ad Banner Styles */
.ad-banner {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    margin: 1rem;
    border-radius: 8px;
}

.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
    min-height: 90px;
}

.top-ad, .bottom-ad {
    max-width: 728px;
    margin: 1rem auto;
}

.vertical-ad {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    width: 160px;
    min-height: 200px;
    margin: 1rem 0;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 180px 1fr 320px;
    gap: 1rem;
    padding: 1rem;
    min-height: 600px;
}

/* Sidebar Styles */
.sidebar {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.left-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Move History */
.move-history-container {
    flex: 1;
}

.move-history-container h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.1rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.move-history {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.move-entry {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.move-number {
    font-weight: bold;
    color: #495057;
    min-width: 30px;
}

.move-white, .move-black {
    flex: 1;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.move-white {
    background: #ffffff;
}

.move-black {
    background: #e9ecef;
}

/* Game Container */
.game-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Player Bars */
.player-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
}

.black-player-bar {
    border-color: #495057;
}

.white-player-bar {
    border-color: #adb5bd;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2c3e50;
}

.player-pieces-taken {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
    font-size: 1.2rem;
}

.timer-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timer {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    min-width: 100px;
    text-align: center;
}

.timer.warning {
    color: #e74c3c;
    border-color: #e74c3c;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Chess Board */
.chess-board-container {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    border: 3px solid #2c3e50;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

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

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

.square:hover {
    background-color: #7fc8f8;
    transform: scale(1.05);
}

.square.selected {
    background-color: #74b816 !important;
    box-shadow: inset 0 0 0 3px #4a7c59;
}

.square.valid-move {
    background-color: #90EE90 !important;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: #228B22;
    border-radius: 50%;
    opacity: 0.7;
}

.square.capture-move {
    background-color: #FFB6C1 !important;
}

.square.capture-move::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid #DC143C;
    border-radius: 50%;
    box-sizing: border-box;
}

.square.in-check {
    background-color: #ff6b6b !important;
    animation: checkPulse 1s infinite;
}

@keyframes checkPulse {
    0%, 100% { background-color: #ff6b6b; }
    50% { background-color: #ff5252; }
}

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

/* Game Status */
.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.game-message {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

.game-controls {
    display: flex;
    gap: 0.5rem;
}

/* Button Styles */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn.primary {
    background: #007bff;
    color: white;
}

.btn.primary:hover {
    background: #0056b3;
}

.btn.secondary {
    background: #6c757d;
    color: white;
}

.btn.secondary:hover {
    background: #545b62;
}

.btn.danger {
    background: #dc3545;
    color: white;
}

.btn.danger:hover {
    background: #c82333;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    text-align: center;
}

.player-setup {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.player-input, .time-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-input label, .time-control label {
    font-weight: bold;
    color: #495057;
}

.player-input input, .time-control select {
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
}

.player-input input:focus, .time-control select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.promotion-pieces {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.promotion-piece {
    font-size: 3rem;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.promotion-piece:hover {
    border-color: #007bff;
    background: #f8f9fa;
    transform: scale(1.1);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 300px;
    }
    
    .left-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .sidebar {
        order: 2;
    }
    
    .game-container {
        order: 1;
        padding: 1rem;
    }
    
    .chess-board {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
    }
    
    .square {
        font-size: 2rem;
    }
    
    .player-bar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .timer-container {
        justify-content: center;
    }
    
    .game-status {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header {
        padding: 0.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .logo {
        width: 40px;
        height: 40px;
    }
    
    .ad-banner {
        margin: 0.5rem;
    }
    
    .vertical-ad {
        width: 100%;
        writing-mode: horizontal-tb;
        min-height: 100px;
    }
}

@media (max-width: 480px) {
    .chess-board {
        grid-template-columns: repeat(8, 35px);
        grid-template-rows: repeat(8, 35px);
    }
    
    .square {
        font-size: 1.5rem;
    }
    
    .timer {
        font-size: 1.2rem;
        padding: 0.4rem 0.8rem;
        min-width: 80px;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .promotion-piece {
        font-size: 2rem;
        padding: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .ad-banner, .timer-controls, .game-controls {
        display: none;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
}
