/**
 * Chess Game Styles
 * Modern, responsive design for 800x800 iframe
 */

/* CSS Variables */
:root {
    /* Colors */
    --color-primary: #2c3e50;
    --color-secondary: #3498db;
    --color-accent: #e74c3c;
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-hint: #8e44ad;
    --color-special: #16a085;

    /* Board colors */
    --board-light: #f0d9b5;
    --board-dark: #b58863;
    --board-selected: rgba(255, 255, 0, 0.5);
    --board-legal-move: rgba(0, 0, 0, 0.1);
    --board-capture: rgba(255, 0, 0, 0.3);
    --board-last-move: rgba(155, 199, 0, 0.4);
    --board-check: rgba(255, 0, 0, 0.5);
    --board-hint: rgba(0, 150, 255, 0.4);

    /* Text */
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #ffffff;

    /* Backgrounds */
    --bg-primary: #ecf0f1;
    --bg-secondary: #ffffff;
    --bg-dark: #2c3e50;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    --font-size-sm: 12px;
    --font-size-md: 14px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html,
body {
    height: 100%;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 1298px;
    min-height: 600px;
    max-height: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    /* Board size - accessible to both board-wrapper and side-panel */
    --board-size: min(calc(100vw - var(--spacing-md) * 2), calc(100vh - 120px), 680px);
}

/* Game Layout (Board + Side Panel) */
.game-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
    /* Side panel fills full height */
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-dark);
    color: var(--text-light);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.game-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
}

.turn-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-md);
}

.turn-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    transition: background-color var(--transition-fast);
}

.turn-indicator.white {
    background: #fff;
    color: #333;
}

.turn-indicator.black {
    background: #333;
    color: #fff;
}

.turn-label {
    opacity: 0.8;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.select-label {
    font-size: var(--font-size-md);
    font-weight: 500;
    opacity: 0.9;
}

/* Header select control - match button height */
.header-right .select-control {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-md);
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    height: auto;
}

.header-right .select-control:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-right .select-control option {
    background: var(--bg-dark);
    color: var(--text-light);
}

/* Buttons */
.btn {
    gap: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: var(--font-size-md);
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-secondary);
    color: var(--text-light);
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-sm {
    padding: 2px 8px;
    font-size: var(--font-size-md);
    min-width: 28px;
}

/* Secondary button on light background */
.side-panel .btn-secondary {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-secondary);
    font-weight: 600;
}

.side-panel .btn-secondary:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.12);
    color: var(--text-primary);
}


/* Status Bar */
.status-bar {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    text-align: center;
    flex-shrink: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-message {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    border-radius: 25px;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

/* Status message types */
.status-message.status-info {
    color: #2980b9;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(52, 152, 219, 0.06));
    border-color: rgba(52, 152, 219, 0.2);
}

.status-message.status-success {
    color: #1e8449;
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.2), rgba(46, 204, 113, 0.1));
    border-color: rgba(39, 174, 96, 0.35);
    box-shadow: 0 3px 12px rgba(39, 174, 96, 0.2);
}

.status-message.status-warning {
    color: #c0392b;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.18), rgba(192, 57, 43, 0.1));
    border-color: rgba(231, 76, 60, 0.35);
    box-shadow: 0 3px 12px rgba(231, 76, 60, 0.25);
    font-weight: 800;
}

.status-message.status-danger {
    color: #c0392b;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.15), rgba(192, 57, 43, 0.08));
    border-color: rgba(231, 76, 60, 0.3);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.2);
}

.status-message.status-thinking {
    color: #5a6268;
    background: linear-gradient(135deg, rgba(52, 73, 94, 0.15), rgba(44, 62, 80, 0.08));
    border-color: rgba(52, 73, 94, 0.25);
    box-shadow: 0 3px 12px rgba(52, 73, 94, 0.15);
    font-style: italic;
}

/* Animated thinking indicator */
.status-message.status-thinking::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #5a6268;
    border-radius: 50%;
    animation: thinkingPulse 1s ease-in-out infinite;
}

@keyframes thinkingPulse {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.status-message.status-hint {
    color: #8e44ad;
    background: linear-gradient(135deg, rgba(142, 68, 173, 0.15), rgba(155, 89, 182, 0.08));
    border-color: rgba(142, 68, 173, 0.25);
    box-shadow: 0 2px 8px rgba(142, 68, 173, 0.15);
}

.status-message.status-capture {
    color: #c0392b;
    background: linear-gradient(135deg, rgba(192, 57, 43, 0.15), rgba(231, 76, 60, 0.08));
    border-color: rgba(192, 57, 43, 0.25);
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.15);
}

