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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Username Page Styles */
#username-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    position: relative;
}

#username-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 30%, rgba(74, 144, 226, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(168, 85, 247, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.username-page-container {
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #4a90e2 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: 20px;
}

.form-control {
    width: 100%;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #ffffff;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.form-control:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

select.form-control option {
    background: #2d2d2d;
    color: #ffffff;
}

.username-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #4a90e2 0%, #a855f7 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.username-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(74, 144, 226, 0.4);
}

.username-submit:active {
    transform: translateY(0);
}

/* Chat Page Styles */
#chat-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

.chat-container {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    height: 600px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.chat-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.chat-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.connecting {
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

#messageArea {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

#messageArea::-webkit-scrollbar {
    width: 6px;
}

#messageArea::-webkit-scrollbar-track {
    background: transparent;
}

#messageArea::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#messageArea::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

#messageArea li {
    margin-bottom: 15px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border-left: 3px solid #4a90e2;
    animation: messageSlideIn 0.3s ease;
}

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

#typing-indicator {
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#typing-indicator p {
    margin: 0;
}

#typing-username {
    color: #4a90e2;
    font-weight: 500;
}

/* Message Form */
#messageForm {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

#message {
    flex: 1;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #ffffff;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    resize: none;
}

#message:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

#message::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.primary {
    padding: 16px 24px;
    background: linear-gradient(135deg, #4a90e2 0%, #a855f7 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

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

.primary:active {
    transform: translateY(0);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* Responsive Design */
@media (max-width: 768px) {
    .username-page-container {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .chat-container {
        height: calc(100vh - 40px);
        margin: 20px;
        border-radius: 15px;
    }
    
    .title {
        font-size: 20px;
    }
    
    .form-control, .primary, .username-submit {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .input-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .primary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .username-page-container {
        padding: 25px 15px;
    }
    
    .chat-container {
        margin: 10px;
        height: calc(100vh - 20px);
    }
    
    .title {
        font-size: 18px;
        margin-bottom: 25px;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    #messageArea {
        padding: 15px;
    }
    
    #messageForm {
        padding: 15px;
    }
}

/* Additional animations and effects */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.username-page-container,
.chat-container {
    animation: fadeIn 0.6s ease;
}

/* Focus states for accessibility */
.form-control:focus,
.primary:focus,
.username-submit:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Smooth transitions */
* {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}