.pcb-app {
    --pcb-board-size: min(100%, var(--pcb-max-size, 560px));
    --pcb-light: #f0d9b5;
    --pcb-dark: #b58863;
    --pcb-selected: rgba(255, 214, 10, 0.65);
    --pcb-legal: rgba(20, 120, 60, 0.35);
    --pcb-last: rgba(80, 140, 255, 0.35);
    --pcb-border: currentColor;
    --pcb-control-bg: #ffffff;
    --pcb-control-text: #1d2327;
    --pcb-control-border: #8c8f94;
    --pcb-control-border-focus: #2271b1;
    --pcb-button-bg: #f6f7f7;
    --pcb-button-bg-hover: #f0f0f1;
    --pcb-button-text: #1d2327;
    --pcb-button-border: #8c8f94;
    --pcb-link-color: #2271b1;
    --pcb-error-bg: #fcf0f1;
    --pcb-error-border: #d63638;
    --pcb-error-text: #8a2424;
    color: inherit;
    max-width: var(--pcb-max-size, 560px);
    width: 100%;
}

.pcb-app * {
    box-sizing: border-box;
}

.pcb-shell {
    display: grid;
    gap: 1rem;
}

.pcb-status {
    font-size: clamp(1rem, 2.6vw, 1.125rem);
    font-weight: 700;
    line-height: 1.45;
    min-height: 1.6rem;
}

.pcb-status small {
    font-weight: 600;
    margin-left: 0.35rem;
    opacity: 0.78;
}

.pcb-board-wrap {
    aspect-ratio: 1 / 1;
    max-width: 100%;
    width: var(--pcb-board-size);
}

.pcb-board {
    border: 2px solid var(--pcb-border);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    height: 100%;
    overflow: hidden;
    position: relative;
    touch-action: manipulation;
    width: 100%;
}

/* Schachfelder sind technisch Buttons, dürfen aber nicht wie WordPress-/Theme-Buttons aussehen. */
.pcb-square {
    align-items: center;
    appearance: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    font: inherit;
    justify-content: center;
    margin: 0;
    min-height: 0;
    outline-offset: -3px;
    padding: 0;
    position: relative;
    text-decoration: none;
    user-select: none;
}

.pcb-square:hover,
.pcb-square:focus {
    box-shadow: none;
    text-decoration: none;
}

.pcb-square:focus-visible {
    outline: 3px solid currentColor;
    z-index: 2;
}

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

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

.pcb-square.is-selected::after,
.pcb-square.is-last::after,
.pcb-square.is-legal::after {
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.pcb-square.is-selected::after {
    background: var(--pcb-selected);
}

.pcb-square.is-last::after {
    background: var(--pcb-last);
}

.pcb-square.is-legal::after {
    background: radial-gradient(circle, var(--pcb-legal) 0 22%, transparent 23% 100%);
}

.pcb-square.is-legal.has-piece::after {
    background: radial-gradient(circle, transparent 0 56%, var(--pcb-legal) 57% 68%, transparent 69% 100%);
}

.pcb-piece {
    cursor: grab;
    display: block;
    font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", "Arial Unicode MS", serif;
    font-size: clamp(1.9rem, 9vw, 4.1rem);
    line-height: 1;
    position: relative;
    z-index: 1;
}

.pcb-piece[data-color="b"] {
    color: #111111;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.35);
}

.pcb-piece[data-color="w"] {
    color: #f7f7f7;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.pcb-piece:active {
    cursor: grabbing;
}

.pcb-coordinate {
    color: rgba(0, 0, 0, 0.65);
    font-size: clamp(0.55rem, 1.8vw, 0.75rem);
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    position: absolute;
    z-index: 1;
}

.pcb-rank {
    left: 0.22rem;
    top: 0.22rem;
}

.pcb-file {
    bottom: 0.22rem;
    right: 0.22rem;
}

.pcb-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* WordPress-nahe Frontend-Buttons: neutral, leserlich, touchfreundlich. */
.pcb-button {
    align-items: center;
    appearance: none;
    background: var(--pcb-button-bg);
    border: 1px solid var(--pcb-button-border);
    border-radius: 4px;
    box-shadow: none;
    color: var(--pcb-button-text);
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    justify-content: center;
    line-height: 1.25;
    margin: 0;
    min-height: 44px;
    padding: 0.6rem 0.95rem;
    text-align: center;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
    white-space: nowrap;
}

.pcb-button:hover {
    background: var(--pcb-button-bg-hover);
    border-color: #646970;
    color: var(--pcb-button-text);
    text-decoration: none;
}

.pcb-button:focus,
.pcb-button:focus-visible {
    border-color: var(--pcb-control-border-focus);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.28);
    color: var(--pcb-button-text);
    outline: 2px solid transparent;
    outline-offset: 2px;
    text-decoration: none;
}

