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

:root {
    --bg-dark: #14141a;
    --card-bg: #1f1f29;
    --card-border: #383842;
    --accent-cyan: #00d4ff;
    --status-text: #80cdeb;
    --label-text: #999999;
    --green: #26d147;
    --yellow: #e6bf10;
    --red: #cc3939;
    --orange: #e07028;
    --blue-p2p: #3378e6;
    --credits-green: #78d850;
    --warning-yellow: #ffd835;
    --signout-red: #b26565;
    --overlay-bg: rgba(0, 0, 0, 0.75);
    --panel-bg: #191922;
    --panel-border: #404050;
    --peer-card-bg: #1b1b26;
    --peer-card-border: #48485a;
    --host-gold: #b88510;
    --client-cyan: #1a99a6;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    color: #ffffff;
    font-family: var(--font-family);
    font-size: 14px;
    overflow: hidden;
    user-select: none;
}

.hidden {
    display: none !important;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.screen.active {
    display: flex;
}

.center-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 95vw;
}

.card-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    color: #ffffff;
    margin: 0;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-label {
    min-width: 72px;
    font-size: 12px;
    color: var(--label-text);
    flex-shrink: 0;
}

.form-input {
    flex: 1;
    background: #0d0d12;
    border: 1px solid #2a2a36;
    border-radius: 6px;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--accent-cyan);
}

.form-input::placeholder {
    color: #555;
}

.form-select {
    width: 100%;
    background: #0d0d12;
    border: 1px solid #2a2a36;
    border-radius: 6px;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--accent-cyan);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--label-text);
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent-cyan);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.btn {
    border: 1px solid #2a2a36;
    border-radius: 6px;
    background: #252530;
    color: #ffffff;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    text-align: center;
}

.btn:hover {
    background: #30303e;
    border-color: #444;
}

.btn:active {
    background: #1a1a24;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    font-size: 15px;
    padding: 0 20px;
}

.btn-tall {
    min-height: 40px;
}

.btn-secondary {
    font-size: 13px;
    min-height: 38px;
    padding: 0 16px;
}

