/* styles.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: #000;
    overflow-x: hidden;
    min-height: 100vh;
}

/* 메인 광고 그리드 컨테이너 */
.ad-grid-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    background: #111;
}

/* 광고 존 공통 스타일 */
.ad-zone {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 상단/하단 배너존 */
.top-banner-zone, .bottom-banner-zone {
    background: #222;
    padding: 10px;
}

/* 메인 광고 그리드 */
.main-ad-grid {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 5px;
    flex: 1;
    min-height: 80vh;
}

/* 광고 컬럼 */
.ad-column {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #1a1a1a;
    padding: 5px;
}

/* 중앙 광고 매트릭스 */
.center-matrix {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #1a1a1a;
    padding: 5px;
}

/* 광고 행 */
.ad-row {
    display: flex;
    gap: 5px;
    flex: 1;
}

.triple-row {
    justify-content: space-between;
}

.quad-row {
    justify-content: space-between;
}

/* 광고 아이템 기본 스타일 */
.ad-item {
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
    border: 2px solid #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.ad-item:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    z-index: 10;
}

.ad-item:nth-child(even) {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.ad-item:nth-child(3n) {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.ad-item:nth-child(4n) {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.ad-item:nth-child(5n) {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
}

/* 광고 콘텐츠 */
.ad-content {
    color: white;
    font-weight: bold;
    text-align: center;
    font-size: 14px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    z-index: 1;
}

/* 광고 크기별 스타일 */
.large-banner {
    min-width: 728px;
    height: 90px;
    flex: 1;
}

.medium-ad {
    width: 300px;
    height: 250px;
}

.small-ad {
    width: 200px;
    height: 150px;
    flex: 1;
}

.mini-ad {
    width: 150px;
    height: 100px;
    flex: 1;
}

.square-ad {
    width: 250px;
    height: 250px;
}

.rectangle-ad {
    min-width: 300px;
    height: 200px;
    flex: 1;
}

.vertical-ad {
    width: 120px;
    height: 600px;
}

.wide-ad {
    width: 100%;
    height: 150px;
}

/* 플로팅 광고 */
.floating-ads {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.floating-ad {
    position: absolute;
    width: 100px;
    height: 100px;
    background: linear-gradient(45deg, #ff9a9e, #fecfef);
    border: 3px solid #fff;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    animation: float 3s ease-in-out infinite;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.floating-ad.top-left {
    top: 20px;
    left: 20px;
    animation-delay: 0s;
}

.floating-ad.top-right {
    top: 20px;
    right: 20px;
    animation-delay: 0.5s;
}

.floating-ad.bottom-left {
    bottom: 20px;
    left: 20px;
    animation-delay: 1s;
}

.floating-ad.bottom-right {
    bottom: 20px;
    right: 20px;
    animation-delay: 1.5s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-10px) rotate(2deg); }
    66% { transform: translateY(5px) rotate(-2deg); }
}

.close-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
}

/* 모바일 광고 스택 (PC에서 숨김) */
.mobile-ad-stack {
    display: none;
}

.mobile-sticky-bottom {
    display: none;
}

/* 반응형 - 태블릿 */
@media (max-width: 1200px) {
    .main-ad-grid {
        grid-template-columns: 200px 1fr 200px;
    }
    
    .ad-column {
        width: 200px;
    }
    
    .large-banner {
        min-width: 500px;
    }
}

/* 반응형 - 모바일 */
@media (max-width: 768px) {
    body {
        margin-bottom: 60px;
    }
    
    .ad-grid-container {
        display: none; /* PC 광고 숨김 */
    }
    
    .floating-ads {
        display: none; /* 플로팅 광고 숨김 */
    }
    
    /* 모바일 전용 광고 스택 표시 */
    .mobile-ad-stack {
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 5px;
        background: #111;
        min-height: 100vh;
    }
    
    .mobile-ad-item {
        background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
        border: 2px solid #fff;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100px;
        margin: 2px 0;
        box-shadow: 0 3px 10px rgba(0,0,0,0.3);
        cursor: pointer;
        transition: transform 0.3s ease;
    }
    
    .mobile-ad-item:hover {
        transform: scale(1.02);
    }
    
    .mobile-ad-item:nth-child(even) {
        background: linear-gradient(135deg, #667eea, #764ba2);
    }
    
    .mobile-ad-item:nth-child(3n) {
        background: linear-gradient(135deg, #f093fb, #f5576c);
    }
    
    .mobile-ad-item.small {
        flex: 1;
        min-height: 80px;
    }
    
    .mobile-ad-item.large {
        min-height: 200px;
    }
    
    .mobile-ad-row {
        display: flex;
        gap: 5px;
    }
    
    /* 모바일 하단 고정 광고 */
    .mobile-sticky-bottom {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(135deg, #ff9a9e, #fecfef);
        border-top: 3px solid #fff;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        box-shadow: 0 -3px 15px rgba(0,0,0,0.3);
    }
    
    .mobile-sticky-bottom .ad-content {
        color: white;
        font-weight: bold;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    }
    
    .mobile-sticky-bottom .close-btn {
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }
}

/* 매우 작은 모바일 화면 */
@media (max-width: 480px) {
    .mobile-ad-item {
        min-height: 80px;
        margin: 1px 0;
    }
    
    .mobile-ad-item.large {
        min-height: 150px;
    }
    
    .mobile-sticky-bottom {
        height: 50px;
    }
    
    body {
        margin-bottom: 50px;
    }
}

/* 광고 로딩 애니메이션 */
.ad-loading {
    position: relative;
    overflow: hidden;
}

.ad-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
    z-index: 2;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* 광고 펄스 효과 */
.ad-pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 매우 큰 화면 대응 */
@media (min-width: 1920px) {
    .main-ad-grid {
        grid-template-columns: 400px 1fr 400px;
    }
    
    .large-banner {
        min-width: 970px;
        height: 120px;
    }
    
    .ad-item {
        font-size: 16px;
    }
}


/* 추가 CSS 효과들 */

/* 파티클 애니메이션 */
@keyframes particleFloat {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-50px) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* 흔들기 효과 */
.shake-effect {
    animation: shake 1s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-10px) rotate(-1deg); }
    20% { transform: translateX(10px) rotate(1deg); }
    30% { transform: translateX(-10px) rotate(-1deg); }
    40% { transform: translateX(10px) rotate(1deg); }
    50% { transform: translateX(-5px) rotate(-0.5deg); }
    60% { transform: translateX(5px) rotate(0.5deg); }
    70% { transform: translateX(-5px) rotate(-0.5deg); }
    80% { transform: translateX(5px) rotate(0.5deg); }
    90% { transform: translateX(-2px) rotate(-0.2deg); }
}

/* 터치 중 효과 */
.touching {
    filter: brightness(1.2);
    transform: scale(1.02) !important;
}

/* 카운터 애니메이션 */
@keyframes counterBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: #ffff00; }
    100% { transform: scale(1); }
}

/* 소리 표시기 */
.sound-indicator {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 5px;
    border-radius: 10px;
    font-size: 12px;
    animation: soundPulse 0.5s ease-in-out infinite alternate;
}

@keyframes soundPulse {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.1); }
}

/* 전면 팝업 광고 */
.fullscreen-popup-ad {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background: white;
    width: 90%;
    max-width: 600px;
    height: 80%;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    animation: popupZoomIn 0.5s ease;
}

@keyframes popupZoomIn {
    0% { transform: scale(0.5) rotate(180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.popup-header {
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.popup-header h2 {
    margin: 0;
    font-size: 24px;
    animation: textGlow 1s ease-in-out infinite alternate;
}

@keyframes textGlow {
    0% { text-shadow: 0 0 5px #fff; }
    100% { text-shadow: 0 0 20px #fff, 0 0 30px #fff; }
}

.popup-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    font-weight: bold;
}

.popup-body {
    padding: 20px;
    height: calc(100% - 80px);
    overflow-y: auto;
}

.popup-main-ad {
    height: 200px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    border-radius: 10px;
    margin-bottom: 20px;
    animation: popupAdPulse 2s ease-in-out infinite;
}

@keyframes popupAdPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(102, 126, 234, 0.5); }
    50% { transform: scale(1.02); box-shadow: 0 0 40px rgba(102, 126, 234, 0.8); }
}

.popup-sub-ads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.popup-sub-ad {
    height: 100px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.popup-sub-ad:hover {
    transform: scale(1.05);
}

/* 통계 디스플레이 개선 */
.stats-display {
    border: 2px solid #4ecdc4;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
}

.stats-item {
    margin: 5px 0;
    padding: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.stats-item:last-child {
    border-bottom: none;
}

/* 광고 로딩 상태 개선 */
.ad-loading {
    opacity: 0.7;
    pointer-events: none;
}

.ad-loaded {
    animation: adFadeIn 0.8s ease forwards;
}

@keyframes adFadeIn {
    0% { 
        opacity: 0; 
        transform: scale(0.8) rotateY(90deg);
    }
    100% { 
        opacity: 1; 
        transform: scale(1) rotateY(0deg);
    }
}

/* 모바일 최적화 추가 */
@media (max-width: 768px) {
    .popup-content {
        width: 95%;
        height: 85%;
    }
    
    .popup-header h2 {
        font-size: 20px;
    }
    
    .popup-main-ad {
        height: 150px;
        font-size: 18px;
    }
    
    .popup-sub-ad {
        height: 80px;
        font-size: 14px;
    }
    
    .stats-display {
        font-size: 10px;
        padding: 8px;
    }
}

/* 극도로 작은 화면 */
@media (max-width: 480px) {
    .floating-ad {
        width: 60px;
        height: 60px;
        font-size: 10px;
    }
    
    .mobile-sticky-bottom {
        height: 45px;
    }
    
    .popup-content {
        height: 90%;
    }
    
    body {
        margin-bottom: 45px;
    }
}

/* 고성능 애니메이션을 위한 GPU 가속 */
.ad-item,
.mobile-ad-item,
.floating-ad {
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* 광고 중요도 표시 */
.ad-item::after {
    content: '🔥';
    position: absolute;
    top: -5px;
    left: -5px;
    font-size: 16px;
    animation: fireBounce 1s ease-in-out infinite alternate;
}

@keyframes fireBounce {
    0% { transform: scale(1) rotate(-5deg); }
    100% { transform: scale(1.2) rotate(5deg); }
}

/* 무한 스크롤 로딩 표시기 */
.loading-more-ads {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 16px;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}