@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-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-bg: #0a0e14;
    --card-bg: #151921;
    --border-color: #1e2328;
    --text-primary: #ffffff;
    --text-secondary: #8b949e;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height */
    position: relative;
}

/* Animated background */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.background-animation::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 200, 255, 0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    33% { transform: translate(-50%, -50%) rotate(120deg); }
    66% { transform: translate(-50%, -50%) rotate(240deg); }
}

/* Welcome Screen */
#welcome-screen {
    display: none; /* Hidden by default to prevent flash */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    padding: 1rem;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#welcome-screen.show {
    display: flex;
    opacity: 1;
}

.welcome-container {
    text-align: center;
    max-width: 420px;
    width: 100%;
    max-height: 100vh;
    overflow: hidden;
    animation: slideInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    animation: none !important;
}

.app-logo {
    margin-bottom: 2rem;
    animation: logoFloat 3s ease-in-out infinite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-image {
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.15));
    transition: all 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.02);
    filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.2));
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.app-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-weight: 400;
    text-align: center;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.4;
}

.room-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 1.5rem;
    backdrop-filter: blur(20px);
    box-shadow: 
        0 32px 64px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.room-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--primary-gradient);
    opacity: 0.5;
}

.room-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


.room-id-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    position: relative;
}

.room-id {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 1.4rem;
    color: var(--text-primary);
    background: var(--dark-bg);
    padding: 1.2rem 0.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    font-weight: 500;
    position: relative;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
    min-height: 3.2rem;
    line-height: 1.2;
    word-break: break-all;
}

.room-id[contenteditable="true"] {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: var(--card-bg);
    cursor: text;
    white-space: nowrap;
    display: block;
    padding: 1.2rem 0.5rem;
    line-height: 1.2;
    min-height: auto;
}

.room-id[contenteditable="true"]:empty:before {
    content: "Enter your Room ID";
    color: var(--text-secondary);
    font-style: italic;
    pointer-events: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.room-id.manual-entry-active[contenteditable="true"]:empty:before {
    animation: placeholderPulse 2s ease-in-out infinite;
}

@keyframes placeholderPulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* When not in edit mode, use flexbox for centering */
.room-id:not([contenteditable="true"]) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.room-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.control-button {
    background: #2a2f38;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 44px;
    height: 44px;
}

.control-button:hover {
    background: #3a3f48;
    color: var(--text-primary);
    transform: translateY(-1px);
}

.control-button:active {
    transform: translateY(0);
}




.room-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-top: 1.5rem;
}

.start-chat-button {
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3);
    width: 100%;
    font-size: 1rem;
}

.start-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.start-chat-button:active {
    transform: translateY(0);
}

/* Messaging Interface */
#message-container {
    display: none;
    height: 100vh;
    width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#message-container.show {
    display: block;
    opacity: 1;
}
.message-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--card-bg);
    border-radius: 0;
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    .message-wrapper {
        max-width: 90%;
        margin: 1rem auto;
        border-radius: 24px;
        box-shadow: 0 32px 64px rgba(0, 0, 0, 0.4);
        height: calc(100vh - 2rem);
    }
}

.header {
    background: var(--primary-gradient);
    color: white;
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 10;
    min-height: 60px;
}

.header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.header-center {
    display: flex;
    justify-content: center;
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-end;
}

.room-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

.current-time {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 500;
}

.connection-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--error-color); /* Default to red (disconnected) */
    transition: background-color 0.3s ease;
    animation: pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

.connection-status.connecting {
    background: var(--warning-color); /* Yellow for connecting */
}

.connection-status.connected {
    background: var(--success-color); /* Green for connected */
    animation: none; /* Stop pulsing when connected */
}

.header-button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

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

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column-reverse;
    background: var(--dark-bg);
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* Reduced gap */
}

