* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Restrictions de scroll uniquement pour le jeu */
body.game-mode {
    overflow-y: hidden;
    height: 100%;
    max-height: 100vh;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Couleurs d'allumage (modifiées via JS avec des variables CSS) */
:root {
    --highlight-color: #ff3333;
    --highlight-glow-color: rgba(255, 51, 51, 0.8);
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Animation de tremblement pour les décorations - utilise seulement translate */
@keyframes shake {
    0%, 100% {
        transform: translate(0, 0);
    }
    10% {
        transform: translate(-3px, -2px);
    }
    20% {
        transform: translate(3px, 2px);
    }
    30% {
        transform: translate(-2px, 3px);
    }
    40% {
        transform: translate(2px, -3px);
    }
    50% {
        transform: translate(-3px, 2px);
    }
    60% {
        transform: translate(3px, -2px);
    }
    70% {
        transform: translate(-2px, -3px);
    }
    80% {
        transform: translate(2px, 3px);
    }
    90% {
        transform: translate(-3px, -2px);
    }
}

/* SYSTÈME D'ÉCRANS */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Restrictions de hauteur uniquement pour le jeu */
#game.screen {
    max-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#settings.screen.active {
    align-items: flex-start;
    padding-top: 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    max-width: 100%;
    width: 100%;
    padding: 30px;
    animation: fadeIn 0.5s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-sizing: border-box;
    overflow-x: hidden;
}

#settings .container {
    max-width: 100%;
    width: calc(100% - 40px);
    margin: 0 auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* MENU PRINCIPAL */
.main-header {
    text-align: center;
    margin-bottom: 50px;
}

.main-header h1 {
    font-size: 4.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    text-shadow: none;
    font-weight: 800;
    letter-spacing: -2px;
}

.subtitle {
    font-size: 1.4em;
    color: #555;
    font-weight: 500;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 25px;
    max-width: 500px;
    margin: 0 auto;
}

.menu-btn {
    padding: 28px 45px;
    font-size: 1.6em;
    font-weight: 700;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.create-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.create-btn:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(16, 185, 129, 0.6);
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.play-btn:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.settings-btn {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(107, 114, 128, 0.4);
}

.settings-btn:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(107, 114, 128, 0.6);
}

/* ÉDITEUR */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
}

.editor-header h2 {
    font-size: 2.5em;
    color: #667eea;
}

.back-btn {
    padding: 10px 25px;
    font-size: 1.1em;
    font-weight: 600;
    background: #e0e7ff;
    color: #667eea;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #c7d2fe;
    transform: translateX(-5px);
}

.level-info {
    margin-bottom: 30px;
}

.level-info label {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.level-info span {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

.level-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.level-info label {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.level-info label span:first-child {
    min-width: 200px;
    font-weight: 600;
    color: #333;
}

.level-info input {
    padding: 12px 20px;
    font-size: 1.1em;
    border: 2px solid #667eea;
    border-radius: 10px;
    outline: none;
    flex: 1;
    max-width: 300px;
}

.speed-display {
    font-weight: bold;
    color: #667eea;
    font-size: 1.2em;
    min-width: 60px;
}

.level-info input:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Onglets de niveaux */
.level-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 3px solid #e0e7ff;
    padding-bottom: 10px;
}

.level-tab {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.1em;
    font-weight: 600;
    background: #f8fafc;
    color: #667eea;
    border: 2px solid #e0e7ff;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: none;
}

.level-tab:hover {
    background: #e0e7ff;
    transform: translateY(-2px);
}

.level-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Contenu des niveaux */
.level-content {
    display: none;
}

.level-content.active {
    display: block;
}

.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 20px;
}

.editor-content h3 {
    font-size: 1.8em;
    color: #333;
    margin: 0;
    flex: 1;
}

.btn-random-level {
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-random-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.4);
}

.info-text {
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1em;
}

/* GRILLE ÉDITEUR */
.editor-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.editor-cell {
    aspect-ratio: 1;
    border: 4px dashed #667eea;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: #f8fafc;
}

.editor-cell:hover {
    border-color: #764ba2;
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.cell-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.cell-number {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #667eea;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
}

.cell-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
}

.add-icon {
    font-size: 3em;
    color: #667eea;
}

.cell-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.editor-cell.has-image {
    border-style: solid;
    background: white;
}

.editor-cell.has-color {
    border-style: solid;
    border-width: 4px;
}

.editor-cell.has-text {
    border-style: solid;
    border-color: #10b981;
}

.cell-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    color: #111827;
    padding: 4px;
    word-break: break-word;
}

