:root {
    --bg-color: #F5F1E8;
    --c-blue: #4DB8E8;
    --c-yellow: #D4A500;
    --c-red: #E63946;
    --c-green: #52B788;
}

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

body {
    background-color: var(--bg-color);
    font-family: 'Konkhmer Sleokchher', serif;
    color: #333;
    overflow: hidden; 
    height: 100vh;
    width: 100vw;
}

/* Scene visibility rules */
.scene {
    display: none !important; /* Oculta por completo y no ocupa espacio */
    width: 100vw;
    height: 100vh;
    position: absolute;       /* Evita que se apilen una debajo de otra */
    top: 0;
    left: 0;
    overflow: hidden;
}

/* Usaremos esta clase desde JavaScript para mostrar las escenas manteniendo su estructura flex */
.scene.active {
    display: flex !important;
}

#exp1 {
    display: block;
}

/* Layouts */
.flex-center {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.title {
    font-size: clamp(3rem, 5vw, 6rem);
    text-align: center;
    margin-bottom: 1rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.title-small {
    font-size: clamp(2rem, 3vw, 3rem);
    text-align: center;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: #555;
    text-align: center;
}

.btn {
    padding: 15px 40px;
    font-size: 1.25rem;
    border: none;
    border-radius: 50px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: inline-block;
}

.btn:hover {
    opacity: 0.8;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.btn-green { background-color: var(--c-green); }
.btn-red { background-color: var(--c-red); }

.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.z-10 { z-index: 10; }
.relative { position: relative; }

.split-layout {
    flex-direction: row; 
    width: 100%;
    height: 100vh;
}

.left-pane, .right-pane {
    flex: 1; /* Mitad y mitad de pantalla */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    height: 100%;
}

.left-pane h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.left-pane p {
    font-size: 1.25rem;
    line-height: 1.6;
    color: #555;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.piece {
    position: absolute;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    
    /* Filtro inicial */
    filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.15));
    
    /* Aceleración de hardware: le dice al navegador que prepare la GPU */
    will-change: transform, filter; 
    
    /* Transición con tiempos ligeramente desfasados para un toque orgánico */
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                filter 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    backface-visibility: hidden;
    perspective: 1000px;
    width: 100%;
    height: 100%;
    transition: filter 0.8s cubic-bezier(0.19, 1, 0.22, 1);
    will-change: filter;
}

.piece:hover {
    /* Usamos !important solo si tienes conflictos de estilos, si no, quítalo */
    transform: scale(1.1) rotate(var(--rotacion-base)) !important;
    
    /* La sombra se expande suavemente */
    filter: drop-shadow(0px 20px 30px rgba(0, 0, 0, 0.3));
    
    z-index: 100;
}

.piece-wrapper {
    position: absolute;
    cursor: pointer;
    /* La transición vive aquí, en el contenedor, no en la imagen */
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
    will-change: transform;
}

.piece-wrapper:hover {
    transform: scale(1.1) rotate(0deg); /* El wrapper escala suave */
}

.piece.floating {
    animation: float 4s ease-in-out infinite alternate;
}

@keyframes popIn {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    70% { transform: scale(1.15) rotate(5deg); opacity: 1; } /* Rebote suave */
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Asegúrate de que esto sea simple */
.popping {
    animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}



.piece-grid {
    position: relative;
    width: 750px;   /* Más ancho para albergar la dispersión */
    height: 380px;  /* Altura ideal para centrar respecto al texto inferior */
    margin: 0 auto;
}

#white-screen {
    position: fixed;
    inset: 0;
    background: #f3ede3;
    z-index: 9999;

    opacity: 0;
    pointer-events: none;

    transform: scale(1.05);
    filter: blur(20px);

    transition:
        opacity 0.6s ease,
        transform 0.6s ease,
        filter 0.6s ease;
}

#white-screen.active {
    opacity: 0.95;
    transform: scale(1);
    filter: blur(0px);
}

/* Efecto hover respetando su rotación original */
.piece:hover {
    transform: scale(1.08) !important; 
}

/* Drop zones */
.drop-zone {
    width: 500px;
    height: 500px;
    border: 4px dashed #ccc;
    border-radius: 24px;
    position: relative;
    margin: 0 auto;
}

/* ============================================================
   EXP 4 — Zona de rebote (izquierda) y zona de construcción (derecha)
   ============================================================ */

