/* ============================================
   메인 화면
   ============================================ */

.main-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    min-height: 100vh;
    box-sizing: border-box;
}

.title {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: bold;
    margin-bottom: clamp(2rem, 5vh, 4rem);
    text-shadow: 4px 4px 8px rgba(0,0,0,0.3),
                 0 0 20px rgba(255,255,255,0.3),
                 0 0 40px rgba(255,255,255,0.2);
    line-height: 1.2;
    position: relative;
    display: inline-block;
    /* 그라데이션 텍스트 */
    background: linear-gradient(135deg, #fff 0%, #e0e7ff 50%, #c7d2fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* 애니메이션 */
    animation: titlePulse 2s ease-in-out infinite,
               titleGradient 5s ease infinite;
}

@keyframes titlePulse {
    0%, 100% { 
        transform: scale(1);
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.05);
        filter: brightness(1.2);
    }
}

@keyframes titleGradient {
    0%, 100% { 
        filter: hue-rotate(0deg) brightness(1);
    }
    50% { 
        filter: hue-rotate(20deg) brightness(1.1);
    }
}

.mode-selection {
    display: flex;
    gap: clamp(1.5rem, 4vw, 3rem);
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.mode-btn {
    background: linear-gradient(135deg, 
        rgba(255,255,255,0.25) 0%, 
        rgba(255,255,255,0.15) 100%);
    border: 3px solid rgba(255,255,255,0.5);
    padding: clamp(1.5rem, 4vw, 2.5rem) clamp(2rem, 5vw, 4rem);
    border-radius: clamp(16px, 3vw, 24px);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    flex: 1;
    min-width: clamp(150px, 30vw, 200px);
    max-width: clamp(200px, 40vw, 350px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: scale(0);
}

.mode-btn:hover::before {
    opacity: 1;
    transform: scale(1);
}

.mode-btn:hover {
    background: linear-gradient(135deg, 
        rgba(255,255,255,0.35) 0%, 
        rgba(255,255,255,0.25) 100%);
    transform: translateY(-10px) scale(1.05) rotateX(5deg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4),
                0 0 40px rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.8);
}

.mode-btn:active {
    transform: translateY(-6px) scale(1.02) rotateX(2deg);
}

.mode-btn.selected {
    background: linear-gradient(135deg, 
        rgba(76, 175, 80, 0.5) 0%, 
        rgba(76, 175, 80, 0.3) 100%);
    border-color: #4CAF50;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.5),
                0 0 30px rgba(76, 175, 80, 0.3);
    animation: selectedGlow 2s ease-in-out infinite;
}

@keyframes selectedGlow {
    0%, 100% { 
        box-shadow: 0 8px 25px rgba(76, 175, 80, 0.5),
                    0 0 30px rgba(76, 175, 80, 0.3);
    }
    50% { 
        box-shadow: 0 8px 25px rgba(76, 175, 80, 0.7),
                    0 0 50px rgba(76, 175, 80, 0.5);
    }
}

.mode-btn-icon {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin-bottom: clamp(0.5rem, 1.5vw, 1rem);
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
    transition: transform 0.3s ease;
}

.mode-btn:hover .mode-btn-icon {
    transform: scale(1.1) rotate(5deg);
}

.mode-btn h2 {
    font-size: clamp(1.2rem, 4vw, 2.5rem);
    margin-bottom: clamp(0.5rem, 1.5vw, 0.75rem);
    font-weight: bold;
    position: relative;
    z-index: 1;
}

.mode-btn p {
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    opacity: 0.9;
    line-height: 1.4;
    position: relative;
    z-index: 1;
}

/* ============================================
   데스크톱 대형 화면 최적화
   ============================================ */

@media (min-width: 1025px) {
    .main-screen {
        padding: 3rem 2rem;
    }
    
    .main-screen .mode-selection {
        max-width: 900px;
        gap: 2.5rem;
    }
    
    .main-screen .mode-btn {
        max-width: 400px;
        padding: 2.5rem 4rem;
    }
}

.level-selection {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.level-selection-area {
    margin: 2rem 0;
    animation: fadeIn 0.3s ease-in;
}

.level-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.4);
    padding: 1rem 2rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: #fff;
    font-size: 1rem;
}

.level-btn:hover {
    background: rgba(255,255,255,0.25);
}

.level-description {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 3rem 0;
    flex-wrap: wrap;
}

.level-info {
    background: rgba(255,255,255,0.1);
    padding: 2rem;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    max-width: 400px;
    flex: 1;
    min-width: 300px;
}

.level-info h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #fff;
}

.level-info p {
    font-size: 1rem;
    line-height: 1.6;
    opacity: 0.9;
}

/* ============================================
   레벨 선택 화면
   ============================================ */

.level-selection-screen {
    text-align: center;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    height: 100vh;
    max-height: 100vh;
    padding: clamp(1rem, 3vh, 2rem);
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
}

.level-selection-screen.active {
    display: flex !important;
}

