/* Reset and Base Styles */
body, html {
    width: 100%;
    /* height: 100%; */ /* Avoid fixed height to allow content scrolling */
    min-height: 100vh; /* Ensure body takes at least full viewport height */
    margin: 0;
    padding: 0;
    font-family: 'Fjalla One', sans-serif; /* Consistent font */
    text-align: center;
    background-color: transparent; /* Let body::before handle background image */
    overflow-x: hidden;
    overflow-y: auto; /* Allow scrolling if content exceeds height */
    position: relative; /* Needed for absolute positioning of floating elements */
    /* display: flex; */ /* Removed flex centering from body for layout */
    /* align-items: center; */
    /* justify-content: center; */
}

/* Full Screen Background */
body::before {
    content: "";
    position: fixed; /* Fixed ensures it covers viewport */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../media/background.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    z-index: -2; /* Behind floating backgrounds and content */
    opacity: 0.8; /* Optional: Adjust opacity */
    animation: zoomInOutBackground 25s ease-in-out infinite alternate; /* Apply zoom animation */
}

@keyframes zoomInOutBackground {
    from {
        transform: scale(1); /* Start at normal size */
    }
    to {
        transform: scale(1.15); /* Zoom in slightly (adjust 1.15 as needed) */
    }
}

/* Floating Background Images (Full Screen Layers with Animation) */
.floating-bg {
    position: fixed;    /* Fixed positioning */
    top: 0;             /* Align top */
    left: 0;            /* Align left */
    width: 100vw;       /* Full width */
    height: 100vh;      /* Full height */
    z-index: -1;        /* Behind wheel, above body::before */
    opacity: 0.9;       /* Base opacity - adjust */
    pointer-events: none;
    object-fit: cover;  /* Cover the viewport */
    will-change: transform; /* Hint for animation */
}

#floating-bg1 {
    opacity: 0.9;  /* Example: Slightly more visible */
    /* Source set in HTML <img> tag */
    animation: floatUpDown 8s ease-in-out infinite alternate; /* APPLY animation */
}

#floating-bg2 {
    opacity: 0.9; /* Example: Slightly less visible */
    /* Source set in HTML <img> tag */
    animation: floatDownUp 4s ease-in-out infinite alternate; /* APPLY animation */
}

/* Define the floating animations */
@keyframes floatUpDown {
    from { transform: translateY(0); }
    to { transform: translateY(-35px); } /* Float UP */
}

@keyframes floatDownUp {
    from { transform: translateY(0); }
    to { transform: translateY(35px); } /* Float DOWN */
}


/* ------------- START: Layout Styles ------------- */

/* Main Flex Container */
#container {
	width: 100%; /* Take full width available */
    max-width: 1400px; /* Max width for large screens */
    margin: 2rem auto; /* Center horizontally, add vertical margin */
    position: relative; /* Keep relative for z-index context */
    z-index: 5; /* Keep above backgrounds */
    display: flex; /* Default layout: horizontal flex */
    flex-direction: row; /* Default: logo left, wheel right */
    align-items: center; /* Vertically align items in the middle */
    justify-content: space-around; /* Distribute space more evenly */
    gap: 20px; /* Space between left and right sections */
    padding: 15px; /* Padding around the container */
    box-sizing: border-box;
    min-height: 80vh; /* Ensure it takes up significant vertical space */
}

/* --- History Button & Popup --- */
.main-buttons-container {
    text-align: center;
    margin-top: 20px;
}
.historyBtn {
    background-color: #6c757d; /* A neutral grey */
    color: white;
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-family: 'Fjalla One', sans-serif;
    text-transform: uppercase;
    transition: background-color 0.2s;
    margin-left: 15px; /* Space between Spin and History */
}
.historyBtn:hover {
    background-color: #5a6268;
}

#history-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 420px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    z-index: 1001; /* Above popup-overlay */
    display: none; /* Initially hidden */
    padding: 20px;
    border: 3px solid #FDE08D;
}
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.popup-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}
.popup-close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #888;
    line-height: 1;
}
#history-content {
    max-height: 400px;
    overflow-y: auto;
}
#history-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
#history-content li {
    display: flex;
    justify-content: space-between;
    padding: 10px 5px;
    border-bottom: 1px dashed #ddd;
}
#history-content li:last-child {
    border-bottom: none;
}
#history-content .timestamp {
    font-size: 0.8em;
    color: #666;
    white-space: nowrap;
    margin-right: 15px;
}
#history-content .prize-info {
    text-align: right;
}
#history-content .prize-amount {
    font-weight: bold;
    display: block;
    color: #000000; /* Add this line to make the text black */
}
#history-content .prize-code {
    font-size: 0.9em;
    color: #888;
    font-family: monospace;
}

