@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Uncial+Antiqua&family=Luckiest+Guy&family=Coming+Soon&display=swap');

/* ========================================
   UTILITIES & TRANSITIONS
   ======================================== */
.hidden {
    display: none !important;
}

.opening-transition {
    transform: scale(3) translateZ(500px) rotateY(0deg) !important;
    opacity: 0;
    transition: all 1s cubic-bezier(0.645, 0.045, 0.355, 1) !important;
    z-index: 10000 !important;
}

/* ========================================
   3D CAROUSEL MENU SYSTEM
   ======================================== */

#kbg-carousel-scene {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    perspective: 2000px;
    background: radial-gradient(circle at center, rgba(26, 26, 46, 0.6) 0%, rgba(15, 15, 30, 0.9) 100%),
        url('../img/kbg-bouc-magique-bg.png') no-repeat center center;
    background-size: cover;
    background-attachment: fixed;
    position: relative;
    overflow: hidden;
}

/* Animated background magic dust */
#kbg-carousel-scene::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(0, 243, 255, 0.4), transparent),
        radial-gradient(3px 3px at 60% 70%, rgba(255, 0, 255, 0.3), transparent),
        radial-gradient(2px 2px at 40% 10%, rgba(0, 102, 255, 0.4), transparent),
        radial-gradient(1px 1px at 80% 50%, rgba(255, 255, 255, 0.6), transparent);
    background-size: 300px 300px;
    animation: floatParticles 15s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes floatParticles {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(-150px, -150px) rotate(5deg);
    }
}

