body, html {
    width:100vw; min-height:100vh; margin:0; padding:0;
    background-image: url('bg.png'); /* Adjusted path: if bg.png is in root, and this CSS is in styles/ */
    /* If bg.png is in the styles/ folder itself, then url('bg.png') was correct. Please verify location of bg.png */
    background-size: cover; background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}
/* Voile mystique sur l'image de fond */
#mystic-veil {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 1;
    background: radial-gradient(ellipse at 60% 40%, rgba(110,226,245,0.13) 0%, rgba(40,60,110,0.22) 60%, rgba(10,10,30,0.55) 100%);
    mix-blend-mode: lighten;
    opacity: 0.85;
    transition: opacity 0.7s;
}

/* Background Animations */
#background-glow {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 0; /* Behind mystic-veil */
    background: radial-gradient(ellipse at center, rgba(70,130,180,0.1) 0%, rgba(70,130,180,0) 70%);
    animation: pulseGlow 10s infinite alternate;
}

@keyframes pulseGlow {
    from { transform: scale(1); opacity: 0.2; }
    to { transform: scale(1.1); opacity: 0.4; }
}

.particle {
    position: fixed;
    border-radius: 50%;
    background-color: rgba(173, 216, 230, 0.3); /* Light blue, semi-transparent */
    pointer-events: none;
    z-index: 0; /* Behind mystic-veil */
    box-shadow: 0 0 5px rgba(173, 216, 230, 0.5), 0 0 10px rgba(173, 216, 230, 0.3);
}

.particle.twinkle { /* For twinkling particles */
    background-color: rgba(220, 240, 255, 0.5);
    box-shadow: 0 0 8px rgba(220, 240, 255, 0.7), 0 0 15px rgba(220, 240, 255, 0.5);
}

#shooting-stars-container { /* Container for shooting stars */
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 0; 
    overflow: hidden;
}

.shooting-star { /* Individual shooting star */
    position: absolute;
    width: 2px; height: 2px;
    background-color: #fffbe7;
    border-radius: 50%;
    box-shadow: 0 0 6px 2px #fffbe7;
    opacity: 0;
}

.shooting-star::after { /* Tail of the shooting star */
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100px; height: 1px;
    background: linear-gradient(to left, transparent 0%, #fffbe7 100%);
    border-radius: 1px;
    opacity: 0.7;
}

#constellations-svg-container { /* Container for SVG constellations */
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.constellation-star { /* Style for stars in SVG constellations */
    fill: rgba(220, 240, 255, 0.7);
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 0.5px;
}

.constellation-line { /* Style for lines in SVG constellations */
    stroke: rgba(173, 216, 230, 0.25); /* Faint blue lines */
    stroke-width: 0.5px;
}

@keyframes mysticalButtonPulse {
    0% {
        box-shadow: 0 0 24px #7fd8ff, 0 0 0 10px #0a223a inset, 0 0 30px rgba(255, 255, 255, 0.842);
        border-color: #7fd8ff;
    }
    50% {
        box-shadow: 0 0 30px #90e0ff, 0 0 0 10px #0a223a inset, 0 0 45px rgba(255, 255, 255, 0.788);
        border-color: #90e0ff;
    }
    100% {
        box-shadow: 0 0 24px #7fd8ff, 0 0 0 10px #0a223a inset, 0 0 30px rgba(255, 255, 255, 0.788);
        border-color: #7fd8ff;
    }
}

#toggle-rotation-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 18px;
    background-color: rgba(10, 34, 58, 0.7);
    border: 2px solid #7fd8ff;
    color: #fffbe7;
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    z-index: 2500; /* Above most elements but below intro message */
    box-shadow: 0 0 12px rgba(127, 216, 255, 0.5);
    transition: background-color 0.3s, box-shadow 0.3s;
}
#toggle-rotation-btn:hover {
    background-color: rgba(30, 60, 90, 0.9);
    box-shadow: 0 0 18px rgba(178, 234, 255, 0.7);
}

