* {
    box-sizing: border-box;
}

body {
    background-color: #121826;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.hidden {
    display: none !important;
}

/* Index page */
body.page-index {
    justify-content: center;
    padding: 20px;
}

body.page-index h1 {
    margin-bottom: 20px;
    font-size: 22px;
    text-align: center;
}

.menu-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 650px;
}

@media (max-width: 768px) {
    .menu-container {
        grid-template-columns: 1fr;
    }
}

.menu-box {
    background-color: #1e293b;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.menu-btn {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: none;
    background-color: #3b82f6;
    color: #ffffff;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    text-decoration: none;
    text-align: center;
    display: block;
}

.menu-btn:hover {
    background-color: #2563eb;
}

.menu-btn.btn-indigo {
    background-color: #6366f1;
}

.menu-btn.btn-indigo:hover {
    background-color: #4f46e5;
}

.menu-btn.btn-purple {
    background-color: #8b5cf6;
}

.menu-btn.btn-purple:hover {
    background-color: #7c3aed;
}

.room-join-form {
    display: flex;
    gap: 5px;
    width: 100%;
}

.room-input {
    flex: 1;
    padding: 12px;
    border-radius: 6px;
    border: none;
    background-color: #334155;
    color: #ffffff;
    outline: none;
    font-size: 14px;
}

.join-btn {
    padding: 12px 16px;
    border-radius: 6px;
    border: none;
    background-color: #10b981;
    color: #ffffff;
    cursor: pointer;
    font-weight: bold;
}

.join-btn:hover {
    background-color: #059669;
}

/* Shared headers & navigation */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 500px;
    margin-top: 20px;
    gap: 8px;
}

.header.header-wide {
    max-width: 800px;
}

.header.header-room {
    width: 95%;
    max-width: 1200px;
    height: 50px;
    margin-top: 5px;
    flex-shrink: 0;
}

.header-spacer {
    width: 50px;
}

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

.back-btn,
.action-btn {
    background: none;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 5px;
    color: #3b82f6;
    text-decoration: none;
}

.back-btn {
    font-size: 16px;
}

.btn-blue {
    color: #3b82f6;
}

.btn-orange {
    color: #f59e0b;
}

.btn-red {
    color: #ef4444;
}

.btn-green {
    color: #10b981;
}

.action-btn:disabled,
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status {
    color: #f59e0b;
    font-size: 14px;
    margin-bottom: 10px;
    min-height: 20px;
    font-weight: bold;
    text-align: center;
}

.status.connected {
    color: #10b981;
}

.room-info {
    font-size: 14px;
    color: #f59e0b;
    font-weight: bold;
    flex: 1;
    text-align: center;
}

/* Chat containers */
.chat-container {
    width: 90%;
    max-width: 500px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    height: 75vh;
    position: relative;
}

.chat-container.chat-random {
    height: 70vh;
    margin-top: 0;
}

#chat-box {
    flex: 1;
    background-color: #1e293b;
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
    margin-bottom: 8px;
    border: 2px dashed transparent;
    transition: border-color 0.2s;
}

#chat-box.dragover,
.room-chat-container.dragover {
    border-color: #3b82f6;
    background-color: #1e293b88;
}

.message {
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-word;
    font-size: 14px;
}

.message.msg-self {
    color: #93c5fd;
}

.message.system {
    color: #94a3b8;
    font-size: 0.9em;
    text-align: center;
    margin: 12px 0;
}

.message.system.msg-host {
    color: #ef4444;
}

#typing-indicator {
    color: #94a3b8;
    font-size: 12px;
    height: 16px;
    margin-bottom: 5px;
    font-style: italic;
}

.form-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.form-container input[type="text"] {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background-color: #334155;
    color: #ffffff;
    outline: none;
    font-size: 14px;
}

.file-upload-label {
    background-color: #4b5563;
    color: #ffffff;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    flex-shrink: 0;
}

.file-upload-label:hover {
    background-color: #6b7280;
}

#img-input {
    display: none;
}

button[type="submit"] {
    padding: 12px 18px;
    border-radius: 8px;
    border: none;
    background-color: #3b82f6;
    color: #ffffff;
    cursor: pointer;
    font-weight: bold;
    flex-shrink: 0;
}

/* Safe blurred image preview */
.chat-img-wrapper {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 5px;
}

.chat-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    display: block;
    transition: filter 0.2s ease;
}

.chat-img.blurred {
    filter: blur(18px);
    cursor: pointer;
}

.img-blur-hint {
    font-size: 11px;
    color: #94a3b8;
    cursor: pointer;
}

/* Video layouts */
.video-container {
    width: 90%;
    max-width: 800px;
    display: flex;
    gap: 10px;
    justify-content: center;
    position: relative;
}

.video-container video {
    width: 48%;
    aspect-ratio: 3 / 4;
    background-color: #1e293b;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.2s;
}

#video-grid.group-grid {
    width: 90%;
    max-width: 800px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    position: relative;
}

#video-grid.group-grid video {
    width: 100%;
    aspect-ratio: 4 / 3;
    background-color: #1e293b;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.2s;
}

.fullscreen-video {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 50;
    margin: 0 !important;
}

.mirrored {
    transform: scaleX(-1);
}

.controls {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

button.control-btn {
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    background-color: #3b82f6;
    color: #ffffff;
    cursor: pointer;
    font-weight: bold;
}

button.toggle-btn {
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    background-color: #4b5563;
    color: #ffffff;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
}

button.toggle-btn.off {
    background-color: #ef4444;
}

/* Custom Room layout */
.main-container {
    width: 95%;
    max-width: 1200px;
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 15px;
    padding-bottom: 15px;
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.left-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#video-grid.room-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background-color: #1e293b;
    border-radius: 12px;
    padding: 10px;
    position: relative;
}

.video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    overflow: hidden;
    background-color: #0f172a;
    cursor: pointer;
    transition: all 0.2s;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fullscreen-wrapper {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 50;
    margin: 0;
    border-radius: 12px;
}

.kick-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background-color: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    z-index: 60;
}

.kick-btn:hover {
    background-color: #dc2626;
}

.room-chat-container {
    height: 450px;
    background-color: #1e293b;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 2px dashed transparent;
    transition: border-color 0.2s;
}

.room-chat-container #chat-box {
    padding: 0 5px 0 0;
    margin-bottom: 10px;
    border: none;
    border-radius: 0;
}

.room-chat-container .chat-img {
    max-width: 180px;
    max-height: 180px;
}

.pwd-btn {
    text-align: right;
    width: 100px;
}

.room-back-btn {
    width: 100px;
    text-align: left;
}

/* P2P privacy notice & connection status badge */
.p2p-notice {
    width: 90%;
    max-width: 500px;
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 12px;
    line-height: 1.45;
    color: #cbd5e1;
    text-align: center;
}

.p2p-notice.notice-wide {
    max-width: 800px;
}

.p2p-notice.notice-room {
    width: 95%;
    max-width: 1200px;
    margin-top: 4px;
}

.p2p-status {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 6px;
    text-align: center;
}

.p2p-status.p2p-ready {
    color: #10b981;
}

.p2p-status.p2p-fallback {
    color: #f59e0b;
}

