* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    touch-action: manipulation;
}

body,
html {
    width: 100%;
    height: 100%;
    background-color: #050510;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
    will-change: transform;
}

#debug-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #00ff00;
    font-family: monospace;
    font-size: 0.85rem;
    padding: 10px;
    border-radius: 4px;
    z-index: 1000;
    pointer-events: none;
    border: 1px solid rgba(0, 255, 0, 0.3);
    max-width: 250px;
}

#backgroundImageLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 10;
    transition: filter 0.5s ease;
}

#screenFadeLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    transition: opacity linear;
}

#dialogInterfaceLayer {
    position: absolute;
    bottom: 4%;
    left: 0;
    width: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

#dialog-wrapper {
    position: relative;
    width: 80%;
}

.characterSprite {
    position: absolute;
    bottom: 95%;
    max-height: 65vh;
    object-fit: contain;
    transition: filter 0.3s ease;
    pointer-events: none;
    transform: translateX(-50%) translateZ(0);
    will-change: filter, transform;
}

#characterImageLeft {
    left: 25%;
}

#characterImageCenter {
    left: 50%;
}

#characterImageRight {
    left: 75%;
}

#dialogMessageContainer {
    position: relative;
    z-index: 10;
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.98), rgba(30, 30, 45, 0.96));
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #ff4444;
    border-radius: 12px;
    padding: 25px 30px;
    color: #e2e8f0;
    font-size: 1.25rem;
    line-height: 1.6;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    min-height: 180px;
    cursor: pointer;
    transition: transform 0.1s ease;
    will-change: transform;
    transform: translateZ(0);
}

#dialogMessageText.hasTitle {
    margin-top: 15px;
}

#dialogMessageContainer:active {
    transform: scale(0.995);
}

#speakerNameContainer {
    position: absolute;
    top: -20px;
    left: 25px;
    background: linear-gradient(to right, #2a2a35, #1a1a25);
    padding: 6px 20px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#dialogAdvanceIndicator {
    position: absolute;
    bottom: 12px;
    right: 20px;
    font-size: 1rem;
    color: #ff4444;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    0% {
        transform: translateY(0);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@keyframes logoEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoHeartbeat {
    0%, 100% {
        transform: scale(1) rotate(-2deg);
    }
    50% {
        transform: scale(1.03) rotate(2deg);
    }
}

.shake-animation {
    animation: shake-effect 0.1s infinite;
}

@keyframes shake-effect {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.jump-animation {
    animation: jump-effect 0.1s infinite;
}

@keyframes jump-effect {
    0% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0); }
}

#decisionOptionsLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 150;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#decisionOptionsContainer {
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideUp {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.option-btn {
    background: linear-gradient(135deg, rgba(40, 40, 50, 0.9), rgba(20, 20, 30, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 4px solid #ff4444;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-family: inherit;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#customTooltip {
    position: absolute;
    background: rgba(30, 30, 45, 0.98);
    border: 1px solid #ff4444;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.tooltip-hidden {
    opacity: 0;
    transform: translateY(5px);
}

.option-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
    border-left-color: #555;
    transform: none;
    box-shadow: none;
    pointer-events: auto;
}

.option-btn:hover {
    background: linear-gradient(135deg, rgba(60, 60, 70, 0.95), rgba(30, 30, 40, 0.95));
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

#gameActionButtons {
    position: absolute;
    top: 20px;
    right: 25px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#backButtonContainer, #homeButtonContainer, #optionsButtonContainer, #saveLoadButtonContainer {
    cursor: pointer;
    background: rgba(40, 40, 50, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
}

#backButtonContainer:hover, #homeButtonContainer:hover, #optionsButtonContainer:hover, #saveLoadButtonContainer:hover {
    background: rgba(60, 60, 70, 0.9);
    border-color: #ff4444;
    color: #ff4444;
    transform: scale(1.1);
}

#saveLoadModalOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: 2500;
    display: flex;
    justify-content: center;
    align-items: center;
}

#saveLoadModalContent {
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.95));
    width: 90%;
    max-width: 500px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #ff4444;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#modalHeaderSection {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

#modalTitleText {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

#closeModalActionIcon,
#closeOptionsModalIcon,
#closeCreditsModalIcon {
    cursor: pointer;
    font-size: 1.5rem;
    color: #aaaaaa;
    transition: color 0.2s ease;
}

#closeModalActionIcon:hover,
#closeOptionsModalIcon:hover,
#closeCreditsModalIcon:hover {
    color: #ff4444;
}

#modalBodySection {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#createNewSaveActionBtn {
    width: 100%;
    border-left: 4px solid #44ff44;
}