#header-portal {
    width:100vw; 
    text-align:center;
}
#portal-center-container {
    position:fixed;
    top:0; left:0; width:100vw; height:100vh;
    display:flex; align-items:center; justify-content:center;
    z-index:2000;
    pointer-events:none;
}
#portal-canvas {
    position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
    width:520px; height:520px; max-width:98vw; max-height:98vh; z-index:2;
    pointer-events:none;
}
#portal-buttons {
    position:fixed;
    left:0; top:0; width:100vw; height:100vh;
    display:flex; align-items:center; justify-content:center;
    z-index:2100;
    pointer-events:none;
}
.portal-btn {
    position: absolute;
    overflow: visible; 
    width:140px; height:140px;
    border-radius:50%;
    background:radial-gradient(circle at 60% 40%, #7fd8ff 60%, #3a4e6b 100%);
    border:4px solid #7fd8ff;
    display:flex; align-items:center; justify-content:center;
    cursor:pointer;
    transition:transform 0.18s, box-shadow 0.18s, background 0.18s, border-color 0.18s;
    pointer-events:auto;
    text-align:center; 
    text-decoration:none;
    user-select:none;
    animation: mysticalButtonPulse 6s infinite ease-in-out;
    padding: 15px; /* Added padding */
    box-sizing: border-box; /* Ensures padding is included in width/height */
}

.portal-btn img {
    display: block; /* Removes extra space below image if it were inline */
    width: 100%;    /* Fills the content box (button width minus padding) */
    height: 100%;   /* Fills the content box (button height minus padding) */
    object-fit: contain; /* Scales image to fit, maintaining aspect ratio */
    border-radius: 50%;  /* Makes the image itself circular */
}

.portal-btn .btn-light-glow {
    pointer-events: none;
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    border-radius: 50%;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.18s;
    background: radial-gradient(circle at var(--x,50%) var(--y,50%), #fffbe7 0%, #7fd8ff 40%, transparent 80%);
    filter: blur(8px);
}
.portal-btn.active-glow .btn-light-glow {
    opacity: 0.7;
    transition: opacity 0.08s;
}
.portal-btn:hover {
    transform:scale(1.12) rotate(-2deg);
    box-shadow:0 0 45px #cceeff, 0 0 0 16px #7fd8ff inset, 0 0 60px rgba(178, 234, 255, 0.7); /* Enhanced hover shadow */
    background:radial-gradient(circle at 55% 35%, #b2eaff 70%, #4f6a8f 100%); /* Slightly adjusted hover gradient */
    animation-play-state: paused; /* Pause pulse on hover to emphasize hover effect */
}

/* Mystical Mouse Tracker Styles */
#mystical-mouse-tracker {
    position: fixed;
    width: 22px;
    height: 22px;
    background: radial-gradient(circle, rgba(200, 230, 255, 0.8) 0%, rgba(127, 216, 255, 0.4) 40%, transparent 70%);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(173, 216, 230, 0.6), 
                0 0 20px rgba(200, 240, 255, 0.4),
                inset 0 0 5px rgba(255, 255, 255, 0.3);
    pointer-events: none; /* Allows clicks to pass through */
    z-index: 2400; /* Below rotation toggle button, above most other things */
    opacity: 0; /* Initially hidden */
    transform: translate(-50%, -50%); /* Center the orb on the cursor */
    transition: opacity 0.3s ease-out; /* Smooth fade-in/out */
    will-change: transform, opacity; /* Performance hint */
}

/* New Scenario Panel Styles (Left Side) */
#scenario-panel-container {
    position: fixed;
    left: 0; /* Position on the left */
    top: 0;
    width: 300px; /* Adjust width as needed */
    height: 100vh;
    background: #0a1225; /* Bleu très foncé, opaque */
    border-right: 2px solid rgba(127, 216, 255, 0.3);
    box-shadow: 0 0 32px 0 #0a223a;
    z-index: 1590; /* Below character panel if they could overlap, or same level */
    display: flex;
    flex-direction: column;
    color: #fffbe7;
    font-family: 'EB Garamond', serif;
    transform: translateX(-100%); /* Initially hidden / fully collapsed to the left */
    transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
    opacity: 0;
    padding: 0 0 30px 0; /* Padding bas pour aérer */
}

#scenario-panel-container.visible {
    transform: translateX(0);
    opacity: 1;
}

