body {
    font-family: sans-serif;
    background-color: #f0f0f0; /* Plain background color */
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: #333;
    /* Removed background-image */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background-color: #333;
    color: #f0f0f0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem; /* Add padding to header */
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

body.dark-mode header {
    background-color: rgba(51, 51, 51, 0.8);
}

header h2 {
    margin: 0;
    color: #007bff;
}

body.dark-mode header h2 {
    color: #61dafb; /* A light blue for dark mode header title */
}

#main-container {
    display: flex;
    justify-content: center;
    align-items: center; /* Center vertically */
    min-height: calc(100vh - 70px); /* Adjust for header height */
    padding: 2rem 1rem; /* Add some padding around the container */
}

#lotto-container {
    text-align: center;
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    max-width: 600px; /* Use max-width instead of flex-basis */
    width: 100%; /* Take full width on small screens */
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode #lotto-container {
    background-color: #444;
    color: #f0f0f0;
}

button {
    padding: 0.75rem 1.5rem;
    font-size: 1.2rem; /* Larger font size */
    cursor: pointer;
    border: none;
    border-radius: 8px; /* More rounded */
    background-color: #28a745; /* Green */
    color: white;
    margin-top: 1.5rem; /* More margin */
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:hover {
    background-color: #218838; /* Darker green on hover */
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark-mode button {
    background-color: #20c997; /* Lighter green for dark mode */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

body.dark-mode button:hover {
    background-color: #17a2b8;
}

#theme-switcher {
    /* Positioned within header, so no need for absolute positioning here */
}

#theme-toggle {
    background-color: #6c757d;
    margin-top: 0; /* Remove top margin as it's in header now */
}

body.dark-mode #theme-toggle {
    background-color: #5a6268;
}

.hidden {
    display: none !important;
}

#initial-lotto-image {
    max-width: 100%;
    height: auto;
    margin-bottom: 2rem;
    border: 5px solid #808080;
    border-radius: 8px;
    box-shadow: 
        inset -4px -4px 0 #808080, 
        inset 4px 4px 0 #ffffff,
        -8px 8px 0 #404040;
    image-rendering: pixelated;
}

/* 16-bit Lotto Machine Animation Styles */
#lotto-machine-animation {
    width: 450px; /* Enlarge width */
    height: 350px; /* Enlarge height */
    background-color: #c0c0c0; /* Retro grey */
    border: 5px solid #808080; /* Darker grey border for 16-bit feel */
    border-radius: 8px;
    margin: 2rem auto;
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset -4px -4px 0 #808080, 
        inset 4px 4px 0 #ffffff,
        -8px 8px 0 #404040; /* 16-bit deeper shadow */
    image-rendering: pixelated; /* Crucial for 16-bit look */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column; /* To stack machine and output */
    perspective: 800px; /* Added for 3D effect */
}

.machine-body {
    width: 90%; /* Main body of the machine */
    height: 90%;
    background-color: #a0a0a0;
    border: 3px solid #606060;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.machine-window {
    width: 80%; /* Round transparent container */
    height: 80%;
    background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.7) 0%, rgba(0,0,0,0.3) 100%); /* Cylindrical look */
    border: 5px solid rgba(0, 200, 200, 0.7); /* Cyan border for transparency effect */
    border-radius: 50%; /* Make it round */
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.7), 0 0 15px rgba(0, 255, 255, 0.5); /* Glow effect with more depth */
    position: relative;
    overflow: hidden; /* Balls will stay inside */
    display: flex;
    justify-content: center;
    align-items: center;
    transform: rotateX(15deg) rotateY(0deg) translateZ(-25px); /* Subtle 3D tilt */
    transform-style: preserve-3d;
}

.spinning-balls {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex; /* Changed from grid to flex for easier ball positioning */
    flex-wrap: wrap; /* Allow balls to wrap */
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d; /* For child 3D transforms */
}