.status-message.status-special {
    color: #16a085;
    background: linear-gradient(135deg, rgba(22, 160, 133, 0.15), rgba(26, 188, 156, 0.08));
    border-color: rgba(22, 160, 133, 0.25);
    box-shadow: 0 2px 8px rgba(22, 160, 133, 0.15);
}

/* Status message icon */
.status-icon {
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
    font-style: normal;
}

/* Animations */
.status-message.fade-in {
    animation: statusFadeIn 0.3s ease-out;
}

.status-message.bounce {
    animation: statusBounce 0.5s ease-out;
}

.status-message.shake {
    animation: statusShake 0.5s ease-out;
}

@keyframes statusFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes statusBounce {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes statusShake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-3px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(3px);
    }
}

/* Pulse animation for important states */
.status-message.pulse {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }

    50% {
        box-shadow: 0 0 0 4px transparent;
        opacity: 0.85;
    }
}

/* Thinking animation (dots) */
.status-message.status-thinking .thinking-dots::after {
    content: '';
    animation: thinkingDots 1.5s infinite;
}

@keyframes thinkingDots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

/* Pulse animation for important messages */
.status-message.pulse {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Main Game Area */
.game-main {
    flex: 0 0 auto;
    /* Don't grow, use natural size */
    display: flex;
    align-items: flex-start;
    /* Align board to top */
    justify-content: center;
    padding: var(--spacing-sm);
    min-height: 0;
}

.board-wrapper {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    flex-shrink: 0;
}

/* Side Panel */
.side-panel {
    display: none;
    /* Hidden by default on mobile */
    flex-direction: column;
    flex: 1;
    /* Fill all remaining space */
    min-width: 250px;
    background: var(--bg-primary);
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-section {

    /* Panel Header */
    .panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--spacing-sm) var(--spacing-md);
        background: var(--bg-secondary);
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        flex-shrink: 0;
    }

    .panel-header-title {
        font-size: var(--font-size-md);
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .btn-icon {
        background: transparent;
        border: none;
        padding: 4px 8px;
        font-size: 16px;
        cursor: pointer;
        border-radius: 4px;
        transition: background 0.2s ease;
    }

    .btn-icon:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    display: flex;
    flex-direction: column;
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    background: var(--bg-secondary);
    border-radius: 8px;
    margin: var(--spacing-xs);
}

.panel-section:last-child {
    flex: 1;
    min-height: 0;
}

.panel-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 var(--spacing-sm) 0;
    display: flex;
    align-items: center;
}

.panel-icon {
    margin-right: var(--spacing-xs);
    font-size: var(--font-size-md);
}

/* Evaluation Bar Section */
.eval-section {
    flex-shrink: 0;
}

.eval-bar-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.eval-icon {
    font-size: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    transform: translateY(-2px);
    /* Slight upward shift for visual centering */
}

.eval-icon-white {
    color: #d4a017;
    /* Bright gold for visibility */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.eval-icon-black {
    color: #222;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.eval-bar {
    flex: 1;
    height: 20px;
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(to right, #f0e6d3 50%, #333 50%);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.15);
    position: relative;
}

/* Center marker (50% = equal position) */
.eval-bar::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(128, 128, 128, 0.6);
    transform: translateX(-50%);
    z-index: 1;
}

.eval-white {
    background: #f0e6d3;
    /* Cream/ivory - visible against white background */
    height: 100%;
    transition: width 0.5s ease;
    width: 50%;
}

.eval-black {
    background: #333;
    height: 100%;
    transition: width 0.5s ease;
    width: 50%;
}

.eval-label {
    font-size: var(--font-size-md);
    font-weight: 700;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    min-width: 45px;
    text-align: right;
    color: var(--text-primary);
}

.eval-label.positive {
    color: var(--color-success);
}

.eval-label.negative {
    color: var(--color-accent);
}

/* Opening Name Display */
.opening-name {
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-sm) 0;
    margin-right: var(--spacing-sm);
    margin-left: var(--spacing-sm);
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid var(--color-secondary);
    border-radius: 4px;
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: opacity 0.3s ease;
}

.opening-name.hidden {
    display: none;
}

.opening-name::before {
    content: '📖';
    font-size: 1.1em;
}

/* Captured Pieces Section */
.captured-section {
    flex-shrink: 0;
}

.captured-pieces {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.captured-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-height: 32px;
}

.captured-color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0, 0, 0, 0.2);
}