#scenario-panel-container.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

#scenario-panel-container.collapsed .scenario-panel-header,
#scenario-panel-container.collapsed #scenario-panel-list {
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

/* Toggle button for scenario panel - fixed position on the left */
#toggle-scenario-panel-btn {
    position: fixed;
    left: 20px; 
    top: 50%;
    transform: translateY(-50%) rotate(0deg); /* Initial state for "expand" icon pointing right */
    width: 40px;
    height: 60px;
    background-color: rgba(20, 35, 60, 0.85);
    border: 2px solid rgba(127, 216, 255, 0.3);
    border-left: 2px solid rgba(127, 216, 255, 0.3);
    border-radius: 8px;
    color: #b2eaff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1591; /* Above its panel */
    transition: background-color 0.3s ease, left 0.5s ease-in-out, transform 0.3s ease-in-out;
}
#toggle-scenario-panel-btn:hover {
    background-color: rgba(30, 50, 80, 0.95);
}

/* Icon direction for the scenario toggle button */
#toggle-scenario-panel-btn span {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* When scenario panel is visible (not collapsed), button icon points left for "collapse" */
#scenario-panel-container.visible + #toggle-scenario-panel-btn span {
    transform: rotate(0deg); /* Icon: « */
}
/* When scenario panel is collapsed, button icon points right for "expand" */
#scenario-panel-container.collapsed + #toggle-scenario-panel-btn span,
#toggle-scenario-panel-btn span { /* Default state for icon */
    transform: rotate(180deg); /* Icon: » */
}


.scenario-panel-header {
    padding: 28px 0 18px 0;
    border-bottom: none;
    background: none;
}
.scenario-panel-header h3 {
    margin: 0;
    font-family: 'Alfa Slab One', 'Creepster', 'UnifrakturCook', 'EB Garamond', serif;
    font-size: 2.2rem;
    color: #7fd8ff;
    text-shadow: 0 0 16px #7fd8ff, 0 2px 0 #22334a, 0 0 2px #fff;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
    filter: drop-shadow(0 0 8px #7fd8ff88);
}

#scenario-panel-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 18px 0 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 10px;
}

/* Nouvelle card scénario façon image + nom en bas */
.scenario-card {
    background: #14233c;
    border-radius: 18px;
    box-shadow: 0 0 22px 4px #7fd8ff55, 0 2px 18px #0a223a99;
    border: 2.5px solid #22334a;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 120px;
    transition: box-shadow 0.25s, border-color 0.25s, transform 0.18s;
    cursor: pointer;
    position: relative;
    padding: 0;
}
.scenario-card:hover {
    box-shadow: 0 0 38px 10px #7fd8ffcc, 0 4px 24px #0a223a99;
    border-color: #7fd8ff;
    transform: scale(1.03) rotate(-1deg);
}

/* Image du scénario, arrondie, ombre portée */
.scenario-card-image {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 14px 14px 0 0;
    background: #22334a;
    display: block;
    box-shadow: 0 4px 18px #7fd8ff55;
}