/* Layout Sections (Left and Right) */
.layout-section {
    display: flex;
    flex-direction: column; /* Stack items vertically within each section */
    align-items: center; /* Center items horizontally within each section */
    justify-content: center; /* Center items vertically within each section */
    flex: 1; /* Allow both sections to grow/shrink equally by default */
    box-sizing: border-box;
    padding: 10px; /* Add some padding within sections */
}

/* Left Section (Logo) */
.section-left {
    /* flex: 1 1 30%; */ /* Removed fixed basis */
    max-width: 350px; /* Set a max-width, but let it shrink */
    min-width: 150px; /* Prevent extreme shrinking */
}

/* Right Section (Wheel & Buttons) */
.section-right {
    /* flex: 1 1 65%; */ /* Removed fixed basis */
    max-width: 700px; /* Keep max-width for the wheel area */
    min-width: 300px; /* Prevent it getting too squished */
}


/* Logo Container - Adjusted for Layout */
#top-logo-container {
    position: relative; /* Now relative to its parent (.section-left) */
    top: 10px; left: auto; /* Remove absolute positioning */
    transform: none; /* Remove transform */
    z-index: auto; /* Reset z-index */
    width: 100%; /* Take width of section-left */
    max-width: 300px; /* Limit logo image size within container */
    height: auto;
    margin: 0 auto; /* Center within its flex container */
    margin-top: -80px; /* Adjust this value. Negative numbers pull it up. */

}

#top-logo { /* Keep logo styles */
    width: 100%;
    height: auto;
    animation: heartbeat 1.5s ease-in-out infinite both;
    filter: drop-shadow(3px 5px 5px rgba(0, 0, 0, 0.4));
}

@keyframes heartbeat {
  from { transform: scale(1); }
  50% { transform: scale(1.1); }
  to { transform: scale(1); }
}

/* ------------- END: Layout Styles ------------- */


/* Popup Overlay */
#popup-overlay {
    display: none; position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Darken */
    z-index: 999; opacity: 0;
    transition: opacity 0.4s ease-in-out;
}
#popup-overlay.visible { display: block; opacity: 1; }

/* Consent Popup */
#consent-popup {
    display: none; /* Shown by JS */
    position: fixed; top: 50%; left: 50%;
    width: 80%; max-width: 500px;
    background-color: rgba(255, 255, 255, 0.95); color: #333;
    padding: 30px; border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3); z-index: 1000;
    text-align: center; opacity: 0; /* Start hidden for animation */
    transform: translate(-50%, -50%) scale(0.7); /* Start smaller for animation */
}
#consent-content { margin-bottom: 20px; font-size: 1.1rem; line-height: 1.6; font-family: Montserrat, sans-serif; }
#consent-content h1 { font-family: 'Fjalla One', sans-serif; color: #E81D62; margin-bottom: 15px; }

/* Consent OK Button */
#consent-ok-btn {
    background-color: #E81D62; color: #ededed;
    padding: 12px 25px; border: none; border-radius: 6px;
    font-size: 1.2rem; font-weight: 700; cursor: pointer;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.25), 0 3px 0 #D71559; /* Enhanced Shadow */
    font-family: Montserrat, sans-serif;
    transition: background-color 0.2s ease, box-shadow 0.3s ease, transform 0.1s ease;
}
#consent-ok-btn:hover { background-color: #d11757; box-shadow: 0 7px 14px rgba(0, 0, 0, 0.3), 0 3px 0 #D71559; }
#consent-ok-btn:active { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2), 0 1px 0 #D71559; transform: translateY(1px); }


/* Code Input Section Styles - Adjusted for Layout */
#code-section {
    width: 100%; /* Relative to parent (.section-right) */
    max-width: 450px; /* Limit width */
    margin: 20px auto 10px auto; /* Vertical margins within section-right */
    padding: 10px; /* Reduced padding */
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px; color: #ededed; text-align: center;
}

/* Container for inline label/input/button */
.code-input-container {
    display: flex; justify-content: center; align-items: center;
    gap: 10px; width: 100%; /* Ensure container takes width */
}

