.chess-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1400px;
}

.muted {
    color: var(--muted);
}

.action-row,
.share-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.share-row input {
    flex: 1;
}

.chess-layout {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(520px, 1fr) minmax(240px, 300px);
    gap: 20px;
    align-items: start;
}

.connection label,
.board-controls label {
    margin-top: 14px;
    display: block;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.connection input {
    width: 100%;
    margin-top: 6px;
}

.connection-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.connection-head .action-row {
    flex-wrap: wrap;
}

.page-title {
    margin: 0 0 6px;
    font-size: 26px;
    letter-spacing: 0.6px;
}

.connection .share-row {
    margin-bottom: 10px;
}

.button-row {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.export-row {
    margin-top: 12px;
}

button.ghost {
    background: transparent;
    border-color: var(--border);
}

.status-card {
    margin-top: 20px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: grid;
    gap: 12px;
    background: rgba(12, 16, 23, 0.6);
}

.status-card .label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}

.notes {
    margin-top: 16px;
    font-size: 13px;
}

.board-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    min-width: 0;
    padding-bottom: 28px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.board-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
}

.board-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(80vmin, 720px);
    max-width: 720px;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    justify-self: center;
}

.square {
    display: grid;
    place-items: center;
    border: none;
    padding: 0;
    width: 100%;
    height: 100%;
    font-size: clamp(20px, 3.8vmin, 40px);
    line-height: 1;
    font-family: "Times New Roman", Georgia, serif;
    color: #e6e9f0;
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.12s ease;
    border-radius: 0;
}

.piece {
    line-height: 1;
    font-size: inherit;
}

.piece.white {
    color: #f4f1e8;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.35);
}

.piece.black {
    color: #15181f;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.square.light {
    background: #e3ddd2;
}

.square.dark {
    background: #565b65;
}

.square.selected {
    box-shadow: inset 0 0 0 3px rgba(96, 165, 250, 0.7);
}

.square.drag-over {
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85);
}

.square.last-move {
    background: rgba(255, 200, 97, 0.55);
}

.square.legal {
    background: rgba(62, 243, 168, 0.55);
}

.square.last-move.legal {
    background: rgba(62, 243, 168, 0.55);
}
.square:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.move-list {
    display: grid;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 6px;
    font-size: 13px;
}

.connection p,
.sidebar p,
.notes,
.muted {
    font-size: 12px;
}

.connection .notes {
    margin-top: 10px;
}

.sidebar textarea {
    width: 100%;
    resize: vertical;
    min-height: 120px;
    margin-top: 8px;
    background: #0c1017;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-family: var(--mono);
    box-sizing: border-box;
}

.move-row {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    gap: 8px;
}

.move-row span {
    color: var(--muted);
}

.server-details {
    margin-top: 16px;
}

.status-line {
    font-size: 13px;
    color: var(--muted);
}

.title {
    font-weight: 700;
    letter-spacing: 0.6px;
}

@media (max-width: 1100px) {
    .chess-layout {
        grid-template-columns: 1fr;
    }

    .board {
        width: min(90vmin, 560px);
        max-width: 560px;
    }
}

@media (max-width: 600px) {
    .action-row,
    .share-row {
        flex-direction: column;
        align-items: stretch;
    }

    .connection-head .action-row {
        align-items: stretch;
    }
}
