/* Main Styles for Vibe8 Chess */
:root {
    --primary-color: #3a86ff;
    --secondary-color: #8338ec;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #38b000;
    --warning-color: #ffbe0b;
    --danger-color: #ff006e;
    --info-color: #3a86ff;
    --board-border: #404040;
    --white-square: #f0d9b5;
    --black-square: #b58863;
    --white-square-premium: linear-gradient(135deg, #f0d9b5, #e8d0a9);
    --black-square-premium: linear-gradient(135deg, #b58863, #a67c5b);
    --highlight-color: rgba(76, 175, 80, 0.8); /* Bright green for better visibility */
    --check-highlight: rgba(255, 0, 0, 0.5);
    --last-move-highlight: rgba(70, 130, 180, 0.5);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
    --transition-fast: all 0.2s ease;
    --transition-normal: all 0.3s ease;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 350px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
        "left-panel board"
        "left-panel board"
        "footer footer";
    gap: 16px;
    min-height: 100vh;
    position: relative; /* For absolute positioning of chat */
}

.board-container {
    grid-area: board;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none; /* Prevent scrolling on touch devices */
    -webkit-user-select: none; /* Prevent selection on iOS */
    user-select: none; /* Prevent selection */
}

#board {
    width: 500px;
    max-width: 100%;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 8px solid #404040;
    transform-origin: center;
    animation: board-appear 0.6s ease-out;
    touch-action: none; /* Prevent scrolling on touch devices */
    -webkit-user-select: none; /* Prevent selection on iOS */
    user-select: none; /* Prevent selection */
}

@keyframes board-appear {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#board:hover {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-5px);
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--dark-color);
    color: white;
    border-radius: 4px;
    margin-bottom: 10px;
}

.player-info.bottom {
    margin-top: 10px;
    margin-bottom: 0;
}

.player-name {
    font-weight: 600;
    display: flex;
    align-items: center;
}

.player-name .material-icons {
    margin-right: 8px;
}

.player-time {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.2rem;
    transition: color 0.3s ease;
}

.time-low {
    color: #ff9800 !important;
    font-weight: bold;
}

.time-critical {
    color: #f44336 !important;
    font-weight: bold;
    animation: time-pulse 1s infinite;
}

.time-out {
    color: #f44336 !important;
    font-weight: bold;
    text-decoration: line-through;
}

@keyframes time-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.active-player {
    background-color: var(--primary-color);
}