#savedGamesListContainer {
    max-height: 40vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.savedGameItemContainer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.savedGameItemContainer:hover {
    background: rgba(40, 40, 50, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
}

.saveSlotInfoData {
    display: flex;
    flex-direction: column;
}

.saveSlotDateText {
    font-size: 0.85rem;
    color: #aaaaaa;
}

.saveSlotSceneText {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 4px;
}

.saveSlotActionsBlock {
    display: flex;
    gap: 15px;
}

.saveSlotActionIcon {
    cursor: pointer;
    font-size: 1.3rem;
    color: #aaaaaa;
    transition: color 0.2s ease, transform 0.2s ease;
}

.saveSlotActionIcon:hover {
    transform: scale(1.15);
}

.iconActLoad:hover {
    color: #44ff88;
}

.iconActDelete:hover {
    color: #ff4444;
}

#confirmationModalOverlay,
#inputModalOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#confirmationModalContent,
#inputModalContent {
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.95));
    width: 85%;
    max-width: 400px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #ffaa44;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    color: white;
    padding: 25px;
    text-align: center;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#inputModalPromptText {
    margin-bottom: 25px;
    font-size: 1.1rem;
    line-height: 1.5;
}

.custom-text-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.custom-text-input:focus {
    border-color: #ffaa44;
}

#inputModalActions {
    display: flex;
    justify-content: center;
}

#confirmationModalText {
    font-size: 1.1rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

#confirmationOptionsContainer {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#startScreenLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 40;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 12vh 20px;
}

#startScreenLogoContainer {
    max-width: 90%;
    display: flex;
    justify-content: center;
    animation: logoEntrance 1.2s ease-out forwards;
}

#startScreenLogo {
    max-width: 100%;
    max-height: min(380px, 40vh);
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0px 10px 15px rgba(0, 0, 0, 0.5));
    animation: logoHeartbeat 5s ease-in-out infinite;
}

#startScreenOptions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 300px;
}

#creditsLink {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

#creditsLink:hover {
    color: white;
    text-decoration: underline;
}

#loadingScreenLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #050510;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

#loadingScreenContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80%;
    max-width: 400px;
}

#loadingTitleText {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

#loadingBarContainer {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#loadingProgressBar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff8888);
    transition: width 0.3s ease;
}

#loadingProgressText {
    font-size: 1rem;
    color: #aaaaaa;
}

#optionsModalOverlay,
#creditsModalOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    z-index: 2500;
    display: flex;
    justify-content: center;
    align-items: center;
}

#optionsModalContent,
#creditsModalContent {
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.95));
    width: 90%;
    max-width: 400px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #ff4444;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#optionsModalBodySection,
#creditsModalBodySection {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#creditsListContainer {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 40vh;
    overflow-y: auto;
}

.credit-item {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.credit-category {
    font-size: 0.85rem;
    color: #ffaa44;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.credit-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.option-slider-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-slider-container label {
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.option-slider-container input[type="range"] {
    width: 100%;
    cursor: pointer;
}

@media (max-width: 768px) {
    #dialogMessageContainer {
        font-size: 1.1rem;
        padding: 18px 20px;
        min-height: 160px;
    }

    .characterSprite {
        max-height: 50vh;
    }

    .option-btn {
        padding: 14px 18px;
        font-size: 1.05rem;
    }

    #speakerNameContainer {
        top: -18px;
        left: 15px;
        padding: 4px 15px;
        font-size: 0.95rem;
    }

    #startScreenLayer {
        justify-content: space-between;
        padding: 10vh 20px;
        box-sizing: border-box;
        overflow-y: auto;
    }

    #startScreenLogoContainer {
        margin-bottom: 0;
        margin-top: 0;
    }

    #startScreenLogo {
        max-height: 30vh;
    }
}

#titleOverlayLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    padding: 40px;
    text-align: center;
    cursor: pointer;
}

#titleContentContainer {
    color: white;
    font-weight: 700;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
    max-width: 90%;
    animation: titleFadeIn 0.5s ease-out;
}

@keyframes titleFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

#titleContentContainer h1 {
    font-size: 3.75rem;
    line-height: 1.1;
    margin: 0;
}

#titleContentContainer h2 {
    font-size: 2.9rem;
    line-height: 1.2;
    margin: 0;
}

#titleContentContainer h3 {
    font-size: 2.0rem;
    line-height: 1.3;
    margin: 0;
}

#titleContentContainer h4 {
    font-size: 1.25rem;
    line-height: 1.4;
    margin: 0;
}

#titleAdvanceIndicator {
    position: absolute;
    bottom: 30px;
    right: 30px;
    font-size: 1.5rem;
    color: #ff4444;
    animation: bounce 1s infinite alternate;
}

@media (max-width: 768px) {
    #titleContentContainer h1 { font-size: 2.5rem; }
    #titleContentContainer h2 { font-size: 2.0rem; }
    #titleContentContainer h3 { font-size: 1.5rem; }
    #titleContentContainer h4 { font-size: 1.1rem; }
    #titleAdvanceIndicator { bottom: 20px; right: 20px; }
}