html {
  scroll-behavior: smooth;
  background-color: rgb(8, 0, 153) !important; /* Explicit fallback to prevent white flash */
  background: rgb(8, 0, 153); /* Fallback color to prevent white flash */
  background: linear-gradient(162deg, rgb(5, 0, 104) 0%, rgb(9, 9, 155) 52%, rgb(0, 74, 185) 100%);
  background-repeat: no-repeat; 
  background-size: cover; 
  background-attachment: fixed;
  min-height: 100vh;
  min-height: -webkit-fill-available; /* For mobile browsers */
  width: 100%;
  height: 100%;
}

body {
  background-color: rgb(8, 0, 153) !important; /* Explicit fallback to prevent white flash */
  background: rgb(8, 0, 153); 
  background: linear-gradient(162deg, rgb(5, 0, 104) 0%, rgb(9, 9, 155) 52%, rgb(0, 74, 185) 100%);
  background-repeat: no-repeat; 
  background-size: cover; 
  background-attachment: fixed;
  min-height: 100vh;
  min-height: -webkit-fill-available; /* For mobile browsers */
  font-family: "Roboto", sans-serif;
  color: white;  
  padding-bottom: 100px;
  width: 100%;
  margin: 0;
  position: relative;
}

/* Full-screen background overlay to prevent white flash */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgb(8, 0, 153);
  background: linear-gradient(162deg, rgb(5, 0, 104) 0%, rgb(9, 9, 155) 52%, rgb(0, 74, 185) 100%);
  z-index: -1;
  pointer-events: none;
}



body.moon-clicker {
  padding-top: 120px; /* only applies on Moon Clicker page */
}

.topnav {
  background-color: #2c00a5;
  overflow: hidden;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  text-align: center;
  margin-left: 3%;
  margin-right: 3%;
  margin-top: 1%;
  width: 93%;
  position: fixed;
  top: 0;
  box-shadow: 0px 0px 25px #293647;
  padding-bottom: 40px;
  position: fixed; 
  z-index: 10;
}

.topnav #logo:hover{
  background-color: transparent;
}

.topnav #logo {
  position: absolute;
  left: 20px;
  top: 15px;
  display: inline-block;
  margin: 15px; 
  float: left;
  height: 60px;
  width: auto; 
  border-radius: 10%; 
  display: inline-block;
  vertical-align: middle;
  transition: border-radius 0.3s ease;
}

.navmain {
  vertical-align: middle;
}

.topnav a {
  float: center;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  transition: 0.3s;
}

.topnav a:hover {
  background-color: #576374;
  color: rgb(255, 255, 255);
  border-radius: 10px;
}

.topnav a.active {
  background-color: #004ab9;
  color: white;
  border-radius: 10px;
}

.topnav #logo:hover {
  background-color: transparent;
  color: rgb(255, 255, 255);
  border-radius: 10px;
}

.transparent {
  opacity: 0;
}

.topnav h1 {
  color: #f2f2f2;
  font-family: "Roboto", sans-serif;
}

.fact-nav {
  margin-top: 150px;
  padding: 20px 30px;
  background-color: #2c00a5;
  overflow: hidden;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  text-align: center;
  position: fixed;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0px 0px 25px #293647;
  width: fit-content; 
  max-width: 90vw;
  white-space: nowrap; 
}


.fact-nav a {
  float: center;
  color: #f2f2f2;
  text-align: center;
  padding: 10px 16px;
  text-decoration: none;
  font-size: 17px;
  transition: 0.3s;
}

.fact-nav a:hover {
  background-color: #576374;
  color: rgb(255, 255, 255);
  border-radius: 50px;
}

.fact-nav a.active {
  background-color: #004ab9;
  color: white;
  border-radius: 50px;
}

.toppart {
  align-items: center, top;
  display: flex;
  justify-content: center;
  margin-top: 168px;
}

.intro {
  background-color: #2c00a5;
  overflow: hidden;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  text-align: left;
  padding-bottom: 0px;
  margin-left: 3%;
  margin-right: 1%;
  margin-top: 15px;
  width: 60%;
}

.moonpic {
  background-color: #2c00a5;
  overflow: hidden;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  text-align: center;
  padding-bottom: 0px;
  margin-left: 1%;
  margin-right: 3%;
  margin-top: 15px;
  width: 36%;
}

.moonpic img {
  max-width: 500px; 
  height: auto;
}

.intro p {
  margin-left: 20px;
  margin-right: 20px;
}

.intro h3 {
  margin-left: 20px;
  margin-right: 20px;
}

.intro img {
  margin-left: 20px;
  margin-right: 20px;
  width: 80px;
}

.intro img:hover {
  transform: scale(1.1);
}

.intro img {
  transition: transform 0.3s;
}

.videosection {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  width: 94%; 
  margin-left: 3%;
  margin-right: 3%;
}

.videosection h2 {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  margin-left: 2%;
  margin-right: 3%;
  width:auto;
  padding-top: 1%;
  border-radius: 30px 30px 0 0;
}

