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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 헤더 */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* 로딩 화면 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading p {
    color: #666;
    font-size: 1.1rem;
}

/* 비디오 컨테이너 수정 */
.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    aspect-ratio: 4 / 3; /* 해상도 비율 유지 */
    margin: 0 auto 20px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    background: #000;
}

.video-container video {
    position: absolute; /* absolute로 변경하여 캔버스와 겹침 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* 거울 모드 */
}

.video-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10; /* 비디오보다 위에 오도록 명시 */
    pointer-events: none; /* 클릭 이벤트가 비디오/버튼에 전달되도록 함 */
    transform: scaleX(-1); /* 비디오와 동일하게 반전 */
}

/* 컨트롤 버튼 */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

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

.btn-primary {
    background: white;
    color: #667eea;
}

.btn-primary:hover:not(:disabled) {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ==========================================
   단계별 분석 컨트롤
   ========================================== */
.step-controls {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.step-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.step-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.step-badge.completed {
    background: #4CAF50;
}

.step-text {
    color: #555;
    font-size: 0.95rem;
}

.step-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-step {
    flex: 1;
    min-width: 150px;
    padding: 15px 20px;
    font-size: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-color {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-color:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(240, 147, 251, 0.4);
}

.btn-color:disabled {
    background: #ccc;
    color: #888;
}

.btn-color.completed {
    background: #4CAF50;
}

.btn-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-body:disabled {
    background: #ccc;
    color: #888;
}

/* 결과 카드 */
.results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.result-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.result-card p {
    font-size: 1.1rem;
    color: #555;
}

/* 컬러 팔레트 */
.color-palette {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.color-palette .color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s;
}

.color-palette .color-swatch:hover {
    transform: scale(1.1);
}

/* 전체 너비 카드 */
.result-card.full-width {
    grid-column: 1 / -1;
}

/* 스타일 추천 */
.style-recommend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.recommend-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.recommend-section h4 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.recommend-section .description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
    font-style: italic;
}

.recommend-list,
.makeup-list {
    margin-bottom: 15px;
}

.recommend-list strong,
.makeup-list strong,
.avoid-list strong {
    color: #444;
    display: block;
    margin-bottom: 8px;
}

.recommend-list ul,
.makeup-list ul {
    list-style: none;
    padding-left: 0;
}

.recommend-list li,
.makeup-list li {
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
    color: #555;
}

.recommend-list li::before,
.makeup-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #667eea;
}

.avoid-list {
    margin-top: 10px;
}

.avoid-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.avoid-tag {
    background: #ffe0e0;
    color: #c53030;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
}

/* 결과 액션 버튼 */
.result-actions {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 10px;
}

/* ==========================================
   공유용 결과 카드
   ========================================== */
.share-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px;
    color: white;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin: 20px 0;
}

.share-card-header h2 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.share-card-header p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.share-card-body {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
}

.share-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.share-result-item:last-of-type {
    border-bottom: none;
}

.share-label {
    font-weight: 600;
    font-size: 1rem;
}

.share-value {
    font-size: 1rem;
    text-align: right;
    max-width: 60%;
}

.share-palette {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.share-palette .color-swatch {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.share-card-footer {
    margin-top: 15px;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* ==========================================
   공유 버튼
   ========================================== */
.share-buttons {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
}

.btn-share {
    padding: 12px 20px;
    font-size: 0.95rem;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-download {
    background: #4CAF50;
    color: white;
}

.btn-download:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.btn-twitter {
    background: #1DA1F2;
    color: white;
}

.btn-twitter:hover {
    background: #1a91da;
    transform: translateY(-2px);
}

.btn-facebook {
    background: #4267B2;
    color: white;
}

.btn-facebook:hover {
    background: #365899;
    transform: translateY(-2px);
}

.btn-kakao {
    background: #FEE500;
    color: #000000;
}

.btn-kakao:hover {
    background: #e6cf00;
    transform: translateY(-2px);
}

/* 푸터 */
footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* 유틸리티 */
.hidden {
    display: none !important;
}

/* 반응형 */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 300px;
    }
}
