:root {
    /* Base size that will be used for scaling calculations */
    --base-font-size: 1rem;
    --base-spacing: 1rem;
}

@media (max-width: 768px) {
    :root {
        --base-font-size: 0.8rem;
        --base-spacing: 0.8rem;
    }
}

@media (max-width: 480px) {
    :root {
        --base-font-size: 0.7rem;
        --base-spacing: 0.6rem;
    }
}

html {
    /* Ensure 100% height works properly on mobile */
    height: -webkit-fill-available;
}

html, body {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    /* Fix for mobile browsers */
    min-height: -webkit-fill-available;
    margin: 0;
    padding: 0;
    /* A dark background makes the colors pop */
    background-color: #1a1a1a;
    /* Hide scrollbars that might appear from rotated text */
    overflow: hidden; /* keep names inside viewport */
    /* avoid position:fixed so the site can be accessible and responsive */
    position: relative;
    /* Prevent text selection on mobile */
    -webkit-user-select: none;
    user-select: none;
    /* Prevent iOS tap highlight */
    -webkit-tap-highlight-color: transparent;
    /* Prevent any elastic scrolling on iOS */
    overscroll-behavior: none;
}

/* This is the style for each repeating name */
.name-span {
    position: absolute;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0.9;
    transform: translate(-50%, -50%) rotate(var(--rotation));
    /* Smooth transition for all properties that change */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    /* Better touch target size */
    padding: calc(var(--base-spacing) / 2);
}

/* Respect reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .name-span {
        transition: none;
    }
}

/* Floating action button (bottom-right) */
.fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    /* Very high z-index so transformed/stacked name spans cannot cover it */
    z-index: 2147483647;
    pointer-events: auto;
    cursor: pointer;
    padding: 6px;
    backdrop-filter: blur(6px);
}

.fab:hover {
    background: rgba(255,255,255,0.06);
}

.fab svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

/* Hover and touch effects! */
.name-span:hover,
.name-span:active {
    transform: translate(-50%, -50%) scale(1.15) rotate(var(--rotation));
    opacity: 1; /* Make it fully opaque */
    z-index: 10; /* Bring hovered/touched element to front */
    cursor: pointer; /* Indicate it's interactive */
}

/* Persistent selected state (click/tap/keyboard) mirrors hover */
.name-span.selected {
    transform: translate(-50%, -50%) scale(1.15) rotate(var(--rotation));
    opacity: 1;
    z-index: 1500; /* keep below the FAB but above other names */
    cursor: pointer;
}

/* Optimized outline effect for different screen sizes */
@media (min-width: 769px) {
    .name-span:hover {
        text-shadow: 
            -1px -1px 0 #fff,  
             1px -1px 0 #fff,
            -1px  1px 0 #fff,
             1px  1px 0 #fff,
            -2px -2px 0 #fff,  
             2px -2px 0 #fff,
            -2px  2px 0 #fff,
             2px  2px 0 #fff;
    }
    .name-span.selected {
        text-shadow: 
            -1px -1px 0 #fff,  
             1px -1px 0 #fff,
            -1px  1px 0 #fff,
             1px  1px 0 #fff,
            -2px -2px 0 #fff,  
             2px -2px 0 #fff,
            -2px  2px 0 #fff,
             2px  2px 0 #fff;
    }
}

@media (max-width: 768px) {
    .name-span:active {
        text-shadow: 
            -0.5px -0.5px 0 #fff,  
             0.5px -0.5px 0 #fff,
            -0.5px  0.5px 0 #fff,
             0.5px  0.5px 0 #fff,
            -1px -1px 0 #fff,  
             1px -1px 0 #fff,
            -1px  1px 0 #fff,
             1px  1px 0 #fff;
    }
    .name-span.selected {
        text-shadow: 
            -0.5px -0.5px 0 #fff,  
             0.5px -0.5px 0 #fff,
            -0.5px  0.5px 0 #fff,
             0.5px  0.5px 0 #fff,
            -1px -1px 0 #fff,  
             1px -1px 0 #fff,
            -1px  1px 0 #fff,
             1px  1px 0 #fff;
    }
}