.vids {
  display: flex;
  flex-wrap: wrap; 
  justify-content: center;
  gap: 15px;
  width: 100%;
  margin: 0 auto;
  margin-bottom: 3%;
}

.vid-container {
  flex: 1 1 calc(34.3333333333% - 20px);
  max-width: 32%;
  aspect-ratio: 16 / 9;
  padding-bottom: 1%;
}

.vid-container iframe {
  width: 100%;
  height: 99%;
  border-radius: 15px;
  filter: brightness(0.98) contrast(1.02);
  transition: filter 0.3s ease;
}

.vid-container:hover iframe {
  filter: brightness(1) contrast(1);
}

a.game-link {
    text-decoration: none;
    color: inherit;
    display: block; 
}

a.game-link .game {
    cursor: pointer;
}


#main {
  padding-top: 10px;
}

#one {
  padding-top: 13px;
}

#one, #hundred, #twohundred, #twohundredfifty, #threehundred, #fourhundred, #fivehundred, #sixhundred, #sevenhundred, #sevenhundredfifty {
  scroll-margin-top: 230px;
}

.first-line-of-facts {
  margin-top: 240px;
  display: flex;
  gap: 20px;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  width: auto;
  padding: 20px;
}

.line-of-facts {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  padding: 20px;
  transition: 0.3s;
  width: 100%;
  box-sizing: border-box;
}

.fact {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  flex: 1;
  padding: 20px;
  text-align: left;
  transition: 0.5s;
}

#videos {
  scroll-margin-top: 230px;
}

.line-of-games {
  background-color: transparent;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  width: 94%; 
  margin-left: 3%;
  margin-right: 3%;
  display: flex;
  gap: 50px;
  justify-content: center;
  margin-top: -25px;
  margin-bottom: 30px;
}

.game {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  padding: 20px;
  text-align: left;
  transition: 0.5s;
  align-items: center;
  justify-content: center;
}

.game:hover {
  scale:1.1;
}

.contact {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  padding: 20px;
  text-align: left;
  transition: 0.5s;
  width: 40%;
  justify-content: center;
  padding-left: 30px;
  margin: 0 auto 20px auto;
  margin-bottom: 40px;
}

.contact p{
  font-family: "Roboto", sans-serif;
}


#games{
  scroll-margin-bottom: 300px;
}


.fact-intro {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  padding: 20px;
  text-align: left;
  width: 60%;
}

.socials {
  background-color: #2c00a5;
  font-family: "Roboto", sans-serif;
  border-radius: 30px;
  padding: 20px;
  text-align: center;
  width: 40%;
  transition: 0.3s;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.book-cover-container {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1; /* Square aspect ratio */
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.book-download-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.book-download-info h2 {
  margin: 0;
  color: #ffffff;
  font-size: 24px;
}

.book-download-info p {
  margin: 0;
  color: #f2f2f2;
  font-size: 16px;
}

.download-button {
  background-color: #004ab9;
  color: #ffffff;
  font-family: "Roboto", sans-serif;
  font-size: 18px;
  font-weight: bold;
  padding: 15px 40px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
  box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
}

.download-button:hover {
  background-color: #0056d6;
  transform: scale(1.05);
}

.download-button:active {
  transform: scale(0.95);
}

.download-count {
  margin-top: 10px;
  font-size: 14px;
  color: #b0b0b0;
}

#download-counter {
  font-weight: bold;
  color: #ffffff;
}

/* Download count page styles */
.download-count-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.download-count-container {
  background-color: #2c00a5;
  border-radius: 30px;
  padding: 60px 40px;
  text-align: center;
  box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 100%;
}

.download-count-container h1 {
  color: #ffffff;
  font-family: "Roboto", sans-serif;
  font-size: 32px;
  margin-bottom: 40px;
}

.download-count-display {
  margin: 40px 0;
}

.download-count-label {
  color: #b0b0b0;
  font-family: "Roboto", sans-serif;
  font-size: 18px;
  margin-bottom: 20px;
}

.download-count-number {
  color: #ffffff;
  font-family: "Roboto", sans-serif;
  font-size: 48px;
  font-weight: bold;
  margin: 0;
}

.back-link {
  display: inline-block;
  background-color: #004ab9;
  color: #ffffff;
  font-family: "Roboto", sans-serif;
  font-size: 18px;
  font-weight: bold;
  padding: 15px 40px;
  border-radius: 10px;
  text-decoration: none;
  transition: background-color 0.3s, transform 0.2s;
  box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
  margin-top: 30px;
}

.back-link:hover {
  background-color: #0056d6;
  transform: scale(1.05);
}

.back-link:active {
  transform: scale(0.95);
}

@media screen and (max-width: 768px) {
  .download-count-container {
    padding: 40px 20px;
    margin: 20px;
  }
  
  .download-count-container h1 {
    font-size: 24px;
  }
  
  .download-count-number {
    font-size: 36px;
  }
}

.fact-intro img{
  width: 60px;
  transition: 0.3s;
}

.fact-intro img:hover{
  scale: 1.2;
}


.fact-intro h2, .fact-intro p {
  padding-left: 10px;
}

.fact-intro {
  padding-top: -100px;
  font-weight: 500;
}

#home:target, #spacefacts:target, #about:target {
  border-color: blue;
  background-color: lightblue;
  font-weight: bold;
}

