* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-0: #080b14;
    --bg-1: #0f1629;
    --bg-2: #101c36;
    --card: rgba(15, 24, 44, 0.72);
    --card-border: rgba(255, 255, 255, 0.12);
    --text: #e8edff;
    --muted: #a6b1cf;
    --primary: #5f86ff;
    --primary-strong: #476ff5;
    --success: #1dbf8b;
    --danger: #ef5a7a;
    --chip: rgba(255, 255, 255, 0.12);
}

body {
    font-family: Inter, 'Segoe UI', Roboto, Arial, sans-serif;
    background:
        radial-gradient(1200px 700px at 10% -10%, #3c4f9a55, transparent 70%),
        radial-gradient(800px 500px at 110% 0%, #3f7dd855, transparent 65%),
        linear-gradient(140deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
    color: var(--text);
    min-height: 100vh;
    padding: 14px;
}

.app-shell {
    width: min(1380px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 14px;
}

.glass-card {
    background: var(--card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.35);
}

.left-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 12px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #6a9dff, #7a6dff);
    font-size: 1.3rem;
}

.brand-row h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.brand-row p {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 3px;
}

.card-block {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: rgba(7, 12, 24, 0.45);
    padding: 12px;
}

.room-card {
    background: linear-gradient(160deg, rgba(17, 29, 55, 0.72), rgba(8, 14, 28, 0.62));
    border-color: rgba(132, 164, 255, 0.34);
}

.room-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.mini-chip {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.76rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #dce7ff;
}

.mini-chip.ok {
    background: rgba(29, 191, 139, 0.2);
    border-color: rgba(70, 221, 173, 0.45);
    color: #cbffed;
}

.mini-chip.warn {
    background: rgba(239, 90, 122, 0.2);
    border-color: rgba(255, 144, 169, 0.45);
    color: #ffd7e1;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.card-block h2 {
    font-size: 0.96rem;
    color: #c7d4ff;
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}

.field-label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.86rem;
    color: var(--muted);
    font-weight: 600;
}

.input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

input,
select,
button {
    font: inherit;
}

input[type='text'],
input[type='password'],
select {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 11px 12px;
    border-radius: 10px;
    outline: none;
}

input::placeholder {
    color: #97a3c7;
}

input:disabled {
    opacity: 0.6;
}

input:focus,
select:focus {
    border-color: #7fa2ff;
    box-shadow: 0 0 0 3px rgba(98, 136, 255, 0.2);
}

.btn {
    border: 0;
    border-radius: 10px;
    color: #fff;
    padding: 11px 13px;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s ease, opacity .15s ease;
}

.btn:hover {
    opacity: 0.96;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn:active {
    transform: translateY(1px) scale(0.99);
}

.btn-primary {
    background: linear-gradient(145deg, var(--primary), var(--primary-strong));
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.14);
}

.btn-success {
    background: linear-gradient(145deg, #1bcf97, #10aa79);
}

.btn-danger {
    background: linear-gradient(145deg, #ff6b8b, #e04668);
}

.checkbox-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.checkbox-wrap input {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.room-status {
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 9px 10px;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.room-status.connected {
    background: rgba(35, 180, 127, 0.18);
    color: #baf4dd;
}

.room-status.disconnected {
    background: rgba(240, 72, 114, 0.2);
    color: #ffd4de;
}

.help-text {
    color: var(--muted);
    font-size: 0.84rem;
}

.sub-hint {
    color: #9aabd8;
    font-size: 0.79rem;
    margin-top: -3px;
    margin-bottom: 8px;
}

.users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#usersList {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.user-badge {
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(95, 134, 255, 0.25);
    border: 1px solid rgba(136, 167, 255, 0.42);
    color: #dfe8ff;
    font-size: 0.82rem;
}

.main-stage {
    padding: 14px;
    display: flex;
    flex-direction: column;
    min-height: min(860px, calc(100vh - 28px));
}

.stage-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.stage-topbar h3 {
    font-size: 1.08rem;
    margin-bottom: 2px;
}

.stage-subtitle {
    color: var(--muted);
    font-size: 0.86rem;
}

.audio-chip {
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--chip);
    color: #d8e2ff;
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.video-container {
    background: #02040a;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px;
    flex: 1;
    min-height: 0;
}

#videoWrapper {
    width: 100%;
    height: 100%;
    min-height: 320px;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    outline: none;
}

#screenShareContainer {
    position: absolute;
    inset: 0;
}

#screenShareVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.no-video {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #95a3cf;
    padding: 20px;
}

.stream-context-menu {
    position: absolute;
    z-index: 50;
    min-width: 235px;
    max-width: 260px;
    background: rgba(9, 15, 30, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    padding: 8px;
    display: none;
}

.stream-context-menu.open {
    display: block;
}

.menu-item {
    width: 100%;
    text-align: left;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #edf2ff;
    cursor: pointer;
    font-weight: 600;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.menu-volume-row {
    margin-top: 8px;
    padding: 9px 6px 4px;
    color: #becbf3;
    font-size: 0.83rem;
}

.menu-volume-row label {
    display: block;
    margin-bottom: 6px;
}

.menu-volume-row input[type='range'] {
    width: 100%;
    accent-color: #7ea2ff;
}

.menu-volume-row span {
    display: inline-block;
    margin-top: 4px;
    font-weight: 600;
    color: #e4ebff;
}

@media (max-width: 1080px) {
    .app-shell {
        display: flex;
        /* Grid'den Flex'e geç, order kullanmak için */
        flex-direction: column;
        grid-template-columns: unset;
    }

    /* Videoyu en başa al */
    .main-stage {
        order: -1;
        min-height: auto;
        /* Yükseklik kısıtlamasını kaldır */
    }

    /* Video alanını mobilde 16:9 oranına zorla */
    #videoWrapper {
        aspect-ratio: 16 / 9;
        min-height: auto;
        /* 320px kısıtlaması yerine oran kullan */
        height: auto;
    }

    /* Sol paneli (bilgi alanı) videonun altına al */
    .left-panel {
        order: 1;
        padding-top: 0;
    }

    /* Kullanıcı listesini kaydırılabilir yap (çok yer kaplamasın) */
    #usersList {
        max-height: 120px;
        overflow-y: auto;
        padding-bottom: 4px;
    }
}

@media (max-width: 680px) {
    body {
        padding: 0;
        /* Mobilde kenar boşluğunu sıfırla, daha geniş alan */
        background: var(--bg-0);
        /* Arkaplanı sadeleştir */
    }

    .app-shell {
        gap: 0;
    }

    .glass-card {
        border-radius: 0;
        /* Köşeleri düzelt */
        border: 0;
        border-bottom: 1px solid var(--card-border);
        box-shadow: none;
        background: rgba(15, 24, 44, 0.95);
        /* Arkaplanı koyulaştır */
    }

    .main-stage {
        padding: 0;
        /* Videoyu kenarlara yapıştır */
        border-bottom: 0;
    }

    .video-container {
        border: 0;
        border-radius: 0;
        /* Video kapsayıcısının köşelerini sıfırla */
        padding: 0;
    }

    #videoWrapper {
        border-radius: 0;
        /* Video köşelerini sıfırla */
        width: 100vw;
        /* Ekran genişliğini tam kapla */
    }

    .stage-topbar {
        padding: 12px 14px 4px;
        /* Başlık boşluklarını ayarla */
        margin-bottom: 8px;
    }

    .left-panel {
        padding: 16px;
        margin-top: -1px;
        /* Boşluk kalmasın */
    }

    /* Dokunmatik hedefleri büyüt */
    .btn,
    .menu-item,
    input,
    select {
        min-height: 48px;
        /* Parmakla basmak için ideal yükseklik */
        font-size: 1rem;
    }

    .input-row,
    .room-join-group,
    .share-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
    }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 16, 0.76);
    backdrop-filter: blur(6px);
    z-index: 120;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    width: min(460px, 100%);
    border-radius: 16px;
    border: 1px solid rgba(149, 177, 255, 0.38);
    background: linear-gradient(155deg, rgba(16, 26, 49, 0.95), rgba(7, 12, 24, 0.98));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
    padding: 16px;
}

.modal-card h3 {
    font-size: 1.03rem;
    margin-bottom: 7px;
}

.modal-card p {
    color: #abc0ef;
    font-size: 0.9rem;
    margin-bottom: 11px;
}

.modal-card input {
    width: 100%;
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

#roomClosedModal .modal-card {
    border-color: rgba(255, 148, 148, 0.42);
    background: linear-gradient(155deg, rgba(48, 19, 29, 0.95), rgba(20, 8, 12, 0.98));
}

#roomClosedModal .modal-card p {
    color: #ffd7e1;
}

@media (max-width: 520px) {
    .modal-actions {
        flex-direction: column;
    }
}

.play-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.play-overlay .btn {
    font-size: 1.1rem;
    padding: 14px 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#videoWrapper {
    position: relative;
    /* ... */
}

#screenShareContainer {
    position: absolute;
    inset: 0;
    z-index: 10;
    /* Lower than button */
}

.fullscreen-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    /* Ensure very high z-index */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.4rem;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

#videoWrapper:fullscreen .fullscreen-btn {
    bottom: 30px;
    right: 30px;
}