/* Chesself - Chess Game Styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50, #4a6fa5);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.status-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 10px;
    display: inline-block;
}

#game-status {
    font-size: 1.2rem;
    font-weight: bold;
}

#result-message {
    color: #ff6b6b;
    margin-left: 15px;
}

main {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-shrink: 0;
}

.board-container {
    position: relative;
    flex-shrink: 0;
}

.ai-thinking {
    margin-top: 10px;
    padding: 10px 20px;
    background: rgba(255, 107, 107, 0.2);
    border: 2px dashed #ff6b6b;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.chess-board {
    border-collapse: collapse;
    border: 4px solid #8b7355;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.chess-board td {
    width: 55px;
    height: 55px;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    position: relative;
}

.chess-board td.light {
    background-color: #f0d9b5;
}

.chess-board td.dark {
    background-color: #b58863;
}

.chess-board td.highlight {
    background-color: #ffeb3b !important;
    border: 2px solid #ff9800;
    padding: 0;
}

.chess-board td.valid-move {
    background-color: rgba(255, 235, 59, 0.5) !important;
}

.chess-board td.tutorial-move {
    background-color: rgba(76, 175, 80, 0.6) !important;
    box-shadow: inset 0 0 0 3px #4CAF50;
}

.piece {
    font-size: 2.2rem;
    user-select: none;
    pointer-events: none;
}

.piece.movable {
    cursor: pointer;
    pointer-events: auto;
}

.piece.white {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.piece.black {
    color: #000;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.sidebar {
    flex-shrink: 0;
    min-width: 200px;
}

.controls {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: translateY(0);
}

.move-history {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.move-history h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

#history-list {
    list-style: none;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.stats {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
}

.stats h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.stats p {
    margin: 8px 0;
}

footer {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    color: #aaa;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    main {
        flex-direction: column;
        gap: 15px;
    }

    .sidebar {
        min-width: 100%;
    }

    .chess-board td {
        width: 45px;
        height: 45px;
        padding: 2px;
    }

    .piece {
        font-size: 1.8rem;
    }

    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .control-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    /* Touch-friendly highlights */
    .chess-board td.valid-move::after,
    .chess-board td.tutorial-move::after {
        width: 20px;
        height: 20px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .chess-board td {
        width: 38px;
        height: 38px;
    }

    .piece {
        font-size: 1.5rem;
    }

    header h1 {
        font-size: 1.8rem;
    }
}

/* Animation for move feedback */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.control-btn.pulse {
    animation: pulse 0.3s ease;
}

/* Modal for game over */
#game-over-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#game-over-modal.active {
    display: flex;
}

.modal-content {
    background: #2c3e50;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    min-width: 300px;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.modal-btn {
    padding: 10px 25px;
    margin: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

/* Toast animations */
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Character Selection Modal */
.character-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.character-modal-content {
    background: linear-gradient(135deg, #2c3e50, #4a6fa5);
    border-radius: 15px;
    padding: 30px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.character-modal-content h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.8rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.character-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.character-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
}

.character-card .emoji {
    font-size: 3rem;
    margin-bottom: 10px;
}

.character-card .name {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.character-card .difficulty {
    font-size: 0.8rem;
    padding: 3px 10px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 8px;
}

.character-card .description {
    font-size: 0.8rem;
    opacity: 0.8;
}

.difficulty.tutorial { background: #3498db; }
.difficulty.veryeasy { background: #2ecc71; }
.difficulty.easy { background: #27ae60; }
.difficulty.careful { background: #f39c12; }
.difficulty.medium { background: #e67e22; }
.difficulty.hard { background: #e74c3c; }
.difficulty.impossible { background: #9b59b6; }

/* Current opponent display */
.current-opponent {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: bold;
}

.current-opponent.clickable {
    cursor: pointer;
    transition: all 0.3s ease;
}

.current-opponent.clickable:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: scale(1.02);
}

.current-opponent .emoji {
    font-size: 1.5rem;
}