.memory-title {
  margin: auto;
  margin-top: 160px;
  margin-bottom: 20px;
  text-align: center;
}

.actions {
  display: flex;
  justify-content: center;
}

.actions button {
  padding: 8px 16px;
  font-size: 30px;
  border-radius: 10px;
  background-color: #2c00a5;
  color: white;
  transition: transform 0.3s ease-in-out;
  will-change: transform;
}

.actions button:hover {
  transform: scale(1.1);
}

.grid-container {
  display: grid;
  justify-content: center;
  grid-gap: 16px;
  grid-template-columns: repeat(6, 140px);
  grid-template-rows: repeat(4, calc(140px / 2 * 2));
  position: relative; 
  z-index: 0; 
}

.card{
  height: calc(140px / 2 * 2);
  width: 140px;
  border-radius: 10px;
  background-color: #5120d6;
  position: relative;
  transform-style: preserve-3d;
  transition: all 0.5s ease-in-out;
}

.card:hover {
  transform: scale(0.9);
}

.front-image {
  width: 100px;
  height: 100px;
}

.card.flipped {
  transform: rotateY(180deg);
}

.front,
.back {
  backface-visibility: hidden;
  position: absolute;
  border-radius: 10px;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
}

.card .front {
  display: flex;
  justify-content: center;
  align-items: center;
  transform: rotateY(180deg);
}

.card .back {
  background-color: #2c00a5;
  background-position: center center;
  background-size: cover;
  backface-visibility: hidden;
}

.score-title {
  text-align: center;
  font-size: 20px;
}

.game img {
  width: 150px;
  height: 150px;
  border-radius: 20px;
  display: block;
  margin: 0 auto;
}

.games-h1{
  text-align: center;
  margin-bottom: 50px;
  font-size: 40px;
}







/*MOON CLICKER*/
.clicker-game {
  margin-top: 500px;
}

.clicker-title {
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: 60px;
  color: whitesmoke;
  font-weight: 900;
}

.clicker-top-right {
  position: absolute;
  top: 150px;
  right: 4%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clicker-top-right span {
font-size: 34px;
font-family: "Fredoka", sans-serif;
color: whitesmoke;
margin-top: 10px;
}

.clicker-top-right img {
height: 80px;
width: 80px;
margin-top: 10px;
font-weight: 900;
}

.clicker-top-left {
position: absolute;
top: 150px;
left: 4%;
display: flex;
align-items: flex-start;
font-family: "Fredoka", sans-serif;
color: whitesmoke;
font-size: 34px;
flex-direction: column;
gap: 0px;
}

.clicker-top-left span {
font-size: 34px;
font-family: "Fredoka", sans-serif;
color: whitesmoke;
margin-top: 0px;
}

.clicker-top-left p {
font-size: 34px;
margin: 0; 
}

.pig-image {
width: 700px;
height: 700px;
margin: auto;
margin-top: -50px;
position: relative;
}

.pig-wrapper {
width: 100%;
height: 100%;
position: relative;
}

#light-effect {
position: absolute;
top: 50%;
left: 50%;
width: 750px;
transform: translate(-50%, -50%) rotate(0deg);
opacity: 0;
z-index: 1; /* behind */
transition: opacity 1s ease;
pointer-events: none;
}

#moon-image {
position: absolute;
top: 50%;
left: 50%;
height: 500px;
width: 500px;
transform: translate(-50%, -50%);
z-index: 2;
transition: transform 0.3s ease, opacity 0.3s ease;
opacity: 1;
top: 480px;
}

#moon-image:hover {
transform: translate(-50%, -50%) scale(1.01);
}

#moon-image:active {
transform: translate(-50%, -50%) scale(0.95);
}

@keyframes spin {
from { transform: translate(-50%, -50%) rotate(0deg); }
to { transform: translate(-50%, -50%) rotate(360deg); }
}

.rotate {
animation: spin 6s linear infinite;
}



.button-section{
display: flex;
justify-content: center;
align-items: center;
margin-top: 30px;
}

.button-section button{
margin-left: 10px;
margin-right: 10px;
padding-left: 10px;
padding-right: 10px;
color: white;
font-size: 15px;
background-color: #5120d6;
border-radius: 10px;
border: none;
transition: transform 0.3s ease;
}

.button-section button:hover {
transform: scale(1.01);
}

.button-section button:active {
transform: scale(0.9);
}

.button-section p{
font-size: 20px;
margin-top: -10px;
margin-bottom: -10px;
color: rgb(241, 240, 240);
}

.button-section h2{
font-weight: 600;
padding-bottom: 1px;
}

.button-section button:disabled {
background-color: #ccc;  
color: #888; 
cursor: not-allowed;  
}

.button-section button:disabled p{
background-color: #ccc;  
color: #888; 
cursor: not-allowed;  
}









