:root {
    --box-width: 120px;
    --box-height: 120px;
    --gap-x: 100px;
    --gap-y: 40px;
    --color-bg: #0f0f0f;
    --color-primary: #d4af37; 
    --color-accent: #f9e79f;
    --color-canSelect: #00cc00;
    --color-isSelected : #3399ff;
    --color-text: #e0e0e0;
    --color-line: rgba(212, 175, 55, 0.4);
    --shadow-gold: 0 0 15px rgba(212, 175, 55, 0.3);
}

body { 
    font-family: 'Cinzel', serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    overflow-x: auto;
    min-height: 100vh;
}

#tree-container {
    display: grid;
    column-gap: var(--gap-x);
    row-gap: var(--gap-y);
    padding: 80px 80px 40px 80px;
    position: relative;
    grid-auto-columns: var(--box-width);
    justify-content: center;
}

/* --- NODES (Losange extérieur) --- */
.node {
    width: var(--box-width);
    height: var(--box-height);
    display: flex;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.node-draw {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%; 
    height: 50%;
    background-color: #1a1a1a;
    border: 2px solid var(--color-line);
    transform: translate(-50%, -50%) rotate(45deg);
    transition: all 0.3s ease;
    z-index: 1;
}

.node.active .node-draw {
    border-color: var(--color-accent);
    transform: translate(-50%, -55%) rotate(45deg) scale(1.1);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.node.canBeSelect .node-draw {
    border-color: var(--color-canSelect);
    transform: translate(-50%, -55%) rotate(45deg) scale(1.1);
    box-shadow: 0 0 15px var(--color-canSelect);
}

.node.isSelected .node-draw {
    border-color: var(--color-isSelected);
    transform: translate(-50%, -55%) rotate(45deg) scale(1.1);
    box-shadow: 0 0 15px var(--color-isSelected);
}

/* --- GEMME (Losange intérieur) --- */
.node-gem {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20%;
    height: 20%;
    transform: translate(-50%, -50%) rotate(45deg);
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.4s ease;
}

/* États des Gemmes */
.node.locked .node-gem {
    background: radial-gradient(circle at 30% 30%, #ff4d4d, #800000);
    box-shadow: 0 0 10px #ff0000;
}
.node.doable .node-gem {
    background: radial-gradient(circle at 30% 30%, #ffcc00, #996600);
    box-shadow: 0 0 10px #ffcc00;
}
.node.done .node-gem {
    background: radial-gradient(circle at 30% 30%, #45f545, #004d00);
    box-shadow: 0 0 10px #00ff00;
}
.node.event .node-gem {
    background: radial-gradient(circle at 30% 30%, #3399ff, #001a33);
    box-shadow: 0 0 10px #3399ff;
}

.node.add .node-gem {
}
.node.add .node-gem::after {
    content: "+";
    transform: translate(0%, 0%) rotate(-45deg);
    z-index: 3;
    font-size: 40px;
    width: 100%;
    height: 100%;
    margin:0;
    position:absolute;
    top:0;
    left:0;
    display:flex;
    justify-content:center;
    align-items:center;
}

/* --- TEXTE --- */
.node-content {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    width: 120px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-primary);
    text-shadow: 1px 1px 2px black;
    pointer-events: none;


    /* --- Troncature sur 2 lignes --- */
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;       /* nombre max de lignes */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-current-display-state {
    position: absolute;
    top: 0px;
    left: 5px;
}

/* --- SVG --- */
#canvas-svg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 50%;
    pointer-events: none;
    z-index: 1;
}
.tree-path {
    stroke: var(--color-line);
    stroke-width: 2;
    fill: none;
    transition: all 0.3s ease;
}
.tree-path.active-path {
    stroke: var(--color-accent);
    stroke-width: 3;
    filter: drop-shadow(0 0 5px var(--color-accent));
}

/* --- HUD --- */
#hud-panel {
    position: fixed;
    bottom: -280px;
    left: 0;
    width: 100%;
    height: 250px;
    background: linear-gradient(to top, #000 80%, #1a1a1a);
    border-top: 3px solid var(--color-primary);
    z-index: 100;
    transition: bottom 0.4s ease;
    display: flex;
    padding: 20px;
    box-sizing: border-box;
}
#hud-panel.visible { bottom: 0; }

.hud-section {
    flex: 1;
    text-align: center;
    padding: 0 10px;
    
}

.scrollable {
    max-height: 100%; /* adapte selon ta HUD */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* évite que le texte colle à la scrollbar */
    word-wrap: break-word;
}

/* Scrollbar Webkit (Chrome, Edge, Safari) */
.scrollable::-webkit-scrollbar {
    width: 8px;
}

.scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable::-webkit-scrollbar-thumb {
    background: var(--color-line);
    border-radius: 10px;
}

/* Scrollbar Firefox */
.scrollable {
    scrollbar-width: thin;
    scrollbar-color: var(--color-line) transparent;
}

.hud-items {gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

.hud-btn {
    background: #222;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 5px 12px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    border-radius: 3px;
}
.hud-btn:hover { background: var(--color-primary); color: #000; }

[contenteditable][data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}

/*#hud-current-desc:empty::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}*/

#btn-status-toggle {
    margin-top: 15px;
    border-width: 2px;
    font-weight: bold;
}

.deselect-btn {
    position: absolute;
    top: 0px;
    right: 0px;
    background: none;
    border: none;
    color: #ff4d4d;
    cursor: pointer;
}

    /* --- HUD --- */
#Selection-panel {
    position: fixed;
    top: -60px;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, #000 10%, #1a1a1a 80%);
    border-bottom: 3px solid var(--color-primary);
    z-index: 100;
    transition: top 0.4s ease;
    display: flex;
    padding: 0px;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}
#Selection-panel.visible { top: 0; }

/* --- Boutons sauvegarde / chargement --- */
#file-buttons {
    position: fixed;
    top: 10px;
    right: 15px;
    z-index: 101;
    display: flex;
    gap: 8px;
}