/* -----------------------------------------------------------
   CORE SYSTEM VARIABLES & CONFIGURATION
   ----------------------------------------------------------- */
:root {
    /* Palette de couleurs "Royal Cyber" */
    --c-void: #030508;
    --c-deep: #0a1120;
    --c-mid: #14203a;
    --c-primary: #00d4ff; /* Cyan Électrique */
    --c-accent: #ffd700; /* Or Pur */
    --c-danger: #ff2a6d;
    --c-success: #05f874;
    --c-glass: rgba(20, 32, 58, 0.65);
    
    /* Effets */
    --glow-primary: 0 0 15px var(--c-primary), 0 0 30px var(--c-primary);
    --glow-gold: 0 0 15px var(--c-accent), 0 0 40px var(--c-accent);
    --blur-glass: 12px;
    --border-tech: 1px solid rgba(0, 212, 255, 0.3);
    
    /* Typographie */
    --font-ui: 'Exo 2', sans-serif;
    --font-deco: 'Cinzel Decorative', serif;
    
    /* Animation Timings */
    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* -----------------------------------------------------------
   RESET & BASE
   ----------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--c-void);
    color: white;
    font-family: var(--font-ui);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* -----------------------------------------------------------
   RENDER LAYERS (Backgrounds)
   ----------------------------------------------------------- */
#render-engine {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;
}

#vignette-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, transparent 40%, black 120%);
    z-index: 1; pointer-events: none;
}

#noise-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    z-index: 2; pointer-events: none;
}

#ui-layer {
    position: relative; z-index: 10; height: 100%; display: flex; flex-direction: column;
}

/* -----------------------------------------------------------
   SYSTEM HEADER
   ----------------------------------------------------------- */
.system-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 2rem; border-bottom: 1px solid rgba(255,255,255,0.1);
    background: linear-gradient(90deg, rgba(0,0,0,0.8), transparent 50%, rgba(0,0,0,0.8));
    backdrop-filter: blur(5px);
}

.pulse-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--c-success); margin-right: 8px;
    box-shadow: 0 0 10px var(--c-success);
    animation: pulse 2s infinite;
}