.message {
    max-width: 80%; /* Slightly wider */
    padding: 0.5rem 0.85rem; /* Reduced padding */
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    font-size: 0.85rem; /* Reduced font size */
    line-height: 1.4;
    animation: messageSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.message.sent {
    background: var(--primary-gradient);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.message.received {
    background: var(--card-bg);
    color: var(--text-primary);
    align-self: flex-start;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.message-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.5rem;
}

.message-text {
    flex: 1;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    white-space: nowrap;
    font-weight: 500;
}

.input-container {
    padding: 0.5rem; /* Reduced padding */
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem; /* Reduced gap */
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 0.85rem 1.2rem;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
    background: var(--dark-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

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

.message-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px; /* Slightly smaller */
    height: 44px; /* Slightly smaller */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3);
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 28px rgba(102, 126, 234, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Responsive */
@media (max-width: 768px) {
    #welcome-screen {
        padding: 1rem;
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    .welcome-container {
        max-width: 100%;
        width: 100%;
        min-height: auto;
    }
    
    .logo-image {
        max-width: 160px;
        max-height: 160px;
    }
    
    .room-card {
        padding: 1.5rem 1rem;
    }
    
    .room-actions {
        gap: 1.5rem;
    }
    
    /* Enhanced Chat Window Responsive Styles */
    #message-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
    
    .message-wrapper {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        height: 100dvh;
    }
    
    .header {
        padding: 0.75rem 1rem;
        min-height: 64px;
    }
    
    .header-left, .header-right {
        flex: 0.8;
        min-width: 0; /* Allow flex items to shrink */
    }
    
    .header-center {
        flex: 1.4;
        min-width: 0;
    }
    
    .room-title {
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .current-time {
        font-size: 0.75rem;
    }
    
    .connection-status {
        width: 10px;
        height: 10px;
    }
    
    .header-button {
        padding: 0.4rem;
        min-width: 36px;
        min-height: 36px;
    }
    
    .messages-area {
        padding: 0.75rem;
    }
    
    .message {
        max-width: 85%;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        border-radius: 16px;
    }
    
    .message.sent {
        border-bottom-right-radius: 4px;
    }
    
    .message.received {
        border-bottom-left-radius: 4px;
    }
    
    .message-time {
        font-size: 0.7rem;
    }
    
    .input-container {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .message-input {
        padding: 0.9rem 1.2rem;
        font-size: 1rem;
        border-radius: 24px;
    }
    
    .send-button {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }
}

@media (max-width: 600px) {
    .logo-image {
        max-width: 140px;
        max-height: 140px;
    }

    .app-logo {
        margin-bottom: 1.5rem;
    }

    .app-subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .room-card {
        padding: 1rem;
        border-radius: 20px;
    }

    .room-label {
        margin-bottom: 0.5rem;
    }

    .room-id {
        font-size: 1.2rem;
        padding: 0.9rem 0.5rem;
    }

    #welcome-screen {
        padding: 1rem 0.5rem;
    }
    
    .welcome-container {
        max-width: 100%;
    }
    
    /* Enhanced Chat Window Styles for Small Screens */
    .header {
        padding: 0.5rem 0.75rem;
        min-height: 56px;
    }
    
    .header-left {
        gap: 0.5rem;
    }
    
    .current-time {
        font-size: 0.7rem;
    }
    
    .room-title {
        font-size: 0.85rem;
    }
    
    .header-button {
        padding: 0.35rem;
        min-width: 32px;
        min-height: 32px;
    }
    
    .header-button svg {
        width: 14px;
        height: 14px;
    }
    
    .messages-area {
        padding: 0.5rem;
    }

    .message-list {
        gap: 0.25rem;
    }

    .message {
        max-width: 90%;
        padding: 0.5rem 0.9rem;
        font-size: 0.85rem;
        border-radius: 14px;
    }
    
    .message.sent {
        border-bottom-right-radius: 3px;
    }
    
    .message.received {
        border-bottom-left-radius: 3px;
    }
    
    .message-time {
        font-size: 0.65rem;
    }

    .input-container {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .message-input {
        padding: 0.8rem 1.1rem;
        font-size: 0.95rem;
        border-radius: 22px;
    }

    .send-button {
        width: 44px;
        height: 44px;
    }
    
    .send-button svg {
        width: 18px;
        height: 18px;
    }
    
    .modal {
        padding: 0.75rem;
        align-items: flex-start;
        padding-top: 15vh;
    }
    
    .modal-content {
        padding: 1.5rem;
        width: 100%;
        max-width: 95%;
        border-radius: 20px;
        max-height: calc(100vh - 3rem);
    }
    
    .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }
    
    .modal-content p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .modal-buttons {
        gap: 0.75rem;
        flex-direction: row;
        justify-content: center;
    }
    
    .modal-button {
        flex: 1;
        max-width: 140px;
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .welcome-container {
        padding: 1rem;
    }
    
    .logo-image {
        max-width: 120px;
        max-height: 120px;
    }
    
    .control-button {
        min-width: 40px;
        height: 40px;
        padding: 0.5rem;
    }
    
    .room-controls {
        gap: 0.25rem;
    }
    
    /* Very Small Screen Chat Optimizations */
    .header {
        padding: 0.4rem 0.5rem;
        min-height: 52px;
    }
    
    .header-left {
        gap: 0.4rem;
    }
    
    .connection-status {
        width: 8px;
        height: 8px;
    }
    
    .current-time {
        font-size: 0.65rem;
    }
    
    .room-title {
        font-size: 0.8rem;
    }
    
    .header-button {
        padding: 0.3rem;
        min-width: 28px;
        min-height: 28px;
    }
    
    .header-button svg {
        width: 12px;
        height: 12px;
    }
    
    .messages-area {
        padding: 0.4rem;
    }
    
    .message {
        max-width: 92%;
        padding: 0.45rem 0.8rem;
        font-size: 0.8rem;
        border-radius: 12px;
    }
    
    .message-time {
        font-size: 0.6rem;
    }
    
    .input-container {
        padding: 0.4rem 0.5rem;
        gap: 0.4rem;
    }
    
    .message-input {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
        border-radius: 20px;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
    }
    
    .send-button svg {
        width: 16px;
        height: 16px;
    }
}

/* Mobile landscape optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    #welcome-screen {
        padding: 0.5rem;
        align-items: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .welcome-container {
        margin-top: 1rem;
        margin-bottom: 1rem;
        max-height: none;
        overflow: visible;
    }
    
    .app-logo {
        margin-bottom: 0.5rem;
    }
    
    .logo-image {
        max-width: 100px;
        max-height: 100px;
    }
    
    .app-logo {
        margin-bottom: 1rem;
    }
    
    .app-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .room-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .room-label {
        margin-bottom: 0.5rem;
    }
    
    .room-id {
        font-size: 1.1rem;
        padding: 0.8rem 0.5rem;
    }
    
    .room-actions {
        margin-top: 1rem;
    }
    
    body {
        overflow: auto;
    }
    
    /* Chat Window Landscape Optimizations */
    #message-container {
        height: 100vh;
        height: 100dvh;
    }
    
    .message-wrapper {
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        margin: 0;
        max-width: 100%;
    }
    
    .header {
        padding: 0.4rem 0.75rem;
        min-height: 48px;
    }
    
    .header-left {
        gap: 0.5rem;
    }
    
    .current-time {
        font-size: 0.7rem;
    }
    
    .room-title {
        font-size: 0.85rem;
    }
    
    .header-button {
        padding: 0.3rem;
        min-width: 32px;
        min-height: 32px;
    }
    
    .messages-area {
        padding: 0.5rem 0.75rem;
    }
    
    .message {
        max-width: 80%;
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .input-container {
        padding: 0.5rem 0.75rem;
    }
    
    .message-input {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }
    
    .send-button {
        width: 42px;
        height: 42px;
    }
}

/* Very small screens in landscape */
@media (max-height: 400px) and (orientation: landscape) {
    .logo-image {
        max-width: 80px;
        max-height: 80px;
    }
    
    .app-subtitle {
        font-size: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .app-logo {
        margin-bottom: 0.75rem;
    }
    
    .room-card {
        padding: 0.75rem;
    }
    
    .room-id {
        font-size: 1rem;
        padding: 0.6rem 0.5rem;
    }
    
    .control-button {
        min-width: 36px;
        height: 36px;
    }
    
    .start-chat-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Enhanced Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 
        0 32px 64px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-button {
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

.modal-button.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3);
}

.modal-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.modal-button.secondary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3);
}

.modal-button.secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

/* Legacy support for existing modal buttons */
.modal-button:not(.primary):not(.secondary) {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3);
}

.modal-button:not(.primary):not(.secondary):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

/* Enhanced button focus states for accessibility */
.modal-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.modal-button.primary:focus {
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3), 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.modal-button.secondary:focus {
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.3), 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Enhanced modal close button */
.modal-close:focus {
    outline: none;
    background: var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.qr-modal-content {
    max-width: 350px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.qr-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#qr-modal-code {
    background: white;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}



/* Enhanced Modal Animations */
@keyframes modalFadeIn {
    from { 
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to { 
        opacity: 1;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced modal content animation */
.modal-content {
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.show .modal-content {
    transform: translateY(0);
}

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

/* Enhanced Safe area support */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    
    .input-container {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    .messages-area {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
    
    #welcome-screen {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    /* Enhanced mobile safe areas */
    @media (max-width: 768px) {
        .header {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
        
        .input-container {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        }
        
        .messages-area {
            padding-left: max(0.75rem, env(safe-area-inset-left));
            padding-right: max(0.75rem, env(safe-area-inset-right));
        }
    }
}

/* Improved scrolling for mobile */
@media (max-width: 768px) {
    #welcome-screen {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    .welcome-container {
        will-change: transform;
    }
    
    /* Enhanced chat scrolling */
    .messages-area {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
    }
    
    .message-wrapper {
        will-change: transform;
    }
    
    /* Prevent zoom on input focus */
    .message-input {
        font-size: max(16px, 1rem); /* Prevents zoom on iOS */
    }
}

/* Fix for iOS viewport issues */
@supports (-webkit-touch-callout: none) {
    #welcome-screen {
        min-height: -webkit-fill-available;
    }
    
    #message-container {
        height: -webkit-fill-available;
    }
    
    .message-wrapper {
        height: -webkit-fill-available;
    }
    
    /* iOS specific chat optimizations */
    .messages-area {
        -webkit-overflow-scrolling: touch;
    }
    
    .message-input {
        -webkit-appearance: none;
        border-radius: 24px; /* Ensures consistent border radius on iOS */
    }
}