.checked-player {
    background-color: var(--danger-color);
    animation: pulse 1.5s infinite;
}

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

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #2c3e50 0%, #1a1a2e 100%);
    color: white;
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    z-index: 100;
    display: none;
    animation: fade-in 0.5s ease-out;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes fade-in {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

.game-over .btn-primary {
    background: linear-gradient(135deg, #4a69bd 0%, #1e3799 100%);
    padding: 15px 25px;
    font-size: 1.1rem;
    margin-top: 10px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.game-over .btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.game-over .btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 90;
    display: none;
}

.game-over h2 {
    margin-bottom: 20px;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-over p {
    margin-bottom: 25px;
    font-size: 1.3rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.result-icon {
    margin-right: 10px;
    font-size: 2.5rem;
    vertical-align: middle;
    color: #ffcc00;
    text-shadow: 0 2px 10px rgba(255, 204, 0, 0.5);
}

.draw-explanation {
    margin-top: 15px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.9rem;
    color: #ddd;
    font-style: italic;
}

.left-panel {
    grid-area: left-panel;
}

.right-panel {
    grid-area: right-panel;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.panel-section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

/* Primary Controls Section */
.primary-controls {
    padding: 14px;
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    border-bottom: 1px solid #eaeaea;
    border-radius: 8px 8px 0 0;
}

.main-actions {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.btn-large {
    padding: 12px 16px;
    font-size: 0.95rem;
    flex: 1;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.btn-large:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Game Status Section */
.game-status-section {
    padding: 10px;
    background: linear-gradient(to bottom, #ffffff, #f9f9f9);
    border-bottom: 1px solid #eaeaea;
}

/* Collapsible Sections */
.collapsible-section {
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 15px;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    transition: all 0.2s ease;
    border-radius: 8px;
    background: linear-gradient(to bottom, #ffffff, #f9f9f9);
}

.section-header:hover {
    color: var(--primary-color);
    background: linear-gradient(to bottom, #f9f9f9, #f5f5f5);
}

.section-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
    margin-left: 8px;
}

.section-header .material-icons {
    font-size: 18px;
}

.toggle-icon {
    transition: transform 0.3s ease;
    color: #888;
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    padding: 0 15px;
    opacity: 0;
}

.collapsible-section.expanded .section-content {
    max-height: 1000px;
    padding: 10px;
    opacity: 1;
    border-top: 1px solid #eee;
}

.collapsible-section.expanded .toggle-icon {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.collapsible-section.expanded .section-header {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.panel-title .material-icons {
    margin-right: 8px;
}

.game-info-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.current-turn-container {
    margin-bottom: 10px;
}

.current-turn-label {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #444;
    margin-bottom: 10px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    animation: label-pulse 2s infinite;
}

@keyframes label-pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.turn-indicator {
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

.player-turn {
    display: flex;
    align-items: center;
    padding: 16px 150px 16px 16px; /* Add right padding to accommodate larger timer */
    border-radius: 12px;
    background-color: #f8f9fa;
    opacity: 0.4;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    transform: scale(0.95);
    min-height: 80px; /* Increased height for better proportions */
}

.player-turn.active {
    opacity: 1;
    background-color: #fff;
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.white-turn.active {
    border: none;
    background: linear-gradient(135deg, #3a86ff 0%, #2667ff 100%);
    color: white;
}

.white-turn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg,
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0.1) 25%,
        rgba(255,255,255,0.2) 25%,
        rgba(255,255,255,0.2) 50%,
        rgba(255,255,255,0.3) 50%,
        rgba(255,255,255,0.3) 75%,
        rgba(255,255,255,0.4) 75%,
        rgba(255,255,255,0.4) 100%);
    background-size: 20px 20px;
    opacity: 0.3;
    animation: move-stripes 3s linear infinite;
}

@keyframes move-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 20px; }
}

.white-turn.active .turn-timer {
    color: white;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: timer-pulse 1.5s infinite;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.black-turn.active {
    border: none;
    background: linear-gradient(135deg, #333333 0%, #111111 100%);
    color: white;
}

.black-turn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg,
        rgba(255,255,255,0.05) 0%,
        rgba(255,255,255,0.05) 25%,
        rgba(255,255,255,0.1) 25%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0.15) 50%,
        rgba(255,255,255,0.15) 75%,
        rgba(255,255,255,0.2) 75%,
        rgba(255,255,255,0.2) 100%);
    background-size: 20px 20px;
    opacity: 0.3;
    animation: move-stripes 3s linear infinite;
}

.black-turn.active .turn-timer {
    color: white;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: timer-pulse 1.5s infinite;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

@keyframes timer-pulse {
    0% { transform: translateY(-50%) scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    50% { transform: translateY(-50%) scale(1.05); box-shadow: 0 0 10px 5px rgba(255, 255, 255, 0.2); }
    100% { transform: translateY(-50%) scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
}

/* Turn transition effects */
.turn-transitioning {
    transform: scale(0.95);
    opacity: 0.6;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.turn-flash {
    animation: turn-flash 0.5s ease-out;
}

@keyframes turn-flash {
    0% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.8); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.turn-piece {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.player-turn.active .turn-piece {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.7);
    animation: piece-glow 2s infinite;
}

@keyframes piece-glow {
    0% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.7); }
    50% { box-shadow: 0 0 15px rgba(255, 255, 255, 0.9); }
    100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.7); }
}

.white-piece {
    background-color: white;
    border: 2px solid #333;
}

.black-piece {
    background-color: #333;
    border: 2px solid #333;
}

.turn-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    z-index: 2;
    padding-right: 20px; /* Reduced padding since we added it to the container */
}

.turn-text-main {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.player-turn.active .turn-text-main {
    transform: scale(1.05);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.player-name-display {
    font-weight: 600;
    font-size: 1rem;
    opacity: 0.95;
    font-style: italic;
    margin-top: 4px;
}

.turn-timer {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Roboto Mono', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    width: 130px;
    text-align: center;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 3; /* Ensure timer is above other elements */
    opacity: 0.8; /* Slightly dim inactive timers */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Make active player's timer more prominent */
.player-turn.active .turn-timer {
    opacity: 1;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(240,240,255,0.95));
}

/* Add a clock icon to the timer */
.turn-timer::before {
    content: '⏱️';
    font-size: 1.6rem;
    margin-right: 8px;
    opacity: 0.9;
    display: inline-block;
    animation: pulse-subtle 2s infinite ease-in-out;
}

@keyframes pulse-subtle {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.status-container {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: white;
    text-align: center;
}

.game-status {
    font-weight: 600;
    font-size: 1.2rem;
    margin-bottom: 5px;
    color: white;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.check-status {
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    min-height: 0;
}

.check-status:not(:empty) {
    background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    animation: pulse 1.5s infinite;
    box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3);
}

.check-status .material-icons {
    margin-right: 8px;
    font-size: 20px;
}

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

.captured-pieces-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.captured-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.captured-row h3 {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 5px;
}

.history-title {
    display: flex;
    align-items: center;
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.history-title .material-icons {
    margin-right: 8px;
}

.move-history-container {
    height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
}

.move-list {
    width: 100%;
    border-collapse: collapse;
}

.move-list th {
    text-align: left;
    padding: 8px;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
}

.move-list td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.move-number {
    color: #777;
    font-weight: 600;
    width: 40px;
}

.white-move, .black-move {
    font-family: 'Roboto Mono', monospace;
}

.last-move {
    background-color: var(--last-move-highlight);
}

.game-controls {
    grid-area: controls;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 16px;
    margin-top: 12px;
}

.control-row {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex: 1;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.2px;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), rgba(255,255,255,0));
    pointer-events: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn .material-icons {
    margin-right: 8px;
    font-size: 18px;
}

.btn-full {
    width: 100%;
    margin-top: 5px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2a75e8;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #7028d8;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #2a9000;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #e0005f;
}

.btn-info {
    background-color: var(--info-color);
    color: white;
}

.btn-info:hover {
    background-color: #2a75e8;
}

.game-mode-selector, .difficulty-selector {
    display: flex;
    background-color: #eee;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}

.mode-option, .difficulty-option {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-option.active, .difficulty-option.active {
    background-color: var(--primary-color);
    color: white;
}

.settings-label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
}

.settings-row {
    margin-top: 8px;
}

.history-section {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.setting-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
}

.setting-option label {
    font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.captured-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.captured-piece {
    width: 30px;
    height: 30px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

footer {
    grid-area: footer;
    text-align: center;
    padding: 20px 0;
    color: #777;
    border-top: 1px solid #ddd;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Algorithm info is now part of the main footer text */

/* Responsive adjustments */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "board"
            "controls"
            "left-panel"
            "footer";
        padding: 12px;
        gap: 12px;
    }

    #board {
        width: 100%;
        max-width: 500px;
        margin: 0 auto;
    }

    .left-panel, .game-controls {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }

    .move-history-container {
        height: 150px;
    }

    /* Chat functionality has been removed */
}

/* Tablet optimization */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        gap: 10px;
    }

    .panel-section {
        margin-bottom: 6px;
        padding: 10px;
    }

    .main-actions {
        gap: 6px;
    }

    .btn-large {
        padding: 8px 10px;
    }

    .move-history-container {
        height: 120px;
    }

    /* Improve spacing between board and controls */
    .board-container {
        margin-bottom: 10px;
    }

    /* Optimize button spacing */
    .control-row {
        gap: 8px;
    }
}

/* Mobile optimization */
@media (max-width: 576px) {
    .container {
        padding: 8px;
        gap: 8px;
        min-height: auto;
    }

    #board {
        margin-bottom: 8px;
    }

    .panel-section {
        margin-bottom: 4px;
        padding: 10px;
    }

    .main-actions {
        gap: 8px;
    }

    .btn-large {
        padding: 10px;
        font-size: 0.9rem;
    }

    .turn-indicator {
        flex-direction: row;
        gap: 8px;
    }

    .player-turn {
        flex: 1;
        padding: 8px;
    }

    .turn-timer {
        font-size: 1.1rem;
        min-width: 70px;
        right: 8px;
    }

    .turn-text {
        font-size: 0.9rem;
    }

    .turn-piece {
        width: 20px;
        height: 20px;
        margin-right: 8px;
    }

    /* Chat functionality has been removed */

    footer {
        margin-top: 8px;
        font-size: 0.8rem;
        padding: 10px 0;
    }

    /* Compact game controls for mobile */
    .game-controls {
        padding: 12px;
        gap: 8px;
        margin-top: 8px;
    }

    /* Improve spacing between board and controls */
    .board-container + .left-panel {
        margin-top: 8px;
    }
}

/* Highlight styles for legal moves - enhanced for better visibility */
.highlight-square {
    box-shadow: inset 0 0 0 5px var(--highlight-color);
    border: 3px solid #4CAF50 !important; /* Bright green border */
    position: relative;
    z-index: 3;
}

/* Add a distinct dot in the center of empty squares for legal moves (modern browsers) */
.highlight-square:not(:has(img)) {
    background-image: radial-gradient(circle at center, rgba(76, 175, 80, 0.9) 0%, rgba(76, 175, 80, 0.9) 15%, transparent 15%) !important;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

/* Fallback move indicator dot for all browsers */
.move-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(76, 175, 80, 0.9);
    z-index: 2;
    pointer-events: none;
}

/* Only apply animations to non-hover highlights to prevent flickering */
.highlight-check, .highlight-last-move {
    position: relative;
    z-index: 4;
}

.highlight-check {
    box-shadow: inset 0 0 0 3px var(--check-highlight);
    border: 2px solid crimson !important;
    animation: pulse-check 1.5s infinite;
}

.highlight-last-move {
    box-shadow: inset 0 0 0 3px var(--last-move-highlight);
    border: 2px solid steelblue !important;
}

/* Simplified after-elements to prevent flickering */
.highlight-check::after, .highlight-last-move::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.highlight-check::after {
    background: radial-gradient(circle, rgba(255, 0, 0, 0.2) 0%, rgba(255, 0, 0, 0) 70%);
}

.highlight-last-move::after {
    background: radial-gradient(circle, rgba(70, 130, 180, 0.2) 0%, rgba(70, 130, 180, 0) 70%);
}

@keyframes pulse-highlight {
    0% { box-shadow: inset 0 0 0 5px rgba(255, 215, 0, 0.6); }
    50% { box-shadow: inset 0 0 0 5px rgba(255, 215, 0, 0.9); }
    100% { box-shadow: inset 0 0 0 5px rgba(255, 215, 0, 0.6); }
}

@keyframes pulse-check {
    0% { box-shadow: inset 0 0 0 5px rgba(255, 0, 0, 0.5); }
    50% { box-shadow: inset 0 0 0 5px rgba(255, 0, 0, 0.8); }
    100% { box-shadow: inset 0 0 0 5px rgba(255, 0, 0, 0.5); }
}

/* Piece styling and transitions - more subtle to prevent flickering */
.piece-417db {
    transition: filter 0.2s ease;
    will-change: filter;
    z-index: 5;
}

/* Only apply subtle highlight effect on hover to prevent flickering */
.square-55d63:hover .piece-417db {
    filter: brightness(1.1);
}

/* Premium Piece animations */
@keyframes piece-drop {
    0% { transform: translateY(-30px); opacity: 0.5; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4)); }
    50% { transform: translateY(8px); filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3)); }
    75% { transform: translateY(-4px); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.2)); }
    100% { transform: translateY(0); opacity: 1; filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.1)); }
}