/* WORDLE GAME */
#wordle-game {
  display: grid;
  place-items: center;
  width: 100%;
  height: 600px;
}

:root {
  --default: #2c00a5;
  --empty: #979797;
  --wrong: #dfc035;
  --right: #3ea535;
  
}

.wordle-grid {
  display: grid;
  grid-template-columns: repeat(5, auto);
  grid-template-rows: repeat(6, auto);
}

.wordle-box {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  margin: 4px;
  color: white;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2.4rem;
  background-color: var(--default);
  border: 0.7px solid #511fd6;
}

.wordle-box.empty {
  background-color: var(--empty);
  animation: fade-empty 0.3s ease forwards;
}

.wordle-box.wrong {
  background-color: var(--wrong);
  animation: fade-wrong 0.3s ease forwards;
}

.wordle-box.right {
  background-color: var(--right);
  animation: fade-right 0.3s ease forwards;
}

.Winner-Lost {
  text-align: center;
  font-size: 30px;
  font-weight: 500;
  margin-top: -60px;
  margin-bottom: 20px;
}

@keyframes fade-empty {
  0% {
    background-color: #ccc; /* Start with neutral color */
    transform: scale(1);
  }
  50% {
    transform: scale(1.1); /* Slight pop */
  }
  100% {
    background-color: var(--empty); /* Target final color */
    transform: scale(1);
  }
}

@keyframes fade-wrong {
  0% {
    background-color: #ccc;
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    background-color: var(--wrong);
    transform: scale(1);
  }
}

@keyframes fade-right {
  0% {
    background-color: #ccc;
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    background-color: var(--right);
    transform: scale(1);
  }
}

.reset-button {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-radius 0.3s ease;
}

#reset-btn {
  display: block;
  margin-top: 20 auto;
  padding: 10px 20px;
  font-size: 16px;
  background-color: #511fd6;
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  transition: transform 0.3s ease;
  font-size: 20px;
}

#reset-btn:hover {
  background-color: #511fd6; 
  transform: scale(1.1);
}

#reset-btn:active {
  background-color: #511fd6; 
  transform: scale(0.9);
}

.wordle-h1{
  margin-top: 180px;
  text-align: center;
  font-size: 40px;
  margin-bottom: -60px;
}

.page-not-found {
  display: grid;
  place-items: center;
  height: 100vh;
  margin: 0;
  align-content: center;
  text-align: center;
}

.page-not-found h1 {
  font-size: 100px;
  margin-bottom: -30px;
}

.page-not-found h3 {
  font-size: 30px;
}

.page-not-found a:hover {
  background-color: #576374;
  color: rgb(255, 255, 255);
  border-radius: 10px;
  transform: scale(1.07);
}

