* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Segoe UI', sans-serif; 
}

body { 
    background: #0a0a0a; 
    color: #fff; 
    overflow: hidden;
    height: 100vh;
}

.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: block;
}

/* FRONT PAGE */
#frontPage {
    background: #1a0a2a;
    display: none;
    justify-content: center;
    align-items: center;
}

#frontPage.active {
    display: flex;
}

.front-background {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}

.front-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(26,10,42,0.3) 0%, rgba(26,10,42,0.8) 100%);
}

.start-button {
    position: relative;
    padding: 20px 60px;
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #6a1b9a, #e94f8a);
    border: 3px solid #fff;
    border-radius: 15px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s;
    text-shadow: 0 0 20px rgba(233,79,138,0.5);
    letter-spacing: 2px;
}

.start-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(233,79,138,0.4);
}

/* HUD */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(20,10,30,0.95);
    border-bottom: 2px solid #6a1b9a;
    height: 60px;
    position: relative;
    z-index: 5;
}

#menuButton {
    background: transparent;
    border: 1px solid #6a1b9a;
    color: #aaa;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

#menuButton:hover {
    background: #6a1b9a;
    color: #fff;
}

#levelTitle {
    font-size: 22px;
    font-weight: bold;
    color: #e94f8a;
    text-shadow: 0 0 20px rgba(233,79,138,0.3);
}

.hud-right {
    display: flex;
    gap: 25px;
    font-size: 14px;
}

.hud-right div span {
    color: #e94f8a;
    font-weight: bold;
    margin-left: 5px;
}

/* GAME LAYOUT */
.game-layout {
    display: flex;
    height: calc(100vh - 60px);
}

.character-panel {
    width: 300px;
    min-width: 300px;
    background: rgba(15,10,25,0.95);
    border-right: 2px solid #2a1a40;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 12px;
    overflow-y: auto;
    gap: 12px;
    height: calc(100vh - 60px);
    min-height: 0;
}

.character-panel > * {
    flex-shrink: 0;
}

.character-panel-title {
    font-size: 14px;
    color: #888;
    letter-spacing: 3px;
    margin-bottom: 10px;
}

#characterCanvas {
    background: #0a0a15;
    border: 2px solid #2a1a40;
    border-radius: 10px;
    width: 200px;
    height: 300px;
    image-rendering: pixelated;
}

#characterAge {
    margin-top: 10px;
    font-size: 18px;
    color: #e94f8a;
    font-weight: bold;
}

.game-wrapper {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

/* OBJECTIVE & CONTROLS */
.objective-box, .controls-box {
    position: absolute;
    padding: 8px 15px;
    background: rgba(0,0,0,0.75);
    border: 1px solid #2a1a40;
    border-radius: 5px;
    font-size: 13px;
    color: #aaa;
     line-height: 1.4;
    position: static;
    flex-shrink: 0;
}

.objective-box {
    bottom: 110px;
    left: 15px;
}

.controls-box {
    bottom: 40px;
    left: 15px;
}

.objective-box strong, .controls-box strong {
    color: #e94f8a;
    margin-right: 10px;
}

/* TRANSITION */
.transition-screen {
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
}

.transition-screen.active {
    display: flex;
}

.transition-card {
    text-align: center;
    padding: 50px 70px;
    background: linear-gradient(135deg, #1a0a2a, #2a1a40);
    border: 2px solid #6a1b9a;
    border-radius: 20px;
    max-width: 600px;
}

.transition-small {
    color: #888;
    font-size: 14px;
    letter-spacing: 4px;
    margin-bottom: 10px;
}

#transitionTitle {
    font-size: 48px;
    color: #e94f8a;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(233,79,138,0.3);
}

#transitionText {
    color: #aaa;
    font-size: 18px;
    margin-bottom: 30px;
}

#continueButton {
    padding: 12px 40px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #6a1b9a, #e94f8a);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

#continueButton:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(233,79,138,0.3);
}

/* MINI GAME */
#miniGameScreen {
    background: #0a0a15;
    display: none;
}

#miniGameScreen.active {
    display: block;
}

#miniCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.mini-hud {
    position: fixed;
    top: 70px;
    left: 20px;
    display: flex;
    gap: 30px;
    font-size: 18px;
    color: #fff;
    background: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid #6a1b9a;
    z-index: 10;
}

.mini-hud span {
    color: #e94f8a;
    font-weight: bold;
}

.mini-instruction {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #888;
    font-size: 16px;
    letter-spacing: 2px;
    background: rgba(0,0,0,0.7);
    padding: 8px 25px;
    border-radius: 20px;
    border: 1px solid #2a1a40;
    z-index: 10;
}