@keyframes piece-capture {
    0% { transform: scale(1); filter: brightness(1); }
    20% { transform: scale(1.4) rotate(5deg); filter: brightness(1.3) drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5)); }
    40% { transform: scale(1.2) rotate(-5deg); filter: brightness(1.2) drop-shadow(0 8px 15px rgba(0, 0, 0, 0.4)); }
    60% { transform: scale(1.3) rotate(3deg); filter: brightness(1.1) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.3)); }
    80% { transform: scale(0.9) rotate(-2deg); filter: brightness(1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2)); }
    100% { transform: scale(1) rotate(0); filter: brightness(1) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.1)); }
}

@keyframes piece-castle {
    0% { transform: translateX(0) scale(1); filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.2)); }
    25% { transform: translateX(15px) translateY(-8px) scale(1.1); filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.3)); }
    50% { transform: translateX(20px) translateY(-5px) scale(1.05); filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4)); }
    75% { transform: translateX(10px) translateY(-2px) scale(1.02); filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3)); }
    100% { transform: translateX(0) translateY(0) scale(1); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1)); }
}

/* Piece movement feedback */
.piece-animated {
    animation: piece-drop 0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000);
    z-index: 10;
}

.piece-captured {
    animation: piece-capture 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 15;
}

.piece-castled {
    animation: piece-castle 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 12;
}

