* {
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;

    margin: 0;
    padding: 20px;
  background-image: url('1.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

#app {
    background: rgba(255, 255, 255, 0.5);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    backdrop-filter: blur(3px);

}

h1 {
    color: #333;
    font-size: 3em;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#level-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-top: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.level-card {
    /*width: 120px;
    height: 120px;*/
    background-color: #f8f9fa;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    border: 3px solid transparent;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.level-card:hover:not(.locked) {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    border-color: #667eea;
}

.level-card.locked {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.level-card.completed {
    border-color: #28a745;
    box-shadow: 0 8px 16px rgba(40, 167, 69, 0.3);
}

.level-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 17px;
    transition: transform 0.3s ease;
}

.level-card:hover:not(.locked) img {
    transform: scale(1.1);
}

.level-card .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 2.5em;
    border-radius: 17px;
    backdrop-filter: blur(2px);
}

.level-card .level-number {
    position: absolute;
    bottom: 5px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
}

#puzzle-game {
    display: none;
    margin-top: 30px;
}

.cheat-code-input {
    display: flex;
    align-items: center;
}

.cheat-code-input input {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 20px;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.3s ease;
}

.cheat-code-input input:focus {
    border-color: #667eea;
}

.cheat-code-input input::placeholder {
    color: #999;
}
.main-container {
    display: flex;
    flex-direction: column; /* Aligne les enfants verticalement */
    align-items: flex-end; /* Aligne le contenu à droite */
    margin-right: 20px; /* Ajoute une marge à droite pour ne pas coller au bord */
}
/* New CSS for the support link */
.support-link-container {
    text-align: center;
    margin-top: 15px; /* Adds some space between the input and the link */
}

.support-link {
    font-size: 0.8em;
    color: #764ba2;
    text-decoration: none; /* Removes the underline from the link */
    transition: color 0.3s ease;
text-align: right
}

.support-link:hover {
    color: #667eea; /* Changes color when you hover over the link */
}
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-button {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.game-info {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.timer, .moves-counter {
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#puzzle-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: nowrap;
    max-width: 1400px;
    margin: 0 auto;
}

#game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 320px;
    min-width: 320px;
}

#preview-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 250px;
    min-width: 250px;
}

#image-preview {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 15px;
    border: 3px solid #28a745;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 250px;
}

#image-preview h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
    font-size: 1.1em;
}

#preview-image {
    width: 100%;
    max-width: 200px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#puzzle-board {
    display: grid;
    gap: 3px;
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

#pieces-area {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    border: 3px solid #764ba2;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);

}

#pieces-area h3 {
    margin-top: 0;
    color: #333;
    font-size: 1.2em;
}

#pieces-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;

}

.puzzle-piece {
    border: 2px solid #ddd;
    cursor: grab;
    background-size: cover;
    background-repeat: no-repeat;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    min-height: 90px;
    width: 90px;
    height: 90px;
}

.puzzle-piece:hover {
    transform: scale(1.05);
    border-color: #667eea;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.puzzle-piece.dragging {
    opacity: 0.8;
    transform: rotate(5deg) scale(1.1);
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.puzzle-piece.correct {
    border-color: #28a745;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
    animation: correctPiece 0.5s ease;
}

.drop-zone.filled .puzzle-piece {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

.drop-zone {
    border: 3px dashed #ccc;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    min-height: 100px;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone.drag-over {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.drop-zone.filled {
    border-color: #28a745;
}

@keyframes correctPiece {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes fireworks {
    0% { 
        transform: scale(0.5);
        opacity: 1;
    }
    50% { 
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% { 
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes sparkle {
    0%, 100% { 
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% { 
        transform: scale(1) rotate(180deg);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.firework-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
}

.sparkle-effect {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 999;
    animation: sparkle 0.6s ease-out;
}

.correct-placement {
    animation: bounce 0.6s ease, pulse 1s ease;
}

.completion-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.5s ease;
}

.completion-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease;
}

.completion-content h2 {
    color: #28a745;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.completion-content video {
    max-width: 400px;
    width: 100%;
    border-radius: 15px;
    margin: 20px 0;
}

.next-level-button {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.2em;
    margin: 10px;
    transition: all 0.3s ease;
}

.next-level-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    #app {
        padding: 20px;
        margin: 10px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .level-card {
        width: 100px;
        height: 100px;
    }
    
    #puzzle-container {
        flex-direction: column;
        align-items: center;
    }
    
    .game-header {
        flex-direction: column;
        text-align: center;
    }
}


.cheat-code-input {
    position: absolute;
    bottom: 20px;
    right: 20px;
}

.cheat-code-input input {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s ease;
}

.cheat-code-input input:focus {
    border-color: #667eea;
}

.cheat-code-input input::placeholder {
    color: #999;
}

.cheat-code-input {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
}

.cheat-code-input input {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 25px 0 0 25px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s ease;
}

.cheat-code-input input:focus {
    border-color: #667eea;
}

.cheat-code-input input::placeholder {
    color: #999;
}

.cheat-code-input button {
    padding: 10px 15px;
    border: 2px solid #667eea;
    background-color: #667eea;
    color: white;
    border-radius: 0 25px 25px 0;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.cheat-code-input button:hover {
    background-color: #5a67d8;
}

const improvedPuzzleCSS = `
.puzzle-piece {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: grab;
    background-clip: padding-box !important;
}

.puzzle-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 10;
}

.puzzle-piece.dragging {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    z-index: 100;
    cursor: grabbing;
}

.puzzle-piece.correct {
    border: 2px solid #4CAF50 !important;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.drop-zone {
    background: rgba(0,0,0,0.05);
    border: 2px dashed rgba(0,0,0,0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.drop-zone.drag-over {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4CAF50;
}

.drop-zone.filled {
    background: transparent;
    border: 2px solid rgba(0,0,0,0.1);
}
`;

#originalPiecesContainer {
    width: 600px; /* Adaptez à la largeur de votre image originale */
    height: 400px; /* Adaptez à la hauteur de votre image originale */
    border: 2px dashed #ccc;
    margin: 10px;
    position: relative; /* Important pour le positionnement absolu des pièces */
    overflow: auto; /* Si vous avez beaucoup de pièces */
}

#puzzleArea {
    width: 600px; /* Adaptez à la largeur de votre image originale */
    height: 400px; /* Adaptez à la hauteur de votre image originale */
    border: 2px solid #000;
    margin: 10px;
    position: relative; /* Important pour le positionnement absolu des pièces */
    background-color: #f0f0f0;
}

#previewCanvas {
    border: 1px solid #ddd;
    margin: 10px;
}

.puzzle-piece {
    /* Dimensions définies par JS */
    /* background-image et background-size définies par JS */
    cursor: grab;
    transition: transform 0.3s ease-in-out; /* Pour une rotation douce */
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.5); /* Bordure pour les pièces */
    background-repeat: no-repeat;
    background-position: center; /* Pour centrer l'image dans la pièce si background-size est 'contain' */
}

.puzzle-piece:active {
    cursor: grabbing;
    z-index: 1000; /* Assure que la pièce glissée est au-dessus des autres */
}

