/* ==========================================================================
   PuzzleSum Startscreen: Optionen, Switches, Dropdown, Start-Button
   ========================================================================== */

/* Schwierigkeit-Auswahl */
#puzzleSumDifficulty {
    width: 100%;
    max-width: 16rem;
    margin-top: 0.35rem;
    padding: 0.55rem 2.5rem 0.55rem 0.85rem;
    border: 2px solid #8a7555;
    border-radius: 10px;
    background-color: #f8f2e8;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath fill='none' stroke='%235c4a32' stroke-width='2' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    color: #3d3428;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#puzzleSumDifficulty:hover {
    border-color: #5c4a32;
}

#puzzleSumDifficulty:focus {
    outline: none;
    border-color: #5c4a32;
    box-shadow: 0 0 0 3px rgba(92, 74, 50, 0.2);
}

/* Optionen-Block */
.puzzle-sum-options {
    margin-top: 1.25rem;
    padding: 1rem 1.15rem 1.15rem;
    border: 2px solid #8a7555;
    border-radius: 14px;
    background: #f4ecdd;
}

.puzzle-sum-options legend {
    padding: 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #5c4a32;
}

/* Options-Zeile: Text links, Switch rechts
   Selektor bewusst spezifisch, sonst gewinnt .start-main label { display: block } */
.start-main label.puzzle-sum-switch-option,
.puzzle-sum-options label.puzzle-sum-switch-option,
.puzzle-sum-switch-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    color: #3d3428;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.puzzle-sum-switch-option:hover {
    background: #ece0cb;
}

/* echte Checkbox aus dem sichtbaren Bereich schieben */
.puzzle-sum-switch-option input[type="checkbox"] {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* Switch-Bahn (aus = grau) */
.puzzle-sum-switch {
    position: relative;
    flex: 0 0 52px;
    flex-shrink: 0;
    width: 52px;
    min-width: 52px;
    height: 28px;
    border: 2px solid #c4c4c4;
    border-radius: 999px;
    background: #d3d3d3;
    transition: background 0.2s ease, border-color 0.2s ease;
}

/* Switch-Knopf */
.puzzle-sum-switch::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

/* eingeschaltet = gruen */
.puzzle-sum-switch-option input[type="checkbox"]:checked + .puzzle-sum-switch {
    background: #3a6b3f;
    border-color: #285030;
}

.puzzle-sum-switch-option input[type="checkbox"]:checked + .puzzle-sum-switch::before {
    transform: translateX(24px);
}

.puzzle-sum-switch-option input[type="checkbox"]:focus-visible + .puzzle-sum-switch {
    box-shadow: 0 0 0 3px rgba(92, 74, 50, 0.25);
}

/* Start-Button */
.puzzle-sum-start-button {
    margin-top: 1.5rem;
    padding: 0.6rem 1.5rem;
    border: 2px solid #285030;
    border-radius: 12px;
    background: #3a6b3f;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(40, 80, 48, 0.4);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

.puzzle-sum-start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 rgba(40, 80, 48, 0.4);
    background: #325c37;
    color: #ffffff;
}

.puzzle-sum-start-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(40, 80, 48, 0.4);
}

.puzzle-sum-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.puzzle-sum-live-layout {
    margin-top: 0.75rem;
}

.puzzle-sum-status-grid {
    margin-top: 0.35rem;
}

#puzzleSumScore.live-score {
    color: #b85c28;
}

#puzzleSumLives {
    color: #b3261e;
    font-weight: 700;
}

#puzzleSumUndoLeft {
    color: #8a7555;
    font-weight: 700;
}

#puzzleSumTime {
    color: #2f80ed;
    font-weight: 700;
}

#puzzleSumGridContainer{
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    touch-action: none;
}

#puzzleSumPieces{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    align-content: start;
    touch-action: none;
}

.puzzle-sum-grid {
    display: grid;
    gap: 6px;
    touch-action: none;
}

#puzzleSumPracticeHint {
    min-height: 24px;
    font-weight: bold;
    color: #2f80ed;
}

.puzzle-sum-cell {
    margin: 0;
    padding: 0.5rem;
    min-height: auto;
    background: #f8f2e8;
    border: 2px solid #8a7555;
    font-weight: 600;

    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, outline-color 0.2s ease;
}

.puzzle-sum-cell-preview {
    outline: 4px solid #2f9e44;
    outline-offset: -4px;
    background: #d3f9d8;
}

.puzzle-sum-cell-preview-invalid {
    outline: 4px solid #e03131;
    outline-offset: -4px;
    background: #ffe3e3;
}

.puzzle-sum-cell-placed {
    color: #ffffff;
    transform: scale(0.96);
}
.puzzle-sum-piece {
    min-width: 64px;
    min-height: 48px;
    border: 2px none #333;
    border-radius: 8px;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    font-size: 20px;
    padding: 8px;
    margin: 0;
    touch-action: none;
}

