/* Story Mode Styles */
#story-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
    z-index: 1000; /* Ensure it's above other screens when active */
    display: none; /* Hidden by default, toggled via JS */
}

#story-screen.active {
    display: block;
}

#story-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 0.5s ease-in-out;
    z-index: 1;
}

#story-cg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.5s ease-in-out;
    opacity: 0;
    z-index: 2;
}

#story-characters {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none; /* Let clicks pass through to advance text */
}

.story-character {
    position: absolute;
    bottom: -5%; /* Slightly below the screen to hide cutoffs */
    height: 85%; /* Adjust based on typical sprite size */
    width: 40%; /* Add width so background-size works */
    background-size: contain;
    background-position: bottom center;
    background-repeat: no-repeat;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    opacity: 0;
}

/* Character Positions */
.story-character.left { left: 5%; transform: translateX(0); }
.story-character.center { left: 50%; transform: translateX(-50%); }
.story-character.right { right: 5%; transform: translateX(0); }

.story-character.active {
    opacity: 1;
}

/* Dim inactive characters */
.story-character.inactive {
    opacity: 0.5;
    filter: brightness(0.7);
}

.story-top-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    gap: 15px;
}

.story-btn {
    background: transparent;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    font-weight: bold;
}

.story-btn:hover {
    color: #ffd700;
    background: transparent;
}

.story-btn.active {
    color: #ffd700;
    border-color: #ffd700;
}

.story-textbox-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 60%, transparent 100%);
    z-index: 5;
    display: flex;
    align-items: flex-end;
    padding: 40px 10%;
    box-sizing: border-box;
    cursor: pointer; /* Indicate clickable to advance */
}

.story-name {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    width: 150px; /* Fixed width for name */
    flex-shrink: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 5px;
}

.story-text-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.story-text {
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    min-height: 20px;
}

.story-text.en {
    font-size: 18px;
    color: #eee;
    line-height: 1.4;
}

.story-text.jp {
    font-size: 16px;
    color: #ccc;
    margin-top: 8px;
}

/* Hide UI elements when CG is full screen and text is hidden */
.story-ui-hidden .story-textbox-container,
.story-ui-hidden .story-top-buttons {
    opacity: 0;
    pointer-events: none;
}
