/* DTR Modal - FRESH SIMPLE APPROACH */

.milestone-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 4000;
    backdrop-filter: blur(12px);
    animation: milestoneModalOpen 0.6s ease-out;
}

@keyframes milestoneModalOpen {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.milestone-scene {
    width: 95%; 
    height: 90%; 
    max-width: 1200px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-radius: 25px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8);
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.1);
}

/* DTR Header */
.milestone-header {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
    flex-shrink: 0;
    border-bottom: 3px solid rgba(255, 255, 255, 0.2);
}

.milestone-title {
    font-size: 2.2em;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    letter-spacing: 1px;
}

.milestone-setting {
    font-size: 1.2em;
    opacity: 0.9;
    margin-top: 8px;
    font-style: italic;
}

/* DTR Content - Main layout with three columns */
.milestone-content {
    flex: 1; /* FIXED: Take remaining space after header */
    display: grid;
    grid-template-columns: 200px 1fr 200px; 
    grid-template-rows: 1fr; 
    gap: 20px;
    padding: 20px;
    position: relative;
    min-height: 0; /* FIXED: Allow shrinking */
    align-items: stretch;
    width: 100%;
    overflow: hidden; /* FIXED: Prevent overflow */
}


/* Character Portraits - FIXED: Explicit positioning */
.milestone-modal .portrait-container {
    display: flex;
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    gap: 15px;
    box-sizing: border-box; 
    height: 100%;
    position: relative;
}


/* FIXED: Absolute grid positioning to prevent overlap */
.milestone-modal .portrait-left {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    justify-self: stretch;
    align-self: stretch;
    z-index: 10;
}


.milestone-modal .portrait-right {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    justify-self: stretch;
    align-self: stretch;
    z-index: 10;
}

.character-portrait-dtr {
    width: 180px;
    height: 270px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 4px solid rgba(255, 255, 255, 0.8);
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    font-weight: bold;
    color: #666;
    transition: all 0.3s ease;
    position: relative; /* FIXED: Relative positioning */
    z-index: 15; /* FIXED: Higher than dialogue area */
}

.character-portrait-dtr img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-portrait-dtr.speaking {
    border-color: #ff6b6b;
    box-shadow: 0 8px 35px rgba(255, 107, 107, 0.5);
    transform: scale(1.05);
}

.portrait-name {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 1em;
    font-weight: bold;
    text-align: center;
    white-space: nowrap; 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    max-width: 100%; 
}

