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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #17212b;
    overflow: hidden;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app {
    width: 100vw;
    height: 100vh;
    max-width: 430px;
    max-height: 932px;
    position: relative;
    background: #000;
    overflow: hidden;
}

@media (max-width: 430px) {
    #app {
        max-width: 100vw;
        max-height: 100vh;
    }
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Экран поиска */
#searchScreen {
    background: #000;
}

.logo {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: white;
}

.btn-primary {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    background: #FFCC00;
    color: #000;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(255,204,0,0.3);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255,204,0,0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.status {
    margin-top: 2rem;
    color: white;
    font-size: 1.2rem;
    animation: pulse 1.5s infinite;
}

.status.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Экран видеочата */
#chatScreen {
    background: #000;
}

.video-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.main-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.pip-video {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 150px;
    height: 200px;
    border-radius: 15px;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 3px solid white;
    transform: scaleX(-1);
    background: #000;
    cursor: pointer;
    z-index: 2;
    opacity: 1;
    transition: all 0.2s ease;
}

.pip-video:hover {
    transform: scaleX(-1) scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

/* Анимация переключения - плавное затухание и появление */
.video-container.switching .main-video {
    animation: fadeSwitch 0.4s ease-in-out;
}

.video-container.switching .pip-video {
    animation: fadeSwitch 0.4s ease-in-out;
}

@keyframes fadeSwitch {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .pip-video {
        width: 100px;
        height: 133px;
        top: 10px;
        right: 10px;
    }
}

.btn-end {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.9rem 2rem;
    font-size: 1rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    z-index: 10; /* Поверх всех видео */
}

.btn-end:hover {
    background: rgba(255,255,255,0.25);
    transform: translateX(-50%) translateY(-1px);
}

.btn-end {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.9rem 2rem;
    font-size: 1rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    z-index: 10; /* Поверх всех видео */
}

.btn-end:hover {
    background: rgba(255,255,255,0.25);
    transform: translateX(-50%) translateY(-1px);
}

/* Экран оценки */
#ratingScreen {
    background: #000;
}

.frozen-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) brightness(0.7);
    position: absolute;
    top: 0;
    left: 0;
    transform: scaleX(-1); /* Отзеркаливание */
}

.rating-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    max-height: 50vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.rating-overlay.show {
    transform: translateY(0);
}

.rating-handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 0 auto 1rem;
}

.rating-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #000;
    text-align: center;
}

.stars {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 1rem;
    font-size: 2rem;
}

.star {
    cursor: pointer;
    filter: grayscale(1);
    opacity: 0.3;
    transition: all 0.15s ease;
}

.star:hover,
.star.active {
    filter: grayscale(0);
    opacity: 1;
    transform: scale(1.1);
}

.qualities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.quality-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.quality-chip:hover {
    background: #ebebeb;
}

.quality-chip input[type="checkbox"] {
    display: none;
}

.quality-chip input[type="checkbox"]:checked + span {
    font-weight: 600;
}

.quality-chip input[type="checkbox"]:checked ~ span,
.quality-chip:has(input:checked) {
    background: #FFCC00;
    border-color: #FFCC00;
}

.quality-chip span {
    color: #333;
}

.btn-next {
    width: 100%;
    padding: 0.9rem;
    font-size: 1rem;
    background: #FFCC00;
    color: #000;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-next:hover {
    background: #FFD700;
    transform: translateY(-1px);
}

.btn-next:active {
    transform: translateY(0);
}

/* Панель выбора масок */
.mask-selector {
    position: absolute;
    bottom: 180px;
    left: 0;
    right: 0;
    padding: 0 24px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    z-index: 10;
}

.mask-btn {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #FFCC00;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mask-btn img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 5px;
}

.mask-btn:hover {
    background: rgba(255, 204, 0, 0.3);
    transform: translateY(-2px);
}

.mask-btn.active {
    background: #FFCC00;
    color: #000;
    border-color: #FFD700;
    box-shadow: 0 4px 12px rgba(255, 204, 0, 0.4);
}

