/* === Reset and Base Styles === */
:root {
    --popup-top: 118px; /* Fallback for homescreenPopup */
    --content-top: 118px; /* Fallback if needed */
    --banner-height: 7vh; /* Default banner height */
    --text-shadow: -3px -3px 0 #333333, 3px -3px 0 #333333, -3px 3px 0 #333333, 3px 3px 0 #333333,
                   -3px 0 0 #333333, 3px 0 0 #333333, 0 -3px 0 #333333, 0 3px 0 #333333;
}

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

body {
    background-color: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh; /* Dynamic height based on viewport */
    overflow-y: auto; /* Enable scrolling */
    font-family: 'Roboto', Arial, sans-serif;
    overflow-x: hidden;
    position: relative;
}

/* === Canvas Styles === */
canvas {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important; /* Ensure canvas covers full viewport */
    z-index: 0 !important;
}

/* === Banner Styles === */
.banner {
    position: fixed !important;
    top: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 100% !important;
    min-height: var(--banner-height);
    max-height: 125px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    z-index: 10 !important;
    padding: calc(var(--banner-height) * 0.1) 0 !important;
    background-color: rgba(0, 0, 0, 0.8) !important;
    border: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.banner-main {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: calc(var(--banner-height) * 0.1) 0;
    font-size: clamp(20px, 4vw, 32px) !important;
}

.banner-main a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.banner-main-text {
    font-family: 'Anton', 'Impact', sans-serif !important;
    font-style: italic;
    text-shadow: var(--text-shadow);
    font-size: inherit !important;
}

.banner-world {
    font-family: 'Anton', 'Impact', sans-serif !important;
    font-style: italic;
    text-shadow: var(--text-shadow);
    font-size: inherit !important;
}

.banner-subtitle {
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: clamp(10px, 2vw, 14px) !important;
    margin: 0;
}

/* === Gradient Bar Styles === */
html .gradient-bar {
    position: fixed !important;
    top: calc(var(--banner-height) + 10px) !important; /* Dynamic positioning */
    left: 0 !important;
    width: 100vw !important;
    height: 1vh !important;
    max-height: 12px !important;
    background: linear-gradient(to right, #333 0%, #999 50%, #333 100%) !important;
    background-size: 200% 100% !important;
    animation: gradientMove 5s linear infinite !important;
    z-index: 7 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* === Animation for Gradient Bar === */
@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* === Navigation Bar Styles === */
.nav-bar {
    position: fixed !important;
    top: calc(var(--banner-height) + 28px) !important; /* Dynamic positioning */
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    gap: 0 !important;
    background-color: #000 !important;
    padding: 5px 0 !important;
    z-index: 8 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.nav-bar a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid grey;
    color: #fff;
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: 7pt;
    padding: 8px;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    position: relative;
}

.nav-bar a:hover { color: lightgrey; }
.nav-bar a.active { background-color: #1a1a1a; }
.nav-bar a.nav-flash { animation: navFlash 0.5s ease-in-out; }

@keyframes navFlash {
    0% { background-color: rgba(64, 64, 64, 0.7); }
    100% { background-color: transparent; }
}

.options-box {
    display: none;
    position: absolute;
    top: 100%;
    left: -1px;
    width: calc(100% + 2px);
    background-color: #000;
    border: 1px solid grey;
    color: #fff;
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: 7pt;
    padding: 8px;
    text-align: center;
    text-transform: uppercase;
    cursor: pointer;
    z-index: 4;
}

.options-box.active {
    display: block !important;
}

/* === Hamburger Menu Styles === */
.hamburger-button {
    position: fixed;
    top: 10px;
    left: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 11 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.hamburger-button span {
    display: block;
    width: 25px;
    height: 3px;
    background: #fff;
    margin: 5px 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger-button.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger-button.active span:nth-child(2) { opacity: 0; }
.hamburger-button.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.hamburger-menu {
    position: fixed;
    top: 0;
    left: -200px; /* Ensure hidden by default */
    width: 200px;
    height: 100vh;
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    padding: 60px 20px 20px;
    transition: left 0.3s ease;
    z-index: 11 !important;
    opacity: 1 !important;
    visibility: hidden !important; /* Hidden until active */
}

.hamburger-menu.active {
    left: 0;
    visibility: visible !important;
}

.hamburger-menu a, .hamburger-menu button {
    color: #fff;
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: 12pt;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    margin: 10px 0;
    cursor: pointer;
}

.hamburger-menu a:hover, .hamburger-menu button:hover { color: lightgrey; }

/* === Popup Base Styles === */
.popup {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
    max-width: 500px;
    min-height: 450px;
    max-height: calc(80vh - var(--trigger-bottom, 0px) - 20px); /* Dynamic max-height */
    background-color: #fff;
    color: #000;
    border: 1px solid #fff; /* 1px white border for other popups */
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 20px; /* Default outer padding for other popups */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.17s ease-in-out;
    z-index: 6 !important;
}

.popup.active {
    opacity: 1;
    pointer-events: auto;
}

/* === Other Popup Styles === */
.popup:not(#timerPopup) {
    overflow-y: auto; /* Scroll for other popups */
}

.popup:not(#timerPopup) .popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: 12pt;
    text-align: center;
}

.popup:not(#timerPopup) .popup-heading {
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: 16pt;
    margin-bottom: 20px;
}

.popup:not(#timerPopup) .popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: grey;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 7pt;
    text-transform: uppercase;
    cursor: pointer;
}

.popup:not(#timerPopup) .popup-close:hover {
    background-color: darkgrey;
}

/* Custom scrollbar for other popups */
.popup:not(#timerPopup)::-webkit-scrollbar {
    width: 8px;
}

.popup:not(#timerPopup)::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.popup:not(#timerPopup)::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.popup:not(#timerPopup)::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#homescreenPopup {
    top: var(--popup-top); /* Fallback for homescreenPopup */
}

#homescreenPopup {
    border-color: grey;
}

/* === Content Container Styles === */
.content-container {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%; /* Ensure full width */
    max-width: 100vw;
    z-index: 2 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.button-container {
    background-color: rgba(0, 0, 0, 0.01);
    border-radius: 10px;
    max-width: calc(100vw - 20px);
    padding: 20px;
    opacity: 0;
    display: none;
}

.button-container.active {
    display: block !important;
    opacity: 1 !important;
    max-height: calc(80vh - var(--trigger-bottom, 0px) - 20px); /* Dynamic max-height for most containers */
    overflow-y: auto; /* Enable internal scrolling */
}

/* Custom scrollbar for content containers */
.button-container::-webkit-scrollbar {
    width: 8px;
}

.button-container::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

.button-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.button-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* === Animation Styles === */
@keyframes pulse-shadow {
    0% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(76, 175, 80, 0.7); }
    50% { box-shadow: 0 0 calc(15px * var(--shadow-size)) calc(5px * var(--shadow-size)) rgba(76, 175, 80, 0.9); }
    100% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(76, 175, 80, 0.7); }
}

@keyframes pulse-shadow-yellow {
    0% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(255, 255, 0, 0.7); }
    50% { box-shadow: 0 0 calc(15px * var(--shadow-size)) calc(5px * var(--shadow-size)) rgba(255, 255, 0, 0.9); }
    100% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(255, 255, 0, 0.7); }
}

@keyframes pulse-shadow-red {
    0% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(255, 0, 0, 0.7); }
    50% { box-shadow: 0 0 calc(15px * var(--shadow-size)) calc(5px * var(--shadow-size)) rgba(255, 0, 0, 0.9); }
    100% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(255, 0, 0, 0.7); }
}

