:root {
    --primary-gradient: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    --accent-color: #667eea;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-color: #333;
    --text-light: #fff;
    --anim-speed: 0.4s;
}

html,
body {
    position: relative;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: #f5f7fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#container {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

/* --- Drawer (OptBox) --- */
.optBox {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 90%;
    max-width: 600px;
    height: 40%;
    /* Lowered from 60% to 40% */
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px 24px 0 0;
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    z-index: 10;
    display: flex;
    flex-direction: column;

    /* Animation State: Default Hidden (pushed down) */
    transform: translateX(-50%) translateY(110%);
    transition: transform var(--anim-speed) cubic-bezier(0.25, 0.8, 0.25, 1);
}

.optBox.up {
    transform: translateX(-50%) translateY(0);
}

.optBox.down {
    transform: translateX(-50%) translateY(110%);
}

/* PERFORMANCE: Hide sphere and pause animation when drawer is closed */
.optBox.down .mainOpt {
    display: none;
    /* Removed from layout completely */
    animation-play-state: paused;
    /* Stop consuming GPU for animation */
}

/* --- Bottom Trigger Bar (.bar) --- */
/* Visible when drawer is closed. Click to open. */
.bar {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 120px;
    height: 30px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 11;
    cursor: pointer;

    /* Centering logic for the handle/wrapper */
    transform: translateX(-50%);
    transition: transform var(--anim-speed) ease, bottom var(--anim-speed) ease;

    display: flex;
    justify-content: center;
    align-items: center;
}

.bar::after {
    content: "";
    width: 40px;
    height: 4px;
    background-color: #ccc;
    border-radius: 2px;
}

/* When drawer opens (.bar.up), hide this bar by pushing it down. 
   WAIT: The logic in JS is:
   click bar -> bar.className = 'bar down'
   click optBar -> bar.className = 'bar up'
   
   Original CSS 'bar down' -> hidden (bottom is negative).
   Original CSS 'bar up' -> visible (bottom is 0).
   
   So 'down' means HIDE (move down). 'up' means SHOW (move up).
*/
.bar.up {
    transform: translateX(-50%) translateY(0);
}

.bar.down {
    transform: translateX(-50%) translateY(150%);
}

/* --- Top Close Bar (.optBar) inside Drawer --- */
/* Visible when drawer is open. Click to close. */
.optBar {
    width: 100%;
    height: 40px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    /* make it overlap with border radius */
    border-radius: 24px 24px 0 0;
}

.optBar::after {
    content: "";
    width: 50px;
    height: 5px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* --- Main Rotating Circle (.mainOpt) --- */
.mainOpt {
    position: absolute;
    top: -50px;
    left: calc(50% - 50px);
    /* Center using calc instead of translate */
    /* transform: translateX(-50%); REMOVED due to conflict with rotation animation on children */
    width: 100px;
    height: 100px;
    background: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
    border-radius: 40%;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    z-index: 20;
    animation: rotateMain 8s linear infinite;
    opacity: 0.9;
}

.mainOpt::before,
.mainOpt::after {
    content: "";
    position: absolute;
    inset: -5px;
    /* Make them slightly larger to create a glow effect relative to core */
    border-radius: 40%;
    z-index: -1;
    opacity: 0.5;
    background: inherit;
    /* Inherit the vibrant gradient from parent */
    filter: blur(8px) brightness(1.2);
    /* Soften and brighten */
}

.mainOpt::before {
    animation: rotateMain 8s linear 2s infinite;
}

.mainOpt::after {
    animation: rotateMain 8s linear 4s infinite;
}

@keyframes rotateMain {
    0% {
        transform: rotate(0deg);
        border-radius: 40%;
    }

    50% {
        transform: rotate(180deg);
        border-radius: 50%;
    }

    100% {
        transform: rotate(360deg);
        border-radius: 40%;
    }
}

/* Info Text inside/over Main Opt */
/* The HTML places .info separate, but previously it was centered. */
.info {
    position: absolute;
    top: -50px;
    left: 0;
    right: 0;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 22;
}


/* --- Controls (Back/Refresh) --- */
.refresh,
.back {
    width: 44px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    position: absolute;
    top: -22px;
    /* Half overlapping top edge */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    font-weight: 600;
    color: #555;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 15;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
}

.back {
    left: 15%;
}

.refresh {
    right: 15%;
}

.refresh:hover,
.back:hover {
    transform: scale(1.15);
    color: var(--accent-color);
    background: white;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.refresh:active,
.back:active {
    transform: scale(0.95);
}

/* --- Main Screen Refresh Button --- */
.main-refresh {
    position: absolute;
    top: 20px;
    left: 20px;
    /* Moved to left to avoid map controls on right */
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    color: #555;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.main-refresh:hover {
    transform: scale(1.1);
    color: var(--accent-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.main-refresh:active {
    transform: scale(0.95);
}

.main-refresh.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

/* --- Options Grid --- */
.opts {
    flex: 1;
    overflow-y: auto;
    padding: 60px 20px 20px;
    /* Top padding to clear the main circle */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    align-content: start;
}

.option {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    padding: 10px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);

    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    user-select: none;

    /* Gradients are applied via inline styles in JS, but we can set a base */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.option:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.option:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* --- Map Elements --- */
.clusterBubble {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    text-align: center;
    /* Gradient handled by JS usually, but here is a nice default */
    background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 90;
    /* Lower than InfoWindow */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.clusterBubble:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

/* InfoWindow Customization */
/* TMap InfoWindow usually sits in an overlay pane with high z-index, but we can enforce style if needed */
.infoWindow {
    width: 220px;
    padding: 0;
    /* ensure it stays on top of cluster bubbles */
    position: relative;
    z-index: 2000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    font-size: 0.9rem;
    color: #333;
    overflow: hidden;
}

.infoWindow img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    background-color: #f0f0f0;
    display: block;
}

.infoWindow>div {
    padding: 10px;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}