/* chess.css */
.chess-page {
    max-width: 1400px;
    margin: 20px auto 30px auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.chess-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.chess-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.chess-toolbar button {
    padding: 10px 14px;
    border: 1px solid #888;
    background: #f6f6f6;
    color: #222;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.95rem;
}

.chess-toolbar button:hover {
    background: #ececec;
}

.chess-toolbar button.active {
    background: #1f3fbf;
    color: #fff;
    border-color: #1f3fbf;
}

.chess-toolbar-select {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
}

.chess-toolbar-select label {
    font-size: 0.92rem;
    color: #444;
    white-space: nowrap;
}

.chess-toolbar-select select {
    padding: 8px 10px;
    font-size: 0.95rem;
    border: 1px solid #888;
    border-radius: 6px;
    background: #fff;
}
.chess-toolbar-select select:disabled {
    background: #f0f0f0;
    color: #777;
}

.chess-title {
    margin: 0 0 4px 0;
    color: #1f3fbf;
    font-size: 2rem;
    font-weight: 400;
}

.chess-subtitle {
    color: #555;
    font-size: 0.98rem;
}

.chess-mode-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.chess-mode-buttons button,
.chess-button-stack button {
    padding: 10px 14px;
    border: 1px solid #888;
    background: #f6f6f6;
    color: #222;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.95rem;
}

.chess-mode-buttons button:hover,
.chess-button-stack button:hover {
    background: #ececec;
}

.chess-mode-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chess-main {
    display: grid;
    grid-template-columns: minmax(320px, 760px) minmax(260px, 360px);
    gap: 24px;
    align-items: start;
}

.chess-board-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 100%;
}

.chess-board-status {
    width: 100%;
    max-width: 720px;
    margin-bottom: 12px;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid #d6d6d6;
    background: #fafafa;
    color: #1f3fbf;
    font-size: 1rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.chess-board {
    width: min(90vw, calc(100vh - 220px), 720px);
	margin: 0 auto;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 3px solid #444;
    box-sizing: border-box;
    user-select: none;
    overflow: hidden;
    background: #999;
}

.chess-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.chess-square:hover {
	box-shadow: inset 0 0 0 2px rgba(0,0,0,0.12);
}

.chess-square.light {
    background-color: #e9e6e0;
}

.chess-square.dark {
    background-color: #b5b2ad;
}

.chess-square.selected {
    outline: 4px solid #2d6cdf;
    outline-offset: -4px;
    z-index: 1;
}

.chess-square.legal::after {
    content: "";
    width: 18%;
    height: 18%;
    border-radius: 50%;
    background: rgba(45, 108, 223, 0.65);
    position: absolute;
}

.chess-square.capture::after {
    content: "";
    position: absolute;
    inset: 10%;
    border: 4px solid rgba(200, 40, 40, 0.7);
    border-radius: 50%;
}

.chess-piece {
    width: 82%;
    height: 82%;
    object-fit: contain;
    pointer-events: none;
    display: block;
	filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
	transition: transform 1.5s ease;
}

.chess-flying-piece {
    position: fixed;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 9999;
}

.chess-flying-piece img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}

.chess-square.capture-flash {
    animation: chessCaptureFlash 0.35s ease-in-out 1;
}

@keyframes chessCaptureFlash {
    0%   { box-shadow: inset 0 0 0 0 rgba(200, 40, 40, 0); }
    50%  { box-shadow: inset 0 0 0 6px rgba(200, 40, 40, 0.75); }
    100% { box-shadow: inset 0 0 0 0 rgba(200, 40, 40, 0); }
}

.chess-coord {
    position: absolute;
    font-size: 0.72rem;
    color: rgba(0, 0, 0, 0.45);
    pointer-events: none;
    line-height: 1;
}

.chess-coord.file {
    bottom: 4px;
    right: 6px;
}

.chess-coord.rank {
    top: 4px;
    left: 6px;
}