/* Nom du scénario façon "cartoon/fantasy" */
.scenario-card-name {
    width: 100%;
    background: #14233c;
    color: #fffbe7;
    font-family: 'Alfa Slab One', 'Creepster', 'UnifrakturCook', 'EB Garamond', serif;
    font-size: 1.35em;
    font-weight: bold;
    text-align: left;
    padding: 18px 18px 14px 18px;
    border-radius: 0 0 14px 14px;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 8px #0a223a99, 0 0 2px #7fd8ff, 0 0 8px #7fd8ff;
    display: flex;
    align-items: center;
    min-height: 38px;
    box-shadow: 0 0 18px #7fd8ff22 inset;
    border-top: 2px solid #22334a;
}

/* ...existing code... */

#character-parchment-list-container {
    position: fixed;
    right: 0;
    top: 0;
    width: 320px; /* Adjust width as needed */
    height: 100vh;
    background: rgba(10, 20, 45, 0.88);
    border-left: 2px solid rgba(127, 216, 255, 0.3);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    z-index: 1600; 
    display: flex;
    flex-direction: column;
    color: #fffbe7;
    font-family: 'EB Garamond', serif;
    transform: translateX(100%); /* Initially hidden / fully collapsed */
    transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
    opacity: 0; 
}

#character-parchment-list-container.visible {
    transform: translateX(0);
    opacity: 1;
}

/* Collapsed state for the parchment list - panel fully off-screen */
#character-parchment-list-container.collapsed {
    transform: translateX(100%);
    opacity: 0; /* Fade out when fully collapsed */
    pointer-events: none; /* Disable interaction when fully collapsed */
}
/* Content inside also fades, though panel itself is moving */
#character-parchment-list-container.collapsed .character-controls-header,
#character-parchment-list-container.collapsed #character-parchment-list {
    opacity: 0;
    transition: opacity 0.2s ease-out;
}


/* Toggle button for parchment list - now fixed position */
#toggle-parchment-list-btn {
    position: fixed; /* Fixed to viewport */
    right: 20px;     /* Position from the right edge of the screen */
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 60px;
    background-color: rgba(20, 35, 60, 0.85);
    border: 2px solid rgba(127, 216, 255, 0.3);
    border-right: 2px solid rgba(127, 216, 255, 0.3); /* Ensure all borders are consistent */
    border-radius: 8px; /* Rounded corners on all sides or specific ones */
    color: #b2eaff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1601; /* Above the panel if it ever overlaps, and other elements */
    transition: background-color 0.3s ease, right 0.5s ease-in-out, transform 0.3s ease-in-out;
}
#toggle-parchment-list-btn:hover {
    background-color: rgba(30, 50, 80, 0.95);
}

/* Icon direction for the toggle button */
#toggle-parchment-list-btn span {
    display: inline-block; /* Allows transform */
    transition: transform 0.3s ease;
}

/* When panel is visible (not collapsed), button icon points left for "collapse" */
#character-parchment-list-container.visible + #toggle-parchment-list-btn span {
    transform: rotate(0deg); /* Default: << */
}
/* When panel is collapsed, button icon points right for "expand" */
#character-parchment-list-container.collapsed + #toggle-parchment-list-btn span,
#toggle-parchment-list-btn span { /* Default state for icon before JS fully kicks in or if panel is initially collapsed */
    transform: rotate(180deg); /* Default: >> */
}


.character-controls-header {
    padding: 15px;
    border-bottom: 1px solid rgba(127, 216, 255, 0.2);
    background: rgba(20, 35, 60, 0.7);
}
.character-controls-header h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.4rem;
    text-align: center;
    color: #b2eaff;
    text-shadow: 0 0 5px #7fd8ff;
}
.character-controls-header #character-search,
.character-controls-header #character-sort {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px 12px;
    background-color: rgba(20, 35, 60, 0.9);
    border: 1px solid rgba(127, 216, 255, 0.4);
    border-radius: 6px;
    color: #fffbe7;
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
}
.character-controls-header #character-search::placeholder {
    color: rgba(220, 240, 255, 0.6);
}
.character-controls-header #character-search:focus,
.character-controls-header #character-sort:focus {
    outline: none;
    border-color: #b2eaff;
    box-shadow: 0 0 10px rgba(178, 234, 255, 0.4);
}
.character-controls-header #character-sort option {
    background-color: #0a1622;
    color: #fffbe7;
}