/* Hide label visually but keep for accessibility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }

/* Code Input Box */
#code-section input[type="text"] {
    padding: 12px 15px; flex-grow: 1; max-width: 250px; /* Adjust max width */
    margin-bottom: 0; border: 3px solid #F1DC15; border-radius: 6px;
    font-size: 1.8rem; font-weight: bold; text-align: center;
    background-color: #fff; color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); transition: box-shadow 0.3s ease;
    letter-spacing: 2px; text-transform: uppercase;
    height: auto; line-height: normal; box-sizing: border-box;
}
 #code-section input[type="text"]:focus { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(241, 220, 21, 0.5); outline: none; }

/* Validate Code Button */
#code-section button {
    background-color: #E81D62; color: #ededed;
    padding: 14px 20px; border: none; border-radius: 25px; /* Rounded */
    font-size: 1rem; font-weight: 700; cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 2px 0 #D71559; /* Pink Shadow Base */
    font-family: Montserrat, sans-serif;
    transition: background-color 0.2s ease, box-shadow 0.3s ease, transform 0.1s ease;
    white-space: nowrap; flex-shrink: 0; height: auto; line-height: normal; box-sizing: border-box;
}
#code-section button:hover { background-color: #d11757; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3), 0 2px 0 #D71559; }
 #code-section button:active { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 0 #D71559; transform: translateY(1px); }

/* Code Validation Message (Moved Above Input) */
#code-message {
    margin-bottom: 5px; /* Space below message */
    font-size: 0.9rem; min-height: 1.2em; font-weight: bold; text-align: center;
}
#code-message.success { color: #2ECC71; }
#code-message.error { color: #E74C3C; }


/* Wheel Container and Elements - Adjusted for Layout */
.wheelContainer {
    position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column;
    width: 100%; /* Takes width of section-right */
    max-width: 650px; /* Adjusted max width */
    margin: 0 auto; /* Center within section-right */
    padding-bottom: 5px;
    filter: drop-shadow(5px 8px 10px rgba(0, 0, 0, 0.3));
    margin-top: -30px; /* Adjust this value. Negative numbers pull it up. */
}

.wheelSVG {
    position: relative; overflow: visible;
    width: 100%; height: auto; max-height: 60vh; /* Constrained height */
    visibility: hidden; /* Shown by JS */
}

.peg { /* Keep peg visible */ }

.centerCircle, .valueContainer, .wheelOutline, .wheelText, .centerCircleImageContainer {
    pointer-events: none;
}

