.kp-container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #222;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* HEADER */

.kp-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.kp-header-row {
    display: flex;
    align-items: center;
    justify-content: center; /* Timer in der Mitte, Buttons links/rechts mit Abstand */
    gap: 15px; /* 15px Abstand zwischen START – Zeit – NEUSTART */
}

.kp-timer {
    font-size: 2.4rem;
    font-weight: 700;
    text-align: center;
    flex: 0 0 auto;
}

.kp-player-buttons {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

/* Buttons */

.kp-btn {
    border: none;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 120px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
    color: #fff;
}

.kp-btn:disabled {
    opacity: 0.55;
    cursor: default;
    box-shadow: none;
}

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

.kp-container .kp-btn-start {
    background-color: #e53935 !important; /* START = ROT */
}

.kp-container .kp-btn-restart {
    background-color: #43a047 !important; /* NEUSTART = GRÜN */
}

.kp-btn-player {
    background-color: #1976d2;
    font-size: 0.9rem;
    padding: 8px 10px;
}

.kp-btn-player.kp-btn-player-active {
    background-color: #e53935;
}

/* Board */

.kp-board-wrapper {
    width: 100%;
}

.kp-board {
    position: relative;
    width: 100%;
    /* vorher 9/12 → jetzt ca. 10% höher: 9 / 13.2 */
    aspect-ratio: 9 / 13.2;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

/* Ebenen im Board */
.kp-board-preview,
.kp-board-grid,
.kp-pieces-layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.kp-board-preview {
    background-repeat: no-repeat;
    pointer-events: none;
}

.kp-board-grid {
    display: grid;
    grid-template-columns: repeat(var(--kp-grid, 3), 1fr);
    grid-template-rows: repeat(var(--kp-grid, 3), 1fr);
    gap: 2px;
    pointer-events: none;
}

.kp-grid-slot {
    border: 1px dashed rgba(0,0,0,0.16);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
}

.kp-pieces-layer {
    position: absolute;
    left: 0;
    top: 0;
}

.kp-piece {
    position: absolute;
    background-size: cover;
    background-position: center;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
    cursor: grab;
    transition: box-shadow 0.1s ease;
}

.kp-piece-dragging {
    cursor: grabbing;
    box-shadow: 0 6px 12px rgba(0,0,0,0.45);
}

/* Config */

.kp-config {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.95rem;
}

.kp-config-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    justify-content: center;
}

.kp-config label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kp-select {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #ccc;
    font-size: 0.95rem;
}

/* Winner overlay */

.kp-winner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 9999;
}

.kp-winner-overlay-visible {
    opacity: 1;
    pointer-events: auto;
}

.kp-winner-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 24px;
    padding: 32px 24px 24px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    overflow: hidden;
}

.kp-winner-close {
    position: absolute;
    right: 12px;
    top: 8px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    cursor: pointer;
}

.kp-winner-text-line {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.kp-winner-time {
    font-size: 1.4rem;
    margin-bottom: 18px;
}

.kp-btn-close-popup {
    background-color: #43a047;
}

.kp-confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.kp-confetti-piece {
    position: absolute;
    top: -10%;
    width: 8px;
    height: 14px;
    background: linear-gradient(180deg, #ffeb3b, #f44336);
    opacity: 0.9;
    animation-name: kp-confetti-fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.kp-confetti-piece:nth-child(3n) {
    background: linear-gradient(180deg, #4caf50, #03a9f4);
}

.kp-confetti-piece:nth-child(5n) {
    background: linear-gradient(180deg, #e91e63, #9c27b0);
}

@keyframes kp-confetti-fall {
    0% {
        transform: translate3d(0, 0, 0) rotateZ(0deg);
    }
    100% {
        transform: translate3d(0, 120vh, 0) rotateZ(360deg);
    }
}

@media (max-width: 768px) {
    .kp-timer {
        font-size: 1.8rem;
    }

    .kp-player-buttons {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