#character-parchment-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Custom Scrollbar for Parchment List */
#character-parchment-list::-webkit-scrollbar {
    width: 8px;
}
#character-parchment-list::-webkit-scrollbar-track {
    background: rgba(10, 20, 45, 0.5);
    border-radius: 8px;
}
#character-parchment-list::-webkit-scrollbar-thumb {
    background: rgba(127, 216, 255, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(127, 216, 255, 0.5);
}
#character-parchment-list::-webkit-scrollbar-thumb:hover {
    background: rgba(127, 216, 255, 0.5);
}

.parchment-item {
    background-color: #fdf5e6; /* Parchment color */
    /* Consider a background-image for texture: url('path/to/parchment-texture.jpg'); */
    border: 1px solid #d2b48c; /* Tan border */
    border-radius: 5px;
    margin-bottom: 10px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: margin-bottom 0.3s ease, max-height 0.5s ease-in-out;
    overflow: hidden; /* Important for unrolling animation */
    max-height: 60px; /* Height of the "rolled-up" state */
}

.parchment-item.unrolled {
    max-height: 500px; /* Adjust to fit content, or use JS to set height */
    margin-bottom: 15px; /* More space when unrolled */
}

.parchment-header {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    color: #5d4037; /* Dark brown text */
    font-weight: bold;
}

.parchment-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    border: 2px solid #8c6b4f; /* Darker brown border for avatar */
}

.parchment-header .character-nickname {
    flex-grow: 1;
    font-size: 1.1rem;
}

.parchment-header .arrow-indicator {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}
.parchment-item.unrolled .parchment-header .arrow-indicator {
    transform: rotate(90deg);
}


.parchment-scroll-content {
    padding: 0 15px 15px 15px;
    color: #6a5244; /* Slightly lighter brown for content */
    font-size: 0.9rem;
    border-top: 1px dashed #c8a97e;
    margin-top: 5px;
    /* Content will be hidden/shown by max-height of .parchment-item */
}
.parchment-scroll-content p {
    margin-bottom: 8px;
}
.parchment-scroll-content strong {
    color: #5d4037;
}
.parchment-scroll-content .character-full-image {
    width: 100%;
    max-width: 200px; /* Limit size of full image */
    height: auto;
    border-radius: 4px;
    margin: 10px auto;
    display: block;
    border: 3px solid #d2b48c;
}

/* Masquer les barres de défilement tout en conservant la fonctionnalité */
/* Pour Webkit (Chrome, Safari, Edge Chromium) */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
#sidebar::-webkit-scrollbar,
#right-sidebar::-webkit-scrollbar,
#chat-history-container::-webkit-scrollbar, /* Conteneur de chat-box */
.sidebar-section::-webkit-scrollbar,
.authors-avatar-list::-webkit-scrollbar, /* Pour les listes d'auteurs dans user_chat.css */
#roomList::-webkit-scrollbar,
#characters::-webkit-scrollbar {
    display: none;
}

/* Pour Firefox */
html,
body,
#sidebar,
#right-sidebar,
#chat-history-container, /* Conteneur de chat-box */
#chat-box,
.sidebar-section,
.authors-avatar-list, /* Pour les listes d'auteurs dans user_chat.css */
#roomList,
#characters {
    scrollbar-width: none;
}

/* Pour IE et Edge (anciennes versions) */
html,
body,
#sidebar,
#right-sidebar,
#chat-history-container, /* Conteneur de chat-box */
.sidebar-section,
.authors-avatar-list, /* Pour les listes d'auteurs dans user_chat.css */
#roomList,
#characters {
    -ms-overflow-style: none;
}