.captured-color-indicator.white {
    background: #fff;
}

.captured-color-indicator.black {
    background: #333;
}

.captured-slots {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 28px;
}

.captured-slot {
    font-size: 20px;
    line-height: 1;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Force consistent text rendering for chess symbols */
    font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', 'Apple Symbols', sans-serif;
    font-variant: normal;
    text-rendering: optimizeLegibility;
}

.captured-slot.empty {
    opacity: 0.15;
}

.captured-slot.filled {
    opacity: 1;
    animation: pieceCapture 0.4s ease;
}

@keyframes pieceCapture {
    0% {
        opacity: 0;
        transform: scale(1.5);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.material-balance {
    font-size: var(--font-size-md);
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    min-width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.material-balance:empty,
.material-balance.neutral {
    display: none;
}

.material-balance.positive {
    color: #fff;
    background: var(--color-success);
}

.material-balance.negative {
    color: #fff;
    background: var(--color-accent);
}

/* AI Analysis Section */
.ai-section {
    flex-shrink: 0;
}

.ai-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.ai-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-stat:last-of-type {
    border-bottom: none;
}

.ai-stat-label {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
}

.ai-stat-value {
    font-size: var(--font-size-md);
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--text-primary);
}

.ai-thinking-indicator {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: var(--spacing-sm) 0;
}

.ai-thinking-indicator.active {
    display: flex;
}

.ai-thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-secondary);
    animation: aiThinkingPulse 1.4s infinite ease-in-out both;
}

.ai-thinking-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-thinking-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes aiThinkingPulse {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Move History Section */
.history-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.move-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    /* No fixed max-height - fills remaining space in side panel */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    border-radius: 4px;
}

.move-history::-webkit-scrollbar {
    width: 6px;
}

.move-history::-webkit-scrollbar-track {
    background: transparent;
}

.move-history::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.move-history::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.move-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-md);
}

.move-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.move-table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    padding: var(--spacing-sm) var(--spacing-xs);
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.move-table td {
    padding: var(--spacing-sm) var(--spacing-xs);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-weight: 500;
}

/* Zebra striping for better readability */
.move-table tbody tr:nth-child(odd) {
    background: rgba(0, 0, 0, 0.02);
}

.move-table tbody tr:nth-child(even) {
    background: transparent;
}

.move-table tbody tr:hover {
    background: rgba(52, 152, 219, 0.08);
}

/* Last move highlight */
.move-table tbody tr.last-move {
    background: rgba(52, 152, 219, 0.15);
    position: relative;
}

.move-table tbody tr.last-move::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-secondary);
}

/* New move animation */
.move-table tbody tr.new-move {
    animation: moveSlideIn 0.3s ease-out;
}

@keyframes moveSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
        background: rgba(52, 152, 219, 0.3);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.move-num-header {
    width: 30px;
}

.move-num {
    color: var(--text-secondary);
    font-weight: 600;
}

.move-empty {
    color: var(--text-secondary);
    font-size: var(--font-size-md);
    font-style: italic;
    text-align: center;
    padding: var(--spacing-lg);
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
}

.move-empty.hidden {
    display: none;
}

/* Show side panel on large screens */
/* Chess Board */
.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    height: 100%;
    border: 3px solid var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.board.flipped {
    transform: rotate(180deg);
}

.board.flipped .piece {
    transform: rotate(180deg);
}

/* Board Squares */
.board-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    outline: none;
    -webkit-user-select: none;
    user-select: none;
}

.board-square.light {
    background: var(--board-light);
}

.board-square.dark {
    background: var(--board-dark);
}

.board-square:focus-visible {
    box-shadow: inset 0 0 0 3px var(--color-secondary);
}

.board-square.selected {
    background: var(--board-selected) !important;
}

.board-square.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: var(--board-legal-move);
    border-radius: 50%;
}

.board-square.capture-target::after {
    width: 90%;
    height: 90%;
    background: transparent;
    border: 5px solid var(--board-capture);
    border-radius: 50%;
}

.board-square.last-move {
    background: var(--board-last-move) !important;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    /* Separator for adjacent moves */
}

.board-square.in-check {
    background: var(--board-check) !important;
}

/* Shake animation for King in check - makes check more noticeable */
@keyframes king-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-3px) rotate(-2deg);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(3px) rotate(2deg);
    }
}

.board-square.in-check .piece {
    animation: king-shake 0.5s ease-in-out;
}

/* Ghost piece for Last Move replay - shows captured piece */
.piece.ghost-piece {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    filter: grayscale(30%);
    transition: opacity 0.3s ease-out;
}

