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

:root {
    --vh: 1vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 모바일에서 텍스트 크기 자동 조정 방지 */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

.header {
    background: white;
    padding: 12px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.lang-selector {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
}

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

.ad-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 120px;
    margin: 10px 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
}

.emoji-section {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.top-nav-categories {
    display: flex;
    gap: 8px;
    margin: 10px auto 10px auto;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    max-width: 1200px;
}

.nav-item {
    padding: 12px 16px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    flex: 1;
    text-align: center;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: 600;
}

.nav-item:hover {
    background: #e9ecef;
}

.nav-item.active:hover {
    background: #0056b3;
}

.content-area {
    min-height: 400px;
}

.empty-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #999;
    font-size: 18px;
}

.search-box {
    width: 100%;
    padding: 15px 20px;
    font-size: 18px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    outline: none;
    margin-bottom: 30px;
    transition: border-color 0.3s ease;
}

.search-box::placeholder {
    font-size: 18px;
}

.search-box:hover {
    background: #e9ecef;
}

.search-box:focus {
    border-color: #007bff;
    background: white;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.emoji-item {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.emoji-item:hover {
    background: #e9ecef;
    transform: scale(1.3);
}

.emoji-item:active {
    transform: scale(0.95);
}

/* iOS에서 터치시 회색 하이라이트 방지 */
.emoji-item, .tab, .copy-all-btn, .clear-btn {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 검색 박스 iOS 스타일링 개선 */
.search-box {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 25px;
}

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

.ad-sidebar {
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    height: 400px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.category-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 18px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
    font-weight: 500;
}

.tab.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: 700;
}

.tab:hover {
    background: #e9ecef;
}

.tab.active:hover {
    background: #0056b3;
}

.copy-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.floating-emoji-box {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 2px solid #007bff;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 700px;
    z-index: 1000;
}

.emoji-collector {
    flex: 1;
    padding: 10px 15px;
    font-size: 16px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
    min-height: 50px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #666;
}

.emoji-collector:not(:empty):not([data-placeholder]) {
    font-size: 24px;
    color: #333;
}

.copy-all-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.copy-all-btn:hover {
    background: #0056b3;
}

.clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.clear-btn:hover {
    background: #c82333;
}

.copy-notification.show {
    transform: translateX(0);
}

.bottom-ad {
    background: linear-gradient(90deg, #a8edea 0%, #fed6e3 100%);
    height: 100px;
    margin: 20px 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-weight: bold;
}

.category-divider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 120px;
    margin: 30px 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
    grid-column: 1 / -1;
}


@media (max-width: 768px) {
    .container {
        padding: 5px 10px;
    }
    
    .header {
        padding: 8px 15px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .emoji-section {
        padding: 20px 15px;
    }

    .top-nav-categories {
        gap: 4px;
        padding: 6px;
        margin: 8px 10px 8px 10px;
    }

    .nav-item {
        padding: 10px 12px;
        font-size: 14px;
        height: 38px;
    }
    
    .search-box {
        padding: 12px 15px;
        font-size: 16px;
        margin-bottom: 20px;
    }
    
    .search-box::placeholder {
        font-size: 16px;
    }
    
    .category-tabs {
        gap: 6px;
        margin-bottom: 15px;
    }
    
    .tab {
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 15px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 8px;
    }
    
    .emoji-item {
        width: 50px;
        height: 50px;
        font-size: 28px;
        border-radius: 8px;
    }
    
    .emoji-item:hover {
        transform: scale(1.2);
    }
    
    .ad-banner, .category-divider {
        height: 80px;
        font-size: 14px;
        margin: 15px 0;
    }
    
    .ad-sidebar {
        height: 120px;
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        order: -1;
    }
    
    .bottom-ad {
        height: 80px;
        font-size: 14px;
    }
    
    .floating-emoji-box {
        position: fixed;
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        min-width: auto;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    .emoji-collector {
        flex: 1 1 100%;
        order: 1;
        min-height: 35px;
        font-size: 14px;
        padding: 8px 12px;
        margin-bottom: 5px;
    }
    
    .emoji-collector:not(:empty):not([data-placeholder]) {
        font-size: 18px;
    }
    
    .copy-all-btn {
        flex: 1 1 calc(60% - 4px);
        order: 2;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .clear-btn {
        flex: 1 1 calc(40% - 4px);
        order: 3;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .copy-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
        text-align: center;
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .copy-notification.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .emoji-section {
        padding: 15px 10px;
    }

    .top-nav-categories {
        gap: 3px;
        padding: 5px;
        margin: 6px 5px 6px 5px;
    }

    .nav-item {
        padding: 8px 10px;
        font-size: 13px;
        height: 34px;
    }
    
    .search-box {
        padding: 10px 12px;
        font-size: 15px;
    }
    
    .category-tabs {
        gap: 4px;
    }
    
    .tab {
        padding: 6px 10px;
        font-size: 13px;
        border-radius: 12px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 6px;
    }
    
    .emoji-item {
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .floating-emoji-box {
        bottom: 5px;
        left: 5px;
        right: 5px;
        padding: 8px;
        gap: 6px;
    }
    
    .emoji-collector {
        min-height: 32px;
        font-size: 13px;
        padding: 6px 10px;
        margin-bottom: 3px;
    }
    
    .emoji-collector:not(:empty):not([data-placeholder]) {
        font-size: 16px;
    }
    
    .copy-all-btn {
        flex: 1 1 calc(65% - 3px);
        padding: 7px 10px;
        font-size: 13px;
    }
    
    .clear-btn {
        flex: 1 1 calc(35% - 3px);
        padding: 7px 10px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 4px;
    }
    
    .emoji-item {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    
    .tab {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .floating-emoji-box {
        padding: 6px;
        gap: 4px;
    }
    
    .emoji-collector {
        min-height: 28px;
        font-size: 12px;
        padding: 5px 8px;
        margin-bottom: 2px;
    }
    
    .emoji-collector:not(:empty):not([data-placeholder]) {
        font-size: 14px;
    }
    
    .copy-all-btn {
        flex: 1 1 calc(70% - 2px);
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .clear-btn {
        flex: 1 1 calc(30% - 2px);
        padding: 6px 8px;
        font-size: 12px;
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .emoji-item {
        transition: all 0.1s ease;
    }
    
    .emoji-item:hover {
        transform: none;
        background: #e9ecef;
    }
    
    .emoji-item:active {
        transform: scale(0.9);
        background: #dee2e6;
    }
    
    .tab:hover {
        background: #f8f9fa;
    }
    
    .tab.active:hover {
        background: #007bff;
    }
}