/* Spin Button - Adjusted for Layout */
button.spinBtn {
    position: relative; display: block;
    margin: 0 auto 10px auto; /* Removed top margin */
    background-color: #E81D62;
    width: 80%; /* Relative to section-right */
    max-width: 350px; /* Adjusted max width */
    padding: 10px; font-weight: 700; font-size: 2rem; color: #ededed;
    border-radius: 6px; border: none;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.25), 0 3px 0 #D71559; /* Enhanced Shadow */
    cursor: pointer; font-family: Montserrat, sans-serif;
    transition: background-color 0.2s ease, opacity 0.3s ease, box-shadow 0.3s ease, transform 0.1s ease;
}
button.spinBtn:hover:not(:disabled) { box-shadow: 0 7px 14px rgba(0, 0, 0, 0.3), 0 3px 0 #D71559; }
button.spinBtn:active:not(:disabled) { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2), 0 1px 0 #D71559; transform: translateY(1px); }
button.spinBtn:disabled { background-color: #a0a0a0; cursor: not-allowed; box-shadow: none; opacity: 0.6; }

button:focus { outline: 0; }

/* Wheel Text Styles (if used) */
.wheelText { text-anchor: start; font-family: Montserrat, sans-serif; user-select: none; }
.wheelText tspan { text-anchor: middle; letter-spacing: 2px; }

/* Center Image Rotation */
.centerCircleImageContainer image { transform-origin: center center; animation: spinCenterImage 20s linear infinite; }
@keyframes spinCenterImage { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


/* Toast Notification Styling */
.toast {
    border-radius: 12px; opacity: 0; visibility: hidden; /* Control via JS */
    background-color: rgba(232, 29, 98, 0.85); /* Pink with 85% opacity */
    position: absolute; bottom: 10px; /* Position Higher */
    left: 50%; transform: translateX(-50%);
    overflow: visible; color: #FFF;
    font-family: Montserrat, sans-serif; font-weight: 400;
    width: 80vw; max-width: 600px;
    padding: 15px 30px; z-index: 20; box-sizing: border-box;
    position: relative; /* For close button */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25); /* Shadow */
}
.toast p {
    clear: both; font-family: Montserrat, Arial, sans-serif; margin: 0;
    padding: 10px 30px 10px 10px; /* Right padding for close btn */
    font-size: 1.5rem; color: #ededed; letter-spacing: 0; user-select: none;
    line-height: 1.4; transition: line-height .2s ease;
}
/* Toast Close Button */
.toast-close-btn {
    position: absolute; top: 5px; right: 8px;
    background: none; border: none; color: rgba(255, 255, 255, 0.8);
    font-size: 24px; font-weight: bold; line-height: 1;
    padding: 5px; cursor: pointer; transition: color 0.2s ease;
}
.toast-close-btn:hover { color: #ffffff; }
.toast-close-btn:focus { outline: 1px dotted white; }


/* ------------- START: Media Query for Layout STACKING ------------- */
/* Targets tablets, unfolded Fold, and smaller screens */
@media only screen and (max-width: 1024px) { /* Adjusted breakpoint */
    body, html {
         display: block; /* Revert body flex centering */
         min-height: 0;
     }

    #container {
        flex-direction: column; /* Stack sections vertically */
        margin: 1rem auto; /* Adjust vertical margin */
        gap: 10px; /* Add small gap when stacked */
        padding: 10px;
        min-height: 0; /* Remove min-height */
    }

    .section-left,
    .section-right {
        flex-basis: auto; /* Reset flex basis */
        width: 95%; /* Take most of the width when stacked */
        max-width: 700px; /* Limit max width when stacked */
        flex: none; /* Disable flex grow/shrink when stacked */
        padding: 0; /* Remove section padding when stacked */
    }

    .section-left {
        order: 1; /* Logo first */
        margin-bottom: 10px; /* Space below logo */
    }

    .section-right {
        order: 2; /* Wheel section below logo */
    }

    #top-logo-container {
         width: 50%; /* Adjust logo size for stacked layout */
         max-width: 200px; /* Further constrain logo */
         margin-bottom: 0px;
     }

    .wheelContainer {
         max-width: 95vw; /* Allow slightly wider wheel */
    }
     .wheelSVG {
         max-height: 70vh; /* Allow slightly taller wheel when stacked */
     }

    #code-section {
        width: 90%; /* Keep relative width */
        margin-top: 15px; /* Adjust margin */
        max-width: 500px;
    }

    button.spinBtn {
        width: 70%; /* Adjust button width */
        margin-top: 15px; /* Adjust margin */
        font-size: 1.8rem; /* Adjust size */
        max-width: 400px;
    }
}
/* ------------- END: Media Query for Layout STACKING ------------- */


/* Media Query for smaller tablets / larger phones */
@media only screen and (max-width: 768px) {
    /* Styles here refine the already stacked layout */
    #top-logo-container { width: 180px; } /* Smaller logo */
    #code-section input[type="text"] { font-size: 1.5rem; max-width: 220px; } /* Adjust input */
    #code-section button { font-size: 0.9rem; padding: 12px 18px; } /* Adjust button */
    button.spinBtn { font-size: 1.5rem; padding: 15px; width: 75vw; max-width: 350px;} /* Adjust spin button */
    .toast { width: 90vw; padding: 10px 20px; }
    .toast p { font-size: 1.2rem; line-height: 1.5rem; padding-right: 25px; }
    .toast-close-btn { font-size: 22px; right: 6px; top: 4px;}
}


/* Media Query for smaller phones */
@media only screen and (max-width: 480px) {
    /* Further refinements for small screens */
    #top-logo-container { width: 150px; } /* Even smaller logo */
    .code-input-container { gap: 8px; } /* Reduce gap */
    #code-section input[type="text"] {
         font-size: 1.2rem; /* Adjust font size */
         padding: 10px 8px;
         max-width: 60%; /* Adjust width */
    }
     #code-section button {
         font-size: 0.8rem;
         padding: 10px 10px; /* Adjust padding */
     }
    button.spinBtn { font-size: 1.2rem; padding: 12px; width: 85vw; max-width: 300px;} /* Adjust spin button */
    .toast { padding: 8px 15px; }
    .toast p { font-size: 1rem; line-height: 1.4rem; padding-right: 20px; }
    .toast-close-btn { font-size: 20px; right: 5px; top: 3px;}
}


/* Links */
a:link, a:visited, a:hover, a:active { color:#F1DC16; }