* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #1e1e1e;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 400px;
    height: 100%;
    max-height: 800px;
    background-color: #0f0f0f;
    position: relative;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.screen.active {
    display: flex;
}

.hidden {
    display: none !important;
}

/* Join Screen */
#join-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#join-screen h2 {
    margin-bottom: 20px;
}

#join-screen input {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: none;
    background-color: #2c2c2c;
    color: white;
    font-size: 16px;
}

#join-screen button {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: none;
    background-color: #8774e1;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

/* Chat Screen */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #1a1a1a;
    border-bottom: 1px solid #2c2c2c;
}

.room-info h2 {
    font-size: 18px;
    margin-bottom: 4px;
}

.room-info span {
    font-size: 14px;
    color: #aaaaaa;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #aaaaaa;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
}

#leave-btn {
    color: #ff5959;
}

main {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.video-grid {
    width: 100%;
    margin-bottom: 20px;
    background: black;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 200px;
}

.video-grid video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.participants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 20px;
    align-items: start;
}

.participant {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    cursor: pointer;
}

.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: #8774e1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
    position: relative;
    border: 3px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.participant.speaking .avatar {
    border-color: #4cd964;
    box-shadow: 0 0 15px rgba(76, 217, 100, 0.5);
}

.participant.muted .avatar::after {
    content: "🔇";
    position: absolute;
    bottom: -2px;
    right: -2px;
    background-color: #2c2c2c;
    border-radius: 50%;
    padding: 4px;
    font-size: 12px;
}

.participant.raised-hand .avatar::before {
    content: "✋";
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #2c2c2c;
    border-radius: 50%;
    padding: 4px;
    font-size: 12px;
    z-index: 2;
}

.participant.admin .name::after {
    content: "★";
    color: #ffcc00;
    margin-left: 4px;
    font-size: 10px;
}

.participant.sharing .avatar {
    border-radius: 16px; /* slightly square to indicate screen */
    border-color: #5ac8fa;
}


.name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: #2c2c2c;
    border-radius: 8px;
    padding: 8px 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    min-width: 120px;
    top: 70px;
}

.context-menu button {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}
.context-menu button:hover {
    background: #3a3a3a;
}
.context-menu button.danger {
    color: #ff5959;
}


footer {
    padding: 20px;
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    border-top: 1px solid #2c2c2c;
}

.controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #2c2c2c;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}
.control-btn.active {
    background-color: #8774e1;
}

.mic-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: #4cd964;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(76, 217, 100, 0.3);
    transition: background-color 0.2s, transform 0.1s;
}

.mic-btn:active {
    transform: scale(0.95);
}

.mic-btn.muted {
    background-color: #2c2c2c;
    box-shadow: none;
}

.mic-btn.disabled {
    background-color: #1a1a1a;
    color: #555;
    cursor: not-allowed;
    box-shadow: none;
}


/* Modal */
.modal {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    width: 80%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content h3 {
    margin-bottom: 10px;
}

.close-btn {
    padding: 10px;
    border: none;
    background: #3a3a3a;
    color: white;
    border-radius: 6px;
    cursor: pointer;
}

/* Reconnect Overlay */
.reconnect-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 15, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.reconnect-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.reconnect-content {
    text-align: center;
}

.reconnect-content .spinner {
    display: inline-block;
    font-size: 40px;
    margin-bottom: 15px;
    animation: spin 2s linear infinite;
}

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