.relationship-indicator {
    background: rgba(255, 107, 107, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    box-sizing: border-box;
    max-width: 100%; 
}

/* Dialogue Area - Center Column, takes remaining space */
dialogue-area {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* FIXED: Start from top instead of bottom */
    padding: 15px; /* FIXED: Reduced padding */
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    height: 100%;
    z-index: 5;
    max-height: 100%; /* FIXED: Don't exceed container */
}

/* Custom scrollbar (keep existing) */
.dialogue-area::-webkit-scrollbar {
    width: 6px;
}

.dialogue-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.dialogue-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Speech Bubbles (keep existing) */
.speech-bubble.dtr-bubble {
    background: white;
    border-radius: 20px;
    padding: 15px 20px; /* FIXED: Reduced padding */
    margin: 8px 0; /* FIXED: Reduced margin */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 85%; /* FIXED: Slightly wider */
    word-wrap: break-word;
    animation: bubbleSlideIn 0.4s ease-out;
    box-sizing: border-box;
    flex-shrink: 0; /* FIXED: Don't shrink bubbles */
}

@keyframes bubbleSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.speech-bubble.dtr-bubble.player {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.speech-bubble.dtr-bubble.character {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: #1f2937;
    align-self: flex-start;
    margin-right: auto;
}

/* Character-specific colors (keep existing) */
.speech-bubble.dtr-bubble.character.jessica {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
    border: 2px solid #9c27b0;
}

.speech-bubble.dtr-bubble.character.ava {
    background: linear-gradient(135deg, #fce7f3, #f8bbd9);
    border: 2px solid #e91e63;
}

/* Speech bubble tails (keep existing) */
.speech-bubble.dtr-bubble::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 12px solid transparent;
    top: 50%;
    transform: translateY(-50%);
}

.speech-bubble.dtr-bubble.player::before {
    right: -22px;
    border-left-color: #ff6b6b;
}

.speech-bubble.dtr-bubble.character::before {
    left: -22px;
    border-right-color: #f1f5f9;
}

.speech-bubble.dtr-bubble.character.jessica::before {
    border-right-color: #f3e5f5;
}

.speech-bubble.dtr-bubble.character.ava::before {
    border-right-color: #fce7f3;
}


/* Dialogue text (keep existing) */
.dialogue-text {
    font-size: 1.1em;
    line-height: 1.5;
    margin: 0;
}

/* DTR Choice Section (keep existing) */
.milestone-choices {
    background: rgba(0, 0, 0, 0.8);
    padding: 20px; /* FIXED: Reduced padding */
    border-top: 3px solid rgba(255, 107, 107, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px; /* FIXED: Reduced gap */
    flex-shrink: 0; /* FIXED: Don't shrink choice area */
    max-height: 30vh; /* FIXED: Limit choice area height */
    overflow-y: auto; /* FIXED: Scroll if too many choices */
}

.dtr-choice-header {
    text-align: center;
    margin-bottom: 15px;
}

.dtr-choice-header h3 {
    color: #ff6b6b;
    font-size: 1.4em;
    margin: 0 0 8px 0;
}

.dtr-choice-header p {
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-size: 1.1em;
}

/* Choice buttons (keep existing) */
.dtr-choice-button {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    border: none;
    padding: 12px 20px; /* FIXED: Reduced padding */
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95em; /* FIXED: Slightly smaller font */
    transition: all 0.3s ease;
    text-align: left;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-height: 50px; /* FIXED: Reduced min height */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dtr-choice-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}

.choice-text {
    font-size: 1.1em;
    line-height: 1.4;
    margin-bottom: 5px;
}

.choice-type-indicator {
    font-size: 0.85em;
    opacity: 0.8;
    font-weight: bold;
}

/* Choice type colors (keep existing) */
.dtr-choice-button.choice-type-official {
    background: linear-gradient(135deg, #10b981, #059669);
}

.dtr-choice-button.choice-type-reject {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.dtr-choice-button.choice-type-delay {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Background styles (keep existing and ensure paths are correct) */
.milestone-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    z-index: 1;
}

.bg-jessica_bedroom_intimate {
    background: 
        linear-gradient(135deg, rgba(220, 20, 60, 0.4), rgba(255, 69, 0, 0.3)),
        url('../assets/hangouts/backgrounds/bedroom.png'),
        linear-gradient(135deg, #DC143C, #FF4500);
}

.bg-ava_rooftop_evening {
    background: 
        linear-gradient(135deg, rgba(30, 144, 255, 0.4), rgba(0, 0, 139, 0.3)),
        url('../assets/hangouts/backgrounds/rooftop.png'),
        linear-gradient(135deg, #1E90FF, #00008B);
}

.bg-cheyenne_living_family {
    background: 
        linear-gradient(135deg, rgba(34, 139, 34, 0.4), rgba(0, 100, 0, 0.3)),
        url('../assets/hangouts/backgrounds/living_room.png'),
        linear-gradient(135deg, #228B22, #006400);
}

.bg-heather_art_studio {
    background: 
        linear-gradient(135deg, rgba(128, 0, 128, 0.4), rgba(75, 0, 130, 0.3)),
        url('../assets/hangouts/backgrounds/art_studio.png'),
        linear-gradient(135deg, #800080, #4B0082);
}

/* Responsive design */
@media (max-width: 1024px) {
    .milestone-content {
        grid-template-columns: 150px 1fr 150px; 
        gap: 10px; 
    }
    
    .character-portrait-dtr {
        width: 120px;
        height: 180px;
    }

    .portrait-name, .relationship-indicator {
        font-size: 0.9em;
        padding: 8px 12px;
    }
}

@media (max-width: 768px) {
    .milestone-content {
        grid-template-columns: 80px 1fr 80px; 
        gap: 10px;
        padding: 10px; 
    }
    
    .portrait-container {
        gap: 3px;
    }
    
    .character-portrait-dtr {
        width: 40px; 
        height: 60px; 
        border-width: 1px;
    }

    .portrait-name, .relationship-indicator {
        font-size: 0.55em; 
        padding: 1px 3px;
        white-space: normal;
        line-height: 1.2;
    }

     .dialogue-area {
        padding: 10px;
    }

    .milestone-header {
        padding: 10px;
    }

    .milestone-title {
        font-size: 1.3em;
    }

    .milestone-setting {
        font-size: 0.75em;
    }

    .speech-bubble.dtr-bubble {
        padding: 10px 15px;
        margin: 5px 0;
        font-size: 0.9em;
    }
}

/* Reduced motion support (keep existing) */
@media (prefers-reduced-motion: reduce) {
    .milestone-modal,
    .speech-bubble.dtr-bubble,
    .character-portrait-dtr {
        animation: none;
    }
    
    .dtr-choice-button:hover {
        transform: none;
    }
}