/* --- Variables & Thème --- */
:root {
    --primary: #ff4081;
    --primary-soft: #ff80ab;
    --secondary: #7c4dff;
    --accent: #00e5ff;
    --bg-main: #f0f4f8;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --text: #2d3436;
    --hair-current: #ffb74d;
    --glass-blur: blur(15px);
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.06);
    --shadow-strong: 0 15px 45px rgba(255, 64, 129, 0.25);
    --radius-lg: 30px;
    --radius-md: 20px;
}

/* --- Base & Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(circle at top left, #fce4ec, #e1f5fe);
    height: 100vh;
    overflow: hidden;
    color: var(--text);
    display: flex;
    flex-direction: column;
}

/* --- Classes Utilitaires --- */
.glassmorphism {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.hidden {
    display: none !important;
}

/* --- Menu de Départ (Corrigé) --- */
.menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.menu-card {
    width: 90%;
    max-width: 550px;
    /* Élargi pour éviter l'effet écrasé */
    padding: 50px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.premium-title {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.8;
}

/* --- Sélection de Personnage --- */
.char-buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
}

.char-btn {
    background: white;
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    padding: 15px; /* Increased padding */
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px; /* Ensure minimum width */
}

.char-btn.selected {
    border-color: var(--primary);
    background: var(--fce4ec);
    transform: translateY(-5px);
}

.char-preview-inner {
    font-size: 2.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 5px;
}

/* --- Layout Principal --- */
.salon-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

.glass-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-md);
}

.logo-text {
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 1px;
    font-size: 1.4rem;
}

.salon-workspace {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    flex: 1;
    gap: 20px;
    min-height: 0;
}

/* --- Panneaux & Outils --- */
.panel {
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-title {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--secondary);
    text-align: center;
    font-weight: 900;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.draggable-tool {
    background: white;
    border-radius: var(--radius-md);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.draggable-tool:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-strong);
}

.draggable-tool.selected-tool {
    border: 2px solid var(--primary);
    background: #fdf2f8;
    transform: translateY(-5px);
    box-shadow: var(--shadow-strong);
}

.tool-icon-wrapper {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

/* --- Scène Centrale & Canvas --- */
.character-stage {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    cursor: default;
    padding-top: 0;
    margin-top: -20px;
}

.drop-zone {
    transition: cursor 0.1s ease;
}

.character-canvas-v3 {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 4/6;
    background: white;
    border-radius: 150px 150px 40px 40px;
    box-shadow: var(--shadow-soft), inset 0 0 40px rgba(0, 0, 0, 0.02);
    border: 15px solid white;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.layers-container {
    width: 100%;
    height: 100%;
    position: relative;
    animation: float 6s infinite ease-in-out;
}

.overlay-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.placed-acc {
    position: absolute;
    font-size: 8rem;
    transform: translate(-50%, -50%);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

.placed-acc:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

/* --- Yeux & Skin --- */
.skin {
    transition: fill 0.3s ease;
}

.natural-eyes ellipse {
    animation: blink 4s infinite;
}

@keyframes blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(0.1);
    }
}

/* --- Couleurs & Accessoires --- */
.colors-grid-v2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.color-swatch-v2 {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.color-swatch-v2.selected {
    transform: scale(1.25);
    border-color: var(--primary);
}

.acc-grid-v2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.acc-item {
    font-size: 2.5rem;
    background: white;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    cursor: grab;
    transition: 0.3s;
}

.acc-item:hover {
    transform: rotate(10deg) scale(1.1);
    background: #fdf2f8;
}

.acc-item.selected-acc-item {
    border: 2px solid var(--primary);
    background: #fdf2f8;
    transform: scale(1.15);
    box-shadow: var(--shadow-strong);
}

/* --- Animations --- */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(60px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* --- Boutons Premium --- */
.btn-premium {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 16px 40px;
    font-size: 1.6rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 64, 129, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    position: relative;
    overflow: hidden;
    margin-top: 10px;
}

.btn-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    100% {
        left: 200%;
    }
}

.btn-premium:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(124, 77, 255, 0.5);
    background: linear-gradient(135deg, var(--secondary), var(--primary));
}

.btn-premium:active {
    transform: translateY(2px) scale(0.98);
}

.wand-icon {
    display: inline-block;
    animation: float-wand 2s ease-in-out infinite;
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes float-wand {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-5px) rotate(15deg);
    }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .salon-workspace {
        grid-template-columns: 120px 1fr 120px;
    }

    .tool-label,
    .panel-title {
        display: none;
    }
}

@media (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
    }

    .salon-container {
        height: auto;
        min-height: 100vh;
        padding: 10px;
        gap: 15px;
    }

    .glass-header {
        height: auto;
        padding: 10px 15px;
        flex-direction: column;
        gap: 10px;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
        display: flex;
        gap: 10px;
    }

    .btn-back-hub {
        margin-right: 0;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .salon-workspace {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .panel {
        padding: 15px;
        height: auto;
        overflow: visible;
    }

    .toolbox {
        order: 2;
    }

    .character-stage {
        order: 1;
        margin-top: 0;
        padding: 0;
    }

    .right-panel {
        order: 3;
    }

    .character-canvas-v3 {
        width: 100%;
        max-width: 350px;
        border-width: 8px;
        border-radius: 100px 100px 30px 30px;
    }

    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .draggable-tool {
        padding: 10px;
    }

    .tool-icon-wrapper {
        font-size: 1.8rem;
        margin-bottom: 0;
    }

    .panel-title {
        display: block;
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    .colors-grid-v2 {
        grid-template-columns: repeat(7, 1fr);
        gap: 8px;
    }

    .acc-grid-v2 {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }

    .acc-item {
        font-size: 1.8rem;
    }

    .menu-card {
        padding: 30px 20px;
        width: 95%;
        gap: 15px;
    }

    .premium-title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .char-buttons-grid {
        gap: 10px;
    }

    .char-preview-inner {
        font-size: 2rem;
        height: 50px;
    }

    .btn-premium {
        padding: 12px 30px;
        font-size: 1.2rem;
    }
}

/* --- Bouton Retour Hub (Intégré au Header) --- */
.btn-back-hub {
    background: var(--primary);
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 900;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(255, 64, 129, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, background 0.2s;
    margin-right: 15px;
}

.btn-back-hub:hover {
    transform: scale(1.05);
    background: var(--primary-soft);
}

/* --- Switch Toggle --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(22px);
}