/* Add a subtle glow effect to pieces being moved */
.piece-417db.dragging {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8)) brightness(1.2);
    transform: scale(1.15);
}

/* Premium square styling */
.white-1e1d7 {
    background: var(--white-square-premium);
    position: relative;
    transition: all 0.3s ease;
}

.black-3c85d {
    background: var(--black-square-premium);
    position: relative;
    transition: all 0.3s ease;
}

/* Add subtle texture to squares */
.white-1e1d7::after, .black-3c85d::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/png;base64,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');
    opacity: 0.03;
    pointer-events: none;
}

/* Square hover effect - more subtle to prevent flickering */
.square-55d63 {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Only apply hover effects when no game is in progress or on empty squares */
.square-55d63:hover {
    z-index: 2;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* Ripple effect for square interactions */
.ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Inline player name editing */
.editable-name {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
}

.player-name-display {
    flex: 1;
    padding: 2px 5px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.player-name-display.editable {
    cursor: pointer;
}

.player-name-display.editable:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.player-name-display.editable:after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 5px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.4);
    vertical-align: middle;
}

.player-name-edit {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 2px 5px;
    border: 1px solid var(--primary-color);
    border-radius: 3px;
    background-color: white;
    color: var(--dark-color);
    font-size: 1rem;
    display: none;
    z-index: 10;
}

.player-name-edit:focus {
    outline: none;
}

.edit-name-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 2px;
    margin-left: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.edit-name-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.edit-name-btn .material-icons {
    font-size: 16px;
}

.editing .player-name-display {
    visibility: hidden;
}

.editing .player-name-edit {
    display: block;
}

.player-icon {
    transition: all 0.3s ease;
}

/* Chat functionality has been removed */

/* Modern Players Dashboard - New Design */
.players-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap between player cards */
    margin-bottom: 20px;
    position: relative;
}

