* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #F8C000, #F8C000);
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

.container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.page {
    display: none;
    width: 100%;
    max-width: 500px;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.active {
    display: flex;
}

h1 {
    font-size: 28px;
    margin-bottom: 30px;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.logo {
    font-size: 42px;
    margin-bottom: 25px;
    color: #ffffff;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 5px #ffffff; }
    to { text-shadow: 0 0 20px #ffffff, 0 0 30px #ffffff; }
}

.username-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.username-input {
    width: 80%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid #333;
    border-radius: 30px;
    font-size: 16px;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.username-input:focus {
    outline: none;
    border-color: #ffffff;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
}

.btn {
    padding: 16px 32px;
    background: transparent;
    color: #fff;
    border: 2px solid #ffffff;
    border-radius: 30px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn:hover {
    background: rgba(76, 175, 80, 0.1);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
    transform: translateY(-2px);
}

.donation-btn {
    background: linear-gradient(135deg, #ff4081, #e91e63);
    border: none;
    color: white;
    margin-top: 25px;
    width: 100%;
    justify-content: center;
}

.donation-btn:hover {
    background: linear-gradient(135deg, #e91e63, #c2185b);
    box-shadow: 0 0 20px rgba(233, 30, 99, 0.4);
}

.click-btn {
    background: linear-gradient(135deg, #ffffff, #ffffff);
    border: none;
    color: white;
    padding: 16px 32px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 25px;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.click-btn:hover {
    background: linear-gradient(135deg, #ffffff, #ffffff);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
    transform: translateY(-2px);
}

.click-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

.click-btn i {
    font-size: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.active-count {
    background: linear-gradient(135deg, #4CAF50, #4CAF50);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

/* Chat page styles - IMPROVED LAYOUT */
.chat-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 500px;
    background: rgba(26, 26, 46, 0.95);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(10, 10, 20, 0.9);
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    min-height: 70px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(76, 175, 80, 0.1);
    font-size: 18px;
}

.online-dot {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    margin-left: 8px;
    animation: pulse 1.5s infinite;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
    padding-bottom: 80px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
}

.message {
    padding: 12px 18px;
    border-radius: 18px;
    margin-bottom: 5px;
    max-width: 80%;
    word-break: break-word;
    position: relative;
    transition: all 0.3s ease;
    animation: messageSlide 0.3s ease;
}

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

.message.received {
    background: linear-gradient(135deg, #2c2c2c, #3a3a3a);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message.sent {
    background: linear-gradient(135deg, #2b5329, #3a7638);
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.system-message {
    background: rgba(76, 175, 80, 0.1);
    color: #aaa;
    padding: 10px 15px;
    border-radius: 10px;
    text-align: center;
    font-style: italic;
    margin: 8px 0;
    align-self: center;
    max-width: 90%;
    font-size: 14px;
}

.system-message.error {
    background: rgba(255, 68, 68, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(255, 68, 68, 0.3);
}

.message.highlight {
    animation: highlight 3s ease;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

@keyframes highlight {
    0%, 100% { background-color: inherit; }
    50% { background-color: rgba(76, 175, 80, 0.3); }
}

.message-username {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 5px;
    color: #ffffff;
}

.message-time {
    font-size: 11px;
    color: #888;
    margin-top: 3px;
    text-align: right;
}

.reply-reference {
    font-size: 12px;
    color: #ffffff;
    margin-bottom: 5px;
    font-style: italic;
}

/* IMPROVED CHAT INPUT AREA - FIXED POSITION */
.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
    background: rgba(10, 10, 20, 0.95);
    border-top: 1px solid #333;
    min-height: 65px;
    z-index: 100;
    max-width: 500px;
    margin: 0 auto;
}

.input-container {
    display: flex;
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    padding: 8px 16px;
    align-items: center;
    min-height: 44px;
    max-height: 120px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    resize: none;
    padding: 8px 0;
    max-height: 104px;
    min-height: 24px;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
}

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

.leave-btn {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.leave-btn:hover {
    background: rgba(255, 68, 68, 0.2);
}

.send-btn {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.send-btn:hover {
    background: rgba(76, 175, 80, 0.2);
}

.send-btn:disabled {
    color: rgba(76, 175, 80, 0.5);
    background: rgba(76, 175, 80, 0.05);
    cursor: not-allowed;
}

.disconnected-state {
    text-align: center;
    padding: 30px;
    background: rgba(26, 26, 46, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
}

.disconnected-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

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

.waiting-text {
    margin-bottom: 30px;
    color: #fff;
}

.loader {
    border: 4px solid #333;
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 25px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.waiting-progress {
    width: 80%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    margin: 25px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffffff, #ffffff);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    font-size: 12px;
    color: #888;
}

.waiting-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.dot {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.3;
    animation: dotPulse 1.5s infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.3s; }
.dot:nth-child(3) { animation-delay: 0.6s; }

@keyframes dotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.waiting-status {
    margin-top: 15px;
    font-size: 14px;
    color: #aaa;
}

.waiting-status small {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #4CAF50;
}

/* Reply Indicator */
.reply-indicator {
    background: rgba(28, 28, 28, 0.9);
    padding: 12px 15px;
    border-left: 4px solid #ffffff;
    margin: 0 15px 10px 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.reply-content {
    flex: 1;
    min-width: 0;
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.reply-label {
    font-size: 11px;
    color: #888;
}

.reply-username {
    font-size: 11px;
    font-weight: bold;
    color: #ffffff;
}

.reply-text {
    font-size: 13px;
    color: #ccc;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reply-close {
    cursor: pointer;
    color: #ff4444;
    padding: 6px;
    margin-left: 10px;
    border-radius: 50%;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.reply-close:hover {
    background: rgba(255, 68, 68, 0.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    margin: 10% auto;
    padding: 30px;
    border: 2px solid #ffffff;
    border-radius: 20px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.close {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #fff;
}

.qr-code-container {
    margin: 25px 0;
    padding: 20px;
    background: #fff;
    border-radius: 15px;
    display: inline-block;
    position: relative;
}

.qr-code {
    width: 200px;
    height: 200px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.qr-placeholder {
    width: 200px;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    border-radius: 10px;
    color: #666;
}

.qr-placeholder i {
    font-size: 48px;
    margin-bottom: 10px;
}

.donation-note {
    font-size: 14px;
    color: #4CAF50;
    margin-top: 20px;
}

.connection-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px;
    text-align: center;
    font-weight: bold;
    z-index: 2000;
    display: none;
    backdrop-filter: blur(10px);
}

.connection-status.offline {
    background: linear-gradient(135deg, #ff4444, #cc0000);
    display: block;
}

.connection-status.online {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    display: block;
}

/* Typing Indicator */
.typing-indicator {
    background: rgba(40, 40, 40, 0.8);
    color: #aaa;
    padding: 10px 15px;
    border-radius: 18px;
    align-self: flex-start;
    margin: 5px 0;
    display: none;
    font-style: italic;
    animation: fadeIn 0.3s ease;
}

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

.typing-dots {
    display: inline-flex;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #ffffff;
    border-radius: 50%;
    margin: 0 2px;
    opacity: 0.6;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

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

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Menu Button Styles */
.menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-content {
    display: none;
    position: absolute;
    right: 15px;
    top: 50px;
    background: rgba(26, 26, 46, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 100;
    min-width: 150px;
    overflow: hidden;
}

.menu-content a {
    display: block;
    padding: 12px 15px;
    color: #fff;
    text-decoration: none;
    text-align: left;
    transition: background 0.3s ease;
}

.menu-content a:hover {
    background: rgba(76, 175, 80, 0.1);
}

.menu-container:hover .menu-content {
    display: block;
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    .username-input {
        width: 90%;
        padding: 14px 18px;
    }
    
    .btn {
        padding: 14px 28px;
        font-size: 15px;
    }
    
    .click-btn {
        padding: 14px 25px;
        font-size: 16px;
    }
    
    .chat-container {
        border-radius: 15px;
    }
    
    .chat-input-area {
        padding: 10px 15px;
        min-height: 65px;
    }
    
    .input-container {
        padding: 6px 14px;
    }
    
    .icon-btn {
        padding: 10px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .modal-content {
        margin: 20% auto;
        padding: 25px;
        width: 95%;
    }
    
    .qr-code-container {
        padding: 15px;
    }
    
    .qr-code, .qr-placeholder {
        width: 150px;
        height: 150px;
    }
    
    .reply-indicator {
        margin: 0 10px 8px 10px;
        padding: 10px 12px;
    }
    
    .disconnected-state {
        padding: 20px;
    }
    
    .disconnected-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .donation-btn {
        margin-top: 20px;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #ffffff;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #ffffff;
}

/* System message at the bottom */
.system-message-bottom {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(76, 175, 80, 0.1);
    color: #aaa;
    padding: 10px 20px;
    border-radius: 20px;
    font-style: italic;
    z-index: 100;
    max-width: 80%;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(76, 175, 80, 0.2);
    animation: slideUp 0.3s ease;
}

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