body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Comic Neue", "Comic Sans MS", cursive, sans-serif;
  color: #FFFFFF;
  scroll-behavior: smooth;
}

* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

#video-background {
  position: fixed;
  right: 0;
  bottom: 0;
  min-width: 100%;
  min-height: 100%;
  z-index: -3;
}

#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: -2;
}

nav {
  position: fixed;
  top: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.51);
  padding: 10px 0;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

nav ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

nav ul li {
  display: inline;
  margin: 0 20px;
}

nav ul li a {
  color: #1aff00;
  text-decoration: none;
  font-size: 18px;
  transition: color 0.3s ease;
}

nav ul li a:hover {
  color: #ff0000;
}

section {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 50px 20px;
  position: relative;
  background: rgba(0, 0, 0, 0.5);
  margin: 0 auto;
  height: 100vh;
  width: 100%;
  scroll-snap-align: start;
}

section div {
  width: 75%;
  max-width: 800px;
  text-align: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 20px;
  border-radius: 10px;
}

#Tetris canvas {
  width: 75%;
  max-width: 800px;
  text-align: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 20px;
  border-radius: 10px;
}

#enable-onscreen-btn,
#disable-onscreen-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 10px 15px;
  background-color: #0a0a0a;
  color: #1aff00;
  border: 1px solid #1aff00;
  border-radius: 5px;
  cursor: pointer;
  z-index: 10;
  font-weight: bold;
  font-size: 16px;
  box-shadow: 0 0 10px rgba(26, 255, 0, 0.3);
  transition: all 0.15s ease-in-out;
}

#enable-onscreen-btn:active,
#disable-onscreen-btn:active {
  background-color: #1aff00;
  color: #000;
  box-shadow: 0 0 15px rgba(26, 255, 0, 0.5);
  transform: scale(0.95);
}

#play-music-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 15px;
  background-color: #1aff00;
  color: black;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  z-index: 10;
  font-weight: bold;
  font-size: 16px;
}

#tetris-onscreen-controls {
  position: fixed;
  bottom: 65px;
  left: 20px;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  mix-blend-mode: normal !important;
  contain: layout paint style;
  will-change: transform;
  transform: translateZ(0);
  isolation: isolate;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
}

#tetris-onscreen-controls.show {
  display: flex !important;
}

#tetris-onscreen-controls > div {
  display: flex !important;
  gap: 4px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

#tetris-onscreen-controls button {
  background: #0a0a0a !important;
  color: #1aff00 !important;
  border: 1px solid #1aff00 !important;
  border-radius: 10px !important;
  width: 56px !important;
  height: 56px !important;
  font-size: 22px !important;
  font-weight: bold !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 0 10px rgba(26, 255, 0, 0.3) !important;
  transition: all 0.15s ease-in-out;
}

#tetris-onscreen-controls button:active {
  background: #1aff00 !important;
  color: #000 !important;
  box-shadow: 0 0 15px rgba(26, 255, 0, 0.5) !important;
  transform: scale(0.95);
}

#tetris-onscreen-controls button[onclick*="rotate"] {
  width: 170px !important;
  height: 56px !important;
}


/* Dpad desktop defaults */
#tetris-dpad {
  display: flex;
  gap: 4px;
}

#tetris-dpad button,
#tetris-rotate-btn {
  background: #0a0a0a;
  color: #1aff00;
  border: 1px solid #1aff00;
  border-radius: 10px;
  width: 56px;
  height: 56px;
  font-size: 22px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(26, 255, 0, 0.3);
  cursor: pointer;
}

#tetris-rotate-btn {
  width: 170px;
  height: 56px;
  margin-top: 3px;
}

/* ═══════════════════════════════════════════
   TETRIS MOBILE UI
   ═══════════════════════════════════════════ */

/* Desktop enable/disable button styles */
#enable-onscreen-btn,
#disable-onscreen-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 10;
  padding: 10px 12px;
  font-size: 15px;
  background: #ffff00;
  color: #000;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#enable-onscreen-btn { display: inline-block; }
#disable-onscreen-btn { display: none; }

@media (max-width: 768px) {

  html {
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  /* Tint strip */
  nav {
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Fix canvas CSS stretch */
  #Tetris canvas, #tetris {
    width: 180px !important;
    height: 300px !important;
    max-width: 180px !important;
    min-width: 180px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    display: block !important;
    box-sizing: content-box !important;
  }

  /* Section */
  section {
    padding: 50px 10px 280px 10px !important;
    background: transparent !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    height: 100vh !important;
  }

  section div {
    width: 96% !important;
    max-width: 100% !important;
    background: rgba(0, 0, 0, 0.82) !important;
    border: 1px solid rgba(26, 255, 0, 0.25) !important;
    border-radius: 10px !important;
    padding: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }

  section div h1 { font-size: 18px !important; margin-bottom: 4px !important; }

  /* Score and speed text */
  section div p {
    font-size: 12px !important;
    margin: 2px 0 !important;
    color: #1aff00;
  }

  /* Hide keyboard hint on mobile */
  section div p[style*="color:#1aff00"] {
    display: none !important;
  }

  /* Hide enable/disable on mobile — controls always visible */
  #enable-onscreen-btn,
  #disable-onscreen-btn {
    display: none !important;
  }

  /* On-screen controls — centered at bottom */
  #tetris-onscreen-controls {
    position: fixed !important;
    bottom: 115px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: max-content !important;
    display: none;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  #tetris-onscreen-controls.show {
    display: flex !important;
  }

  #tetris-dpad {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #tetris-dpad button {
    width: 72px !important;
    height: 72px !important;
    font-size: 28px !important;
    border-radius: 12px !important;
  }

  #tetris-rotate-btn {
    width: 234px !important;
    height: 60px !important;
    font-size: 18px !important;
    border-radius: 12px !important;
  }

  /* Music controls full width */
  #music-select {
    position: fixed !important;
    bottom: 58px !important;
    right: 10px !important;
    left: 10px !important;
    width: calc(100% - 20px) !important;
    font-size: 13px !important;
    z-index: 13 !important;
  }

  #play-music-btn,
  #pause-music-btn {
    position: fixed !important;
    bottom: 10px !important;
    right: 10px !important;
    left: 10px !important;
    width: calc(100% - 20px) !important;
    text-align: center !important;
    font-size: 14px !important;
    padding: 12px !important;
    border-radius: 6px !important;
  }
}

@media (max-width: 400px) {
  #tetris-onscreen-controls button {
    width: 64px !important;
    height: 64px !important;
    font-size: 24px !important;
  }

  #tetris-onscreen-controls button[onclick*="rotate"] {
    width: 208px !important;
    height: 56px !important;
  }
}