/* MENU MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
    z-index: 999;
}
.modal-overlay.active {
    display: flex;
}
.modal-box {
    background: #1a0a2a;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid #e94f8a;
    box-shadow: 0 0 30px rgba(233,79,138,0.3);
}
.modal-box h3 {
    color: #e94f8a;
    margin-bottom: 20px;
    font-size: 24px;
}
.modal-box button {
    display: block;
    margin: 15px auto;
    padding: 15px 40px;
    background: linear-gradient(135deg, #6a1b9a, #e94f8a);
    border: none;
    color: white;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s;
}
.modal-box button:hover {
    transform: scale(1.05);
}

#jumpscareScreen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
#jumpscareScreen.active { display: flex; }
#jumpscareScreen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}
/* LEVEL 8 PUZZLE OVERLAY */
.puzzle-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: auto;
    z-index: 1000;
}
.puzzle-overlay.active {
    display: block;
}
.puzzle-box {
    position: absolute;
    top: 50%;
    left: 40px;
    transform: translateY(-50%);
    background: rgba(200, 200, 200, 0.95);
    width: 380px;
    padding: 25px;
    border-radius: 10px;
    color: #333;
    font-family: 'Segoe UI', sans-serif;
    text-align: center;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
    pointer-events: auto; /* Re-enable clicks on the box itself */
}
.puzzle-close {
    position: absolute;
    top: 5px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
}
.puzzle-close:hover { color: #e94f8a; }
.puzzle-box h2 { 
    margin-top: 0; 
    font-size: 22px; 
    letter-spacing: 2px; 
    border-bottom: 2px solid #333;
    padding-bottom: 8px;
}
#questionText {
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
    min-height: 80px;
    margin: 15px 0;
}
.puzzle-box h3 { 
    margin-bottom: 8px; 
    font-size: 16px; 
    color: #555;
}
#puzzleAnswer { 
    width: 90%; 
    padding: 8px; 
    margin-bottom: 10px; 
    font-size: 14px; 
    border: 2px solid #333;
    border-radius: 5px;
    text-align: center;
}
#puzzleSubmit { 
    padding: 8px 20px; 
    font-size: 14px; 
    font-weight: bold;
    cursor: pointer; 
    background: #333; 
    color: #fff;
    border: none; 
    border-radius: 5px;
}
#puzzleSubmit:hover { background: #e94f8a; }
#puzzleFeedback {
    font-size: 13px;
    font-weight: bold;
    min-height: 18px;
    margin-top: 8px;
}
/* ============================================ */
/* CHARACTER PANEL — wider, holds objectives    */
/* ============================================ */
.character-panel {
    width: 300px;
    min-width: 300px;
    background: rgba(15,10,25,0.95);
    border-right: 2px solid #2a1a40;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 12px;
    overflow-y: auto;
    gap: 12px;
}

#characterCanvas {
    background: #0a0a15;
    border: 2px solid #2a1a40;
    border-radius: 10px;
    width: 240px;
    height: 350px;
    image-rendering: pixelated;
}

/* Objective + Controls now inside the character panel */
.objective-box, .controls-box {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0,0,0,0.75);
    border: 1px solid #2a1a40;
    border-radius: 8px;
    font-size: 13px;
    color: #ccc;
    line-height: 1.4;
    position: static;
}

.objective-box strong, .controls-box strong {
    display: block;
    color: #e94f8a;
    margin-bottom: 6px;
    font-size: 12px;
    letter-spacing: 2px;
}

/* ============================================ */
/* CUTSCENE SCREEN                              */
/* ============================================ */
.cutscene-screen {
    background: #000;
    display: none;
    justify-content: center;
    align-items: center;
}

.cutscene-screen.active {
    display: flex;
}

#cutsceneVideo {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.cutscene-message {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 10, 30, 0.95);
    border: 2px solid #6a1b9a;
    border-radius: 15px;
    padding: 25px 40px;
    text-align: center;
    max-width: 850px;
    width: 80%;
    box-shadow: 0 0 40px rgba(233,79,138,0.4);
    z-index: 10;
}

#cutsceneText {
    font-size: 20px;
    color: #fff;
    margin-bottom: 18px;
    line-height: 1.5;
    font-family: 'Segoe UI', sans-serif;
}

#cutsceneContinue {
    padding: 12px 40px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #6a1b9a, #e94f8a);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

#cutsceneContinue:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(233,79,138,0.4);
}