.pcb-fields {
    display: grid;
    gap: 0.85rem;
}

.pcb-field {
    display: grid;
    gap: 0.35rem;
}

.pcb-field-control {
    width: 100%;
}

.pcb-label {
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.35;
}

/* WordPress-nahe Formularfelder: klarer Kontrast, 16px gegen Mobile-Zoom, volle Breite. */
.pcb-input,
.pcb-textarea {
    appearance: none;
    background: var(--pcb-control-bg);
    border: 1px solid var(--pcb-control-border);
    border-radius: 4px;
    box-shadow: none;
    color: var(--pcb-control-text);
    display: block;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.45;
    margin: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 0.62rem 0.75rem;
    width: 100%;
}

.pcb-input:focus,
.pcb-textarea:focus {
    border-color: var(--pcb-control-border-focus);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.22);
    outline: 2px solid transparent;
}

.pcb-input[readonly],
.pcb-textarea[readonly] {
    background: #ffffff;
    color: var(--pcb-control-text);
    opacity: 1;
}

.pcb-input-short {
    max-width: 9rem;
}

.pcb-textarea {
    min-height: 7.5rem;
    overflow: auto;
    resize: vertical;
}

.pcb-opening-link {
    color: var(--pcb-link-color);
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 0.35rem;
    text-decoration: underline;
    text-underline-offset: 0.16em;
}

.pcb-opening-link:hover,
.pcb-opening-link:focus {
    text-decoration-thickness: 2px;
}

.pcb-opening-link[hidden] {
    display: none;
}

.pcb-note {
    font-size: 0.875rem;
    line-height: 1.45;
    opacity: 0.78;
}

.pcb-error {
    background: var(--pcb-error-bg);
    border: 1px solid var(--pcb-error-border);
    border-radius: 4px;
    color: var(--pcb-error-text);
    line-height: 1.45;
    padding: 0.85rem 1rem;
}

@media (max-width: 600px) {
    .pcb-shell {
        gap: 0.9rem;
    }

    .pcb-controls {
        align-items: stretch;
        flex-direction: column;
        gap: 0.5rem;
    }

    .pcb-button {
        width: 100%;
    }

    .pcb-input-short {
        max-width: 100%;
    }

    .pcb-status {
        min-height: auto;
    }
}

@media (prefers-color-scheme: dark) {
    .pcb-app {
        --pcb-control-bg: #ffffff;
        --pcb-control-text: #1d2327;
        --pcb-control-border: #8c8f94;
        --pcb-button-bg: #f6f7f7;
        --pcb-button-bg-hover: #f0f0f1;
        --pcb-button-text: #1d2327;
        --pcb-button-border: #8c8f94;
    }
}

/* Standalone boards used by [knighttest] and [boardsinglepiece]. */
.pcb-standalone {
    color: #1f2a33;
    max-width: var(--pcb-max-size, 560px);
    width: 100%;
}

.pcb-standalone * {
    box-sizing: border-box;
}

.pcb-knighttest-app {
    --pcb-team-green: #79ad75;
    --pcb-team-yellow: #e4c14a;
    --pcb-team-red: #ee746d;
    --pcb-team-blue: #7da9c8;
    --pcb-card-bg: rgba(255, 255, 255, 0.86);
    --pcb-card-border: rgba(33, 42, 51, 0.10);
    --pcb-soft-bg: #f7f8f8;
    margin-left: auto;
    margin-right: auto;
}