@keyframes pulse-shadow-rest {
    0% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(255, 255, 255, 0.7); }
    50% { box-shadow: 0 0 calc(15px * var(--shadow-size)) calc(5px * var(--shadow-size)) rgba(255, 255, 255, 0.9); }
    100% { box-shadow: 0 0 calc(5px * var(--shadow-size)) calc(2px * var(--shadow-size)) rgba(255, 255, 0.7); }
}

.animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1 !important;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent !important;
    pointer-events: none;
}

.swirl {
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    background: conic-gradient(rgba(255, 255, 255, 0.07), transparent, rgba(255, 255, 255, 0.07), transparent);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
}

@media (min-width: 1024px) {
    .swirl { display: none; }
}

.flash { animation: radialFlashFade 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards; }
.swirl-active { animation: swirlEffect 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards; }

@keyframes radialFlashFade {
    0%, 5% { background: rgba(255, 255, 255, 0.12); }
    6%, 11% { background: transparent; }
    12%, 17% { background: rgba(255, 255, 255, 0.08); }
    18%, 23% { background: transparent; }
    24%, 29% { background: rgba(255, 255, 255, 0.04); }
    30% { background: radial-gradient(circle at var(--x) var(--y), rgba(255, 255, 255, 0.07) 0%, transparent 10%); }
    40% { background: radial-gradient(circle at var(--x) var(--y), rgba(255, 255, 255, 0.07) 100%, rgba(255, 255, 255, 0.07) 100%); }
    100% { background: radial-gradient(circle at var(--x) var(--y), transparent 100%, transparent 100%); }
}

@keyframes swirlEffect {
    0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 1; }
    20% { transform: translate(-50%, -50%) scale(10) rotate(360deg); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(10) rotate(720deg); opacity: 0; }
}

/* === Bottom Bar Styles === */
.bottom-bar {
    position: fixed !important;
    bottom: 58px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 98.5vw !important;
    height: 10px !important;
    background: linear-gradient(to right, #000000 80%, #8B0000 80%, #8B0000 90%, #000000 90%) !important;
    border: 1px solid rgb(64, 64, 64) !important;
    border-radius: 3px !important;
    z-index: 6 !important; /* Match floating-bar */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* === Floating Bar Styles === */
.floating-bar {
    position: fixed !important;
    bottom: 5px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 98.5vw !important;
    height: 50px !important;
    background-color: #000 !important;
    border: 1px solid rgb(64, 64, 64) !important;
    border-radius: 5px !important;
    box-shadow: 0 -5px 10px rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 5px !important;
    z-index: 6 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.floating-bar-text {
    font-family: 'Roboto', Arial, sans-serif !important;
    font-weight: 400;
    font-size: 12px;
    text-align: center;
    color: #fff !important;
}

/* === Media Query for Samsung Mobile Devices === */
@media only screen and (max-device-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    .banner {
        min-height: 80px !important; /* Override for Samsung devices */
    }
    html .gradient-bar {
        top: calc(80px + 10px) !important; /* Adjust for Samsung */
    }
    .nav-bar {
        top: calc(80px + 28px) !important; /* Adjust for Samsung */
    }
}