.page-not-found a {
  display: inline-block;
  background-color: #004ab9;
  color: white;
  border-radius: 10px;
  padding: 20px;
  font-size: 40px;
  text-decoration: none;
  font-weight: 800;
  transition: transform 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

/* ===== MOBILE RESPONSIVENESS ===== */

/* Mobile devices (portrait and landscape) */
@media screen and (max-width: 768px) {
  
  /* Navigation */
  .topnav {
    margin-top: 15px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: calc(100vw - 40px) !important;  /* Use vw to prevent overflow, 20px margin on each side */
    max-width: calc(100vw - 40px) !important;
    padding: 15px 20px;      /* increased vertical padding to fit logo */
    min-height: 80px;        /* ensure enough height for logo */
    border-radius: 20px;
    box-sizing: border-box;
    left: 20px !important;  /* 20px from left edge */
    right: auto !important;
    z-index: 50;  /* below mobile menu */
  }
  
  .topnav h1 {
    display: none !important;  /* hide text on mobile */
  }
  
  .topnav #logo {
    position: absolute;
    left: 20px;              /* position to the left */
    top: 50%;
    transform: translateY(-50%);
    float: none;
    height: 40px;
    margin: 0;
    display: block;
  }
  
  .topnav .hamburger {
    position: absolute;
    right: 20px;             /* position to the right */
    top: 50%;
    transform: translateY(-50%);
    display: flex !important;
    z-index: 10001;          /* above mobile menu */
  }
  
  .topnav .hamburger {
    color-scheme: light !important;
    -webkit-color-scheme: light !important;
    filter: none !important;
    -webkit-filter: none !important;
  }
  
  .topnav .hamburger {
    color-scheme: light !important;
    -webkit-color-scheme: light !important;
    filter: none !important;
    -webkit-filter: none !important;
  }
  
  .topnav .hamburger span {
    background-color: #ffffff !important;
    background: #ffffff !important;
    background-image: linear-gradient(to right, #ffffff, #ffffff) !important;
    color: #ffffff !important;
    filter: none !important;
    -webkit-filter: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    color-scheme: light !important;
    -webkit-color-scheme: light !important;
    border: none !important;
    outline: none !important;
  }
  
  .topnav .hamburger.active span {
    background-color: #ffffff !important;
    background: #ffffff !important;
    background-image: linear-gradient(to right, #ffffff, #ffffff) !important;
    filter: none !important;
    -webkit-filter: none !important;
  }
  
  .topnav a:not(.mobile-menu a) {
    display: none !important;  /* hide desktop nav links on mobile */
  }
  
  /* Main content spacing - ALWAYS VERTICAL STACK */
  .toppart {
    margin-top: 120px;
    flex-direction: column !important;
    gap: 30px;
  }
  
  .intro {
    width: calc(100vw - 40px) !important;
    max-width: calc(100vw - 40px) !important;
    margin-left: 20px !important;
    margin-right: auto !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    padding: 20px;
    box-sizing: border-box;
  }
  
  .moonpic {
    width: calc(100vw - 40px) !important;
    max-width: calc(100vw - 40px) !important;
    margin-left: 20px !important;
    margin-right: auto !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    padding: 20px;
    box-sizing: border-box;
  }
  
  .moonpic img {
    max-width: 100%;
    height: auto;
  }
  
  /* Video section - ALWAYS VERTICAL STACK */
  .videosection {
    width: calc(100vw - 40px) !important;
    max-width: calc(100vw - 40px) !important;
    margin-left: 20px !important;
    margin-right: auto !important;
    box-sizing: border-box;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
  
  .vids {
    flex-direction: column !important;
    gap: 0px !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  
  .vid-container {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    margin-bottom: 30px;
    box-sizing: border-box;
    aspect-ratio: 16 / 9 !important;
    width: 100% !important;
    position: relative;
    padding-bottom: 0 !important;
  }
  
  .vid-container iframe {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 16 / 9 !important;
    border-radius: 15px;
    position: absolute;
    top: 0;
    left: 0;
  }
  
  /* Games section - ALWAYS VERTICAL STACK */
  .line-of-games {
    flex-direction: column !important;
    gap: 30px;
    width: calc(100vw - 40px) !important;
    max-width: calc(100vw - 40px) !important;
    margin-left: 20px !important;
    margin-right: auto !important;
    box-sizing: border-box;
  }
  
  .game {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    padding: 10px !important;  /* thinner padding on mobile */
    box-sizing: border-box;
  }
  
  .game img {
    width: 120px;
    height: 120px;
  }
  
  .games-h1 {
    font-size: 28px;
    margin-bottom: 30px;
  }
  
  /* Contact section */
  .contact {
    width: calc(100vw - 40px) !important;
    max-width: calc(100vw - 40px) !important;
    margin-left: 20px !important;
    margin-right: auto !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    padding: 20px;
    box-sizing: border-box;
  }
  
  /* Space facts navigation */
.fact-nav {
  display: flex;
  flex-wrap: nowrap;       /* prevents stacking */
  justify-content: center; /* center items */
  align-items: center;    /* vertically center */
  gap: 0;                     /* no gap - use negative margins instead */
  padding: 1px 2px;       /* thinner padding for mobile */
  background-color: #2c00a5;
  border-radius: 50px;     /* pill shape - very rounded */
  font-family: "Roboto", sans-serif;
  box-shadow: 0px 0px 15px #293647;

  position: fixed;
  top: -35px;               /* very close to top navbar */
  width: calc(100% - 40px) !important;  /* same width as topnav */
  max-width: calc(100% - 40px) !important;
  left: 50%;
  transform: translateX(-50%);
  margin-left: 0 !important;
  margin-right: 0 !important;
  z-index: 10;              /* below mobile menu */
  overflow-x: hidden;      /* prevent horizontal scrolling */
  white-space: nowrap;     /* anchors stay in one line */
  height: auto;            /* auto height for pill */
}

  
  .fact-nav a {
    font-size: 13px;       /* slightly smaller font */
    font-weight: bold;     /* bold text */
    padding: 4px 6px;      /* reduced horizontal padding */
    min-width: auto;       /* remove minimum width constraint */
    border-radius: 20px;  /* rounded links */
    margin-left: -2px;    /* increased negative margin to bring items closer */
    margin-right: -2px;   /* increased negative margin to bring items closer */
  }
  
  .fact-nav a:first-child {
    margin-left: 0;        /* no negative margin on first item */
  }
  
  .fact-nav a:last-child {
    margin-right: 0;      /* no negative margin on last item */
  }
  
  .fact-nav a.active,
  .fact-nav a:hover {
    padding: 1px 0px;      /* thinner padding for active/hover box */
  }
  
  /* Facts layout - ALWAYS VERTICAL STACK */
  .first-line-of-facts {
    margin-top: 180px;
    flex-direction: column !important;
    gap: 20px;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 20px !important;    /* add padding to match line-of-facts */
    box-sizing: border-box;
  }
  
  .line-of-facts {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    gap: 30px;                /* keep gap between boxes in same line */
    padding: 20px;            /* restore padding for sides */
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: -0px !important;  /* negative margin to cancel gap between containers */
    margin-top: 0 !important;
    box-sizing: border-box;
    clear: both;
  }
  
  .line-of-facts:first-child {
    margin-top: 0 !important;
  }
  
  .line-of-facts:last-child {
    margin-bottom: 0 !important;  /* no negative margin on last container */
  }
  
  .fact {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px;
    margin-bottom: 0 !important;  /* no margin - gap handles spacing */
    box-sizing: border-box;
  }
  
  /* Memory game */
  .memory-title {
    margin-top: 120px;
    font-size: 24px;
  }
  
  .grid-container {
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(4, 100px);
    grid-gap: 10px;
  }
  
  .card {
    height: 100px;
    width: 100px;
  }
  
  .front-image {
    width: 70px;
    height: 70px;
  }
  
  /* Moon Clicker */
  .clicker-game {
    margin-top: 120px;
  }
  
  .clicker-title {
    font-size: 32px;
  }
  
  .clicker-top-right {
    position: relative;
    top: auto;
    right: auto;
    justify-content: center;
    margin: 20px auto;
  }
  
  .clicker-top-left {
    position: relative;
    top: auto;
    left: auto;
    align-items: center;
    margin: 20px auto;
    text-align: center;
  }
  
  .pig-image {
    width: 300px;
    height: 300px;
    margin-top: 20px;
  }
  
  #moon-image {
    height: 250px;
    width: 250px;
    top: 250px;
  }
  
  #light-effect {
    width: 350px;
  }
  
  .button-section {
    flex-direction: column !important;
    gap: 20px;
    margin-top: 20px;
  }
  
  .button-section button {
    margin: 5px;
    padding: 15px 20px;
    font-size: 14px;
  }
  
  /* Wordle game */
  .wordle-h1 {
    margin-top: 120px;
    font-size: 28px;
  }
  
  #wordle-game {
    height: 400px;
  }
  
  .wordle-grid {
    transform: scale(0.8);
  }
  
  .wordle-box {
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    margin: 2px;
  }
  
  .Winner-Lost {
    font-size: 20px;
    margin-top: -40px;
  }
  
  #reset-btn {
    font-size: 16px;
    padding: 8px 16px;
  }
  
  /* 404 page */
  .page-not-found h1 {
    font-size: 60px;
  }
  
  .page-not-found h3 {
    font-size: 20px;
  }
  
  .page-not-found a {
    font-size: 24px;
    padding: 15px;
  }
  
  /* Scroll margins */
  #one, #hundred, #twohundred, #twohundredfifty, #threehundred, #fourhundred, #fivehundred, #sixhundred, #sevenhundred, #sevenhundredfifty {
    scroll-margin-top: 150px;
  }
  
  #videos {
    scroll-margin-top: 150px;
  }
  
  /* Social media icons */
  .intro img {
    width: 60px;
  }
  
  .socials img {
    width: 50px;
  }
  
  /* Fact intro and socials */
  .fact-intro {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto 20px auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 20px;           /* keep internal padding, container handles spacing */
    box-sizing: border-box;
  }
  
  .socials {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
  }
  
  .book-cover-container {
    max-width: 250px;
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
  }
  
  .book-cover {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
  
  .topnav h1 {
    font-size: 16px;
  }
  
  .topnav a {
    font-size: 12px;
    padding: 6px 8px;
  }
  
  .intro {
    width: 95%;
    padding: 10px;
  }
  
  .moonpic {
    width: 95%;
    padding: 10px;
  }
  
  .videosection {
    width: 95%;
    margin-left: 2.5%;
    margin-right: 2.5%;
  }
  
  .line-of-games {
    width: 95%;
    margin-left: 2.5%;
    margin-right: 2.5%;
  }
  
  .contact {
    width: 95%;
    padding: 15px;
  }
  
  .fact-nav {
    width: 95%;
    margin-left: 2.5%;
    margin-right: 2.5%;
  }
  
  .fact-intro {
    width: 95%;
  }
  
  .socials {
    width: 95%;
  }
  
  /* Facts layout - ensure vertical stacking on small screens */
  .line-of-facts {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 15px;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 15px !important;
    box-sizing: border-box;
    clear: both;
  }
  
  .fact {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 15px;
    box-sizing: border-box;
  }
  
  /* Memory game - even smaller grid */
  .grid-container {
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(4, 80px);
    grid-gap: 8px;
  }
  
  .card {
    height: 80px;
    width: 80px;
  }
  
  .front-image {
    width: 55px;
    height: 55px;
  }
  
  /* Moon Clicker - smaller elements */
  .clicker-title {
    font-size: 24px;
  }
  
  .clicker-top-right span,
  .clicker-top-left span,
  .clicker-top-left p {
    font-size: 24px;
  }
  
  .clicker-top-right img {
    height: 60px;
    width: 60px;
  }
  
  .pig-image {
    width: 250px;
    height: 250px;
  }
  
  #moon-image {
    height: 200px;
    width: 200px;
    top: 200px;
  }
  
  #light-effect {
    width: 280px;
  }
  
  /* Wordle - smaller grid */
  .wordle-grid {
    transform: scale(0.7);
  }
  
  .wordle-box {
    width: 45px;
    height: 45px;
    font-size: 1.6rem;
    margin: 1px;
  }
  
  .games-h1 {
    font-size: 24px;
  }
  
  .memory-title {
    font-size: 20px;
  }
  
  .wordle-h1 {
    font-size: 24px;
  }
}

