@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
    --primary: #FF6B9D;
    --secondary: #C66EFD;
    --dark: #0F0F14;
    --darker: #08080B;
    --light: #FFFFFF;
    --gray: #6B6B7C;
    --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--darker);
    color: var(--light);
    height: 100vh;
    overflow: hidden;
}

.app-container { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--dark);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
}

.credits-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.credits-info { flex: 1; }
.credits-label {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 4px;
}
.credits-value {
    font-size: 18px;
    font-weight: 600;
}

.upgrade-btn {
    background: var(--gradient);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
.upgrade-btn:hover { transform: scale(1.05); }

.characters-section {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) rgba(255,255,255,0.05);
}

.section-title {
    font-size: 14px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.character-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.character-card:hover {
    background: rgba(255,255,255,0.05);
    transform: translateX(4px);
}

.character-card.active {
    background: rgba(255,107,157,0.1);
    border-color: var(--primary);
}

.character-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    position: relative;
}

.character-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.character-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #00D26A;
    border: 3px solid var(--dark);
    border-radius: 50%;
}

.character-info { flex: 1; }
.character-name {
    font-weight: 600;
    margin-bottom: 4px;
}
.character-traits {
    font-size: 12px;
    color: var(--gray);
}

/* Chat */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--darker);
    position: relative;
}

.game-button {
    position: absolute;
    top: 56px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--gray);
    padding: 0;
    cursor: pointer;
    font-size: 22px;
    display: none;
    transition: all 0.2s;
    z-index: 100;
}

.game-button:hover {
    transform: scale(1.2);
    filter: brightness(1.3);
}

.game-button::after {
    content: 'Play!';
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15,15,20,0.95);
    color: var(--light);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    border: 1px solid rgba(255,255,255,0.1);
}

.game-button:hover::after { opacity: 1; }

#chatMenuBtn {
    margin: 12px;
    background: rgba(15,15,20,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--gray);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
}

#chatMenuBtn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
}

#chatMenu {
    display: none;
    position: absolute;
    top: 50px;
    right: 12px;
    background: var(--dark);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 4px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
}

#chatMenu button {
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--light);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
}

#chatMenu button:hover { background: rgba(255,255,255,0.05); }

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) rgba(255,255,255,0.05);
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.3s ease;
}

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

.message.user { flex-direction: row-reverse; }

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

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

.message-content { max-width: 70%; }

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
}

.message.user .message-bubble { background: var(--gradient); }

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    color: var(--gray);
    margin-top: 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray);
    animation: typing 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-10px); opacity: 1; }
}

.input-container {
    padding: 20px;
    background: var(--dark);
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 4px;
}

.message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--light);
    padding: 12px 16px;
    font-size: 15px;
    outline: none;
}

.message-input::placeholder { color: var(--gray); }

.send-button {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--gradient);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-button:hover:not(:disabled) { transform: scale(1.05); }
.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--dark);
    border-radius: 20px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    border: 1px solid rgba(255,255,255,0.1);
}

.modal-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-modal {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--light);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
}

/* Welcome */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.welcome-icon { font-size: 64px; margin-bottom: 24px; }

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-text {
    color: var(--gray);
    font-size: 16px;
    max-width: 400px;
    line-height: 1.6;
}

/* Fix chat layout overflow bug */
#chatInterface {
    display: flex;
    flex: 1;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* Profile Navigation */
.profile-nav {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    text-decoration: none;
    color: var(--light);
    transition: all 0.2s;
    border: 2px solid transparent;
}

.profile-link:hover {
    background: rgba(255,107,157,0.1);
    border-color: var(--primary);
    transform: translateX(4px);
}

.profile-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.profile-text {
    flex: 1;
}

.profile-label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.profile-desc {
    font-size: 12px;
    color: var(--gray);
}

.profile-arrow {
    color: var(--gray);
    font-size: 18px;
    transition: transform 0.2s;
}

.profile-link:hover .profile-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

/* Menu separator */
.menu-separator {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 4px 8px;
}

/* Clickable logo */
.logo-link {
    text-decoration: none;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.logo-link:hover {
    transform: scale(1.02);
}

/* Sticky section header */
.sticky-header {
    position: sticky;
    top: 0;
    background: var(--dark);
    padding: 16px 0 8px 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 8px;
}
/* Logo clickable */
.logo-link {
    text-decoration: none;
    display: block;
}

.logo-link:hover .logo {
    opacity: 0.8;
    cursor: pointer;
}

/* Sticky section title */
.sticky-title {
    position: sticky;
    top: 0;
    background: var(--dark);
    z-index: 10;
    padding: 12px 0;
    margin: -12px 0 16px 0;
}

/* Sticky header for AI Companions */
.sticky-header {
    position: sticky;
    top: 0;
    background: var(--dark);
    z-index: 10;
    padding: 12px 0;
    margin: -12px 0 16px 0;
}
/* Sticky section title - stays visible when scrolling */
.section-title-sticky {
    position: sticky;
    top: 0;
    background: var(--dark);
    z-index: 10;
    padding-top: 0;
    padding-bottom: 4px;
}