/* ACTIONS ÉDITEUR */
.editor-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 18px 50px;
    font-size: 1.3em;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-save {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-save:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.btn-random {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-random:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

/* Bouton Mode texte - plus petit et coloré */
.btn-text-mode {
    padding: 10px 20px !important;
    font-size: 0.95em !important;
    font-weight: 600 !important;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    color: white !important;
    border: 2px solid #1d4ed8 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-transform: none !important;
    letter-spacing: 0.5px !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4) !important;
}

.btn-text-mode:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.6) !important;
}

.btn-text-mode:active {
    transform: translateY(0) !important;
}

/* LISTE DES NIVEAUX */
.levels-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.level-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.level-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.level-card h3 {
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 15px;
}

.level-preview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 15px;
}

.level-preview-img {
    aspect-ratio: 1;
    border-radius: 5px;
    overflow: hidden;
}

.level-preview-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.level-card button {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    font-weight: bold;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.level-card button:hover {
    background: #764ba2;
}

.delete-level {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 35px;
    height: 35px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.delete-level:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.empty-state {
    text-align: center;
    color: #666;
    font-size: 1.3em;
    margin-top: 50px;
    font-style: italic;
}

/* JEU */
#game {
    background: #ffffff;
    padding: 0;
    overflow: hidden;
    max-height: 100vh;
    height: 100vh;
}

/* Écran blanc avec fond papier */
.white-screen {
    width: 100vw;
    height: 100vh;
    background: url("image/fond papier.jpg") center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
}

.white-screen-content {
    font-size: 4rem;
    font-weight: 900;
    color: #000;
    font-family: 'Bangers', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.05em;
}

/* Zone de jeu avec même fond papier */
.game-area {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    background: url("image/fond papier.jpg") center/cover no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Décorations autour de la grille (images fournies) */
.decor {
    position: absolute;
    pointer-events: none;
}

.decor {
    position: absolute;
    z-index: 5;
    cursor: default;
    pointer-events: auto; /* permet de cliquer/glisser/molette sur les images */
    transform-origin: center center;
    /* L'animation shake est gérée par JavaScript pour combiner avec rotate/scale */
}

/* Délais différents pour chaque décor pour un effet plus naturel */
.decor-top-left {
    animation-delay: 0s;
}

.decor-top-right {
    animation-delay: 0.1s;
}

.decor-bottom-left {
    animation-delay: 0.2s;
}

.decor-bottom-right {
    animation-delay: 0.15s;
}

/* En mode édition, les décors deviennent déplaçables visuellement */
.decor-edit-mode .decor {
    cursor: move;
    animation: none; /* Désactiver l'animation en mode édition */
}

.decor-top-left {
    top: 35px;
    left: -10px;
    width: 240px;
    transform: rotate(-8deg);
}

.decor-top-right {
    top: 40px;
    right: -10px;
    width: 220px;
    transform: rotate(10deg);
}

.decor-bottom-left {
    bottom: 80px;
    left: 10px;
    width: 170px;
    transform: rotate(-8deg);
}

.decor-bottom-right {
    bottom: 90px;
    right: 25px;
    width: 180px;
    transform: rotate(6deg);
}

/* Header visible pour permettre l'édition des décorations */
.game-header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    display: flex !important;
    justify-content: center;
    align-items: center;
    padding: 20px 40px;
    z-index: 1000;
    background: transparent;
    pointer-events: none;
}

.game-header-actions {
    position: absolute !important;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex !important;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

/* Les boutons d'édition doivent être visibles */
.edit-decor-btn,
.copy-decor-btn,
.quit-btn {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Masquer les boutons uniquement dans la page du jeu (via classe ajoutée par React) */
body.game-page .game-header-actions,
body.game-page .edit-decor-btn,
body.game-page .copy-decor-btn,
body.game-page .quit-btn {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.game-header h3 {
    font-size: 3rem;
    color: #000;
    text-shadow: none;
    font-family: 'Bangers', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0.05em;
    text-align: center;
    position: relative;
    transform-origin: center center;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto;
    margin: 0;
}

.game-header-actions {
    position: relative;
    display: flex !important;
    gap: 10px;
    align-items: center;
    visibility: visible !important;
    opacity: 1 !important;
}

.quit-btn {
    padding: 12px 25px;
    font-size: 1.1em;
    font-weight: bold;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quit-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.edit-decor-btn {
    padding: 8px 10px;
    font-size: 1.1em;
    background: rgba(15, 23, 42, 0.85);
    color: #f9fafb;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-decor-btn:hover {
    transform: scale(1.05);
    background: #111827;
}

.copy-decor-btn {
    padding: 8px 10px;
    font-size: 0.95rem;
    background: rgba(16, 185, 129, 0.9);
    color: #ecfdf5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-decor-btn:hover {
    transform: scale(1.05);
    background: #059669;
}

/* GRILLE DE JEU */
.game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 22px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.game-grid.show {
    opacity: 1;
    transform: scale(1);
}

.game-cell {
    aspect-ratio: 1;
    border: 6px solid #000000;
    border-radius: 0;
    overflow: hidden;
    background: #ffffff;
    transition: border-color 0.2s ease;
    box-shadow: none;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(1);
    transform-origin: center center;
}

.game-cell-text {
    position: absolute;
    inset: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #000;
    font-family: 'Bangers', sans-serif;
    font-size: 32px;
    pointer-events: none;
    padding: 4px;
    word-break: break-word;
}

.game-cell.highlight {
    border-color: var(--highlight-color);
    border-width: 8px;
    box-shadow: 0 0 35px var(--highlight-glow-color);
}

.cell-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

/* Empêcher l'affichage de placeholders ou d'emojis dans les images vides */
.cell-image:not([src]),
.cell-image[src=""],
.cell-image[src="undefined"] {
    display: none !important;
    content: none !important;
}

/* S'assurer que les cases vides n'affichent rien */
/* MAIS ne pas masquer le texte si celui-ci a été explicitement affiché */
.game-cell:has(.cell-image:not([src])) .game-cell-text:not([style*="display: flex"]):not([style*="display:block"]),
.game-cell:has(.cell-image[src=""]) .game-cell-text:not([style*="display: flex"]):not([style*="display:block"]) {
    display: none !important;
    content: none !important;
}

/* Supprimer complètement les emojis de musique dans les cases */
.game-cell-text {
    /* Masquer par défaut si vide ou contient seulement des emojis */
}

/* Masquer le texte s'il contient uniquement des emojis de musique */
.game-cell-text:empty {
    display: none !important;
}

/* Règle pour supprimer visuellement les emojis */
.game-cell-text::before,
.game-cell-text::after {
    content: none !important;
    display: none !important;
}

.game-instruction {
    position: absolute;
    bottom: 50px;
    text-align: center;
}

.game-instruction p {
    font-size: 1.4rem;
    color: #000;
    font-weight: 600;
    text-shadow: none;
}

/* MODALES PERSONNALISÉES */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.show {
    display: flex;
}

.modal-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    transform: scale(1);
}

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

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
    font-size: 1.1em;
    line-height: 1.6;
    color: #333;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-body p {
    margin: 0;
    white-space: pre-line;
}

.modal-footer {
    padding: 20px 30px;
    background: #f8fafc;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    border-top: 1px solid #e0e7ff;
}

.modal-btn {
    padding: 12px 30px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.modal-btn-secondary {
    background: #e0e7ff;
    color: #667eea;
}

.modal-btn-secondary:hover {
    background: #c7d2fe;
    transform: translateY(-2px);
}

.modal-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.modal-btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.modal-btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.modal-btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 158, 11, 0.4);
}

/* AMÉLIORATION DU DESIGN GÉNÉRAL */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    max-width: 1000px;
    width: 100%;
    padding: 50px;
    animation: fadeIn 0.5s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.main-header h1 {
    font-size: 4.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    text-shadow: none;
    font-weight: 800;
    letter-spacing: -2px;
}

.subtitle {
    font-size: 1.4em;
    color: #555;
    font-weight: 500;
}

.menu-btn {
    padding: 28px 45px;
    font-size: 1.6em;
    font-weight: 700;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.menu-btn:hover {
    transform: translateY(-8px) scale(1.02);
}

.create-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.create-btn:hover {
    box-shadow: 0 15px 40px rgba(16, 185, 129, 0.6);
}

.play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.play-btn:hover {
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

/* PARAMÈTRES */
.settings-content {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 10px;
    width: 100%;
    box-sizing: border-box;
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 500px);
    gap: 30px;
    align-items: start;
    width: 100%;
    max-width: 100%;
}

@media (max-width: 1200px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }
    
    .settings-right {
        position: relative;
        top: 0;
    }
}

.settings-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    overflow-x: hidden;
}

.settings-right {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    min-width: 0;
    width: 100%;
}

.settings-section {
    margin-bottom: 40px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 15px;
    border: 2px solid #e0e7ff;
    min-width: 0;
}

.settings-section h3 {
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e7ff;
}

.settings-group {
    margin-bottom: 15px;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    color: #333;
    font-weight: 500;
}

.settings-group input[type="number"] {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 8px;
    width: 120px;
    outline: none;
    transition: all 0.3s ease;
}

.settings-group input[type="number"]:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.settings-group .unit {
    color: #666;
    font-size: 0.9em;
    min-width: 30px;
}

.settings-hint {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.settings-preview {
    background: white;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #667eea;
    margin-top: 15px;
}

.settings-preview p {
    margin: 0;
    font-size: 1.1em;
    color: #333;
}

.settings-preview span {
    color: #667eea;
    font-weight: bold;
}

.settings-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e0e7ff;
}

.btn-reset {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

.btn-reset:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(107, 114, 128, 0.4);
}

/* APERÇU EN TEMPS RÉEL */
.settings-preview-section {
    margin-top: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    border-radius: 15px;
    border: 3px solid #667eea;
}

.settings-preview-section h3 {
    font-size: 1.8em;
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.preview-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.btn-preview {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 15px 30px;
    font-size: 1.1em;
}

.btn-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 15px 30px;
    font-size: 1.1em;
}

.btn-stop:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.preview-container {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
    min-width: 0;
}

.preview-cell {
    aspect-ratio: 1;
    border: 4px solid #667eea;
    border-radius: 10px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.preview-cell.highlight {
    border-color: var(--highlight-color);
    border-width: 8px;
    transform: scale(1.1);
    box-shadow: 0 0 30px var(--highlight-glow-color);
    background: rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.preview-cell.active {
    background: #e0e7ff;
    border-color: #764ba2;
}

.preview-info {
    text-align: center;
    padding: 15px;
    background: #f8fafc;
    border-radius: 10px;
}

.preview-info p {
    margin: 5px 0;
    font-size: 1.2em;
    color: #333;
    font-weight: 600;
}

.preview-info span {
    color: #667eea;
}

#previewWhiteScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 1000;
    border-radius: 15px;
    display: none;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .main-header h1 {
        font-size: 2.5em;
    }

    .editor-grid,
    .game-grid {
        gap: 10px;
    }

    .menu-btn {
        font-size: 1.2em;
        padding: 18px 30px;
    }

    .editor-header h2 {
        font-size: 1.8em;
    }

    .game-header h3 {
        font-size: 1.5em;
    }

    .game-instruction p {
        font-size: 1.3em;
    }

    .modal-container {
        width: 95%;
        margin: 20px;
    }

    .modal-header h3 {
        font-size: 1.4em;
    }

    .modal-body {
        padding: 20px;
        font-size: 1em;
    }
}

/* Super Levels Editor */
.game-info {
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    border-radius: 15px;
    border: 2px solid #667eea;
}

.game-info .highlight-color-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.game-info .highlight-color-label span {
    font-weight: 600;
}

.game-info #highlightColorInput {
    width: 48px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.game-info label {
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-info label span {
    min-width: 150px;
    font-weight: 600;
    color: #333;
}

.super-levels-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.super-level-editor {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 3px solid #e0e7ff;
    border-radius: 15px;
    padding: 20px;
    transition: all 0.3s ease;
}

.super-level-editor.active {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.super-level-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.super-level-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    min-width: 300px;
}

.super-level-info label {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.super-level-info label span:first-child {
    min-width: 150px;
    font-weight: 600;
    color: #333;
}

.super-level-info input {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 8px;
    outline: none;
    flex: 1;
    max-width: 200px;
}

.super-level-actions {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.btn-select-super-level {
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-select-super-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-delete-super-level {
    padding: 10px 15px;
    font-size: 1em;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-delete-super-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.add-super-level-container {
    margin-bottom: 30px;
    text-align: center;
}

.btn-add-super-level {
    padding: 15px 30px;
    font-size: 1.2em;
    font-weight: bold;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-add-super-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.4);
}

.level-tabs-container {
    margin-bottom: 20px;
}

/* Navigation entre super levels */
.super-level-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    gap: 20px;
}

.super-level-counter {
    font-size: 1.2em;
    font-weight: bold;
    color: white;
    flex: 1;
    text-align: center;
}

.btn-nav-super-level {
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn-nav-super-level:hover:not(:disabled) {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

.btn-nav-super-level:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Popup personnalisé pour remplacer prompt() */
.custom-prompt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.custom-prompt-modal {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    border-radius: 20px;
    padding: 2rem;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

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

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

.custom-prompt-title {
    color: white;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.custom-prompt-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    margin-bottom: 1.5rem;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.custom-prompt-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
    background: white;
}

.custom-prompt-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.custom-prompt-button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.custom-prompt-button-ok {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.custom-prompt-button-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.custom-prompt-button-cancel {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.custom-prompt-button-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

@media (max-width: 480px) {
    .custom-prompt-modal {
        min-width: 90vw;
        padding: 1.5rem;
    }
    
    .custom-prompt-buttons {
        flex-direction: column;
    }
    
    .custom-prompt-button {
        width: 100%;
    }
}