/* CSS Variables */
:root {
    --primary-color: #4a90d9;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --background-dark: #1a1a2e;
    --background-medium: #16213e;
    --background-light: #0f3460;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --message-received: #2d2d44;
    --message-sent: #4a90d9;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Game Container */
#game-container {
    width: 100%;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
}

/* Title Screen */
#title-screen {
    background: linear-gradient(135deg, var(--background-dark) 0%, var(--background-medium) 50%, var(--background-light) 100%);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#title-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('assets/scenes/title_bg.jpg') center/cover no-repeat;
    opacity: 0.3;
    z-index: 0;
}

.title-content {
    text-align: center;
    z-index: 1;
    padding: 40px;
    animation: fadeInUp 1s ease-out;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(74, 144, 217, 0.5);
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Buttons */
.main-button, .secondary-button {
    display: block;
    width: 200px;
    margin: 10px auto;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.main-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, #357abd 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 144, 217, 0.4);
}

.main-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 217, 0.6);
}

.secondary-button {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--text-secondary);
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.icon-button {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background var(--transition-speed);
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Game Screen */
#game-screen {
    flex-direction: column;
    background: var(--background-dark);
}

/* Media Container */
#media-container {
    position: relative;
    width: 100%;
    height: 45%;
    min-height: 200px;
    background: #000;
    overflow: hidden;
}

.media-element {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.media-element.active {
    opacity: 1;
}

#media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(transparent, var(--background-dark));
    pointer-events: none;
}

/* Chat Container */
#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-dark);
    min-height: 0;
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--background-medium);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#scene-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#header-buttons {
    display: flex;
    gap: 5px;
}

/* Chat Messages */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
    opacity: 0;
    transform: translateY(20px);
}

.message.visible {
    opacity: 1;
    transform: translateY(0);
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.narrator {
    align-self: center;
    max-width: 90%;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--background-light);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.message.sent .message-sender {
    text-align: right;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
}

.message.received .message-bubble {
    background: var(--message-received);
    border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
    background: var(--message-sent);
    border-bottom-right-radius: 4px;
}

.message.narrator .message-bubble {
    background: transparent;
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 8px 16px;
}

/* Phone Message Style */
.message.phone-message .message-bubble {
    background: var(--background-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.message.phone-message.sent .message-bubble {
    background: #075e54;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--message-received);
    border-radius: 18px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Choices Container */
#choices-container {
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--background-medium);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 40%;
    overflow-y: auto;
}

#choices-container.hidden {
    display: none;
}

.choice-button {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--background-light) 0%, var(--secondary-color) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    position: relative;
    overflow: hidden;
}

.choice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.choice-button:hover {
    transform: translateX(5px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(74, 144, 217, 0.3);
}

.choice-button:hover::before {
    left: 100%;
}

.choice-button:active {
    transform: scale(0.98);
}

/* Continue Indicator */
#continue-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--background-medium);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    animation: pulse 2s infinite;
}

#continue-indicator.hidden {
    display: none;
}

.arrow {
    animation: bounce 1s infinite;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--background-medium);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-primary);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-item label {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.setting-item input[type="range"] {
    width: 120px;
    accent-color: var(--primary-color);
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

/* Save Slots */
#save-slots {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.save-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--background-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.save-slot:hover {
    background: var(--secondary-color);
}

.save-slot-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.save-slot-title {
    font-weight: 600;
    color: var(--text-primary);
}

.save-slot-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.save-slot-empty {
    color: var(--text-secondary);
    font-style: italic;
}

.save-slot-actions {
    display: flex;
    gap: 5px;
}

/* Notification Toast */
#notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

#notification.hidden {
    display: none;
}

#notification.error {
    background: var(--error-color);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Scrollbar Styling */
#chat-messages::-webkit-scrollbar,
#choices-container::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track,
#choices-container::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb,
#choices-container::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: var(--background-light);
    border-radius: 3px;
}

/* Responsive Design */
@media (min-width: 768px) {
    #game-container {
        max-width: 100%;
    }

    .game-title {
        font-size: 5rem;
    }

    .game-subtitle {
        font-size: 1.5rem;
    }

    #media-container {
        height: 55%;
    }

    #chat-messages {
        padding: 30px 15%;
    }

    #choices-container {
        padding: 20px 15%;
    }

    .message {
        max-width: 60%;
    }

    .message-bubble {
        font-size: 1.1rem;
    }

    .choice-button {
        padding: 18px 24px;
        font-size: 1.1rem;
    }

    #chat-header {
        padding: 15px 30px;
    }

    .main-button, .secondary-button {
        width: 250px;
        padding: 18px 36px;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2.5rem;
    }

    .game-subtitle {
        font-size: 1rem;
    }

    .main-button, .secondary-button {
        width: 180px;
        padding: 12px 24px;
        font-size: 0.9rem;
    }

    #chat-messages {
        padding: 15px;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .choice-button {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Landscape Mode */
@media (max-height: 500px) and (orientation: landscape) {
    #media-container {
        height: 35%;
        min-height: 150px;
    }

    #chat-header {
        padding: 8px 15px;
    }

    #chat-messages {
        padding: 10px 15px;
    }

    #choices-container {
        padding: 10px 15px;
    }
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Cutscene Overlay */
#cutscene-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cutscene-video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
}

.cutscene-skip-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
    z-index: 10000;
}

.cutscene-skip-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

@media (max-width: 600px) {
    .cutscene-skip-btn {
        bottom: 20px;
        right: 20px;
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}
