
:root {
    --background: #101936;
    --panel: #202d55;
    --panel-light: #2b3b6a;
    --primary: #ffbe3d;
    --primary-dark: #e99a18;
    --text: #ffffff;
    --muted: #c7d3f1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(
        ellipse at top,
        #304c91 0%,
        #17244b 45%,
        #101936 100%
    );
}

button {
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

.app {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 25px;
}

.header h1 {
    font-size: clamp(28px, 5vw, 48px);
    margin: 10px 0;
    color: var(--primary);
}

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

.screen {
    width: 100%;
}

.hidden {
    display: none !important;
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
    background: var(--panel);
    border: 1px solid #41548c;
    border-radius: 20px;
    box-shadow: 0 8px 25px #0003;
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 21px;
}

.categories,
.difficulty-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.categories button,
.difficulty {
    padding: 13px 20px;
    border-radius: 12px;
    border: 2px solid #51649b;
    background: var(--panel-light);
    color: white;
    font-weight: bold;
}

.categories button:hover,
.difficulty:hover {
    border-color: var(--primary);
}

.categories button.active,
.difficulty.active {
    border-color: var(--primary);
    background: #5b4872;
}

.pictures {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 15px;
}

.picture-card {
    padding: 7px;
    border: 3px solid transparent;
    border-radius: 14px;
    background: #344671;
    color: white;
    cursor: pointer;
}

.picture-card.active {
    border-color: var(--primary);
}

.picture-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 9px;
}

.primary-button {
    display: block;
    width: min(100%, 400px);
    margin: 24px auto;
    padding: 17px;
    border: none;
    border-radius: 15px;
    background: linear-gradient(135deg, #ffd65c, #ff9a26);
    color: #30200c;
    font-size: 20px;
    font-weight: 800;
}

.primary-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    margin-bottom: 20px;
    background: var(--panel);
    border-radius: 15px;
    flex-wrap: wrap;
}

.game-toolbar button {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    background: #415789;
    color: white;
}

.game-stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.puzzle-area,
.game-sidebar {
    padding: 18px;
    background: var(--panel);
    border-radius: 18px;
    min-width: 0;
}

.puzzle-area h2 {
    margin-top: 0;
}

#puzzle-board {
    position: relative;
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    border: 3px dashed #8ca0d7;
    border-radius: 12px;
    overflow: hidden;
    background: #111b38;
}

#preview-image {
    width: 100%;
    max-height: 230px;
    object-fit: contain;
    border-radius: 12px;
}

#puzzle-pieces {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.puzzle-piece {
    cursor: grab;
    touch-action: none;
    user-select: none;
}

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

.win-card {
    max-width: 520px;
    margin: 50px auto;
    padding: 40px 25px;
    text-align: center;
    background: var(--panel);
    border-radius: 25px;
}

.win-card h2 {
    color: var(--primary);
    font-size: 36px;
}

.trophy {
    font-size: 75px;
}

@media (max-width: 850px) {
    .app {
        padding: 10px;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        width: 100%;
    }

    #puzzle-pieces {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .game-toolbar {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 14px;
    }

    .pictures {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .categories button,
    .difficulty {
        flex: 1 1 40%;
        padding: 12px 8px;
    }

    #puzzle-pieces {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-stats {
        font-size: 13px;
        gap: 10px;
    }
}

/* Puzzle – opravene rozmery a ovladanie */

#puzzle-board {
    height: auto;
    overflow: visible;
}

.puzzle-slot {
    position: relative;
    min-width: 0;
    min-height: 0;
    border: 1px dashed #536a99;
    background: #192849;
}

.puzzle-slot[data-filled="true"] {
    border-color: transparent;
    background: transparent;
}

#puzzle-pieces {
    align-items: start;
}

.puzzle-piece {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    touch-action: none;
    cursor: grab;
    user-select: none;
}

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

.puzzle-piece.selected {
    outline: 2px solid #ffbe3d;
    outline-offset: 3px;
}

.puzzle-piece.placed {
    width: 100%;
    min-height: 0;
    outline: none;
    pointer-events: none;
}

.puzzle-slot.wrong-slot {
    background: #963c4b;
}
