/* Basic Reset & Full-screen setup */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Hide scrollbars */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    background-color: #000000; /* Ensure a solid black background */
}

/* --- Top Progress Bar --- */
#progress-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px; /* Increased height to accommodate capsule */
    background-color: rgba(0, 0, 0, 0.3); /* Darker semi-transparent background */
    z-index: 2000;
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;

    /* Animation */
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#ads-timer-capsule {
    background-color: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 10px;
    white-space: nowrap;
}
#progress-bar-wraper {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 2.5px;
}
#progress-bar {
    width: 0%; /* Starts at 0% */
    height: 5px; /* The actual bar height */
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.25s linear; /* Faster transition for smoother updates */
    border-radius: 2.5px;
}

#progress-bar-container.visible {
    opacity: 1;
    transform: translateY(0);
}

#fake-close-btn {
    position: fixed;
    right: 20px;
    top: 20px;
    z-index: 99999;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default; /* Initially not clickable */
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.5);
}

#fake-close-btn.ready {
    cursor: pointer;
}

#fake-close-btn.ready:hover {
    transform: scale(1.1);
}

#fake-close-btn.ready:active {
    transform: scale(0.95);
}

#fake-close-btn .countdown-text {
    display: block;
}

#fake-close-btn .close-icon {
    display: none;
    width: 24px;
    height: 24px;
    fill: white;
}

#fake-close-btn.ready .countdown-text {
    display: none;
}

#fake-close-btn.ready .close-icon {
    display: block;
}

/* Game container for the iframe */
#game-container {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
    position: relative; /* Establish a stacking context */
    z-index: 1;         /* Place it at the bottom of the stacking order */
}

#game-container > iframe {
    width: 100%;
    /* Reserve space for the download bar. 60px (bar) + 20px (bottom margin) + 10px (buffer) */
    height: calc(100% - 100px);
    border: none;
}

/* Download Bar at the bottom - Universal Dynamic Island Style */
#download-bar {
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    padding: 10px 15px;
    box-sizing: border-box;
    border-radius: 12px;

    /* Positioning */
    position: fixed;
    z-index: 1000;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 500px;

    /* Glassmorphism Effect */
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);

    /* Animation */
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#download-bar.loaded {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.app-info {
    display: flex;
    align-items: center;
}

.app-icon {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    border-radius: 8px;
}

.app-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.app-name {
    font-weight: bold;
    font-size: 16px;
}


.app-slogan {
    font-size: 12px;
    color: #cccccc;
}

/* 'PLAY REAL' Button - Refined Style */
.play-real-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    font-weight: bold;
    border-radius: 12px;
    font-size: 14px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.play-real-button:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.play-real-button:active {
    transform: scale(0.98);
}

/* --- Floating Game Switcher --- */
#switcher-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1499; /* Below the switcher, but above everything else */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#game-switcher.expanded + #switcher-overlay, /* This is incorrect, overlay should be controlled by switcher's class */
#game-switcher.expanded ~ #switcher-overlay {
    opacity: 1;
    pointer-events: auto;
}

#game-switcher {
    position: fixed;
    bottom: 120px;
    right: 20px;
    z-index: 1500;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#switcher-toggle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(30, 30, 30, 0.65);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    transition: opacity 0.3s ease, transform 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
}

#switcher-toggle-btn:active {
    cursor: grabbing;
}

#switcher-toggle-btn svg {
    width: 24px;
    height: 24px;
    color: white;
}

#switcher-panel {
    position: absolute;
    bottom: 65px; /* Offset from the button (50px height + 15px gap) */
    right: 0;
    max-width: 300px; /* Increased width */
    max-height: 400px;
    padding: 20px;
    border-radius: 25px;
    background: rgba(30, 30, 30, 0.75);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)); /* Increased icon size */
    gap: 20px;
    overflow-y: auto;
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    transform-origin: bottom right; /* Animation originates from the toggle button's corner */
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Expanded State */
#game-switcher.expanded #switcher-toggle-btn {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

#game-switcher.expanded ~ #switcher-overlay {
    opacity: 1;
    pointer-events: auto;
}

#game-switcher.expanded #switcher-panel {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

#switcher-panel a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.game-icon-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 300 / 220;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}

.game-icon-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 60%);
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.1), inset -2px -2px 5px rgba(0, 0, 0, 0.1);
    border-radius: 18px;
    pointer-events: none;
}

#switcher-panel a:hover .game-icon-wrapper {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

#switcher-panel img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 115%;
    height: 115%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#switcher-panel a:hover img {
    transform: translate(-50%, -50%) scale(1.05);
}

.switcher-game-name {
    font-size: 11px;
    color: #e0e0e0;
    margin-top: 8px;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Engagement Popup Styles --- */
#engagement-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.engagement-popup {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 16px;
    max-width: 300px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: popupSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup-app-icon {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    margin: -70px auto 20px;
    display: block;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    background-color: rgba(0,0,0,0.2);
}

.popup-content p {
    color: #e0e0e0;
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 10px 0;
}

.popup-content .app-description {
    font-size: 14px;
    color: #a0a0a0;
    margin-bottom: 25px;
}

.popup-content h2 {
    color: #ffffff;
    font-size: 24px;
    margin: 0 0 15px 0;
    font-weight: bold;
}

.popup-content p {
    color: #e0e0e0;
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 25px 0;
}

.popup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.popup-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.popup-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.popup-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.popup-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.popup-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* --- Click Guide Animation --- */
#click-guide {
    position: absolute;
    display: block;
    left: 50%;
    top: 80%; /* Position at 2/3 of the screen height */
    transform: rotate(-10deg) translate(-50%, -50%);
    z-index: 999999; /* Above the iframe, but below other UI */
    cursor: pointer;
    transition: opacity 0.3s ease;
}

#click-guide.hidden {
    opacity: 0;
    display: none;
}

.hand-icon {
    width: 80px;
    height: 80px;
    color: rgba(255, 255, 255, 0.8);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    animation: tap-animation 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tap-animation {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(0.9);
        opacity: 1;
    }
}

/* --- Voucher Code Bubble --- */
#voucher-bubble {
    position: fixed;
    bottom: 95px; /* Positioned above the download bar (20px bottom + ~60px height + 15px gap) */
    left: 50%;
    transform: translateX(-50%);
    z-index: 999; /* Below the download bar but above other content */
    background: linear-gradient(135deg, #ff4b2b, #ff416c);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(255, 65, 108, 0.4);
    font-size: 14px;
    animation: subtle-bounce 2.5s infinite cubic-bezier(0.68, -0.55, 0.27, 1.55);
    white-space: nowrap;
}

#voucher-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 16px;
    height: 16px;
    background: #ff455c; /* Average of the gradient */
    z-index: -1;
}

.voucher-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voucher-icon {
    width: 24px;
    height: 24px;
    transform: rotate(135deg);
}

#voucher-code {
    font-weight: bold;
}

#copy-voucher-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 15px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    transition: background 0.2s ease, transform 0.2s ease;
}
#copy-voucher-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#copy-voucher-btn:active {
    transform: scale(0.95);
}

#copy-voucher-btn .copy-text.copied {
    color: #a7ffc0; /* Light green to indicate success */
}

@keyframes subtle-bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-8px);
    }
}