/* Landscape orientation on mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
  
  /* Keep everything vertical even in landscape for better readability */
  .toppart {
    flex-direction: column !important;
    gap: 20px;
  }
  
  .intro {
    width: 90%;
    margin: 0 auto 15px auto;
  }
  
  .moonpic {
    width: 90%;
    margin: 0 auto;
  }
  
  /* Keep videos vertical */
  .vids {
    flex-direction: column !important;
    gap: 20px;
  }
  
  .vid-container {
    flex: 1 1 100% !important;
    max-width: 100% !important;
  }
  
  /* Keep games vertical */
  .line-of-games {
    flex-direction: column !important;
    gap: 20px;
  }
  
  /* Keep facts vertical */
  .first-line-of-facts {
    flex-direction: column !important;
    gap: 15px;
  }
  
  .line-of-facts {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 15px !important;
    box-sizing: border-box;
    clear: both;
  }
  
  .fact {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  
  /* Keep buttons vertical */
  .button-section {
    flex-direction: column !important;
    gap: 15px;
  }
  
  .memory-title {
    margin-top: 100px;
  }
  
  .clicker-game {
    margin-top: 100px;
  }
  
  .wordle-h1 {
    margin-top: 100px;
  }
  
  .fact-nav {
    margin-top: 100px;
  }
  
  .first-line-of-facts {
    margin-top: 140px;
  }
}

