:root {
  --mario-red: #e52521;
  --mario-blue: #049cd8;
  --mario-yellow: #fbd000;
  --mario-green: #43b047;
  --pipe-green: #43b047;
  --hill-green: #5aa832;
  --bush-green: #7cc850;
}

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

body {
  font-family: "Press Start 2P", cursive;
  background-color: var(--mario-blue);
  color: white;
  text-align: center;
  padding: 10px 10px 120px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(251,208,0,0.2) 0%, transparent 20%),
    radial-gradient(circle at 80% 70%, rgba(229,37,33,0.2) 0%, transparent 20%);
}

/* Character Rain */
.character-rain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.falling-character {
  position: absolute;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 0;
  animation: falling linear infinite;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  image-rendering: optimizeQuality;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  width: auto !important;
  height: auto !important;
  will-change: transform;
}

@keyframes falling {
  0% { 
    transform: translateY(-100px) translateX(0) rotate(0deg); 
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% { 
    transform: translateY(calc(100vh + 100px)) translateX(20px) rotate(360deg); 
    opacity: 0;
  }
}
/* Mobile-specific styles */
body.mobile {
  padding-bottom: 20px !important;
}

body.mobile .title-container {
  justify-content: center;
}

body.mobile .coin-box {
  display: none !important;
}

body.mobile .landscape {
  display: none !important;
}

/* Adjust game buttons for mobile */
body.mobile .game-buttons {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
  gap: 12px !important;
  padding-bottom: 10px !important;
}

body.mobile .game-button {
  height: 110px !important;
  font-size: 12px !important;
}

body.mobile .game-icon {
  width: 40px !important;
  height: 40px !important;
}

/* Title adjustments for mobile */
body.mobile h1 {
  font-size: 1.1rem !important;
  padding: 0 8px !important;
  white-space: normal !important;
}

body.mobile .title-text {
  animation: none !important;
  border-right: none !important;
}

/* Character Rain */
.character-rain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.falling-character {
  position: absolute;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 0;
  animation: falling linear infinite;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  image-rendering: optimizeQuality;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  width: 30px !important;
  height: 30px !important;
}

@keyframes falling {
  0% { transform: translateY(-100px) rotate(0deg); }
  100% { transform: translateY(calc(100vh + 100px)) rotate(360deg); }
}

/* Title Container */
.title-container {
  background: linear-gradient(90deg, var(--mario-red), var(--mario-yellow), var(--mario-green), var(--mario-blue));
  background-size: 300% 300%;
  padding: 10px;
  margin: -10px -10px 15px -10px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  animation: titleGradient 8s ease infinite;
  position: relative;
  overflow: hidden;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.coin-box {
  width: 30px;
  height: 30px;
  background: #fbd000;
  border: 4px solid #d4a900;
  border-radius: 5px;
  margin: 0 8px;
  position: relative;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.coin-box::before {
  content: "?";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #8a6d00;
  font-size: 16px;
}

h1 {
  color: white;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.3);
  margin: 0;
  font-size: 1.2rem;
  position: relative;
  z-index: 2;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 5px;
}

.title-text {
  display: inline-block;
  overflow: hidden;
  border-right: 5px solid white;
  animation: typing 3s steps(20, end), blink-caret 0.75s step-end infinite;
}

/* Game Buttons Grid */
.game-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 15px;
  padding: 10px 10px 20px;
  max-width: 100%;
  margin: 0 auto;
}

.game-button {
  width: 100%;
  height: 120px;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 0 rgba(0,0,0,0.2), inset 0 -5px 0 rgba(255,255,255,0.2);
  font-weight: bold;
  font-size: clamp(12px, 3vw, 16px);
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  aspect-ratio: 1/1;
  -webkit-tap-highlight-color: transparent;
}

.game-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 11px 0 rgba(0,0,0,0.2), inset 0 -5px 0 rgba(255,255,255,0.2);
}

.game-icon {
  width: 50px;
  height: 50px;
  margin-bottom: 8px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(3px 3px 0 rgba(0,0,0,0.2));
  transition: transform 0.3s;
}

/* Decorative Elements */
.cloud {
  position: absolute;
  background: white;
  border-radius: 50%;
  opacity: 0.9;
  z-index: 1;
  filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.1));
}

.coin {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fbd000;
  border-radius: 50%;
  border: 2px solid #d4a900;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
  z-index: 3;
  animation: spinCoin 2s linear infinite;
}

/* Cloud Positions */
.cloud-1 {
  width: 100px;
  height: 50px;
  top: 15%;
  left: -150px;
  animation: floatCloud 25s linear infinite;
}

.cloud-2 {
  width: 150px;
  height: 75px;
  top: 30%;
  right: -200px;
  animation: floatCloud 30s linear infinite 5s;
}

.cloud-3 {
  width: 120px;
  height: 60px;
  top: 60%;
  left: -180px;
  animation: floatCloud 28s linear infinite 10s;
}

/* Super Mario World Landscape */
.landscape {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 120px;
  z-index: 5;
  overflow: hidden;
}

.hills {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--hill-green);
  border-top: 4px solid #3e7a25;
}

.hills::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 300%;
  height: 60px;
  background: 
    radial-gradient(ellipse at bottom, var(--hill-green) 70%, transparent 70.5%) 0 0 / 120px 60px,
    radial-gradient(ellipse at bottom, var(--hill-green) 70%, transparent 70.5%) 60px 0 / 120px 60px;
  animation: scrollHills 60s linear infinite;
}