.pcb-kt-shell {
    background: #f7f8f8;
    border-radius: 20px;
    box-shadow: 0 18px 44px rgba(31, 42, 51, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    display: grid;
    gap: 1rem;
    padding: clamp(1rem, 4vw, 1.7rem);
}

.pcb-kt-section-title {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    font-weight: 900;
    letter-spacing: 0.38em;
    margin: 0 0 0.75rem;
    text-transform: uppercase;
}

.pcb-kt-card-list {
    display: grid;
    gap: 0.7rem;
}

.pcb-kt-card {
    --pcb-team-color: #9aa3aa;
    align-items: center;
    appearance: none;
    background: var(--pcb-card-bg);
    border: 1px solid var(--pcb-card-border);
    border-left: 7px solid var(--pcb-team-color);
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(31, 42, 51, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.82);
    color: #1f2a33;
    display: grid;
    font-family: inherit;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    min-height: 70px;
    padding: 0.85rem 1rem;
    text-align: left;
    transition: border-color 150ms ease, box-shadow 150ms ease, filter 150ms ease, transform 150ms ease;
    width: 100%;
}

.pcb-kt-card.is-team-green { --pcb-team-color: var(--pcb-team-green); }
.pcb-kt-card.is-team-yellow { --pcb-team-color: var(--pcb-team-yellow); }
.pcb-kt-card.is-team-red { --pcb-team-color: var(--pcb-team-red); }
.pcb-kt-card.is-team-blue { --pcb-team-color: var(--pcb-team-blue); }

button.pcb-kt-card {
    cursor: pointer;
}

button.pcb-kt-card:hover,
button.pcb-kt-card:focus-visible {
    box-shadow: 0 14px 34px rgba(31, 42, 51, 0.12), 0 0 0 3px color-mix(in srgb, var(--pcb-team-color) 30%, transparent);
    filter: brightness(1.01);
    transform: translateY(-1px);
}

button.pcb-kt-card:focus-visible {
    outline: 3px solid var(--pcb-team-color);
    outline-offset: 3px;
}

.pcb-kt-card.is-selected {
    border-color: color-mix(in srgb, var(--pcb-team-color) 60%, var(--pcb-card-border));
    border-left-color: var(--pcb-team-color);
    box-shadow: 0 12px 34px rgba(31, 42, 51, 0.12), 0 0 0 4px color-mix(in srgb, var(--pcb-team-color) 30%, transparent);
}

.pcb-kt-card:disabled {
    cursor: default;
    opacity: 0.76;
    transform: none;
}

.pcb-kt-icon {
    align-items: center;
    background: rgba(31, 42, 51, 0.04);
    border-radius: 999px;
    color: var(--pcb-team-color);
    display: inline-flex;
    height: 3.2rem;
    justify-content: center;
    width: 3.2rem;
}

.pcb-kt-icon svg {
    fill: none;
    height: 1.75rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3.6;
    width: 1.75rem;
}

.pcb-kt-separator {
    background: rgba(31, 42, 51, 0.12);
    display: inline-block;
    height: 2.7rem;
    margin: 0 1rem;
    width: 1px;
}

.pcb-kt-team-label {
    font-size: clamp(1.15rem, 4vw, 1.55rem);
    font-weight: 900;
    letter-spacing: 0.02em;
}

.pcb-kt-score-meta {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    justify-self: end;
    min-width: 6.5rem;
}

.pcb-kt-player {
    color: rgba(31, 42, 51, 0.72);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.pcb-kt-time,
.pcb-kt-timer {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
}

.pcb-kt-time {
    font-size: 0.95rem;
    font-weight: 900;
}

.pcb-kt-card.is-new-highscore {
    animation: pcbKtHighscoreBlink 760ms ease-in-out infinite;
}

.pcb-kt-timer {
    font-size: clamp(1.65rem, 7vw, 2.75rem);
    font-weight: 950;
    letter-spacing: 0.03em;
    line-height: 1;
    text-align: center;
}

.pcb-kt-board-wrap {
    aspect-ratio: 1 / 1;
    justify-self: center;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
    width: min(100%, var(--pcb-max-size, 560px));
}

.pcb-kt-board {
    border: 2px solid currentColor;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    height: 100%;
    overflow: hidden;
    position: relative;
    touch-action: manipulation;
    width: 100%;
}

.pcb-kt-board-wrap.is-success .pcb-kt-board {
    border-color: #00c853;
    box-shadow: 0 0 0 5px rgba(0, 200, 83, 0.22), 0 0 24px rgba(0, 200, 83, 0.32);
}

.pcb-kt-square {
    align-items: center;
    appearance: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    font: inherit;
    justify-content: center;
    margin: 0;
    min-height: 0;
    outline-offset: -3px;
    padding: 0;
    position: relative;
    user-select: none;
}

.pcb-kt-square.is-light { background: #f0d9b5; }
.pcb-kt-square.is-dark { background: #b58863; }

.pcb-kt-square.is-target::before,
.pcb-kt-square.is-completed::before {
    border-radius: 999px;
    content: "";
    height: 58%;
    left: 50%;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 58%;
    z-index: 2;
}

.pcb-kt-square.is-target::before {
    animation: pcbKtTargetBlink 620ms ease-in-out infinite;
    border: clamp(4px, 1.1vw, 7px) solid #00e676;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.86), 0 0 18px rgba(0, 230, 118, 0.92);
}

.pcb-kt-square.is-completed::before {
    border: clamp(4px, 1.1vw, 7px) solid #3b3f42;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.48), 0 0 12px rgba(0, 0, 0, 0.42);
}

.pcb-kt-square.is-finished.is-completed::before {
    border-color: #00e676;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.88), 0 0 18px rgba(0, 230, 118, 0.86);
}

.pcb-kt-square.is-legal::after {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 21%, rgba(255, 255, 255, 0.42) 22% 28%, transparent 29% 100%);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 1;
}

.pcb-kt-knight {
    color: #111;
    font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", "Arial Unicode MS", serif;
    font-size: clamp(2.25rem, 13vw, 5.4rem);
    line-height: 1;
    position: relative;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.35);
    z-index: 3;
}

.pcb-kt-star {
    color: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.72));
    font-size: clamp(2.4rem, 9vw, 4.8rem);
    left: 50%;
    line-height: 1;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.pcb-kt-square.is-finished .pcb-kt-star {
    color: #ffd400;
    transform: translate(-50%, -50%) scale(1.12);
}

.pcb-kt-coord {
    color: rgba(0, 0, 0, 0.65);
    font-size: clamp(0.55rem, 1.8vw, 0.75rem);
    font-weight: 800;
    line-height: 1;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

.pcb-kt-rank { left: 0.22rem; top: 0.22rem; }
.pcb-kt-file { bottom: 0.22rem; right: 0.22rem; }

.pcb-kt-restart {
    --pcb-team-color: #9aa3aa;
    align-items: center;
    appearance: none;
    background: var(--pcb-card-bg);
    border: 1px solid var(--pcb-card-border);
    border-left: 7px solid var(--pcb-team-color);
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(31, 42, 51, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.82);
    color: #1f2a33;
    cursor: pointer;
    display: grid;
    font: inherit;
    grid-template-columns: auto auto minmax(0, 1fr);
    justify-self: center;
    min-height: 66px;
    padding: 0.75rem 1rem;
    text-align: left;
    transition: border-color 150ms ease, box-shadow 150ms ease, filter 150ms ease, transform 150ms ease;
    width: min(100%, var(--pcb-max-size, 560px));
}

.pcb-kt-restart:hover,
.pcb-kt-restart:focus-visible {
    box-shadow: 0 14px 34px rgba(31, 42, 51, 0.12), 0 0 0 3px rgba(154, 163, 170, 0.22);
    filter: brightness(1.01);
    transform: translateY(-1px);
}

.pcb-kt-restart:focus-visible {
    outline: 3px solid var(--pcb-team-color);
    outline-offset: 3px;
}

.pcb-kt-restart .pcb-kt-team-label {
    font-size: clamp(1.05rem, 3.4vw, 1.35rem);
}

.pcb-kt-team-heading {
    border: 2px solid transparent;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 900;
    justify-self: center;
    margin-bottom: 0.6rem;
    padding: 0.28rem 0.9rem;
    text-align: center;
}

.pcb-kt-teams.is-waiting-for-team .pcb-kt-team-heading {
    animation: pcbKtTeamPromptBlink 760ms ease-in-out infinite;
    background: rgba(255, 214, 10, 0.18);
    border-color: rgba(255, 214, 10, 0.86);
    box-shadow: 0 0 0 4px rgba(255, 214, 10, 0.14), 0 0 18px rgba(255, 214, 10, 0.38);
}

.pcb-kt-message {
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.4;
    min-height: 2.8rem;
    text-align: center;
}

.pcb-kt-message-line + .pcb-kt-message-line {
    margin-top: 0.12rem;
}

.pcb-kt-challenge-line {
    font-size: 0.9em;
    font-weight: 900;
}

.pcb-sp-board {
    aspect-ratio: 1 / 1;
    border: 2px solid currentColor;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    max-width: var(--pcb-max-size, 560px);
    width: 100%;
}

.pcb-sp-square {
    align-items: center;
    appearance: none;
    border: 0;
    display: flex;
    font: inherit;
    justify-content: center;
    margin: 0;
    padding: 0;
    position: relative;
}

.pcb-sp-square.is-light { background: #f0d9b5; }
.pcb-sp-square.is-dark { background: #b58863; }
.pcb-sp-piece {
    font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", "Arial Unicode MS", serif;
    font-size: clamp(1.9rem, 9vw, 4.1rem);
    line-height: 1;
}

@keyframes pcbKtTargetBlink {
    0%, 100% { opacity: 0.78; }
    50% { opacity: 1; }
}

@keyframes pcbKtTeamPromptBlink {
    0%, 100% { filter: brightness(1); transform: scale(1); }
    50% { filter: brightness(1.18); transform: scale(1.035); }
}

@keyframes pcbKtHighscoreBlink {
    0%, 100% {
        box-shadow: 0 10px 28px rgba(31, 42, 51, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.82);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 12px 34px rgba(31, 42, 51, 0.12), 0 0 0 5px color-mix(in srgb, var(--pcb-team-color) 34%, transparent), 0 0 24px color-mix(in srgb, var(--pcb-team-color) 55%, transparent);
        filter: brightness(1.04);
    }
}

@media (max-width: 600px) {
    .pcb-kt-card {
        grid-template-columns: auto auto minmax(0, 1fr);
    }
    .pcb-kt-score-meta {
        grid-column: 3;
        justify-self: start;
        margin-top: 0.25rem;
    }
}