/* Carousel Container - NO rotation, just a stage */
.kbg-carousel {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: translateY(10vh);
    /* Lowering the books to the magic hands area */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Individual 3D Carousel Book */
.kbg-carousel-book {
    position: absolute;
    width: 15.75vh;
    /* Matched to kbh-home.css */
    height: 22.5vh;
    /* Matched to kbh-home.css */
    /* No left/top/margin tricks, we use flex center + transforms relative to center */
    transform-style: preserve-3d;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    /* Default hidden */
}

/* Smooth hover effect */
.kbg-carousel-book:hover {
    transform: translateY(-10px) scale(1.02);
    filter: brightness(1.2) !important;
}

/* Active/Focus state for keyboard navigation */
.kbg-carousel-book:focus {
    outline: 3px solid rgba(255, 215, 0, 0.8);
    outline-offset: 5px;
}

/* Specific Cover for Rencontres Book - DEPRECATED: Now handled via PHP index */
[data-book-id="rencontres"] .kbg-carousel-book-spine::before {
    background: transparent !important;
    border: none !important;
}

@keyframes floatBook {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Book 3D Structure Container */
.kbg-carousel-book-spine {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

/* Front Cover (Face avant du livre) */
.kbg-carousel-book-spine::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
    border-radius: 4px;
    box-shadow:
        inset 5px 0 10px rgba(0, 0, 0, 0.5),
        0 15px 40px rgba(0, 0, 0, 0.8);
    transform: translateZ(0);
    /* Flat front */
    backface-visibility: hidden;
}

/* Back Cover (Dos du livre) */
.kbg-carousel-book-spine::after {
    display: none;
    /* Not needed for facing-front carousel */
}

/* Spine (Tranche du livre) - HIDDEN in carousel */
.kbg-book-3d-spine {
    display: none;
}

/* Top edge - HIDDEN in carousel */
.kbg-book-3d-top {
    display: none;
}

/* Bottom edge - HIDDEN in carousel */
.kbg-book-3d-bottom {
    display: none;
}

/* Title on Front Cover - VISIBLE NOW? Optional. Let's hide to focus on image covers for now */
.kbg-spine-title {
    display: none !important;
}

/* Decorative border on cover - HIDDEN */
.kbg-spine-title::before {
    display: none !important;
}

/* ========================================
   INDIVIDUAL BOOK POSITIONS (TOMB RAIDER STYLE)
   - All faces forward (rotateY(0deg))
   - Horizontal spacing with Z-depth scaling
   ======================================== */

/* Center Position - THE ACTIVE BOOK */
.kbg-carousel-book.pos-center {
    transform: translateX(0) translateZ(200px) scale(1.1);
    z-index: 100;
    opacity: 1;
    filter: brightness(1.1) drop-shadow(0 20px 50px rgba(0, 0, 0, 0.8));
    pointer-events: auto;
}

/* Left 1 */
.kbg-carousel-book.pos-left-1 {
    transform: translateX(-300px) translateZ(50px) scale(0.9);
    z-index: 50;
    opacity: 0.9;
    filter: brightness(0.6);
    pointer-events: auto;
}

/* Left 2 */
.kbg-carousel-book.pos-left-2 {
    transform: translateX(-550px) translateZ(-100px) scale(0.8);
    z-index: 20;
    opacity: 0.7;
    filter: brightness(0.4) blur(1px);
    pointer-events: auto;
}

/* Right 1 */
.kbg-carousel-book.pos-right-1 {
    transform: translateX(300px) translateZ(50px) scale(0.9);
    z-index: 50;
    opacity: 0.9;
    filter: brightness(0.6);
    pointer-events: auto;
}

/* Right 2 */
.kbg-carousel-book.pos-right-2 {
    transform: translateX(550px) translateZ(-100px) scale(0.8);
    z-index: 20;
    opacity: 0.7;
    filter: brightness(0.4) blur(1px);
    pointer-events: auto;
}

/* Active book pulsing glow - CYBER BLUE */
.kbg-carousel-book.active .kbg-carousel-book-spine::before {
    box-shadow:
        inset 10px 0 20px rgba(0, 0, 0, 0.5),
        0 20px 80px rgba(0, 0, 0, 0.9),
        0 0 80px rgba(0, 243, 255, 0.8);
    animation: pulseGlow 3s ease-in-out infinite;
}

/* ========================================
   OPENING TRANSITION ANIMATION
   ======================================== */

@keyframes openBookTransition {
    0% {
        transform: translateZ(200px) scale(1.2);
        opacity: 1;
    }

    50% {
        transform: translateZ(400px) scale(2.5);
        opacity: 1;
    }

    100% {
        transform: translateZ(600px) scale(4);
        opacity: 0;
    }
}

.kbg-carousel-book.opening-transition {
    animation: openBookTransition 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 1000;
}

/* Fade out other books during transition */
.kbg-carousel-book.opening-transition~.kbg-carousel-book,
.kbg-carousel:has(.opening-transition) .kbg-carousel-book:not(.opening-transition) {
    animation: fadeOutBooks 0.6s ease-out forwards;
}

@keyframes fadeOutBooks {
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow:
            inset 10px 0 20px rgba(0, 0, 0, 0.5),
            0 20px 80px rgba(0, 0, 0, 0.9),
            0 0 80px rgba(0, 243, 255, 0.6),
            0 0 120px rgba(0, 243, 255, 0.2);
    }

    50% {
        box-shadow:
            inset 10px 0 20px rgba(0, 0, 0, 0.5),
            0 20px 80px rgba(0, 0, 0, 0.9),
            0 0 130px rgba(0, 243, 255, 1),
            0 0 180px rgba(0, 243, 255, 0.4);
    }
}

/* Carousel Controls */
.kbg-carousel-controls {
    position: absolute;
    bottom: 12%;
    display: flex;
    gap: 30px;
    z-index: 1000;
    pointer-events: none;
    /* Let clicks pass to books behind if not on buttons */
}

.kbg-carousel-btn {
    pointer-events: auto;
    /* Buttons are clickable */
}

.kbg-carousel-title-display {
    position: absolute;
    top: 15%;
    z-index: 100;
    pointer-events: none;
    /* Never block clicks */
}

.kbg-carousel-btn {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.3rem;
    padding: 15px 35px;
    background: linear-gradient(135deg, #8b4513 0%, #3e2723 100%);
    color: #ffd700;
    border: 2px solid #d4af37;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 0 #5d4037, 0 6px 20px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.kbg-carousel-btn:hover {
    background: linear-gradient(135deg, #a0522d 0%, #4a1c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #5d4037, 0 8px 25px rgba(0, 0, 0, 0.6);
}

.kbg-carousel-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #5d4037, 0 4px 15px rgba(0, 0, 0, 0.5);
}

.kbg-carousel-select {
    background: linear-gradient(135deg, #d35400 0%, #a04000 100%) !important;
    border-color: #ffd700 !important;
    font-size: 1.5rem !important;
    animation: pulseButton 2s ease-in-out infinite;
}

@keyframes pulseButton {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Title Display */
.kbg-carousel-title-display {
    position: absolute;
    top: 8%;
    text-align: center;
    z-index: 200;
}

.kbg-carousel-title-display h2 {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 3.5rem;
    color: #ffd700;
    text-shadow:
        0 3px 0 #5d4037,
        0 6px 10px rgba(0, 0, 0, 0.7),
        0 0 40px rgba(255, 215, 0, 0.5);
    margin: 0;
    animation: fadeInTitle 0.6s ease-out;
}

@keyframes fadeInTitle {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   ORIGINAL BOOK STYLES (When book opened)
   ======================================== */

/* --- MAIN LAYOUT --- */
#kbg-games-container {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative;
    /* GLOBAL BACKGROUND (Same as Carousel) */
    background: radial-gradient(circle at center, rgba(26, 26, 46, 0.6) 0%, rgba(15, 15, 30, 0.9) 100%),
        url('../img/kbg-bouc-magique-bg.png') no-repeat center center !important;
    background-size: cover;
    background-attachment: fixed;
    font-family: 'Georgia', serif;
}

/* --- GRIMOIRE TYPOGRAPHY --- */
.kbg-title-kissbook {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 3rem;
    color: #e0c080;
    text-shadow: 2px 2px 0px #3e2723;
    margin: 0 0 20px 0;
    line-height: 1.2;
}

.kbg-title-games {
    font-family: 'Uncial Antiqua', cursive;
    font-size: 4.5rem;
    color: #ffd700;
    letter-spacing: 8px;
    text-shadow: 0 2px 0 #5d4037,
        0 4px 6px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(255, 215, 0, 0.4);
    margin: 0 0 25px 0;
    line-height: 1;
}

.kbg-title-sub {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 1.2rem;
    color: #c7b299;
    letter-spacing: 4px;
    text-transform: uppercase;
    border-top: 1px solid rgba(199, 178, 153, 0.4);
    border-bottom: 1px solid rgba(199, 178, 153, 0.4);
    display: inline-block;
    padding: 8px 30px;
    margin-top: 5px;
}

/* --- SHELF (Book Container) --- */
.kbg-shelf {
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 3500px;
    width: 100%;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

/* --- THE BOOK OBJECT --- */
.kbg-book {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: default;
    z-index: 10;

    /* RESPONSIVE SIZE - LARGE */
    height: 92vh;
    width: 70vh;
    /* Wider aspect ratio */
    margin-top: 1vh;
    max-width: 900px;
    /* Cap width for huge screens */
    max-height: 1200px;
}

/* Open State Centering */
.kbg-book[data-state="open"] {
    /* Move to right by half width (35vh) to center the spread */
    transform: translateX(35vh) !important;
}

@media (max-width: 1000px) {
    .kbg-book {
        height: 80vh;
        width: 55vh;
    }

    .kbg-book[data-state="open"] {
        transform: translateX(150px);
    }
}

/* 🖥️ HUGE SCREEN / TV OPTIMIZATION (>= 1600px) */
/* HUGE SCREEN OPTIMIZATION - Removed, now using generic VH units above */

/* 💻 STANDARD DESKTOP (1200px - 1599px) */
@media (min-width: 1200px) and (max-width: 1599px) {
    .kbg-book {
        width: 500px;
        height: 700px;
        margin-top: 10px;
    }

    .kbg-book[data-state="open"] {
        transform: translateX(250px);
    }

    .kbg-book[data-state="closed-back"] {
        transform: translateX(0);
    }
}

/* 📱 TABLET / MOBILE */
@media (max-width: 1199px) {
    .kbg-book {
        width: 80vw;
        height: 60vh;
        margin-top: 0;
    }

    .kbg-book[data-state="open"],
    .kbg-book[data-state="closed-back"] {
        transform: translateX(0);
    }

    .kbg-shelf {
        perspective: 1500px;
    }
}

/* --- ZOOM-IN ANIMATION (Game Launch) --- */
@keyframes zoomIntoBook {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

.kbg-book.zoom-in {
    animation: zoomIntoBook 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* --- PAGE STRUCTURE --- */
.kbg-page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    will-change: transform;
}

.kbg-page.flipped {
    transform: rotateY(-180deg);
}

/* --- PAGE FACES --- */
.kbg-page-front,
.kbg-page-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    overflow: visible !important;
    /* CRITICAL FIX: Allow cards to swipe OUT of the page */
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.1);
    background: #fdf6e3;
    /* Added beige background to both sides */
}

.kbg-page-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.kbg-page-back {
    z-index: 1;
    transform: rotateY(180deg);
}

/* 0. COVER STYLES */
.kbg-cover-front {
    background: #3e2723;
    background-image: url('https://www.transparenttextures.com/patterns/leather.png');
    border-radius: 5px 15px 15px 5px;
    box-shadow: inset 10px 0 20px rgba(0, 0, 0, 0.5), 5px 5px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.kbg-cover-back {
    background: #3e2723;
    background-image: url('../img/cover-back.png');
    /* Use local texture */
    background-size: cover;
    border-radius: 15px 5px 5px 15px;
    box-shadow: inset 10px 0 20px rgba(0, 0, 0, 0.5);
    color: #c7b299;
    display: flex;
    justify-content: center;
    align-items: center;
}

.kbg-cover-deco {
    border: 3px solid #6d4c41;
    margin: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* --- COVER LOGO: 3D EMBROIDERY EFFECT --- */
.kbg-cover-logo-container {
    margin-top: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    perspective: 500px;
}

.kbg-cover-embroidery {
    max-width: 250px;
    height: auto;
    filter: drop-shadow(0px 4px 0px #3e2723) drop-shadow(0px 6px 6px rgba(0, 0, 0, 0.6));
    transform: translateZ(5px);
    transition: transform 0.3s ease, filter 0.3s ease;
}

.kbg-cover-embroidery:hover {
    transform: translateZ(10px) scale(1.05);
    filter: drop-shadow(0px 6px 0px #3e2723) drop-shadow(0px 12px 15px rgba(0, 0, 0, 0.5)) brightness(1.1);
    cursor: pointer;
}

/* 1+. INNER PAGES (Paper) */
.kbg-page-front:not(.kbg-cover-front) {
    background: #fffcf5;
    background-image: linear-gradient(to right, #e8dcc5, #fffcf5 6%, #fffcf5 96%, #e0d0b0);
    border-radius: 0 5px 5px 0;
    box-shadow: inset 3px 0 5px rgba(0, 0, 0, 0.05);
    padding: 30px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-family: 'Coming Soon', cursive;
    /* Cartoon text font */
}

.kbg-page-back:not(.kbg-cover-back) {
    background: #fffcf5;
    background-image: linear-gradient(to left, #e8dcc5, #fffcf5 6%, #fffcf5 96%, #e0d0b0);
    border-radius: 5px 0 0 5px;
    box-shadow: inset -3px 0 5px rgba(0, 0, 0, 0.05);
    padding: 30px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-family: 'Coming Soon', cursive;
    /* Cartoon text font */
}

/* --- PAGE ELEMENTS --- */
.kbg-page-title {
    font-family: 'Luckiest Guy', cursive;
    /* Cartoon title font */
    font-size: 2.2rem;
    color: #d35400;
    text-align: center;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 0;
    letter-spacing: 1.5px;
}

/* --- INDEX LIST --- */
.kbg-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.kbg-index-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    align-content: start;
    overflow-y: auto;
}

.kbg-toc-item,
.kbg-index-item {
    font-size: 1.1rem;
    color: #4a1c1c;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(139, 69, 19, 0.2);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    transition: color 0.2s, background 0.2s;
}

.kbg-toc-item:hover,
.kbg-index-item:hover {
    color: #d35400;
    background: rgba(211, 84, 0, 0.05);
    padding-left: 5px;
}

.kbg-index-page {
    font-size: 0.9rem;
    opacity: 0.5;
    font-family: 'Coming Soon', cursive;
    font-style: italic;
}

/* --- INDEX STORY & PREVIEW --- */
.kbg-index-story-container {
    padding: 30px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, rgba(255, 252, 245, 0.8) 0%, rgba(245, 235, 215, 0.9) 100%);
    border-radius: 20px;
    box-shadow: inset 0 0 60px rgba(139, 69, 19, 0.15);
    border: 1px solid rgba(139, 69, 19, 0.2);
    overflow: hidden;
}

.kbg-index-preview-wrapper {
    margin-top: 15px;
    padding: 10px;
    background: rgba(139, 69, 19, 0.05);
    border-radius: 12px;
    min-height: 480px;
    /* 4x increase from ~120px */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(139, 69, 19, 0.1);
}

.kbg-index-preview-img {
    max-height: 450px;
    /* 4x increase from ~112px */
    width: auto;
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0.5;
}

/* --- PAGE NUMBERING --- */
.kbg-page-number {
    position: absolute;
    bottom: 15px;
    font-family: 'Uncial Antiqua', serif;
    font-size: 1rem;
    color: #8b4513;
    pointer-events: none;
    opacity: 0.8;
    z-index: 150;
    transform: translateZ(1px);
}

.kbg-page-front .kbg-page-number {
    right: 25px;
}

.kbg-page-back .kbg-page-number {
    left: 25px;
}

/* Home Button */
.kbg-home-btn {
    cursor: pointer;
    font-size: 1.5rem;
    margin-right: 8px;
    opacity: 0.6;
    transition: all 0.2s;
    pointer-events: auto !important;
    position: relative;
    z-index: 1000;
    display: inline-block;
    color: #8b4513;
}

.kbg-home-btn:hover {
    opacity: 1;
    color: #d35400;
    transform: scale(1.2);
}

/* --- NAVIGATION CORNERS --- */
.kbg-page-corner {
    position: absolute;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 500;
    overflow: hidden;
    backface-visibility: hidden;
    pointer-events: auto !important;
    transform: translateZ(2px);
}

.kbg-corner-next {
    top: 0;
    right: 0;
    background: linear-gradient(225deg, rgba(139, 69, 19, 0.2) 0%, transparent 60%);
    border-bottom-left-radius: 100%;
}

.kbg-corner-next:hover {
    width: 90px;
    height: 90px;
    background: linear-gradient(225deg, #d35400 0%, #fdf6e3 60%);
}

.kbg-corner-prev {
    top: 0;
    left: 0;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.2) 0%, transparent 60%);
    border-bottom-right-radius: 100%;
}

.kbg-corner-prev:hover {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, #d35400 0%, #fdf6e3 60%);
}

/* --- GAME DETAILS LAYOUT --- */
.kbg-game-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kbg-game-jacket-frame {
    border: 5px double #8b4513;
    background: #fffcf5;
    padding: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin: 10px 0;
}

.kbg-game-jacket-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s;
}

.kbg-game-jacket-img:hover {
    transform: scale(1.05);
}

/* Play Button */
.kbg-btn-play {
    display: block;
    width: 100%;
    background: #d35400;
    color: #fff;
    border: none;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    box-shadow: 0 4px 0 #a04000;
    transition: all 0.1s;
    font-family: 'Cinzel Decorative', serif;
}

.kbg-btn-play:hover {
    background: #e67e22;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #a04000;
}

.kbg-btn-play:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #a04000;
}

/* --- RUNNER --- */
#kbg-fullscreen-runner {
    position: fixed;
    top: 0;
    /* Start from very top to cover everything */
    left: 0;
    width: 100%;
    height: 100%;
    /* Full screen */
    background: #000;
    /* Pure black to hide background elements */
    z-index: 2147483647 !important;
    /* Maximum possible z-index */
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#kbg-fullscreen-runner.active {
    display: flex;
}

#kbg-runner-controls {
    z-index: 2;
    /* Relative to parent runner */
    position: relative;
}

#kbg-runner-frame {
    z-index: 1;
    position: relative;
    width: 100%;
    height: 100%;
    border: none;
}

/* --- LOBBY / MULTIPLAYER STYLES --- */
.kbg-lobby-tabs .kbg-tab-btn {
    background: rgba(139, 69, 19, 0.1);
    border: 1px solid #8b4513;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Coming Soon', cursive;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.kbg-lobby-tabs .kbg-tab-btn.active {
    background: #8b4513;
    color: #fff;
}

.kbg-lobby-panel {
    display: none;
    flex: 1;
    min-height: 200px;
    flex-direction: column;
}

.kbg-lobby-panel.active {
    display: flex;
}

.kbg-lobby-scroll-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.kbg-lobby-scroll-list::-webkit-scrollbar {
    width: 6px;
}

.kbg-lobby-scroll-list::-webkit-scrollbar-thumb {
    background: rgba(139, 69, 19, 0.3);
    border-radius: 10px;
}

.kbg-lobby-card,
.kbg-online-card {
    background: #fff;
    border: 1px solid rgba(139, 69, 19, 0.2);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kbg-lobby-card:hover,
.kbg-online-card:hover {
    transform: translateX(3px);
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========================================
   SPECIFIC BOOK COVERS (Overrides)
   ======================================== */

/* GAMES (Default) */
.kbg-carousel-book[data-book-id="games"] .kbg-carousel-book-spine::before {
    background-image: url('../img/cover-games.png') !important;
    background-size: cover !important;
    background-position: center !important;
}

/* RENCONTRES */
.kbg-carousel-book[data-book-id="rencontres"] .kbg-carousel-book-spine::before {
    background-image: url('../img/cover-rencontres.png') !important;
    background-size: cover !important;
    background-position: center !important;
}

/* PARAMETRES */
.kbg-carousel-book[data-book-id="parametres"] .kbg-carousel-book-spine::before {
    background-image: url('../img/cover-parametres.png') !important;
    background-size: cover !important;
    background-position: center !important;
}

/* PROFIL */
.kbg-carousel-book[data-book-id="profil"] .kbg-carousel-book-spine::before {
    background-image: url('../img/cover-profile.png') !important;
    background-size: cover !important;
    background-position: center !important;
}

/* INSCRIPTION */
.kbg-carousel-book[data-book-id="inscription"] .kbg-carousel-book-spine::before {
    background-image: url('../img/cover-inscription.png') !important;
    background-size: cover !important;
    background-position: center !important;
}



.kbg-avatar-mini {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #8b4513;
    object-fit: cover;
}

.kbg-lobby-info {
    flex: 1;
}

.kbg-lobby-info h4 {
    margin: 0;
    font-size: 0.9rem;
    color: #8b4513;
    font-family: 'Luckiest Guy', cursive;
}

.kbg-lobby-info p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.7;
}

.kbg-btn-mini {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    transition: transform 0.2s;
}

.kbg-btn-mini:hover {
    transform: rotate(30deg) scale(1.2);
}

.kbg-btn-join {
    background: #27ae60;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-family: 'Luckiest Guy', cursive;
    cursor: pointer;
}

.kbg-btn-join:hover {
    background: #2ecc71;
}

.kbg-btn-challenge {
    background: #d35400;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-family: 'Luckiest Guy', cursive;
    cursor: pointer;
}

/* Online Pulse */
.kbg-online-dot {
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    animation: kbg-online-pulse 2s infinite;
}

@keyframes kbg-online-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(39, 174, 96, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(39, 174, 96, 0);
    }
}

/* --- CHAT SYSTEM STYLES --- */
.kbg-chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: rgba(139, 69, 19, 0.03);
    border-radius: 15px;
    border: 1px solid rgba(139, 69, 19, 0.1);
    overflow: hidden;
    margin: 0 10px 20px 10px;
}

.kbg-chat-header {
    padding: 10px;
    background: rgba(139, 69, 19, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(139, 69, 19, 0.1);
}

#kbg-chat-room-label {
    font-family: 'Coming Soon', cursive;
    font-size: 0.9rem;
    color: #8b4513;
    font-weight: bold;
}

.kbg-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kbg-chat-msg {
    max-width: 85%;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    position: relative;
    font-family: 'Coming Soon', cursive;
}

.kbg-chat-msg.mine {
    align-self: flex-end;
    background: #d35400;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.kbg-chat-msg.other {
    align-self: flex-start;
    background: #fff;
    color: #3e2723;
    border: 1px solid rgba(139, 69, 19, 0.2);
    border-bottom-left-radius: 2px;
}

.kbg-chat-author {
    font-size: 0.7rem;
    font-weight: bold;
    margin-bottom: 2px;
    display: block;
    opacity: 0.8;
}

.kbg-chat-input-area {
    padding: 10px;
    display: flex;
    gap: 8px;
    background: #fff;
    border-top: 1px solid rgba(139, 69, 19, 0.1);
}

.kbg-chat-input-area input {
    flex: 1;
    border: 1px solid #ccc;
    padding: 8px 12px;
    border-radius: 20px;
    font-family: 'Coming Soon', cursive;
    font-size: 0.9rem;
}

.kbg-chat-input-area button {
    background: #8b4513;
    color: #fff;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Utilities */
.hidden {
    display: none !important;
}

/* ========================================
   NEW LOBBY & CHAT STYLES (Phase 1)
   ======================================== */

/* Larger Host Avatar */
.kbg-avatar-host {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 3px solid #ffd700;
    /* Gold border for host */
    object-fit: cover;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.kbg-player-count {
    font-weight: bold;
    color: #d35400;
}

/* Chat Emoji Button */
.kbg-chat-emoji-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
    border-radius: 50%;
    transition: transform 0.2s;
}

.kbg-chat-emoji-btn:hover {
    transform: scale(1.2);
    background: rgba(255, 215, 0, 0.2);
}

/* Emoji Picker Popup */
#kbg-emoji-picker {
    z-index: 1000;
    animation: fadeInEmoji 0.2s ease-out;
}

#kbg-emoji-picker span {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 35px;
    width: 35px;
    border-radius: 5px;
    transition: background 0.1s;
}