.landscape-pipe {
  position: absolute;
  bottom: 0;
  width: 80px;
  height: 120px;
  background: var(--pipe-green);
  border: 4px solid #2d7a30;
  border-radius: 10px 10px 0 0;
  z-index: 6;
}

.landscape-pipe::before {
  content: "";
  position: absolute;
  top: -8px;
  left: -4px;
  right: -4px;
  height: 15px;
  background: var(--pipe-green);
  border: 4px solid #2d7a30;
  border-radius: 10px 10px 0 0;
}

.bush {
  position: absolute;
  bottom: 0;
  width: 80px;
  height: 40px;
  background: var(--bush-green);
  border-radius: 20px;
  z-index: 6;
}

.landscape-character {
  position: absolute;
  bottom: 60px;
  width: 40px;
  height: 50px;
  background-size: contain;
  background-repeat: no-repeat;
  z-index: 7;
  animation: bounce 2s ease-in-out infinite;
}

/* Animations */
@keyframes titleGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: white }
}

@keyframes spinCoin {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 300px)); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes scrollHills {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Tablet Styles */
@media (min-width: 600px) {
  body {
    padding: 15px 15px 140px;
  }
  
  body.mobile {
    padding-bottom: 20px !important;
  }
  
  .game-buttons {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    padding-bottom: 30px;
  }
  
  .game-button {
    height: 150px;
  }
  
  .game-icon {
    width: 60px;
    height: 60px;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .coin-box {
    width: 40px;
    height: 40px;
    margin: 0 15px;
  }
  
  .coin-box::before {
    font-size: 20px;
  }
  
  .landscape {
    height: 140px;
  }
  
  .hills::before {
    height: 70px;
    background-size: 140px 70px;
  }
  
  .landscape-pipe {
    width: 90px;
    height: 140px;
  }
  
  .landscape-character {
    bottom: 70px;
    width: 45px;
    height: 55px;
  }
  
  .bush {
    width: 90px;
    height: 45px;
  }
}

/* Desktop Styles */
@media (min-width: 1024px) {
  .game-buttons {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 25px;
    max-width: 900px;
    padding-bottom: 40px;
  }
  
  .game-button {
    height: 180px;
  }
  
  .game-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
  }
  
  .title-container {
    flex-wrap: nowrap;
    justify-content: space-between;
  }
  
  h1 {
    flex-grow: 1;
    text-align: center;
    padding: 0 20px;
    font-size: 2rem;
  }
  
  .coin {
    width: 20px;
    height: 20px;
  }
  
  body {
    padding-bottom: 160px;
  }
  
  .landscape {
    height: 160px;
  }
  
  .hills::before {
    height: 80px;
    background-size: 160px 80px;
  }
  
  .landscape-pipe {
    width: 100px;
    height: 160px;
  }
  
  .landscape-character {
    bottom: 80px;
    width: 50px;
    height: 60px;
  }
  
  .bush {
    width: 100px;
    height: 50px;
  }
/* Rainbow Game Buttons */
.game-buttons a {
    background: var(--button-bg) !important;
    border: 4px solid white !important;
    box-shadow: 0 6px 0 rgba(0,0,0,0.2), inset 0 -5px 0 rgba(255,255,255,0.2) !important;
    transition: all 0.3s ease !important;
}

.game-buttons a:hover {
    transform: translateY(-5px) !important;
    box-shadow: 0 11px 0 rgba(0,0,0,0.2), inset 0 -5px 0 rgba(255,255,255,0.2) !important;
    filter: brightness(1.1) !important;
}

/* Specific rainbow colors for each button */
.game-buttons a:nth-child(1) { --button-bg: linear-gradient(135deg, #FF0000 0%, #FF4500 100%); }
.game-buttons a:nth-child(2) { --button-bg: linear-gradient(135deg, #FF8C00 0%, #FFD700 100%); }
.game-buttons a:nth-child(3) { --button-bg: linear-gradient(135deg, #FFD700 0%, #9ACD32 100%); }
.game-buttons a:nth-child(4) { --button-bg: linear-gradient(135deg, #32CD32 0%, #00FA9A 100%); }
.game-buttons a:nth-child(5) { --button-bg: linear-gradient(135deg, #00BFFF 0%, #1E90FF 100%); }
.game-buttons a:nth-child(6) { --button-bg: linear-gradient(135deg, #9370DB 0%, #8A2BE2 100%); }
.game-buttons a:nth-child(7) { --button-bg: linear-gradient(135deg, #FF69B4 0%, #FF1493 100%); }
}
@media (max-width: 599px) {
  .game-button {
    background: var(--button-bg, linear-gradient(135deg, #ff1a1a 0%, #cc0000 100%)) !important;
    border: 4px solid white !important;
  }
  
  /* Explicitly set rainbow colors for mobile */
  .game-buttons a:nth-child(1) { 
    background: linear-gradient(135deg, #FF0000 0%, #FF4500 100%) !important; 
  }
  .game-buttons a:nth-child(2) { 
    background: linear-gradient(135deg, #FF8C00 0%, #FFD700 100%) !important; 
  }
  .game-buttons a:nth-child(3) { 
    background: linear-gradient(135deg, #FFD700 0%, #9ACD32 100%) !important; 
  }
  .game-buttons a:nth-child(4) { 
    background: linear-gradient(135deg, #32CD32 0%, #00FA9A 100%) !important; 
  }
  .game-buttons a:nth-child(5) { 
    background: linear-gradient(135deg, #00BFFF 0%, #1E90FF 100%) !important; 
  }
  .game-buttons a:nth-child(6) { 
    background: linear-gradient(135deg, #9370DB 0%, #8A2BE2 100%) !important; 
  }
}