.piece.ghost-piece.visible {
    opacity: 0.7;
}

/* Capture replay highlight - soft red glow */
.board-square.capture-replay {
    box-shadow: inset 0 0 20px rgba(192, 57, 43, 0.4);
    background: linear-gradient(135deg,
            rgba(192, 57, 43, 0.15),
            rgba(231, 76, 60, 0.1)) !important;
}

@keyframes ghost-pulse {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.02);
    }
}

.piece.ghost-piece.pulse {
    animation: ghost-pulse 1s ease-in-out infinite;
}

.board-square.hint {
    background: var(--board-hint) !important;
}

/* Board centered message (hint calculation) */
.board-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(40, 40, 50, 0.95), rgba(30, 30, 40, 0.98));
    padding: 16px 28px;
    border-radius: 12px;
    z-index: 9999;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: block;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.board-overlay.hidden {
    display: none;
}

.overlay-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.thinking-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #6ecf7d;
    border-radius: 50%;
    animation: spinnerRotate 0.7s linear infinite;
}

@keyframes spinnerRotate {
    to {
        transform: rotate(360deg);
    }
}

/* Pulsing hint animation for progressive hints */
.board-square.hint-pulse {
    animation: hintPulse 1.5s ease-in-out infinite;
}

.board-square.hint-target {
    background: rgba(0, 200, 100, 0.5) !important;
}

.board-square.hint-target.hint-pulse {
    animation: hintPulseTarget 1.5s ease-in-out infinite;
}

@keyframes hintPulse {

    0%,
    100% {
        background: var(--board-hint);
        box-shadow: inset 0 0 0 3px rgba(0, 150, 255, 0.3);
    }

    50% {
        background: rgba(0, 150, 255, 0.6);
        box-shadow: inset 0 0 0 4px rgba(0, 150, 255, 0.6);
    }
}

@keyframes hintPulseTarget {

    0%,
    100% {
        background: rgba(0, 200, 100, 0.4);
        box-shadow: inset 0 0 0 3px rgba(0, 200, 100, 0.3);
    }

    50% {
        background: rgba(0, 200, 100, 0.7);
        box-shadow: inset 0 0 0 4px rgba(0, 200, 100, 0.6);
    }
}

/* Coordinate Labels */
.coord-label {
    position: absolute;
    font-size: 11px;
    font-weight: 700;
    pointer-events: none;
    opacity: 0.85;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.3);
}

.rank-label {
    top: 2px;
    left: 2px;
}

.file-label {
    bottom: 2px;
    right: 2px;
}

.board-square.light .coord-label {
    color: var(--board-dark);
}

.board-square.dark .coord-label {
    color: var(--board-light);
}

/* Chess Pieces */
.piece {
    position: absolute;
    width: 85%;
    height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: transform var(--transition-fast);
    z-index: 1;
}

.piece:active {
    cursor: grabbing;
}

.piece.dragging {
    opacity: 0.8;
    z-index: 100;
    cursor: grabbing;
    transition: none;
}

.piece.animating {
    z-index: 100;
    transition: transform 0.2s ease-out;
}

.piece-svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Controls Panel */
.controls-panel {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.control-group label {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
}

.select-control {
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: var(--font-size-md);
    border: 1px solid #ddd;
    border-radius: 4px;
    background: var(--bg-secondary);
    cursor: pointer;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.25s ease;
}

/* Modal close button */
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 1;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
}

