body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: sans-serif;
}

img {
    -webkit-user-drag: none;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none; /* Disables the touch menu (Save Image) on iOS */
    pointer-events: auto; /* Ensure clicks still work for interactive elements */
}

/* Loader */
#loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffd332, #912af7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out;
}

#loader-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

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

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid white;
    border-top: 6px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

#loading-text {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

.split {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.left {
    background-color: #ffd332;
}

.right {
    background-color: #912af7;
}

.bg-pattern-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    opacity: 0.2; /* Reduced opacity to 20% */
}

.bg-tile {
    font-size: 50px;
    font-weight: bold;
    color: white;
    padding: 15px; /* Increased padding to reduce density */
    margin: 0;
    user-select: none;
    line-height: 1; /* Increased line height */
}

.bottom-ui-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.contract-card {
    position: absolute;
    bottom: 12%; /* Increased from 8% to move it up */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    width: 95%;
    max-width: 1200px;
    pointer-events: auto; /* Ensure interaction works */
    background: white;
    padding: 15px 40px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    font-weight: bold;
    font-size: 1.5rem;
    white-space: nowrap;
    border: 8px solid #000;
    gap: 10px;
    transition: transform 0.2s, background-color 0.2s;
}

.ca-group {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative; /* For tooltip positioning */
    flex-grow: 1; /* Allow it to take available space */
}

.ca-group:active {
    transform: scale(0.98);
}

.social-links {
    display: flex;
    align-items: center;
    gap: 15px;
}

.social-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    transition: transform 0.2s;
    display: block; /* Remove inline spacing */
}

.social-icon:hover {
    transform: rotate(360deg) scale(1.1);
    transition: transform 0.5s ease-in-out;
}

.contract-card:active {
    /* Removed global active state */
}

.copy-btn {
    background-color: #000;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.copy-btn:hover {
    background-color: #333;
}

.copy-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.copy-tooltip.show {
    opacity: 1;
}

.official-label {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: auto;
    bottom: calc(12% + 43px); /* Updated to match new card position (12% + half height) */
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 25;
    width: auto;
    max-width: 40%;
    pointer-events: none; /* Allow clicking through to the card */
}

.label-img {
    max-width: 100%;
    height: auto;
    max-height: 50px; /* Reduced from 80px */
    display: block;
    transition: opacity 0.1s ease-in-out;
}

.tap-counter {
    position: absolute;
    top: 30%;
    left: 30px;
    font-size: 3rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.9);
    z-index: 12;
    pointer-events: none;
    font-family: sans-serif;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.1s, opacity 0.3s;
    opacity: 0; /* Hidden by default */
}

.tap-counter::after {
    display: block;
    font-size: 1.2rem;
    letter-spacing: 1px;
    margin-top: 5px; /* Added margin for spacing */
    opacity: 0.9;
}

#cz-counter::after {
    content: "CZ TAP COUNTER";
}

#toby-counter::after {
    content: "TOLY TAP COUNTER";
}

.tap-counter.show {
    opacity: 1;
}

.tap-counter.bump {
    transform: scale(1.2);
    color: #ffffff;
}

.speech-bubble {
    position: absolute;
    top: 10%; /* Moved slightly up */
    left: 50%;
    transform: translateX(-50%) scale(0.5) rotate(-5deg); /* Start small and rotated */
    background: #fff;
    color: #000;
    padding: 15px 30px;
    border-radius: 50%; /* Oval shape */
    font-weight: 900;
    font-size: 1.4rem;
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    z-index: 20;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Fast pop-in */
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 5px 5px 0px #000; /* Hard shadow */
    border: 3px solid #000;
    text-transform: uppercase;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 15px 15px 0;
    border-style: solid;
    border-color: #000 transparent transparent transparent;
    z-index: -1;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -11px; /* Inner white triangle */
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    z-index: 1;
}

.speech-bubble.bullying {
    background: #ffeb3b; /* Yellow background for bullying/idle talk */
    border-color: #000;
    font-size: 1.1rem;
    padding: 10px 20px;
    z-index: 18; /* Slightly lower than tap bubbles */
}

.speech-bubble.bullying::before {
    border-color: #ffeb3b transparent transparent transparent;
}

.speech-bubble.show {
    opacity: 1;
    transform: translateX(-50%) scale(1) rotate(0deg);
}

.main-img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    position: relative;
    z-index: 10;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
    cursor: pointer;
    transition: transform 0.1s;
}

.main-img:active,
.main-img.tapped {
    transform: scale(0.95);
}

.animated-img {
    position: absolute;
    max-width: 30%; /* Reduced size slightly to fit better in corner */
    max-height: 30%;
    z-index: 11;
    /* Position top-left */
    top: 20px;
    left: 20px;
}

.bg-tweet {
    position: absolute;
    max-width: 35%; /* Reduced from 45% */
    z-index: 6; /* Behind main image (10) but above pattern (0) */
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.tweet-left {
    top: 5%;
    right: 2%;
}

.tweet-right {
    top: 5%;
    right: 2%;
}

/* Rain Animation */
#rain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.rain-drop {
    position: absolute;
    top: -100px;
    opacity: 1; /* Changed from 0.8 to 1 (100%) */
    animation: rainFall linear infinite;
}

@keyframes rainFall {
    0% {
        transform: translateY(-100px);
    }
    100% {
        transform: translateY(110vh);
    }
}