.player-card {
    display: flex;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    background-color: #f8f9fa;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    min-width: 0; /* Ensures text truncation works */
}

.player-card.white-player {
    background: linear-gradient(135deg, #f0f4ff 0%, #e6eeff 100%);
    border-left: 5px solid #4a7feb;
}

.player-card.black-player {
    background: linear-gradient(135deg, #f0f0f0 0%, #e6e6e6 100%);
    border-left: 5px solid #333;
}

/* Active player styling - both use green when active */
.player-card.active {
    background: none !important; /* Reset any background first */
    background-color: #2e9e3a !important; /* Solid color as fallback */
    background-image: linear-gradient(135deg, #2e9e3a 0%, #1b8e26 100%) !important; /* Green for active turn */
    color: white !important;
    box-shadow: 0 8px 20px rgba(30, 142, 38, 0.3) !important;
    transform: translateY(-2px) !important;
    border-left: 5px solid #1b8e26 !important; /* Consistent border color */
}

/* Black player uses same active styling as white player */

/* No specific styling for black piece in active state */

/* Player avatar section */
.player-avatar {
    position: relative;
    margin-right: 16px;
}

.piece-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.white-piece {
    background-color: white !important;
    border: 2px solid #ddd !important;
}

.black-piece {
    background-color: #333 !important;
    border: 2px solid #222 !important;
}

/* No custom styling for pieces in active state to ensure consistency */

.player-card.active .piece-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.player-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #ccc;
    border: 2px solid white;
    transition: all 0.3s ease;
}

.player-status.active {
    background-color: #4CAF50 !important;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6) !important;
    animation: pulse 2s infinite !important;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* Player info section */
.player-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    min-width: 0; /* Ensures text truncation works */
    max-width: 100px; /* Smaller width to prevent overflow */
    margin: 0 8px; /* Add horizontal spacing */
    height: 48px; /* Match the height of the piece icon */
}

.player-name {
    font-weight: 700;
    font-size: 1.2rem; /* Larger font since we removed the state text */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Make computer player name smaller */
.player-card.black-player .player-name {
    font-size: 1.1rem;
}

/* Player state removed for cleaner UI */

.player-card.active .player-name,
.player-card.active .player-state {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Special styling for active states */
.player-card.active .player-state {
    color: #e6ffea; /* Lighter green for better contrast */
    font-weight: 600;
}

/* Timer section */
.player-timer {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin-left: 12px;
    transition: all 0.3s ease;
    min-width: 100px;
}

.player-card.active .player-timer {
    background: rgba(0, 0, 0, 0.15) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
}

.timer-icon {
    margin-right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-icon .material-icons {
    font-size: 18px;
    color: #555;
}

.player-card.active .timer-icon .material-icons {
    color: white;
}

.timer-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: #333;
    letter-spacing: 1px;
}

.player-card.active .timer-display {
    color: white;
}

/* VS indicator removed as requested */

/* Mobile tap-to-move improvements */
.square-55d63 {
    cursor: pointer !important;
    position: relative !important;
}

/* Make the move indicators more visible on mobile */
.move-indicator {
    width: 20px !important;
    height: 20px !important;
    background-color: rgba(76, 175, 80, 0.9) !important;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.7) !important;
    border-radius: 50% !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 10 !important;
    pointer-events: none !important;
}

/* Special styling for mobile devices */
body.mobile-device .move-indicator {
    width: 24px !important;
    height: 24px !important;
    background-color: rgba(76, 175, 80, 1) !important;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.9) !important;
}

/* Make sure the board is not draggable on mobile */
body.mobile-device .piece-417db {
    cursor: pointer !important;
    pointer-events: auto !important;
}

/* Highlight the selected square more prominently */
.highlight-square {
    box-shadow: inset 0 0 0 5px #4CAF50 !important;
    border: 3px solid #4CAF50 !important;
    position: relative !important;
    z-index: 3 !important;
}

/* Make the squares more tappable on mobile */
@media (max-width: 768px) {
    .square-55d63 {
        min-height: 40px !important;
        min-width: 40px !important;
    }

    /* Larger indicators for mobile */
    .move-indicator {
        width: 24px !important;
        height: 24px !important;
        background-color: rgba(76, 175, 80, 1) !important;
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.9) !important;
    }

    /* Ensure pieces are visible and tappable */
    .square-55d63 img {
        width: 90% !important;
        height: 90% !important;
        margin: 5% !important;
    }
}