/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
    /* Colors */

    /* Deep Blue Radial (darker center, lighter edges) */
    --bg-dark: #0a0e1a;
    --bg-surface: #131b2e;
    --bg-surface-light: #1a2742;

    --primary-gold: #fcab3b;
    --dark-gold: #d88c1f;
    --accent-gold: #fdc15e;
    --text-white: #ffffff;
    --text-gray: #9ca3af;
    --gold: #fcab3b;
    --gold-dark: #e89525;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --radius-pill: 50rem;

    /* Fonts */
    --font-display: "Nabla", system-ui, sans-serif;
    --font-body: "JetBrains Mono", monospace;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-gold: 0 0 30px rgba(255, 215, 0, 0.4);
    --shadow-glow-gold-strong: 0 0 40px rgba(255, 215, 0, 0.6);
}

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

html {
    scroll-behavior: smooth;
    background-color: var(--bg-dark);
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-surface) 100%);
    color: var(--text-white);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========================================
   Floating Header
   ======================================== */
.floating-header {
    position: fixed;
    top: var(--spacing-md);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 1400px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: rgba(19, 27, 46, 0.85);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 40px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: var(--spacing-md);
}

.nav-link {
    color: var(--text-white);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-pill);
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: var(--dark-gold);
    color: var(--primary-gold);
}

a {
    text-decoration: none;
}

/* ========================================
   Hero Section
   ======================================== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, var(--bg-dark) 0%, #131e36 100%);
}

.hero-content {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xl);
    max-width: 1400px;
    width: 100%;
    align-items: center;
}

.hero-text {
    padding: var(--spacing-lg);
    z-index: 1;
}

.hero-title {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.title-main {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 6rem);
    background: linear-gradient(135deg, var(--primary-gold), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.5;
    letter-spacing: 0.6rem;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
    animation: titleGlow 4s ease-in-out infinite;
}

@keyframes titleGlow {
    0%,
    100% {
        text-shadow: 0 0 3px rgba(255, 153, 0, 0.6), 0 0 3px rgba(255, 153, 0, 0.4), 0 0 3px rgba(255, 153, 0, 0.2);
    }

    50% {
        text-shadow: 0 0 7px rgba(255, 153, 0, 1), 0 0 7px rgba(255, 153, 0, 0.8), 0 0 7px rgba(255, 153, 0, 0.6);
    }
}

.title-sub {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 600;
    color: var(--text-white);
}

.hero-description {
    font-size: 1.1rem;
    color: var(--text-gray);
    line-height: 1.8;
}

.cta-button {
    padding: var(--spacing-md) var(--spacing-xl);
    background: linear-gradient(135deg, var(--primary-gold), var(--accent-gold));
    color: var(--bg-dark);
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glow-gold);
}

.cta-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 40px rgba(255, 153, 0, 0.5);
}

.cta-button:active {
    transform: translateY(0) scale(1);
}

/* ========================================
   Hero Visual & Three.js Container
   ======================================== */
.hero-visual {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

#threejs-container {
    position: relative;
    top: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    max-width: 1400px;
}

#threejs-container canvas {
    display: block;
    outline: none;
    width: 100% !important;
    height: 100% !important;
}

/* Old dice and chest animations removed - now handled by Three.js */

/* ========================================
   CTA After Animation
   ======================================== */
.cta-after-animation {
    position: absolute;
    bottom: 0;
    opacity: 0;
    animation: ctaFadeIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) 4.5s forwards;
    margin-bottom: var(--spacing-xl);
}

@keyframes ctaFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Info Section
   ======================================== */
.info-section {
    padding: var(--spacing-2xl) var(--spacing-md);
}

.info-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2xl);
}

.section-title {
    font-family: var(--font-body);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-gold);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

/* ========================================
   Contact Info
   ======================================== */
.contact-info {
    background: var(--bg-surface-light);
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
}

.contact-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-gold);
}

.contact-icon {
    font-size: 1.5rem;
}

.contact-text {
    font-size: 1rem;
    font-weight: 500;
}

/* ========================================
   Winners Ticker
   ======================================== */
.winners-section {
    background: var(--bg-surface-light);
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 215, 0, 0.1);
    overflow: hidden;
}

.winners-ticker {
    overflow: hidden;
    position: relative;
    margin-top: var(--spacing-lg);
}

