/* Chess Master - Main Styles */

:root {
    --primary-color: #1a73e8;
    --secondary-color: #34a853;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --light-square: #f0d9b5;
    --dark-square: #b58863;
    --highlight-move: rgba(20, 85, 30, 0.5);
    --highlight-check: rgba(255, 0, 0, 0.4);
    --selected-piece: rgba(20, 85, 30, 0.8);
    --bg-color: #1e1e1e;
    --panel-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --border-color: #404040;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    color: var(--text-color);
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-mode-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: var(--panel-bg);
    color: var(--text-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
}

.mode-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.mode-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.game-layout {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1400px) {
    .game-layout {
        grid-template-columns: 250px 1fr 250px;
    }
}

@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
    .left-panel, .right-panel {
        max-width: 600px;
        margin: 0 auto;
    }
}

/* Panels */
.left-panel, .right-panel {
    background: var(--panel-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.player-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.player-name {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
}

.player-clock {
    font-size: 2em;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: var(--secondary-color);
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    margin-bottom: 10px;
}

.player-clock.active {
    background: rgba(26, 115, 232, 0.3);
    box-shadow: 0 0 10px rgba(26, 115, 232, 0.5);
}

.player-clock.low-time {
    color: var(--danger-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 30px;
    padding: 10px 0;
}

.captured-piece {
    width: 24px;
    height: 24px;
    font-size: 20px;
}

/* Chessboard Container */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 640px;
    height: 640px;
    border: 3px solid #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

@media (max-width: 768px) {
    .chessboard {
        width: 90vw;
        height: 90vw;
        max-width: 640px;
        max-height: 640px;
    }
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.square.light {
    background-color: var(--light-square);
}

.square.dark {
    background-color: var(--dark-square);
}

.square.selected {
    background-color: var(--selected-piece) !important;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.square.valid-move::after {
    content: '';
    width: 30%;
    height: 30%;
    background-color: var(--highlight-move);
    border-radius: 50%;
    position: absolute;
}

.square.valid-capture::after {
    content: '';
    width: 85%;
    height: 85%;
    border: 4px solid var(--highlight-move);
    border-radius: 50%;
    position: absolute;
}

.square.last-move {
    background-color: rgba(255, 255, 0, 0.3);
}

.square.in-check {
    background-color: var(--highlight-check) !important;
    animation: check-pulse 0.5s ease-in-out;
}

@keyframes check-pulse {
    0%, 100% { box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.8); }
    50% { box-shadow: inset 0 0 40px rgba(255, 0, 0, 1); }
}

.square-label {
    position: absolute;
    font-size: 12px;
    font-weight: bold;
    opacity: 0.7;
}

.square-label.file {
    bottom: 2px;
    right: 4px;
}

.square-label.rank {
    top: 2px;
    left: 4px;
}

.square.light .square-label {
    color: var(--dark-square);
}

.square.dark .square-label {
    color: var(--light-square);
}

/* Game Status */
.game-status {
    padding: 15px 30px;
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.3em;
    font-weight: bold;
    text-align: center;
    min-width: 300px;
}

/* Controls */
.game-controls, .move-controls {
    margin-bottom: 20px;
}

.game-controls h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.control-group select,
.control-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 1em;
}

.control-group input {
    margin-bottom: 10px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1557b0;
    box-shadow: 0 4px 8px rgba(26, 115, 232, 0.3);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #2d8e47;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c5351f;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.9em;
}

.move-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.move-controls .btn {
    margin-bottom: 0;
}

/* Move History */
.move-history {
    margin-bottom: 20px;
}

.move-history h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.move-list {
    max-height: 300px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
}

.move-entry {
    padding: 5px;
    margin: 2px 0;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.2s;
}

.move-entry:hover {
    background: rgba(26, 115, 232, 0.3);
}

.move-entry.current {
    background: var(--primary-color);
    color: white;
}

/* Analysis Panel */
.analysis-panel {
    margin-bottom: 20px;
}

.analysis-panel h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.evaluation-bar {
    margin-bottom: 15px;
}

.eval-score {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.eval-bar-container {
    height: 20px;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.eval-bar-white {
    height: 100%;
    background: linear-gradient(90deg, #fff 0%, #ddd 100%);
    width: 50%;
    transition: width 0.3s ease;
}

.best-move, .opening-name {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.export-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.export-controls .btn {
    margin-bottom: 0;
}

.export-controls .btn:last-child {
    grid-column: 1 / -1;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--panel-bg);
    margin: 10% auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: white;
}

.modal h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

/* Online Play */
.online-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.room-input {
    display: flex;
    gap: 10px;
}

.room-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 5px;
}

#room-info {
    padding: 15px;
    background: rgba(52, 168, 83, 0.2);
    border-radius: 5px;
    border: 1px solid var(--secondary-color);
}

/* Tournament */
.tournament-setup label {
    display: block;
    margin: 10px 0 5px;
}

.tournament-setup select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 5px;
    margin-bottom: 15px;
}

.bracket-container {
    margin-top: 20px;
    overflow-x: auto;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