/* Tablet devices */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  
  .topnav {
    margin-left: 2%;
    margin-right: 2%;
    width: 96%;
  }
  
  .toppart {
    gap: 20px;
  }
  
  .intro {
    width: 55%;
    margin-left: 2%;
    margin-right: 1%;
  }
  
  .moonpic {
    width: 41%;
    margin-left: 1%;
    margin-right: 2%;
  }
  
  .vids {
    gap: 20px;
  }
  
  .vid-container {
    flex: 1 1 calc(50% - 20px);
    max-width: 48%;
  }
  
  .line-of-games {
    gap: 30px;
  }
  
  .game {
    flex: 1;
  }
  
  .grid-container {
    grid-template-columns: repeat(4, 120px);
    grid-template-rows: repeat(3, 120px);
    grid-gap: 12px;
  }
  
  .card {
    height: 120px;
    width: 120px;
  }
  
  .front-image {
    width: 85px;
    height: 85px;
  }
  
  .pig-image {
    width: 500px;
    height: 500px;
  }
  
  #moon-image {
    height: 350px;
    width: 350px;
    top: 400px;
  }
  
  #light-effect {
    width: 550px;
  }
  
  .wordle-grid {
    transform: scale(0.9);
  }
  
  .wordle-box {
    width: 55px;
    height: 55px;
    font-size: 2rem;
  }
}

/* Ensure touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
  
  .topnav a:hover,
  .fact-nav a:hover,
  .game:hover,
  .intro img:hover,
  .socials img:hover,
  .card:hover,
  #moon-image:hover,
  .button-section button:hover,
  #reset-btn:hover,
  .actions button:hover {
    transform: none;
    scale: none;
  }
  
  .topnav a:active,
  .fact-nav a:active,
  .game:active,
  .intro img:active,
  .socials img:active,
  .card:active,
  #moon-image:active,
  .button-section button:active,
  #reset-btn:active,
  .actions button:active {
    transform: scale(0.95);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  
  .topnav #logo,
  .game img,
  .front-image,
  .clicker-top-right img,
  .intro img,
  .socials img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Accessibility improvements for mobile */