.chess-side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chess-card {
    border: 1px solid #d6d6d6;
    background: #fafafa;
    padding: 14px;
    box-sizing: border-box;
}

.chess-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f3fbf;
    margin-bottom: 10px;
}

.chess-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.chess-form-row label {
    font-size: 0.92rem;
    color: #444;
}

.chess-form-row select {
    padding: 8px;
    font-size: 0.95rem;
}

.chess-button-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chess-move-list {
    min-height: 120px;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    padding: 10px;
    box-sizing: border-box;
    line-height: 1.55;
    font-size: 0.95rem;
}

.chess-help-text {
    color: #444;
    line-height: 1.55;
    font-size: 0.95rem;
}

@media (max-width: 980px) {
    .chess-main {
        grid-template-columns: 1fr;
    }

    .chess-board-status {
        max-width: 100%;
    }

    .chess-side-panel {
        width: 100%;
    }
}

.chess-mode-buttons button.active {
    background: #1f3fbf;
    color: #fff;
    border-color: #1f3fbf;
}

.captured-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.captured-label {
    font-size: 0.9rem;
    color: #444;
    margin-bottom: 4px;
}

.captured-row {
    min-height: 42px;
    border: 1px solid #ddd;
    background: #fff;
    padding: 6px;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.captured-row img {
    width: 28px;
    margin-right: 4px;
}

.captured-piece {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/*.chess-square.last-from {
    box-shadow: inset 0 0 0 4px rgba(255, 196, 0, 0.75);
}

.chess-square.last-to {
    box-shadow: inset 0 0 0 4px rgba(0, 170, 80, 0.75);
}

*/

.last-from {
    box-shadow: inset 0 0 0 3px rgba(255,200,0,0.5);
}

.last-to {
    box-shadow: inset 0 0 0 3px rgba(255,200,0,0.8);
}


.chess-square.last-capture {
    animation: capturePulse 0.5s ease-in-out 2;
}

@keyframes capturePulse {
    0%   { box-shadow: inset 0 0 0 2px rgba(220, 30, 30, 0.3); }
    50%  { box-shadow: inset 0 0 0 6px rgba(220, 30, 30, 0.85); }
    100% { box-shadow: inset 0 0 0 2px rgba(220, 30, 30, 0.3); }
}

.chess-board-status {
    width: 100%;
    max-width: 720px;
    margin-bottom: 12px;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid #d6d6d6;
    background: #fafafa;
    color: #1f3fbf;
    font-size: 1rem;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.chess-board-status.status-normal {
    background: #ffffff;
    color: #1f3fbf;
    border-color: #d6d6d6;
}

.chess-board-status.status-thinking {
    background: #eaf3ff;
    color: #1f3fbf;
    border-color: #9fc2ff;
}

.chess-board-status.status-check {
    background: #fff4bf;
    color: #7a5a00;
    border-color: #e0c24f;
}

.chess-board-status.status-checkmate {
    background: #ffd9d9;
    color: #9b0000;
    border-color: #e07a7a;
    font-weight: 700;
}

.chess-board-status.status-draw {
    background: #eef1ec;
    color: #506050;
    border-color: #b9c3b2;
}

.chess-board-wrap {
    width: min(90vw, 720px);
    margin: 20px auto 30px auto;
}

.chess-toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.chess-toolbar-skill {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chess-toolbar-skill label {
    margin: 0;
    font-size: 0.92rem;
    color: #444;
    white-space: nowrap;
}

.chess-toolbar-skill select {
    width: 140px;
}

.chess-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.chess-info-panel {
    border: 1px solid #d6d6d6;
    background: #fafafa;
    padding: 14px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .chess-toolbar-row {
        flex-direction: column;
        align-items: stretch;
    }

    .chess-toolbar-skill {
        justify-content: space-between;
    }

    .chess-info-row {
        grid-template-columns: 1fr;
    }
}