/* Кнопка добавления маски */
.mask-btn-add {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.mask-btn-add:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Таймер оценки */
.rating-timer {
    position: absolute;
    top: 20px;
    left: 24px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    color: #21201f;
    z-index: 10;
    transition: all 0.2s;
    cursor: default;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    max-width: calc(100% - 48px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rating-timer:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Сообщение о завершении */
.partner-ended-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 24px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
    z-index: 15;
    backdrop-filter: blur(10px);
}

/* Кнопки управления */
.control-buttons {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
    display: flex;
    gap: 16px;
    z-index: 10;
}

.btn-control {
    flex: 1;
    padding: 16px 24px;
    font-size: 1em;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.btn-end-call {
    background: rgba(255, 59, 48, 0.95);
    color: white;
}

.btn-end-call:hover {
    background: rgba(255, 59, 48, 1);
    transform: translateY(-1px);
}

.btn-skip-call {
    background: rgba(255, 255, 255, 0.95);
    color: #21201f;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-skip-call:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

/* Модальное окно редактора */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px 30px;
    overflow-y: auto;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
}

.editor-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

.editor-panel h3 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #667eea;
}

.editor-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#editorCanvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    background: #000;
}

.file-upload-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px dashed #667eea;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    color: #667eea;
    font-weight: 600;
    background: white;
}

.file-upload-btn:hover {
    background: #f0f3ff;
    border-color: #764ba2;
}

.mask-preview {
    margin: 15px 0;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 10px;
    padding: 10px;
}

.mask-preview img {
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
}

.control-group {
    margin: 15px 0;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 600;
    font-size: 0.9em;
}

.control-group input[type="range"] {
    width: 100%;
    margin: 5px 0;
}

.control-group input[type="text"],
.control-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.control-group input[type="text"]:focus,
.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-save {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

@media (max-width: 1024px) {
    .editor-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mask-selector {
        bottom: 170px;
        padding: 0 16px;
        gap: 12px;
    }
    
    .mask-btn {
        padding: 10px 16px;
        font-size: 0.8em;
    }
    
    .mask-btn img {
        width: 20px;
        height: 20px;
    }
    
    .control-buttons {
        left: 16px;
        right: 16px;
        gap: 12px;
    }
    
    .btn-control {
        padding: 14px 20px;
        font-size: 0.95em;
    }
    
    .rating-timer {
        font-size: 0.8em;
        padding: 10px 14px;
        left: 16px;
        max-width: calc(100% - 32px);
    }
}

/* Экран выбора пола */
#genderScreen {
    background: #fff;
    overflow-y: auto;
}

.gender-container {
    max-width: 430px;
    width: 100%;
    padding: 20px 24px;
    box-sizing: border-box;
}

.gender-container h1 {
    text-align: center;
    color: #21201f;
    margin: 0 0 24px 0;
    font-size: 2em;
    font-weight: 700;
}

.gender-section {
    margin: 24px 0;
}

.gender-section h3 {
    color: #21201f;
    margin: 0 0 16px 0;
    font-size: 1.1em;
    text-align: left;
    font-weight: 600;
}

.gender-buttons {
    display: flex;
    gap: 16px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.gender-btn, .partner-gender-btn {
    padding: 16px 24px;
    font-size: 1em;
    background: #f5f5f5;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: #21201f;
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.gender-btn:hover, .partner-gender-btn:hover {
    background: #ebebeb;
    border-color: #d5d5d5;
}

.gender-btn.selected, .partner-gender-btn.selected {
    background: #FFCC00;
    border-color: #FFCC00;
    color: #21201f;
    font-weight: 600;
}

.btn-start-chat {
    width: 100%;
    padding: 16px 24px;
    margin-top: 24px;
    background: #FFCC00;
    color: #21201f;
    border: none;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(255, 204, 0, 0.3);
}

.btn-start-chat:hover {
    background: #FFD700;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 204, 0, 0.4);
}

.user-stats {
    margin-top: 24px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e5e5e5;
}

.user-stats h4 {
    color: #21201f;
    margin: 0 0 16px 0;
    font-weight: 600;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e5e5e5;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
    font-size: 0.95em;
}

.stat-value {
    color: #21201f;
    font-weight: 600;
}

/* Кнопка отмены поиска */
.btn-cancel {
    margin-top: 2rem;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

/* Модальное окно оценки */
.rating-modal-content {
    max-width: 500px;
}

.btn-save-rating {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background: #FFCC00;
    color: #000;
    border: none;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-save-rating:hover {
    background: #FFD700;
    transform: translateY(-2px);
}

/* Кнопка экспорта маски */
.btn-export {
    width: 100%;
    padding: 15px;
    margin-top: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Замороженный canvas */
#frozenCanvas {
    filter: grayscale(1) brightness(0.7);
}