.ticker-track {
    display: flex;
    gap: var(--spacing-lg);
    animation: tickerScroll 30s linear infinite;
}

.winner-item {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--dark-gold);
    min-width: 200px;
}

.winner-name {
    font-weight: 600;
    color: var(--text-white);
    font-size: 1rem;
}

.winner-amount {
    font-weight: 700;
    color: var(--primary-gold);
    font-size: 1.2rem;
}

@keyframes tickerScroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* ========================================
   Game Launch Button
   ======================================== */
.game-launch {
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-2xl);
    background: linear-gradient(135deg, var(--primary-gold), var(--accent-gold));
    color: var(--bg-dark);
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glow-gold);
    text-transform: uppercase;
}

.game-button:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 0 50px rgba(255, 153, 0, 0.6);
}

.game-button:active {
    transform: translateY(-2px) scale(1.02);
}

.button-icon {
    font-size: 2rem;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    position: relative;
    padding: var(--spacing-xl) var(--spacing-md);
    background: var(--bg-surface);
    border-top: 1px solid rgba(255, 153, 0, 0.1);
    overflow: hidden;
}

.footer-coins-container {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
    pointer-events: none;
    z-index: 0;
}

.footer-coin {
    position: absolute;
    bottom: 5px;
    filter: drop-shadow(0 4px 8px rgba(251, 191, 36, 0.4));
    opacity: 0.7;
    animation: footerCoinFloat 3s ease-in-out infinite;
}

.footer-coin svg {
    width: 100%;
    height: 100%;
}

@keyframes footerCoinFloat {

    0%,
    100% {
        transform: translateY(0) rotate(var(--rotation, 0deg));
    }

    50% {
        transform: translateY(-8px) rotate(calc(var(--rotation, 0deg) + 5deg));
    }
}

.footer-content {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.footer-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--bg-surface-light);
    color: var(--text-white);
    border: 1px solid var(--dark-gold);
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.footer-button:hover {
    background: var(--dark-gold);
    color: var(--primary-gold);
    transform: translateY(-2px);
}

.footer-copyright {
    text-align: center;
    color: var(--text-gray);
    font-size: 0.85rem;
}

/* ========================================
   Modals
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal-content {
    background: var(--bg-surface);
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    max-width: 1000px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.modal-content h2 {
    color: var(--primary-gold);
    margin-bottom: var(--spacing-lg);
    font-size: 1.8rem;
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-surface-light);
    color: var(--primary-gold);
}

.modal-body {
    color: var(--text-gray);
    line-height: 1.8;
    max-height: 70vh;
    overflow-y: scroll;
}

.modal-body p {
    margin-bottom: var(--spacing-md);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .winners-section {
        padding: 2rem 1.2rem;
    }

    .floating-header {
        width: 95%;
        top: var(--spacing-sm);
    }

    .header-content {
        padding: var(--spacing-xs) var(--spacing-md);
        gap: 1rem;
        flex-direction: column;
    }

    .logo img {
        height: 32px;
    }

    .nav-links {
        gap: var(--spacing-sm);
    }

    .nav-link {
        font-size: 0.8rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .hero-text {
        margin-top: calc(var(--spacing-lg)*4);
        padding-bottom: 0;
        text-align: center;
    }

    .title-main {
        font-size: 2rem;
    }

    .title-sub {
        font-size: 0.8rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .hero-visual {
        min-height: 60vh;
    }

    #threejs-container {
        top: 0%;
        height: 60vh;
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    .game-button {
        font-size: 1.2rem;
        padding: var(--spacing-md) var(--spacing-xl);
    }

    .button-icon {
        font-size: 1.5rem;
    }

    .footer-content {
        gap: var(--spacing-sm);
    }

    .footer-button {
        width: 100%;
    }

    .modal-content {
        padding: var(--spacing-lg);
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    /* Semi-transparent background */
    background: rgba(10, 14, 26, 0.7);

    /* The "out of focus" effect */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* For Safari */

    z-index: 3000;

    /* Hidden by default, will be changed to 'flex' by JS */
    display: none;
    align-items: center;
    justify-content: center;

    /* Fade-in animation for the overlay */
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