.puzzle-sum-rotate-button {
    position: relative;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    min-height: 22px;
    margin: 0;
    padding: 0;
    border: 1px solid #5c4a32;
    border-radius: 50%;
    background: #f8f2e8;
    color: #3d3428;
    font-size: 13px;
    line-height: 1;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.puzzle-sum-rotate-button:hover {
    background: #ffffff;
    transform: scale(1.08);
}

.puzzle-sum-piece-dragging {
    opacity: 0.65;
    transform: scale(1.05);
    z-index: 10;
}

.puzzle-sum-piece:active {
    cursor: grabbing;
    transform: scale(0.96);
}

.puzzle-sum-piece-shape {
    display: grid;
    gap: 2px;
}

.puzzle-sum-piece-shape-cell {
    width: 22px;
    height: 22px;
}

.puzzle-sum-piece-shape-cell.filled {
    border: 2px solid #8a7555;
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Add more styles as needed */

.puzzle-sum-piece-shape {
    display: grid;
    gap: 2px;
}

.puzzle-sum-piece-shape-cell {
    width: 20px;
    height: 20px;
}

.puzzle-sum-piece-shape-cell.filled {
    background: #ffbf3f;
    border: 1px solid #333;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}


@media (max-width: 760px) {
    #PuzzleSumMain .game-layout {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    #PuzzleSumMain .panel {
        padding: 0.5rem;
    }

    #PuzzleSumMain .game-left {
        display: block;
        min-width: 0;
        font-size: 0.8rem;
    }

    #PuzzleSumMain .game-left .screen-title {
        display: none;
    }

    #puzzle-sum-status p,
    #puzzle-sum-status div {
        margin-bottom: 0.2rem;
        font-size: 0.85rem;
    }

    .puzzle-sum-live-layout {
        align-items: center;
    }

    #PuzzleSumMain .live-score {
        font-size: 1.7rem;
    }

    #PuzzleSumMain .stats-grid {
        column-gap: 0.6rem;
        row-gap: 0.1rem;
    }

    .puzzle-sum-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.25rem;
    }

    .puzzle-sum-actions button {
        margin-top: 0;
        padding: 0.35rem;
        font-size: 0.8rem;
    }

    #PuzzleSumMain .game-center,
    #PuzzleSumMain .game-right {
        min-width: 0;
    }

    #puzzleSumGrid {
        gap: 3px;
        transform: scale(0.9);
        transform-origin: top center;
    }

    .puzzle-sum-cell {
        padding: 0.25rem;
        font-size: 0.85rem;
    }

    #puzzleSumPieces {
        grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
        gap: 4px;
        max-height: 28vh;
        overflow: hidden;
    }

    .puzzle-sum-piece {
        min-width: 44px;
        min-height: 36px;
        padding: 3px;
    }

    .puzzle-sum-rotate-button {
        top: -5px;
        right: -5px;
        width: 18px;
        height: 18px;
        min-height: 18px;
        font-size: 10px;
    }

    .puzzle-sum-piece-shape {
        gap: 1px;
    }

    .puzzle-sum-piece-shape-cell,
    .puzzle-sum-piece-shape-cell.filled {
        width: 14px;
        height: 14px;
        font-size: 7px;
    }
}
/* ==========================================================================
   PuzzleSum Spielbildschirm: Aktions-Buttons farbig
   ========================================================================== */

.puzzle-sum-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.25rem;
}

#buttonBackToPuzzleSumStart,
#buttonRestartPuzzleSum,
#buttonResetPuzzleSum,
#buttonUndoPuzzleSum {
    width: 100%;
    margin-top: 0;
    padding: 0.6rem 1.25rem;
    border: 2px solid #5c4a32;
    border-radius: 12px;
    font: inherit;
    font-weight: 700;
    color: #f8f2e8;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(92, 74, 50, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

#buttonBackToPuzzleSumStart:hover,
#buttonRestartPuzzleSum:hover,
#buttonResetPuzzleSum:hover,
#buttonUndoPuzzleSum:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 rgba(92, 74, 50, 0.35);
    color: #f8f2e8;
}

#buttonBackToPuzzleSumStart:active,
#buttonRestartPuzzleSum:active,
#buttonResetPuzzleSum:active,
#buttonUndoPuzzleSum:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(92, 74, 50, 0.35);
}

#buttonBackToPuzzleSumStart:disabled,
#buttonRestartPuzzleSum:disabled,
#buttonResetPuzzleSum:disabled,
#buttonUndoPuzzleSum:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 3px 0 rgba(92, 74, 50, 0.35);
}

/* Zurueck -> rot */
#buttonBackToPuzzleSumStart {
    background: #b3261e;
    border-color: #8a1c16;
}

#buttonBackToPuzzleSumStart:hover {
    background: #9c211a;
}

/* Neue Runde -> gruen */
#buttonRestartPuzzleSum {
    background: #4c8a52;
    border-color: #3a6b3f;
}

#buttonRestartPuzzleSum:hover {
    background: #427848;
}

/* Zuruecksetzen -> orange */
#buttonResetPuzzleSum {
    background: #c9772f;
    border-color: #9a5a23;
}

#buttonResetPuzzleSum:hover {
    background: #b06827;
}

/* Undo -> blau */
#buttonUndoPuzzleSum {
    background: #4f7cac;
    border-color: #3a5f86;
}

#buttonUndoPuzzleSum:hover {
    background: #456d97;
}