#kbg-emoji-picker span:hover {
    background: #f0e6d2;
}

@keyframes fadeInEmoji {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE & TABLET
   ======================================== */

/* Tablet (Portrait) */
@media (max-width: 1024px) {
    .kbg-carousel-book {
        width: 280px;
        height: 400px;
    }

    .kbg-carousel-book.pos-center {
        transform: translateX(0) translateZ(150px) scale(1.05);
    }

    .kbg-carousel-book.pos-left-1,
    .kbg-carousel-book.pos-right-1 {
        transform: translateX(-250px) translateZ(30px) scale(0.85);
    }

    .kbg-carousel-book.pos-left-2,
    .kbg-carousel-book.pos-right-2 {
        transform: translateX(-450px) translateZ(-80px) scale(0.75);
    }

    .kbg-carousel-controls button {
        min-width: 50px;
        min-height: 50px;
        font-size: 1.3em;
    }
}

/* Mobile (Landscape) */
@media (max-width: 768px) {
    #kbg-carousel-scene {
        height: 100vh;
        background-attachment: scroll;
    }

    .kbg-carousel {
        transform: translateY(80px);
    }

    .kbg-carousel-book {
        width: 220px;
        height: 320px;
    }

    .kbg-carousel-book.pos-center {
        transform: translateX(0) translateZ(100px) scale(1);
    }

    .kbg-carousel-book.pos-left-1,
    .kbg-carousel-book.pos-right-1 {
        transform: translateX(-180px) translateZ(20px) scale(0.8);
    }

    .kbg-carousel-book.pos-left-2,
    .kbg-carousel-book.pos-right-2 {
        transform: translateX(-320px) translateZ(-60px) scale(0.7);
        opacity: 0.5;
    }

    .kbg-carousel-controls {
        gap: 15px;
        margin-top: 30px;
    }

    .kbg-carousel-controls button {
        min-width: 60px;
        min-height: 60px;
        font-size: 1.5em;
        padding: 10px;
    }

    /* Improve touch targets */
    .kbg-carousel-book {
        cursor: pointer;
    }
}