@media screen and (max-width: 768px) {
  
  /* Ensure minimum touch target size */
  .topnav a,
  .fact-nav a,
  .button-section button,
  #reset-btn,
  .actions button {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Improve text readability and fix background */
  body {
    font-size: 16px;
    line-height: 1.5;
    background-color: rgb(8, 0, 153) !important; /* Explicit fallback to prevent white flash */
    background: rgb(8, 0, 153) !important; /* Fallback color */
    background: linear-gradient(162deg, rgb(5, 0, 104) 0%, rgb(9, 9, 155) 52%, rgb(0, 74, 185) 100%) !important;
    background-attachment: scroll !important; /* Fix black flash on mobile */
    background-size: cover !important;
    background-repeat: no-repeat !important;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Full height on mobile */
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    width: 100% !important;
    max-width: 100vw !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* Fix for when browser UI hides - ensure background covers */
  html {
    background-color: rgb(8, 0, 153) !important; /* Explicit fallback to prevent white flash */
    background: rgb(8, 0, 153) !important; /* Fallback color */
    background: linear-gradient(162deg, rgb(5, 0, 104) 0%, rgb(9, 9, 155) 52%, rgb(0, 74, 185) 100%) !important;
    background-attachment: scroll !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    width: 100% !important;
    max-width: 100vw !important;
  }
  
  /* Ensure sufficient contrast */
  .topnav,
  .fact-nav,
  .intro,
  .moonpic,
  .videosection,
  .game,
  .contact,
  .fact-intro,
  .socials,
  .fact {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

/* Hamburger Menu Styles */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 10px;
  position: absolute;
  right: 20px;
  top: 20px;
  z-index: 1001;
  color: #ffffff !important;
  color-scheme: light !important;
  -webkit-color-scheme: light !important;
  filter: none !important;
  -webkit-filter: none !important;
}

.hamburger span {
  display: none; /* Hide spans, using SVG instead */
}

.hamburger svg {
  display: block;
  width: 25px;
  height: 18px;
  fill: #ffffff !important;
  color: #ffffff !important;
  filter: none !important;
  -webkit-filter: none !important;
  color-scheme: light !important;
  -webkit-color-scheme: light !important;
}

.hamburger svg {
  transition: transform 0.3s;
  fill: #ffffff !important;
  display: block;
}

.hamburger svg rect {
  transition: transform 0.3s ease, opacity 0.3s ease;
  fill: #ffffff !important;
  transform-origin: center;
}

.hamburger.active svg rect:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
  fill: #ffffff !important;
}

.hamburger.active svg rect:nth-child(2) {
  opacity: 0;
  fill: #ffffff !important;
}

.hamburger.active svg rect:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
  fill: #ffffff !important;
}

.menu-overlay {
  display: none !important;  /* hide overlay completely */
}

.mobile-menu {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background-color: #2c00a5;
  border-radius: 20px 0 0 20px;
  padding: 80px 20px 20px 20px;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.3);
  z-index: 10000;            /* above everything */
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
  overflow-y: auto;
  visibility: hidden;
}
.mobile-menu.active {
  opacity: 1 !important;
  transform: translateX(0) !important;
  pointer-events: auto !important;
  visibility: visible !important;
  display: flex !important;
}

.mobile-menu.active a {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.mobile-menu a {
  color: #f2f2f2 !important;
  text-align: center;
  padding-top: 0px !important;
  text-decoration: none;
  font-size: 20px;
  font-weight: bold !important;
  transition: 0.3s;
  border: none !important;
  border-radius: 10px;
  margin: 8px 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  visibility: visible !important;
  opacity: 1 !important;
  background-color: rgba(255, 255, 255, 0.05);
  min-height: 50px;
  height: 50px;
  line-height: 3 !important;
}

.mobile-menu a:last-child {
  border: none !important;
}

.mobile-menu a:hover {
  background-color: #576374;
  color: rgb(255, 255, 255) !important;
}

.mobile-menu a.active {
  background-color: #004ab9;
  color: white !important;
}

/* Desktop menu centered in navbar */
.desktop-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  height: 100%;
  justify-content: center;
  margin-left: 0;
  width: auto;
  margin-top: 30px;
}

.desktop-menu a {
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  transition: 0.3s;
}

.desktop-menu a:hover {
  background-color: #576374;
  color: rgb(255, 255, 255);
  border-radius: 10px;
}

.desktop-menu a.active {
  background-color: #004ab9;
  color: white;
  border-radius: 10px;
}

@media screen and (max-width: 768px) {
  .desktop-menu {
    display: none !important;
    position: static;
    left: auto;
    transform: none;
  }
  .hamburger {
    display: flex !important;
  }
  .mobile-menu {
    top: 0;
    border-radius: 20px 0 0 20px;
  }
  .menu-overlay {
    display: block;
  }
  .topnav a {
    display: none !important;
  }
  
  /* Mobile game overlay - disable games on mobile */
  .mobile-game-overlay {
    position: fixed;
    top: 0;  /* Start from top to blur behind navbar too */
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;  /* Below navbar but above content */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
  }
  
  /* Ensure navbar stays above overlay and unblurred */
  .topnav {
    z-index: 1000 !important;  /* Above overlay */
  }
  
  .topnav .hamburger {
    z-index: 10001 !important;  /* Above everything */
  }
  
  .mobile-menu {
    z-index: 10000 !important;  /* Above overlay */
  }
  
  .mobile-game-message {
    background-color: #2c00a5;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.5);
    max-width: 90%;
  }
  
  .mobile-game-message h2 {
    color: #ffffff;
    font-family: "Roboto", sans-serif;
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 30px 0;
  }
  
  .mobile-game-home-button {
    display: inline-block;
    background-color: #004ab9;
    color: #ffffff;
    font-family: "Roboto", sans-serif;
    font-size: 18px;
    font-weight: bold;
    padding: 15px 30px;
    border-radius: 10px;
    text-decoration: none;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .mobile-game-home-button:hover {
    background-color: #0056d6;
    transform: scale(1.05);
  }
  
  .mobile-game-home-button:active {
    transform: scale(0.95);
  }
}

/* Hide overlay on desktop */
@media screen and (min-width: 769px) {
  .mobile-game-overlay {
    display: none !important;
  }
}