/* Keyframes for animation */
@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
    100% {
        transform: translateY(0px);
    }
}

.floating {
    animation: float 3s ease-in-out infinite;
}

/* Vibration Animation */
@keyframes vibrate {
    0% { transform: translate(0); }
    20% { transform: translate(-5px, 5px); }
    40% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    80% { transform: translate(5px, -5px); }
    100% { transform: translate(0); }
}

@keyframes mild-vibrate {
    0% { transform: translate(0); }
    25% { transform: translate(-2px, 2px); }
    50% { transform: translate(2px, -2px); }
    75% { transform: translate(-2px, -2px); }
    100% { transform: translate(0); }
}

.main-img.annoyed {
    transform: scale(1.05);
    animation: mild-vibrate 0.4s linear infinite;
}

.main-img.annoyed:active,
.main-img.annoyed.tapped {
    transform: scale(1.0);
}

.main-img.angry {
    filter: drop-shadow(0 10px 20px rgba(255, 0, 0, 0.6)) sepia(100%) hue-rotate(-50deg) saturate(400%);
    transform: scale(1.1);
    animation: vibrate 0.2s linear infinite;
}

.main-img.angry:active {
    transform: scale(1.05); /* Slightly smaller than base angry scale */
}

/* Shattered Animation */
@keyframes shatter {
    0% { transform: translate(0) rotate(0) scale(1.1); filter: hue-rotate(0deg); }
    25% { transform: translate(-10px, 10px) rotate(-5deg) scale(1.2); filter: hue-rotate(90deg); }
    50% { transform: translate(10px, -10px) rotate(5deg) scale(1.1); filter: hue-rotate(180deg) invert(1); }
    75% { transform: translate(-10px, -10px) rotate(-5deg) scale(1.3); filter: hue-rotate(270deg); }
    100% { transform: translate(10px, 10px) rotate(5deg) scale(1.1); filter: hue-rotate(360deg); }
}

.main-img.shattered {
    animation: shatter 0.1s linear infinite; /* Extremely fast chaotic movement */
    opacity: 0.8;
    border-radius: 0; /* Remove smooth edges */
    clip-path: polygon(
        20% 0%, 0% 20%, 30% 50%, 0% 80%, 20% 100%, 50% 70%, 80% 100%, 100% 80%, 70% 50%, 100% 20%, 80% 0%, 50% 30%
    ); /* jagged edges look */
}

/* Mobile Responsive Design */
@media (max-width: 1024px), (orientation: portrait) {
    .container {
        flex-direction: column;
    }

    .split {
        width: 100%;
        height: 50%;
    }

    .contract-card {
        position: absolute;
        width: 85%; /* Decreased width from 95% */
        padding: 18px 40px; /* Increased vertical padding for height */
        border-width: 3px;
        bottom: 5%;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row; /* Keep horizontal */
        gap: 5px;
        box-sizing: border-box; /* Ensure padding doesn't increase width */
        z-index: 20;
    }

    .ca-group {
        width: auto;
        justify-content: flex-start;
        font-size: 0.9rem; /* Increased from 0.8rem */
        flex: 1;
        min-width: 0;
    }

    #ca-text {
        font-size: 0.85rem; /* Increased from 0.75rem */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .copy-btn {
        padding: 6px 14px; /* Increased padding */
        font-size: 0.8rem; /* Increased font size */
    }

    .social-links {
        width: auto;
        justify-content: flex-end;
        gap: 8px;
        flex-shrink: 0;
    }

    .social-icon {
        width: 32px; /* Increased from 25px */
        height: 32px; /* Increased from 25px */
    }

    .main-img {
        max-width: 85%; /* Reduced from 95% to be balanced */
        max-height: 85%; /* Reduced from 95% to be balanced */
    }

    .speech-bubble {
        top: 2%; /* Moved up for mobile */
        font-size: 1rem; /* Increased from 0.85rem */
        padding: 10px 20px; /* Increased padding */
        transform: translateX(-50%) scale(0.5) rotate(-5deg);
    }

    .speech-bubble.bullying {
        font-size: 0.9rem; /* Increased from 0.8rem */
        padding: 8px 15px;
    }

    .speech-bubble.show {
        transform: translateX(-50%) scale(0.85) rotate(0deg); /* Increased scale from 0.7 */
    }

    .official-label {
        /* Mobile overrides */
        position: absolute;
        top: auto;
        bottom: 56%; /* 50% + 6% (12% of 50vh) */
        width: 80%;
        max-width: none;
        padding: 10px 15px;
        transform: translateX(-50%);
        /* Re-adding card styles for mobile */
        background: white;
        border-radius: 50px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        border: 3px solid #000;
        left: 50%;
    }

    .label-img {
        max-height: 50px; /* Limit height for mobile */
    }

    .rain-drop {
        max-width: 30px; /* Cap rain drop size on mobile */
    }

    .tweet-left, .tweet-right {
        top: 3%; /* Move up */
        right: 0%; /* Move to right side */
        max-width: 35%; /* Slightly smaller to avoid crowding */
    }

    .tap-counter {
        font-size: 2rem; /* Reduced from 3rem */
        left: 20px; /* Adjust position slightly */
        top: 25%;
    }

    .tap-counter::after {
        font-size: 0.8rem; /* Reduced from 1.2rem */
        letter-spacing: 0.5px;
    }
}
