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

body {
    background: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#main-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
}

#game-container {
    position: relative;
    width: min(90vw, 160vh);
    height: min(90vh, 50.625vw);
}

/* PC Ad Container */
#ad-container-pc {
    width: 160px;
    height: 600px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

#ad-placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    text-align: center;
}

/* Hide placeholder when ad loads */
#ad-container-pc .kakao_ad_area[style*="display: block"] ~ #ad-placeholder,
#ad-container-pc .kakao_ad_area:not([style*="display:none"]):not([style*="display: none"]) ~ #ad-placeholder {
    display: none;
}

/* Mobile Ad Container (Inside game area, shown on game over) */
#ad-container-mobile {
    position: absolute;
    top: 50%;
    left: calc(75% - 125px); /* 오른쪽 절반 중앙에 배치 (250px 광고의 절반) */
    transform: translateY(-50%);
    width: 250px;
    height: 250px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

#ad-container-mobile.hidden {
    display: none !important;
}

#ad-placeholder-mobile {
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
}

/* Hide mobile ad placeholder when ad loads */
#ad-container-mobile .kakao_ad_area[style*="display: block"] ~ #ad-placeholder-mobile,
#ad-container-mobile .kakao_ad_area:not([style*="display:none"]):not([style*="display: none"]) ~ #ad-placeholder-mobile {
    display: none;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #16213e;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    pointer-events: none;
}

.mobile-btn {
    pointer-events: auto;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.mobile-btn:active {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

#btn-pause {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
}

#btn-pause:hover {
    background: rgba(0, 0, 0, 0.5);
}

.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    #game-container {
        max-width: 100%;
        border-radius: 0;
    }

    #game-canvas {
        border-radius: 0;
    }

    .mobile-btn {
        width: 70px;
        height: 70px;
        font-size: 12px;
    }
}

/* Touch prevention for game area */
#game-container {
    touch-action: none;
}

/* Portrait Mode Rotate Overlay */
#rotate-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a2e;
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.rotate-content {
    text-align: center;
    color: white;
}

.rotate-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotate-hint 2s infinite ease-in-out;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rotate-content p {
    font-size: 24px;
    margin: 10px 0;
}

.rotate-sub {
    font-size: 16px !important;
    opacity: 0.7;
}

/* PC: hide mobile ad completely */
@media screen and (min-width: 1201px) {
    #ad-container-mobile {
        display: none !important;
    }
}

/* Mobile/Tablet: hide PC ad */
@media screen and (max-width: 1200px) {
    #ad-container-pc {
        display: none;
    }
}

/* Show rotate overlay only on mobile portrait mode */
@media screen and (max-width: 900px) and (orientation: portrait) {
    #rotate-overlay {
        display: flex;
    }

    #game-container {
        display: none;
    }
}