.btn-short {
    min-height: 36px;
    font-size: 13px;
    padding: 0 16px;
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn-flex {
    flex: 1;
}

.btn-signout {
    min-height: 32px;
    font-size: 12px;
    padding: 0 12px;
    color: var(--signout-red);
}

.btn-signout:hover {
    color: #d47a7a;
}

.btn-flat {
    background: none;
    border: none;
    color: #cccccc;
    font-size: 13px;
    font-family: var(--font-family);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.btn-flat:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.btn-small {
    font-size: 12px;
    padding: 2px 6px;
}

.separator {
    height: 1px;
    background: #2a2a36;
}

.status-label {
    font-size: 12px;
    color: var(--status-text);
    text-align: center;
    word-wrap: break-word;
    min-height: 16px;
}

.credits-label {
    font-size: 12px;
    color: var(--credits-green);
    text-align: center;
}

.warning-label {
    font-size: 12px;
    color: var(--warning-yellow);
    text-align: center;
}

.ext-status {
    font-size: 10px;
    text-align: center;
    color: #73bf73;
}

.version-label {
    font-size: 10px;
    text-align: center;
    color: #595966;
}

.player-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    overflow: hidden;
}

.video-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.tap-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay.visible {
    opacity: 1;
}

.overlay > * {
    pointer-events: auto;
}

.users-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 22;
    background: var(--overlay-bg);
    padding: 8px 12px 10px;
    display: none;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.users-panel.docked {
    display: flex;
}

.users-panel.docked.visible {
    opacity: 1;
    pointer-events: auto;
}

.users-panel.free {
    display: flex;
    right: auto;
    min-width: 300px;
    max-width: 80vw;
    border-radius: 0 0 10px 10px;
    border: 1px solid var(--panel-border);
    border-top: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.users-panel.free .users-header {
    cursor: grab;
}

.users-panel.free.dragging .users-header {
    cursor: grabbing;
}

.btn-pin {
    font-size: 11px;
    color: #888;
    margin-left: auto;
}

.btn-pin:hover {
    color: #ccc;
}

.users-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-info {
    flex: 1;
    font-size: 13px;
    color: #b3b3b3;
}

.peers-scroll {
    overflow-x: auto;
    overflow-y: hidden;
}

.peers-container {
    display: flex;
    gap: 8px;
    min-height: 0;
}

.peer-card {
    background: var(--peer-card-bg);
    border: 1px solid var(--peer-card-border);
    border-radius: 8px;
    padding: 8px 8px 6px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.peer-top-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.peer-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

.peer-status-dot.connecting {
    background: var(--yellow);
}

.peer-status-dot.disconnected {
    background: var(--red);
}

.peer-status-dot.talking {
    background: #00e060;
    box-shadow: 0 0 6px #00e060;
    animation: voice-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes voice-pulse {
    from { box-shadow: 0 0 4px #00e060; }
    to { box-shadow: 0 0 10px #00e060, 0 0 2px #00e060; }
}

.peer-name {
    flex: 1;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.peer-role-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.peer-role-badge.host {
    background: rgba(184, 133, 16, 0.25);
    color: var(--host-gold);
}

.peer-role-badge.client {
    background: rgba(26, 153, 166, 0.25);
    color: var(--client-cyan);
}

.peer-mode-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.peer-mode-badge.p2p {
    background: rgba(51, 120, 230, 0.25);
    color: var(--blue-p2p);
}

.peer-mode-badge.relay {
    background: rgba(224, 112, 40, 0.25);
    color: var(--orange);
}

.peer-mode-badge.ws {
    background: rgba(150, 150, 150, 0.25);
    color: #999;
}

.peer-quality-dot {
    font-size: 10px;
    color: var(--green);
}

.peer-transfer-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--label-text);
}

.peer-direction {
    font-size: 11px;
    white-space: nowrap;
}

.peer-filename {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}

.peer-progress-bar {
    width: 60px;
    height: 4px;
    background: #2a2a36;
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.peer-progress-fill {
    height: 100%;
    background: var(--accent-cyan);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.peer-speed {
    font-size: 10px;
    white-space: nowrap;
    color: var(--label-text);
}

.buffering-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: rgba(204, 204, 204, 0.9);
    pointer-events: none;
}

.activity-log {
    position: absolute;
    left: 12px;
    bottom: 8px;
    width: 40%;
    font-size: 11px;
    color: rgba(153, 179, 204, 0.5);
    pointer-events: none;
    line-height: 1.5;
}

.client-status {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(217, 217, 217, 0.6);
    pointer-events: none;
}

.bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bottom-bar.visible {
    opacity: 1;
}

.seek-panel {
    background: var(--overlay-bg);
    padding: 6px 16px;
}

.seek-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seek-wrapper {
    flex: 1;
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

.download-bar {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    transform: translateY(-50%);
    background: rgba(38, 38, 38, 0.8);
    border-radius: 2px;
    overflow: hidden;
}

.download-fill {
    height: 100%;
    background: rgba(115, 115, 115, 0.9);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.seek-bar {
    position: relative;
    width: 100%;
    height: 24px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    z-index: 2;
}

.seek-bar::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-cyan);
    margin-top: -4px;
    cursor: pointer;
    transition: transform 0.1s;
}

.seek-bar::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.seek-bar::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    border: none;
}

.seek-bar::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-cyan);
    border: none;
    cursor: pointer;
}

.seek-time {
    min-width: 80px;
    text-align: right;
    font-size: 12px;
    color: #cccccc;
}

.host-controls {
    background: var(--overlay-bg);
    padding: 8px 16px 10px;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}

.btn-control {
    min-height: 36px;
    font-size: 14px;
    padding: 0 16px;
    min-width: 100px;
}

.btn-control.active {
    background: #2a5a3a;
    border-color: #3a8a5a;
}

.btn-play {
    font-size: 16px;
    min-width: 120px;
}

.info-row {
    display: flex;
    gap: 12px;
}

.info-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-right {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.file-label {
    font-size: 12px;
    color: #b3b3b3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-label {
    font-size: 11px;
    color: #e6cc66;
}

.playback-status {
    font-size: 12px;
    color: #80e5ff;
}

.quality-label {
    font-size: 11px;
    color: #e6dca0;
    text-align: right;
}

.data-stats-label {
    font-size: 10px;
    color: var(--credits-green);
    text-align: right;
}

.subtitle-label {
    position: absolute;
    bottom: 60px;
    left: 10%;
    right: 10%;
    text-align: center;
    font-size: 22px;
    color: #ffffff;
    text-shadow:
        -2px -2px 0 #000,
         2px -2px 0 #000,
        -2px  2px 0 #000,
         2px  2px 0 #000,
         0    2px 4px rgba(0, 0, 0, 0.7);
    z-index: 30;
    pointer-events: none;
    line-height: 1.4;
}

.options-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 40%;
    min-width: 300px;
    max-width: 500px;
    height: 100%;
    background: var(--panel-bg);
    border-left: 1px solid var(--panel-border);
    border-radius: 10px 0 0 10px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.options-panel.visible {
    transform: translateX(0);
    display: flex;
}

.options-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.options-title {
    font-size: 16px;
    font-weight: 600;
}

.options-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.options-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.options-section-label {
    font-size: 13px;
    color: var(--label-text);
    font-weight: 500;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-label {
    min-width: 50px;
    font-size: 12px;
    color: #cccccc;
}

.volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #2a2a36;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-cyan);
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-cyan);
    border: none;
    cursor: pointer;
}

.slider-value {
    min-width: 36px;
    font-size: 11px;
    color: var(--label-text);
    text-align: right;
}

.camera-container {
    position: absolute;
    bottom: 140px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 30;
}

.camera-wrap {
    position: relative;
    display: inline-block;
}

.camera-wrap.floating {
    position: fixed;
    z-index: 50;
    opacity: 0.5;
    cursor: grab;
}

.camera-wrap.floating.dragging { cursor: grabbing; }

.btn-cam-pop {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
}

.camera-wrap:hover .btn-cam-pop,
.camera-wrap.floating .btn-cam-pop { opacity: 1; }

.camera-preview {
    width: 160px;
    height: 120px;
    border-radius: 8px;
    background: #000;
    object-fit: cover;
    transform: scaleX(-1);
    border: 2px solid var(--accent-cyan);
    display: block;
}

.camera-peers {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.camera-peer-feed {
    width: 160px;
    height: 120px;
    border-radius: 8px;
    background: #000;
    object-fit: cover;
    border: 2px solid var(--green);
    display: block;
}

@media (max-width: 500px) {
    .card {
        width: 100% !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .peer-card {
        min-width: 220px;
        max-width: 220px;
    }

    .options-panel {
        width: 100%;
        min-width: unset;
        max-width: unset;
        border-radius: 0;
    }

    .controls-row {
        flex-wrap: wrap;
    }
}

.no-credits-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.no-credits-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    color: #fff;
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.store-section {
    text-align: center;
}
.store-title {
    font-size: 13px;
    color: var(--label-text);
    margin-bottom: 8px;
}
.store-packs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.btn-store {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s;
}
.btn-store:hover {
    border-color: var(--accent-cyan);
}
.btn-store .per-gb {
    float: right;
    color: var(--label-text);
    font-size: 11px;
}

.legal-footer {
    margin-top: 12px;
    text-align: center;
    font-size: 11px;
}
.legal-footer a {
    color: #555;
    text-decoration: none;
}
.legal-footer a:hover {
    color: #00d4ff;
}

.btn-small {
    font-size: 12px !important;
    min-height: 0 !important;
    padding: 6px 12px !important;
    opacity: 0.6;
}