.mega-title {
    font-family: var(--font-deco); font-size: 1.8rem; letter-spacing: 4px;
    background: linear-gradient(to bottom, #fff, #aaa); -webkit-background-clip: text; color: transparent;
    text-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.version { font-size: 0.6rem; color: var(--c-primary); vertical-align: super; letter-spacing: 1px; }

/* -----------------------------------------------------------
   SCENE MANAGEMENT
   ----------------------------------------------------------- */
#main-stage {
    flex: 1; position: relative; overflow: hidden; perspective: 1000px;
}

.scene {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    opacity: 0; transform: scale(1.1); pointer-events: none;
    transition: opacity 0.8s var(--ease-smooth), transform 0.8s var(--ease-smooth);
}

.scene.active-scene {
    opacity: 1; transform: scale(1); pointer-events: all;
}

/* -----------------------------------------------------------
   SCENE 0: LOADER COMPLEX
   ----------------------------------------------------------- */
.loader-content { text-align: center; width: 300px; }

.spinner-complex {
    width: 100px; height: 100px; margin: 0 auto 30px; position: relative;
    transform-style: preserve-3d; animation: spin-all 10s linear infinite;
}

.ring {
    position: absolute; border: 2px solid transparent; border-radius: 50%;
}
.r1 { width: 100%; height: 100%; border-top-color: var(--c-primary); border-bottom-color: var(--c-primary); animation: spin 2s infinite linear; }
.r2 { width: 70%; height: 70%; top: 15%; left: 15%; border-left-color: var(--c-accent); border-right-color: var(--c-accent); animation: spin 2s infinite reverse; }
.r3 { width: 40%; height: 40%; top: 30%; left: 30%; border: 1px dashed white; animation: pulse 1s infinite; }
.core {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 2rem; color: var(--c-primary); text-shadow: var(--glow-primary);
}

.progress-container {
    width: 100%; height: 4px; background: #333; margin-top: 10px; border-radius: 2px; overflow: hidden;
}
.progress-fill { width: 0%; height: 100%; background: var(--c-primary); box-shadow: 0 0 10px var(--c-primary); transition: width 0.1s linear; }

.log-terminal {
    font-family: monospace; font-size: 0.7rem; color: #666; text-align: left;
    height: 60px; overflow: hidden; margin-top: 10px; border-top: 1px solid #333; padding-top: 5px;
}

/* -----------------------------------------------------------
   SCENE 1: MENORAH TECH
   ----------------------------------------------------------- */
.menorah-complex-structure {
    position: relative; width: 80%; height: 400px;
    display: flex; align-items: flex-end; justify-content: center;
}

.arms-container {
    display: flex; gap: 20px; align-items: flex-end;
}

/* Bougies générées par JS, mais voici le style de base */
.candle-unit {
    width: 20px; height: 100px; background: #222; border: 1px solid #444;
    position: relative; transition: height 0.5s, box-shadow 0.3s;
    cursor: pointer;
}
.candle-unit:hover { border-color: var(--c-primary); box-shadow: 0 0 10px var(--c-primary); }
.candle-unit.shamash { height: 140px; margin: 0 20px; background: #333; }

.flame-emitter {
    position: absolute; top: -30px; left: 50%; transform: translateX(-50%) scale(0);
    width: 15px; height: 30px; border-radius: 50% 50% 20% 20%;
    background: linear-gradient(to bottom, #fff, var(--c-accent), orangered);
    filter: blur(2px); opacity: 0; transition: all 0.5s var(--ease-elastic);
}

.candle-unit.lit .flame-emitter {
    opacity: 1; transform: translateX(-50%) scale(1);
    animation: flicker-complex 0.1s infinite alternate;
}

.control-panel {
    margin-top: 40px; background: var(--c-glass); padding: 20px; border-radius: 10px;
    border: var(--border-tech); width: 80%; max-width: 500px;
    display: flex; justify-content: space-between; align-items: center;
}

/* -----------------------------------------------------------
   SCENE 2: ARENA & PHYSICS
   ----------------------------------------------------------- */
.physics-viewport {
    width: 90%; height: 300px; background: rgba(0,0,0,0.3);
    border: 2px dashed var(--c-primary); border-radius: 10px;
    position: relative; overflow: hidden; margin: 20px 0;
}

.dreidel-entity {
    width: 60px; height: 60px; background: var(--c-accent);
    position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
    display: flex; justify-content: center; align-items: center;
    font-weight: 900; font-size: 2rem; color: black;
    box-shadow: 0 0 20px var(--c-accent); border-radius: 8px;
    transition: transform 0.1s linear; /* Géré par JS loop */
}

/* -----------------------------------------------------------
   SCENE 3: CODEX HOLOGRAPHIC
   ----------------------------------------------------------- */
.codex-frame {
    display: flex; flex-direction: column; align-items: center; gap: 30px;
}

.cube-spinner {
    width: 100px; height: 100px; transform-style: preserve-3d;
    animation: rotate3d 10s infinite linear;
}
.cube-spinner .face {
    position: absolute; width: 100px; height: 100px; background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--c-primary); display: flex; justify-content: center; align-items: center;
    font-size: 2rem;
}
/* Transformations Cube */
.face.front { transform: translateZ(50px); }
.face.back { transform: rotateY(180deg) translateZ(50px); }
.face.right { transform: rotateY(90deg) translateZ(50px); }
.face.left { transform: rotateY(-90deg) translateZ(50px); }
.face.top { transform: rotateX(90deg) translateZ(50px); }
.face.bottom { transform: rotateX(-90deg) translateZ(50px); }

.answers-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; max-width: 600px;
}

.holo-option {
    background: rgba(0,0,0,0.6); border: 1px solid #444; padding: 15px;
    cursor: pointer; transition: all 0.3s; position: relative; overflow: hidden;
}
.holo-option:hover { border-color: var(--c-primary); background: rgba(0, 212, 255, 0.1); }
.holo-option.correct { background: var(--c-success); color: black; border-color: var(--c-success); box-shadow: 0 0 20px var(--c-success); }
.holo-option.wrong { background: var(--c-danger); border-color: var(--c-danger); }

/* -----------------------------------------------------------
   UI COMPONENTS (Buttons, etc)
   ----------------------------------------------------------- */
.ultra-btn {
    background: transparent; border: 2px solid var(--c-primary); color: var(--c-primary);
    padding: 15px 40px; font-family: var(--font-ui); font-weight: 900; letter-spacing: 2px;
    cursor: pointer; position: relative; overflow: hidden; transition: 0.3s;
    text-transform: uppercase;
}
.ultra-btn::before {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: var(--c-primary); transition: left 0.3s; z-index: -1;
}
.ultra-btn:hover { color: black; box-shadow: 0 0 30px var(--c-primary); }
.ultra-btn:hover::before { left: 0; }

.hidden { display: none !important; }

/* -----------------------------------------------------------
   NAV DOCK
   ----------------------------------------------------------- */
.nav-dock {
    height: 80px; background: rgba(0,0,0,0.9); border-top: 1px solid #333;
    display: flex; justify-content: space-around; align-items: center;
    position: relative; z-index: 100;
}
.dock-item {
    background: none; border: none; color: #666; font-size: 0.8rem;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    cursor: pointer; transition: 0.3s;
}
.dock-item.active { color: var(--c-primary); text-shadow: 0 0 10px var(--c-primary); transform: translateY(-5px); }

/* -----------------------------------------------------------
   ANIMATIONS KEYFRAMES
   ----------------------------------------------------------- */
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 0.5; transform: scale(1); } 100% { opacity: 1; transform: scale(1.2); } }
@keyframes flicker-complex {
    0% { transform: translateX(-50%) scale(1); opacity: 0.9; filter: hue-rotate(0deg); }
    50% { transform: translateX(-52%) scale(1.05); opacity: 1; filter: hue-rotate(10deg); }
    100% { transform: translateX(-48%) scale(0.95); opacity: 0.8; filter: hue-rotate(-5deg); }
}
@keyframes rotate3d { from { transform: rotateX(0) rotateY(0); } to { transform: rotateX(360deg) rotateY(360deg); } }

/* Et bien plus encore pour le responsive... */
@media (max-width: 768px) {
    .mega-title { font-size: 1.2rem; }
    .menorah-complex-structure { width: 100%; }
    .candle-unit { width: 15px; margin: 0 2px; }
}