/* Mobile (Portrait) */
@media (max-width: 480px) {
    .kbg-carousel {
        transform: translateY(60px);
    }

    .kbg-carousel-book {
        width: 180px;
        height: 260px;
    }

    .kbg-carousel-book.pos-center {
        transform: translateX(0) translateZ(80px) scale(1);
    }

    .kbg-carousel-book.pos-left-1,
    .kbg-carousel-book.pos-right-1 {
        transform: translateX(-140px) translateZ(10px) scale(0.75);
    }

    .kbg-carousel-book.pos-left-2,
    .kbg-carousel-book.pos-right-2 {
        transform: translateX(-240px) translateZ(-40px) scale(0.65);
        opacity: 0.4;
        filter: brightness(0.3) blur(2px);
    }

    .kbg-carousel-controls {
        gap: 10px;
        margin-top: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .kbg-carousel-controls button {
        min-width: 55px;
        min-height: 55px;
        font-size: 1.4em;
    }

    .kbg-carousel-btn.kbg-carousel-select {
        order: -1;
        width: 100%;
        max-width: 200px;
        margin-bottom: 10px;
    }

    /* Reduce hover effect on mobile (touch devices) */
    .kbg-carousel-book:hover {
        transform: translateY(-5px) scale(1.01);
    }

    /* Hide focus outline on touch devices */
    @media (hover: none) {
        .kbg-carousel-book:focus {
            outline: none;
        }
    }
}