.exp4-left {
    position: relative;
    overflow: hidden; /* las piezas rebotan dentro de este marco */
    width: 100%;
    height: 100%;
    padding: 0;
}

.exp4-right {
    position: relative;
    justify-content: center;
    align-items: center;
}

.drop-zone-flower {
    position: relative;
    width: 420px;
    height: 460px;
    max-width: 90%;
    max-height: 80vh;
    border: 3px dashed #c9beac;
    border-radius: 28px;
    margin: 0 auto;
}

.drop-zone-hint {
    position: absolute;
    bottom: 24px;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: bold;
    color: #5a4b41;
    font-size: 1.1rem;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* Pieza flotando/rebotando libremente dentro del panel izquierdo de exp4 */
.piece-wrapper.bouncing {
    transition: none; /* la posición la controla el loop de animación, no CSS */
}

/* Slot vacío dentro de la zona de construcción: marca sutil de dónde va cada pieza */
.flower-slot-ghost {
    position: absolute;
    border: 2px dashed #d8cdb8;
    border-radius: 16px;
    box-sizing: border-box;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.free-drag-zone {
    width: 100%;
    height: 60vh;
    position: relative;
    margin: 0 auto;
}

.draggable-group {
    position: absolute;
    width: 400px;
    height: 400px;
    cursor: grab;
}

.draggable-group:active {
    cursor: grabbing;
}

/* Shapes fallbacks if images are missing */
.shape-square, .shape-circle, .shape-triangle, .shape-rectangle, .shape-curve {
    background-color: transparent !important;
    clip-path: none !important;
    border-radius: 0 !important;
    
}

.flower-container {
    position: relative;
    width: 400px;
    height: 500px;
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.flower-container:hover {
    transform: scale(1.05); /* Pequeño zoom al pasar el mouse indicando que es clickeable */
}

.flower-composition .piece-wrapper {
    position: absolute;
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: default; /* Ya no es draggable en la flor */
}

.flower-composition .piece {
    filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.15));
    /* Sin el hover de crecimiento de las piezas dispersas */
}

/* ---- Layout general de exp5 ---- */
#exp5 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 3rem 4rem;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}
 
/* ---- Columna izquierda ---- */
.exp5-left {
  flex: 0 0 42%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
 
.exp5-headline {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
  /* los colores se aplican letra a letra desde JS */
}
 
.exp5-subtitle {
  font-size: 1rem;
  font-weight: 600;
  color: #7a6a5a;           /* mismo tono cálido del resto de la UI */
  line-height: 1.6;
  margin: 0;
  text-align: center;
}
 
.exp5-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
 
.exp5-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.exp5-btn:hover  { transform: scale(1.04); }
.exp5-btn:active { transform: scale(0.97); opacity: 0.9; }
 
.exp5-btn--save       { background: #E05252; }   /* rojo */
.exp5-btn--reassemble { background: #4CA65A; }   /* verde */
 
/* ---- Columna derecha: canvas editable ---- */
.exp5-right {
  flex: 0 0 52%;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.exp5-canvas {
  position: relative;
  width:  420px;
  height: 560px;
  border: 2px dashed #c4b9ab;
  border-radius: 24px;
  background: transparent;
  overflow: hidden;
}
 
.exp5-tray {
    margin-top: 24px;
    text-align: center;
}

.exp5-tray-hint {
    font-family: "obliqua", sans-serif;
    font-size: 1rem;
    color: rgba(91, 67, 67, 0.75);
    margin-bottom: 14px;
}

.exp5-tray-grid {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
}

.exp5-tray-item {
    width: 70px;
    height: 70px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(91, 67, 67, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
}

.exp5-tray-item img {
    width: 75%;
    height: 75%;
    object-fit: contain;
}

.exp5-tray-item:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 18px rgba(91, 67, 67, 0.15);
}

.exp5-tray-item.disabled {
    pointer-events: none;
    opacity: 0.35;
}

.exp5-tray-item.selected {
    opacity: 1;
    border-color: #e1ab04;
    box-shadow: 0 0 0 3px rgba(225, 171, 4, 0.4);
}

.exp3-delete-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;

    padding: 0.45rem 1rem;
    border: none;
    border-radius: 999px;
    background: #E05252;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    opacity: 0.9;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.exp3-delete-btn:hover  { transform: scale(1.05); opacity: 1; }
.exp3-delete-btn:active { transform: scale(0.96); }