/* Style for dynamically created balls inside the machine */
.machine-ball {
    width: 25px; 
    height: 25px;
    background-color: #ff00ff; /* Vibrant 16-bit color */
    border-radius: 50%;
    border: 2px solid #800080;
    box-shadow: inset -1px -1px 0 #800080, inset 1px 1px 0 #ffffff;
    opacity: 0.8;
    margin: 2px; /* Spacing between balls */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: white; /* Reverted to white */
    font-weight: bold;
    position: absolute; /* Allow free movement for animation */
    animation: pinball-bounce var(--animation-duration) infinite ease-in-out alternate;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

@keyframes pinball-bounce {
    0% { transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
    25% { transform: translate3d(calc(var(--rand-x) * 1px), calc(var(--rand-y) * 1px), calc(var(--rand-z) * 1px)) rotateX(calc(var(--rand-deg-x) * 1deg)) rotateY(calc(var(--rand-deg-y) * 1deg)) rotateZ(calc(var(--rand-deg-z) * 1deg)); }
    50% { transform: translate3d(calc(var(--rand-x-2) * 1px), calc(var(--rand-y-2) * 1px), calc(var(--rand-z-2) * 1px)) rotateX(calc(var(--rand-deg-x-2) * 1deg)) rotateY(calc(var(--rand-deg-y-2) * 1deg)) rotateZ(calc(var(--rand-deg-z-2) * 1deg)); }
    75% { transform: translate3d(calc(var(--rand-x-3) * 1px), calc(var(--rand-y-3) * 1px), calc(var(--rand-z-3) * 1px)) rotateX(calc(var(--rand-deg-x-3) * 1deg)) rotateY(calc(var(--rand-deg-y-3) * 1deg)) rotateZ(calc(var(--rand-deg-z-3) * 1deg)); }
    100% { transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
}

@keyframes roll-out {
    0% { transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(0deg); opacity: 1; }
    100% { transform: translate3d(150px, 0px, 100px) rotateX(360deg) rotateY(360deg) rotateZ(360deg); opacity: 0; } /* Rolls out to the side with 3D effect */
}

/* Sequential Number Display Styles */
#sequential-numbers-display {
    min-height: 80px; /* Ensure space for numbers */
    margin-top: 1rem;
    display: flex; /* For single line display */
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap; /* Keep numbers in one line */
    gap: 0.5rem; /* Spacing between numbers */
}

#ball-output { /* This will be the container for extracted balls */
    display: flex; /* To arrange extracted balls horizontally */
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    min-height: 50px;
}

#ball-output .lotto-ball { /* Target individual balls within ball-output */
    font-size: 1.2rem; /* Adjusted for smaller balls in sequential display */
    font-weight: bold;
    color: white; /* Reverted to white */
    min-width: 40px; /* Smaller size for extracted balls */
    min-height: 40px;
    line-height: 40px; /* Center text vertically */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: #333; /* Dark background for extracted ball */
    /* background: radial-gradient(circle at 30% 30%, #ffffff 0%, var(--ball-color) 100%); Spherical look */
    border: 2px solid #000; /* Simple border */
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5), 2px 2px 5px rgba(0,0,0,0.5);
    margin: 0; /* Remove extra margin, gap handles spacing */
}


#lotto-numbers {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap; /* Keep numbers in one line */
    gap: 0.5rem;
    margin-top: 1rem; /* Adjust margin */
}

.lotto-ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white; /* Reverted to white */
    font-size: 1.2rem;
    font-weight: bold;
    transition: background-color 0.3s ease;
    background-color: #007bff; /* Simple background color */
    /* background: radial-gradient(circle at 30% 30%, #ffffff 0%, var(--ball-color) 100%); Spherical look */
    border: 2px solid #000; /* Simple border */
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.5), 2px 2px 5px rgba(0,0,0,0.5);
}

.bonus-ball {
    background-color: #999; /* Simple background color */
    /* background: radial-gradient(circle at 30% 30%, #ffffff 0%, #999 100%); Spherical look for bonus */
    border: 2px solid #555;
}