.level-selection-screen .title {
    font-size: clamp(1.5rem, 6vw, 3rem);
    margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
    margin-top: clamp(0.5rem, 2vh, 1rem);
    text-shadow: 4px 4px 8px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.level-selection-subtitle {
    font-size: clamp(0.875rem, 2.5vw, 1.125rem);
    color: rgba(255,255,255,0.8);
    margin-bottom: clamp(1rem, 3vh, 1.5rem);
    opacity: 0.9;
    flex-shrink: 0;
}

/* 레벨 카드 컨테이너 - 수평 배치 */
.level-cards {
    display: flex;
    flex-direction: row;
    gap: clamp(1rem, 3vw, 2rem);
    width: 100%;
    max-width: 900px;
    margin-bottom: clamp(1rem, 2.5vh, 1.5rem);
    flex-shrink: 0;
    justify-content: center;
    align-items: stretch;
}

/* 레벨 카드 - 컴팩트 디자인 */
.level-card {
    background: rgba(255,255,255,0.15);
    border: 3px solid rgba(255,255,255,0.4);
    border-radius: clamp(12px, 2.5vw, 20px);
    padding: clamp(1rem, 2.5vw, 1.5rem);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    gap: clamp(0.5rem, 1.5vw, 0.75rem);
    text-align: left;
    position: relative;
    overflow: hidden;
    flex: 1;
    min-width: 0;
    max-width: 400px;
    min-height: auto;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.level-card:hover::before {
    transform: translateX(100%);
}

.level-card:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.7);
}

.level-card:active {
    transform: translateY(-4px) scale(1);
}

/* 레벨별 색상 차별화 */
.level-card-easy {
    border-left: 4px solid #4CAF50;
}

.level-card-easy:hover {
    border-left-color: #66BB6A;
    box-shadow: 0 12px 40px rgba(76, 175, 80, 0.3);
}

.level-card-hard {
    border-left: 4px solid #FF9800;
}

.level-card-hard:hover {
    border-left-color: #FFB74D;
    box-shadow: 0 12px 40px rgba(255, 152, 0, 0.3);
}

.level-card.selected {
    background: rgba(76, 175, 80, 0.3);
    border-color: #4CAF50;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
    transform: translateY(-4px);
}

.level-card.selected.level-card-hard {
    background: rgba(255, 152, 0, 0.25);
    border-color: #FF9800;
    box-shadow: 0 8px 25px rgba(255, 152, 0, 0.4);
}

/* 레벨 카드 헤더 */
.level-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
}

.level-card-icon {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.level-card-badge {
    padding: clamp(0.25rem, 1vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: clamp(12px, 2vw, 20px);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-badge-easy {
    background: rgba(76, 175, 80, 0.3);
    color: #81C784;
    border: 2px solid #4CAF50;
}

.level-badge-hard {
    background: rgba(255, 152, 0, 0.3);
    color: #FFB74D;
    border: 2px solid #FF9800;
}

.level-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(0.4rem, 1.2vw, 0.6rem);
}

.level-card-title {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: bold;
    margin-bottom: clamp(0.15rem, 0.8vw, 0.3rem);
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.level-card-subtitle {
    font-size: clamp(0.875rem, 2.5vw, 1.125rem);
    font-weight: 600;
    margin-bottom: clamp(0.4rem, 1.5vw, 0.6rem);
    color: rgba(255,255,255,0.95);
    opacity: 0.95;
}

/* 단일 특징 표시 */
.level-card-feature-single {
    display: flex;
    align-items: center;
    gap: clamp(0.4rem, 1.2vw, 0.6rem);
    font-size: clamp(0.8125rem, 2vw, 0.9375rem);
    color: rgba(255,255,255,0.9);
    margin-top: auto;
    padding: clamp(0.4rem, 1vw, 0.6rem);
    background: rgba(255,255,255,0.05);
    border-radius: clamp(6px, 1.2vw, 10px);
}

.level-card-feature-single .feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(18px, 2.5vw, 22px);
    height: clamp(18px, 2.5vw, 22px);
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    font-size: clamp(0.6875rem, 1.8vw, 0.8125rem);
    font-weight: bold;
    flex-shrink: 0;
}

.level-card-easy .level-card-feature-single .feature-icon {
    background: rgba(76, 175, 80, 0.3);
    color: #81C784;
}

.level-card-hard .level-card-feature-single .feature-icon {
    background: rgba(255, 152, 0, 0.3);
    color: #FFB74D;
}

/* 작은 화면에서 수직 배치로 전환 */
@media (max-width: 768px) {
    .level-cards {
        flex-direction: column;
        max-width: 100%;
    }
    
    .level-card {
        max-width: 100%;
    }
}

.level-card-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    color: #fff;
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
    border-radius: clamp(8px, 1.5vw, 12px);
    font-size: clamp(0.875rem, 2.2vw, 1rem);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: stretch;
    margin-top: clamp(0.5rem, 1.5vw, 0.75rem);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.level-card-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.level-card-btn:hover::before {
    width: 300px;
    height: 300px;
}

.level-card-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.7);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.level-card-btn:active {
    transform: scale(0.98);
}

.level-card.selected .level-card-btn {
    background: rgba(76, 175, 80, 0.5);
    border-color: #4CAF50;
    color: #fff;
}

.level-card.selected.level-card-hard .level-card-btn {
    background: rgba(255, 152, 0, 0.5);
    border-color: #FF9800;
}

.level-selection-actions {
    margin-top: clamp(0.75rem, 2vh, 1rem);
    margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
    flex-shrink: 0;
}

.level-selection-actions .btn {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
    font-size: clamp(0.9375rem, 2.5vw, 1.125rem);
}


/* 방 입장 모달 스타일 */
#joinRoomModal .modal-content {
    max-width: 400px;
}

#roomIdInput {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    margin: 1rem 0;
    box-sizing: border-box;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#roomIdInput:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.15);
}

#roomIdInput::placeholder {
    color: rgba(255,255,255,0.5);
    text-transform: none;
    letter-spacing: normal;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.error-message {
    font-size: 0.9rem;
    text-align: center;
    padding: 0.5rem;
    border-radius: 4px;
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid rgba(244, 67, 54, 0.5);
}

