/* Darstellung des spielbaren Schachmoduls mit Brett, Sidebar und Promotion-Overlay. */
/* Gesamtabstand des Unterprojekts innerhalb von Willys Works. */
.playable-chess {
    margin-top: 24px;
}

/* Zweispaltiges Layout: Brett links, Kontext/History rechts. */
.playable-chess-layout {
    display: grid;
    grid-template-columns: minmax(320px, 560px) minmax(220px, 1fr);
    gap: 20px;
    align-items: start;
}

/* Gemeinsame Panel-Huelle fuer Spielflaeche und Sidebar. */
.playable-chess-panel,
.playable-chess-sidebar {
    padding: 18px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
    box-shadow: var(--shadow);
}

.playable-chess-panel h3,
.playable-chess-sidebar h4 {
    margin-top: 0;
}

/* Laufende Textausgabe fuer Zugstatus und Hinweise. */
.playable-chess-status,
.playable-chess-hint {
    margin: 0 0 12px;
}

.playable-chess-draw-status {
    margin: -4px 0 14px;
    padding: 8px 10px;
    border: 1px solid rgba(124, 231, 255, 0.45);
    background: rgba(16, 40, 35, 0.52);
    color: var(--heading);
}

/* Steuerleiste fuer Reset und spaetere Spielaktionen. */
.playable-chess-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
}

/* Ablageleisten ober- und unterhalb des Bretts fuer bereits geschlagene Figuren. */
.playable-chess-captured {
    margin: 0 0 14px;
}

.playable-chess-captured-white {
    margin: 14px 0 0;
}

.playable-chess-captured h4 {
    margin: 0 0 8px;
}

.playable-chess-captured-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 48px;
    padding: 8px 10px;
    border: 1px solid rgba(4, 10, 8, 0.85);
    background: rgba(0, 0, 0, 0.26);
}

.playable-chess-captured-empty {
    color: var(--text-soft);
    font-size: 0.95rem;
}

.playable-chess-captured-piece {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1.45rem;
    line-height: 1;
    user-select: none;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.playable-chess-reset,
.playable-chess-action {
    padding: 10px 14px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
    color: var(--heading);
    font: inherit;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.playable-chess-reset:hover,
.playable-chess-action:hover {
    background: rgba(0, 0, 0, 0.42);
}

.playable-chess-action[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Scroll-Container, damit das Brett auch mobil sauber erreichbar bleibt. */
.playable-chess-board-wrap {
    overflow-x: auto;
}

/* Brett als CSS-Grid mit Randkoordinaten und 8x8 Spielfeldern. */
.playable-chess-board {
    display: grid;
    grid-template-columns: 26px repeat(8, 56px) 26px;
    grid-template-rows: 26px repeat(8, 56px) 26px;
    gap: 0;
    width: fit-content;
    background: var(--panel);
    border: 1px solid rgba(3, 9, 7, 0.9);
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.3);
}

/* Beschriftungsfelder fuer Reihen- und Spaltenkoordinaten. */
.playable-chess-label {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-strong);
    color: var(--heading);
    font-weight: 700;
}

.playable-chess-label.is-rotated {
    transform: rotate(180deg);
}

/* Interaktive Brettfelder. */
.playable-chess-square {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 1px solid rgba(4, 10, 8, 0.85);
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, outline-color 120ms ease;
}

/* Helle und dunkle Brettfarben. */
.playable-chess-square.is-light {
    background: linear-gradient(180deg, #f2f7dc 0%, #dce7b1 100%);
}

.playable-chess-square.is-dark {
    background: linear-gradient(180deg, #294d3f 0%, #173227 100%);
}

.playable-chess-square:hover {
    transform: translateY(-1px);
}

/* Visuelle Zustandsmarkierungen fuer Auswahl und legale Zielfelder. */
.playable-chess-square.is-selected {
    box-shadow: inset 0 0 0 3px rgba(246, 236, 210, 0.9), 0 0 16px rgba(246, 236, 210, 0.25);
}

.playable-chess-square.is-legal {
    box-shadow: inset 0 0 0 3px rgba(124, 231, 255, 0.8);
}

.playable-chess-square.is-capture {
    box-shadow: inset 0 0 0 3px rgba(255, 143, 177, 0.88);
}

/* Figuren als Unicode-Glyphen. */
.playable-chess-piece {
    font-size: 2rem;
    line-height: 1;
    user-select: none;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.playable-chess-piece.is-white {
    color: #fffde8;
    text-shadow:
        -1px -1px 0 rgba(20, 36, 28, 0.92),
        1px -1px 0 rgba(20, 36, 28, 0.92),
        -1px 1px 0 rgba(20, 36, 28, 0.92),
        1px 1px 0 rgba(20, 36, 28, 0.92),
        0 0 8px rgba(245, 255, 135, 0.2);
}

.playable-chess-piece.is-black {
    color: #06110d;
    text-shadow:
        -1px -1px 0 rgba(231, 243, 196, 0.72),
        1px -1px 0 rgba(231, 243, 196, 0.72),
        -1px 1px 0 rgba(231, 243, 196, 0.72),
        1px 1px 0 rgba(231, 243, 196, 0.72),
        0 0 6px rgba(125, 247, 190, 0.12);
}

/* Standardlisten in der Sidebar. */
.playable-chess-sidebar ul {
    margin: 0 0 18px;
    padding-left: 18px;
}

/* Zughistorie als eigene nummerierte Liste. */
.playable-chess-history-toggle {
    margin: 0 0 10px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
    color: var(--heading);
    font: inherit;
    cursor: pointer;
}

.playable-chess-history-toggle:hover {
    background: rgba(0, 0, 0, 0.42);
}

.playable-chess-history {
    margin: 0 0 18px;
    padding-left: 20px;
}

.playable-chess-history li + li {
    margin-top: 6px;
}

/* Overlay fuer die Bauernumwandlung. */
.playable-chess-promotion {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 7, 6, 0.72);
    z-index: 40;
}

/* Das HTML-Attribut `hidden` muss das Overlay auch gegen das feste Flex-Layout sicher ausblenden. */
.playable-chess-promotion[hidden] {
    display: none;
}

.playable-chess-promotion-window {
    max-width: 420px;
    width: 100%;
    padding: 20px;
    border: 1px solid var(--line);
    background: rgba(9, 18, 14, 0.96);
    box-shadow: var(--shadow);
}

.playable-chess-promotion-window h4 {
    margin-top: 0;
}

.playable-chess-promotion-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.playable-chess-promotion-actions button {
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
    color: var(--heading);
    font: inherit;
    cursor: pointer;
}

.playable-chess-promotion-actions button:hover {
    background: rgba(0, 0, 0, 0.42);
}

/* Listenabstaende innerhalb der Sidebar. */
.playable-chess-sidebar li + li {
    margin-top: 6px;
}

/* Mobile Anpassung:
   Auf schmalen Screens wird die Sidebar unter das Brett geschoben. */
@media (max-width: 900px) {
    .playable-chess-layout {
        grid-template-columns: 1fr;
    }
}