/* The popup modal itself */
#popup-modal {
    position: relative;
    background: var(--bg-surface);
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;

    /* Strong gold glow to make it pop */
    box-shadow: var(--shadow-glow-gold-strong);
    border: 2px solid var(--primary-gold);

    z-index: 3001;
    text-align: center;

    /* Pop-in animation for the modal */
    opacity: 0;
    transform: scale(0.9);
    animation: popIn 0.4s 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Re-using the .modal-close style, just need to make sure it's positioned */
#popup-close-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    z-index: 10;
}

.popup-title {
    font-family: var(--font-body);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-gold);
    margin-bottom: var(--spacing-md);
}

.popup-description {
    font-size: 1.1rem;
    color: var(--text-gray);
    line-height: 1.8;
    margin-bottom: var(--spacing-lg);
}

/* This is the class JS will add to the overlay to show it */
#popup-overlay.show {
    display: flex;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hide animation */
#popup-overlay.hide {
    animation: fadeOut 0.3s ease-out forwards;
}

#popup-overlay.hide #popup-modal {
    animation: popOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes popOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* ========================================
   FAQ Section
   ======================================== */
.faq-section {
    padding: var(--spacing-xl) var(--spacing-md);
}

.faq-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    /* Sidebar: 300px, Main content: 1fr */
    grid-template-columns: 300px 1fr;
    gap: var(--spacing-xl);
}

/* --- FAQ Sidebar --- */
.faq-sidebar .section-title {
    text-align: left;
    margin-bottom: var(--spacing-md);
}

.sidebar-description {
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-lg);
    line-height: 1.7;
}

.sidebar-sticky-content {
    /* Sticky position */
    position: sticky;
    top: 120px;
    /* Adjust based on your floating header height */
    align-self: start;

    /* Styling */
    padding: var(--spacing-lg);
    background: var(--bg-surface-light);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.search-wrapper {
    position: relative;
}

#faq-search {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--bg-surface);
    border: 1px solid var(--dark-gold);
    border-radius: var(--radius-sm);
    color: var(--text-white);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.3s ease;
}

#faq-search:focus {
    outline: none;
    border-color: var(--primary-gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

/* --- FAQ List --- */
.faq-list {
    background: var(--bg-surface-light);
    border-radius: var(--radius-xl);
    padding: var(--spacing-sm) var(--spacing-xl);
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.faq-item {
    border-bottom: 1px solid var(--bg-surface);
    transition: opacity 0.3s ease;
}

.faq-item:last-child {
    border-bottom: none;
}

/* Class added by JS to hide non-matching items */
.faq-item.hidden {
    display: none;
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);

    /* Button reset */
    background: none;
    border: none;
    cursor: pointer;

    /* Text styling */
    padding: var(--spacing-lg) 0;
    color: var(--text-white);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: left;

    transition: color 0.3s ease;
}

.faq-question:hover {
    color: var(--primary-gold);
}

.faq-icon {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--primary-gold);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- Active State (JS controlled) --- */
.faq-question.active {
    color: var(--primary-gold);
}

.faq-question.active .faq-icon {
    transform: rotate(180deg);
    /* Use rotate for smooth animation */
}

.faq-answer {
    /* Accordion collapse */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;

    /* Text styling */
    color: var(--text-gray);
    font-size: 1rem;
    line-height: 1.8;
}

/* Class added by JS to show the answer */
.faq-answer.show {
    max-height: 500px;
    /* Set to a value larger than any answer */
    padding-bottom: var(--spacing-lg);
    transition: max-height 0.5s ease-in, padding 0.5s ease-in;
}

/* --- Responsive (Mobile View) --- */
@media (max-width: 900px) {
    .faq-container {
        /* Stack sidebar and list */
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .faq-sidebar {
        /* Sidebar is now at the top */
        grid-row: 1;
    }

    .sidebar-sticky-content {
        /* Remove sticky behavior */
        position: static;
        top: auto;
    }

    .faq-sidebar .section-title {
        text-align: center;
    }

    .faq-list {
        grid-row: 2;
        padding: var(--spacing-xs) var(--spacing-md);
    }

    .faq-question {
        font-size: 1rem;
        padding: var(--spacing-md) 0;
    }

    .faq-answer p {
        font-size: 0.9rem;
    }
}

.faq-no-results {
    padding: var(--spacing-2xl);
    text-align: center;
    color: var(--text-gray);
    font-size: 1.1rem;
    font-style: italic;
    height: 100%;
    align-items: center;
    justify-content: center;
    display: flex;
}

.faq-no-results.hidden {
    display: none !important;
}