.modal-close-btn:active {
    transform: scale(0.95);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-title {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.modal-message {
    text-align: center;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

.modal-stats {
    text-align: center;
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.modal-buttons {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

.modal-buttons .btn {
    gap: 6px;
    min-width: 100px;
    padding: var(--spacing-sm) var(--spacing-md);
}

/* Secondary button in modals (light background) */
.modal-content .btn-secondary {
    background: #e0e0e0;
    color: #333;
    border: 1px solid #ccc;
}

.modal-content .btn-secondary:hover:not(:disabled) {
    background: #d0d0d0;
    color: #222;
}

/* Settings Modal */
.settings-content {
    margin-bottom: var(--spacing-lg);
}

.setting-group {
    margin-bottom: var(--spacing-md);
}

.setting-group h3 {
    font-size: var(--font-size-md);
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.radio-group {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
}

.radio-group input[type="radio"] {
    cursor: pointer;
}

/* Promotion Dialog */
.promotion-dialog {
    position: fixed;
    z-index: 1100;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    padding: var(--spacing-sm);
    animation: modalSlideIn 0.2s ease;
}

.promotion-dialog.hidden {
    display: none;
}

.promotion-content {
    display: flex;
    gap: var(--spacing-xs);
}

.promotion-piece {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    border-radius: 4px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.promotion-piece:hover {
    border-color: var(--color-secondary);
    background: var(--bg-secondary);
}

.promotion-piece svg {
    width: 40px;
    height: 40px;
}

/* Responsive Design */

/* Small screens (mobile) */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm);
    }

    .header-left,
    .header-right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .game-title {
        font-size: var(--font-size-md);
    }

    /* Larger touch targets for mobile */
    .btn {
        gap: 6px;
        padding: var(--spacing-sm) var(--spacing-sm);
        font-size: 13px;
        min-height: 40px;
    }

    .select-control {
        min-height: 40px;
        font-size: 14px;
    }

    .status-message {
        font-size: 13px;
        padding: 10px 16px;
    }

    .game-container {
        --board-size: min(calc(100vw - var(--spacing-sm) * 2), calc(100vh - 160px));
    }

    .coord-label {
        font-size: 9px;
    }
}

/* Short screens */
@media (max-height: 700px) {
    .game-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .status-bar {
        padding: var(--spacing-xs);
        min-height: 28px;
    }

    .game-main {
        padding: var(--spacing-xs);
    }

    /* Hide Move History on short screens */
    .history-section {
        display: none;
    }
}

/* Medium screens - centered board without side panel */
@media (min-width: 601px) and (max-width: 919px) {
    .game-main {
        max-width: 800px;
        margin: 0 auto;
    }
}

/* Large screens - show side panel */
@media (min-width: 800px) {
    .side-panel {
        display: flex;
        height: var(--board-size);
        max-height: var(--board-size);
    }

    .game-container {
        /* Account for side panel min-width (250px) + padding */
        --board-size: min(calc(100vw - 280px), calc(100vh - 120px), 680px);
    }
}

/* Side panel visible but not enough height for Move History */
@media (min-width: 800px) and (max-height: 750px) {
    .history-section {
        display: none;
    }
}

/* Extra large screens */
@media (min-width: 1200px) {
    .panel-section {
        padding: var(--spacing-md) var(--spacing-xl);
    }
}

/* Embedded (iframe) specific styles */
body.embedded {
    background: transparent;
}

body.embedded .game-container {
    max-width: none;
}

/* Print styles */
@media print {

    .game-header,
    .status-bar,
    .side-panel,
    .modal {
        display: none;
    }

    .game-main {
        padding: 0;
    }
}

/* Info Modal Styles */
.modal-content-wide {
    max-width: 500px;
}

.info-modal-content {
    margin: var(--spacing-md) 0;
}

.info-section {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.info-section h3 {
    font-size: var(--font-size-md);
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.info-section p {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.info-section ul {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    margin: var(--spacing-xs) 0 0 var(--spacing-md);
    padding: 0;
    line-height: 1.6;
}

.info-section li {
    margin-bottom: var(--spacing-xs);
}

/* Panel Info Button in Header - only visible when side panel shows */
.panel-info-btn {
    display: none;
}

@media (min-width: 800px) {
    .panel-info-btn {
        display: inline-flex;
    }
}

/* Game Over Modal - Enhanced Design */
.game-over-content {
    max-width: 360px;
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    border-radius: 16px;
}

.game-over-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: var(--spacing-md);
}

/* Difficulty Change Modal */
.difficulty-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: var(--spacing-sm);
    text-align: center;
}

.difficulty-message {
    text-align: center;
    font-size: var(--font-size-md);
    margin-bottom: var(--spacing-sm);
}

.difficulty-message strong {
    color: var(--primary);
    text-transform: capitalize;
}

.difficulty-hint {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    animation: gameOverBounce 0.6s ease-out;
}

@keyframes gameOverBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.game-over-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.5px;
}

.game-over-title.win {
    color: #27ae60;
}

.game-over-title.lose {
    color: #c0392b;
}

.game-over-title.draw {
    color: #7f8c8d;
}

.game-over-message {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.game-over-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xs);
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-over-content .modal-buttons {
    flex-direction: column;
    gap: var(--spacing-sm);
}

.game-over-content .btn-large {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-md);
    font-weight: 600;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.game-over-content .btn-large .btn-icon {
    font-size: 16px;
}

.game-over-content .btn-secondary {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: var(--font-size-md);
}

.game-over-content .btn-secondary:hover {
    color: var(--text-primary);
    background: transparent;
}