Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- about -->
<div class="about">
   <a class="bg_links social portfolio" href="https://www.rafaelalucas.com" target="_blank">
      <span class="icon"></span>
   </a>
   <a class="bg_links social dribbble" href="https://dribbble.com/rafaelalucas" target="_blank">
      <span class="icon"></span>
   </a>
   <a class="bg_links social linkedin" href="https://www.linkedin.com/in/rafaelalucas/" target="_blank">
      <span class="icon"></span>
   </a>
   <a class="bg_links logo"></a>
</div>
<!-- end about -->

<div class="test">
   <div class="buttonsTest">
      <button class="btnOver">gameover</button>
      <button class="btnAdd">add all pieces</button>
      <button class="btnRemove">remove all pieces</button>
   </div>
   <div class="toggles">

      <div class="number n-2" data-number="n-2">2</div>
      <div class="number n-4" data-number="n-4">4</div>
      <div class="number n-8" data-number="n-8">8</div>
      <div class="number n-16" data-number="n-16">16</div>
      <div class="number n-32" data-number="n-32">32</div>
      <div class="number n-64" data-number="n-64">64</div>
      <div class="number n-128" data-number="n-128">128</div>
      <div class="number n-256" data-number="n-256">256</div>
      <div class="number n-512" data-number="n-512">512</div>
      <div class="number n-1024" data-number="n-1024">1024</div>
      <div class="number n-2048" data-number="n-2048">2048</div>
      <div class="number n-4096" data-number="n-4096">4096</div>
      <div class="number n-8192" data-number="n-8192">8192</div>
      <div class="number generic" data-number="n-16384">16384</div>

   </div>
</div>
<div class="mainTitle">2048</div>
<div class="content">
   <div class="controls">
      <div class="score">
         <p class="title">Your Score</p>
         <p class="scoreNumber">2047898</p>
      </div>
      <button class="btn"><span></span><p data-title="new game" data-text="start!" data-start="good luck!"></p></button>

   </div>
   <div class="game">
      <ul class="grid-container">
         <li>
            <div id="n-2" class="piece n-2 pieceNone">2</div>
         </li>
         <li>
            <div id="n-4" class="piece n-4 pieceNone">4</div>
         </li>
         <li>
            <div id="n-8" class="piece n-8 pieceNone">8</div>
         </li>
         <li>
            <div id="n-16" class="piece n-16 pieceNone">16</div>
         </li>
         <li>
            <div id="n-32" class="piece n-32 pieceNone">32</div>
         </li>
         <li>
            <div id="n-64" class="piece n-64 pieceNone">64</div>
         </li>
         <li>
            <div id="n-128" class="piece n-128 pieceNone">128</div>
         </li>
         <li>
            <div id="n-256" class="piece n-256 pieceNone">256</div>
         </li>
         <li>
            <div id="n-512" class="piece n-512 pieceNone">512</div>
         </li>
         <li>
            <div id="n-1024" class="piece n-1024 pieceNone">1024</div>
         </li>
         <li>
            <div id="n-2048" class="piece n-2048 pieceNone">2048</div>
         </li>
         <li>
            <div id="n-4096" class="piece n-4096 pieceNone">4096</div>
         </li>
         <li>
            <div id="n-8192" class="piece n-8192 pieceNone">8192</div>
         </li>
         <li>
            <div id="n-16384" class="piece generic pieceNone">16384</div>
         </li>
         <li></li>
         <li></li>
      </ul>
      <div class="gameOver">
         <div class="text">
            <p>Game Over!</p>

            <button class="btn"><span></span><p data-title="new game" data-text="start!" data-start="good luck!"></p></button>
         </div>
      </div>
   </div>
</div>
              
            
!

CSS

              
                .about {
   $cubic: cubic-bezier(0.64, 0.01, 0.07, 1.65);
   $transition: 0.6s $cubic;
   $size: 40px;
   position: fixed;
   z-index: 10;
   bottom: 10px;
   right: 10px;
   width: $size;
   height: $size;
   display: flex;
   justify-content: flex-end;
   align-items: flex-end;
   transition: all 0.2s ease;

   .bg_links {
      width: $size;
      height: $size;
      border-radius: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: rgba(#000000, 0.2);
      border-radius: 100%;
      backdrop-filter: blur(5px);
      position: absolute;
   }

   .logo {
      width: $size;
      height: $size;
      z-index: 9;
      background-image: url(https://rafaelavlucas.github.io/assets/codepen/logo_white.svg);
      background-size: 50%;
      background-repeat: no-repeat;
      background-position: 10px 7px;
      opacity: 0.9;
      transition: all 1s 0.2s ease;
      bottom: 0;
      right: 0;
   }

   .social {
      opacity: 0;
      right: 0;
      bottom: 0;

      .icon {
         width: 100%;
         height: 100%;
         background-size: 20px;
         background-repeat: no-repeat;
         background-position: center;
         background-color: transparent;
         display: flex;
         transition: all 0.2s ease, background-color 0.4s ease;
         opacity: 0;
         border-radius: 100%;
      }

      &.portfolio {
         transition: all 0.8s ease;

         .icon {
            background-image: url(https://rafaelavlucas.github.io/assets/codepen/link.svg);
         }
      }

      &.dribbble {
         transition: all 0.3s ease;
         .icon {
            background-image: url(https://rafaelavlucas.github.io/assets/codepen/dribbble.svg);
         }
      }

      &.linkedin {
         transition: all 0.8s ease;
         .icon {
            background-image: url(https://rafaelavlucas.github.io/assets/codepen/linkedin.svg);
         }
      }
   }

   &:hover {
      width: 105px;
      height: 105px;
      transition: all $transition;

      .logo {
         opacity: 1;
         transition: all 0.6s ease;
      }

      .social {
         opacity: 1;

         .icon {
            opacity: 0.9;
         }

         &:hover {
            background-size: 28px;
            .icon {
               background-size: 65%;
               opacity: 1;
            }
         }

         &.portfolio {
            right: 0;
            bottom: calc(100% - 40px);
            transition: all 0.3s 0s $cubic;
            .icon {
               &:hover {
                  background-color: #698fb7;
               }
            }
         }

         &.dribbble {
            bottom: 45%;
            right: 45%;
            transition: all 0.3s 0.15s $cubic;
            .icon {
               &:hover {
                  background-color: #ea4c89;
               }
            }
         }

         &.linkedin {
            bottom: 0;
            right: calc(100% - 40px);
            transition: all 0.3s 0.25s $cubic;
            .icon {
               &:hover {
                  background-color: #0077b5;
               }
            }
         }
      }
   }
}

@import url("https://fonts.googleapis.com/css?family=Barlow+Condensed:300,400,500,600,700,800,900|Barlow+Semi+Condensed:300,400,500,600,700,800,900|Barlow:300,400,500,600,700,800,900&display=swap");

$bg-01: #fdf5f0; /*game*/
$bg-02: #f3e7e0; /*pieces*/
$bg-03: #ffe4d4; /*general*/

$c-01: #f9d1c0; /*txt*/
$c-02: #7084a1; /*txt*/
$c-03: #81c7b8; /*success*/

$n-2: #ffe09d;
$n-4: #ecb562;
$n-8: #e89355;
$n-16: #f1cec6;
$n-32: #eb8a7b;
$n-64: #d75c48;
$n-128: #bae3db;
$n-256: #81c7b8;
$n-512: #36857b;
$n-1024: #d4ddea;
$n-2048: #acc3de;
$n-4096: #7084a1;
$n-8192: #39537a;
$n-16384: #69597a;

@mixin lg {
   @media screen and (max-width: 850px), screen and (max-height: 800px) {
      @content;
   }
} 
@mixin md {
   @media screen and (max-width: 650px), screen and (max-height: 800px) {
      @content;
   }
}

@mixin sm {
   @media screen and (max-width: 500px), screen and (max-height: 700px) {
      @content;
   }
}

body {
   margin: 0;
   padding: 0;
   display: flex;
   align-items: center;
   justify-content: center;
   height: 100vh;
   width: 100%;
   background-color: $bg-03;
   font-family: "Barlow", sans-serif;
   overflow: hidden;
   font-size: 16px;
}

.test {
   width: 120px;
   position: absolute;
   left: 0;
   top: 0;
   display: flex;
   flex-direction: column;
   margin: 20px;
   transition: all 0.5s ease;
   
   .buttonsTest {
      height: 140px;
      
      
         button {
      width: 120px;
      border:0;
      padding: 8px 6px;
      font-size: 12px;
      font-family: "Barlow", sans-serif;
      border-radius: 5px;
      cursor: pointer;
      color: $c-03;
      background-color: white;
       margin: 5px 0;
      
      &.btnAdd {
         color: white;
         background-color: $n-256;
         display: block;
      }
      &.btnRemove {
         color: white;
        background-color: $n-64; 
         display: none;
      }
      &.btnOver {
         color: $c-02;
        background-color: white; 
         margin-bottom: 30px;
      }
      
      &:focus {
         outline:0;
      }
   }
   }

   
   .toggles {
      margin-top: 30px;
      height: 100%;
      display: grid;
      grid-template-columns: 1fr 1fr;
      
      @include lg {
         display: none;
      }
      .number {
         width: 50px;
         height: 50px;
         display: flex;
         justify-content: center;
         align-items: center;
         border-radius: 3px;
         margin: 5px;
         transition: all 0.5s ease;
         cursor: pointer;
         
         &:hover {
            opacity: 0.5;
         }
         
         &.on {
            box-shadow: inset 0px 0px 0px 4px white, 0px 0px 10px 0px darken($bg-03, 10%);
         }
         
          &.n-2 {
               background-color: $n-2;
               color: darken($n-2, 35%);
            }
            &.n-4 {
               background-color: $n-4;
               color: lighten($n-4, 25%);
            }
            &.n-8 {
               background-color: $n-8;
               color: lighten($n-8, 25%);
            }

            &.n-16 {
               background-color: $n-16;
               color: darken($n-16, 20%);
            }
            &.n-32 {
               background-color: $n-32;
               color: lighten($n-32, 20%);
            }
            &.n-64 {
               background-color: $n-64;
               color: lighten($n-64, 30%);
            }
            &.n-128 {
               background-color: $n-128;
               color: darken($n-128, 35%);
            }
            &.n-256 {
               background-color: $n-256;
               color: darken($n-256, 30%);
            }
            &.n-512 {
               background-color: $n-512;
               color: lighten($n-512, 30%);
            }
            &.n-128,
            &.n-256,
            &.n-512 {
               font-family: "Barlow Semi Condensed", sans-serif;
               letter-spacing: 1px;
            }
            &.n-1024 {
               background-color: $n-1024;
               color: darken($n-1024, 30%);
            }
            &.n-2048 {
               background-color: $n-2048;
               color: darken($n-2048, 30%);
            }
            &.n-4096 {
               background-color: $n-4096;
               color: lighten($n-4096, 30%);
            }
            &.n-8192 {
               background-color: $n-8192;
               color: lighten($n-8192, 32%);
            }
            &.n-1024,
            &.n-2048,
            &.n-4096,
            &.n-8192 {
               
               font-family: "Barlow Condensed", sans-serif;
               letter-spacing: 1px;
            }

            &.generic {
               background-color: $n-16384;
               color: lighten($n-16384, 35%);
               font-family: "Barlow Condensed", sans-serif;
               letter-spacing: 1px;
               
            }
      }
   }
}

p {
   margin: 0;
   padding: 0;
}

.btn {
         width: 130px;
         height: 42px;
         background-color: $bg-01;
         color: $c-02;
         position: relative;
         overflow: hidden;
         font-size: 14px;
         letter-spacing: 1px;
         font-weight: 500;
         text-transform: uppercase;
         font-family: "Barlow", sans-serif;
         transition: all 0.3s ease;
         cursor: pointer;
         border: 0;
         display: flex;
         align-items: center;
         justify-content: center;
         border-radius: 3px;

         &:before,
         &:after {
            content: "";
            position: absolute;
            width: 0;
            height: 2px;
            background-color: $c-03;
            transition: all 0.3s cubic-bezier(0.35, 0.1, 0.25, 1);
         }

         &:before {
            right: 0;
            top: 0;
            transition: all 0.5s cubic-bezier(0.35, 0.1, 0.25, 1);
         }

         &:after {
            left: 0;
            bottom: 0;
         }

         span {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            margin: 0;
            padding: 0;
            z-index: 1;

            &:before,
            &:after {
               content: "";
               position: absolute;
               width: 2px;
               height: 0;
               background-color: $c-03;
               transition: all 0.3s cubic-bezier(0.35, 0.1, 0.25, 1);
            }

            &:before {
               right: 0;
               top: 0;
               transition: all 0.5s cubic-bezier(0.35, 0.1, 0.25, 1);
            }

            &:after {
               left: 0;
               bottom: 0;
            }
         }

         p {
            padding: 0;
            margin: 0;
            transition: all 0.4s cubic-bezier(0.35, 0.1, 0.25, 1);
            position: absolute;
            width: 100%;
            height: 100%;

            &:before,
            &:after {
               position: absolute;
               width: 100%;
               transition: all 0.4s cubic-bezier(0.35, 0.1, 0.25, 1);
               z-index: 1;
               left: 0;
            }

            &:before {
               content: attr(data-title);
               top: 50%;
               transform: translateY(-50%);
            }

            &:after {
               content: attr(data-text);
               top: 150%;
               color: $c-03;
            }
         }

         &:hover {
            &:before,
            &:after {
               width: 100%;
               @include md {
                  width:0;
               }
            }

            span {
               z-index: 1;
               &:before,
               &:after {
                  height: 100%;
                  @include md {
                  height:0;
               }
               }
            }

            p {
               &:before {
                  top: -50%;
                  transform: rotate(5deg);
                  
                 @include md {
                     //content:'';
                     top: 50%;
                    transform: rotate(0deg);
               }
               }

               &:after {
                  top: 50%;
                  transform: translateY(-50%);
                 @include md {
                     content:'';
                     transform: translateY(0%);
               }
               }
            }
         }

         &.start {
            background-color: $c-03;
            box-shadow: 0px 5px 10px -10px rgba(0, 0, 0, 0.2);
            transition: all 0.2s ease;

            p {
               &:before {
                  top: -50%;
                  transform: rotate(5deg);
               }
               &:after {
                  color: white;
                  transition: all 0s ease;
                  content: attr(data-start);
                  top: 50%;
                  transform: translateY(-50%);
                  animation: start 0.3s ease;
                  animation-fill-mode: forwards;

                  @keyframes start {
                     from {
                        top: -50%;
                     }
                  }
               }
            }

            &:hover {
               &:before,
               &:after {
                  display: none;
               }
               span {
                  display: none;
               }
            }
         }
   
      &:active {
         outline: none;
         border: none;
      }
      &:focus {
         outline: 0;
      }
      }

.mainTitle {
   font-size: 350px;
   position: absolute;
   z-index: -1;
   color: $c-01;
   font-weight: 600;
   transform: translateY(-320px);
   opacity: 0.6;
   transition: all 0.5s ease;
   @include md {
      transform: translateY(-250px);
      font-size: 280px;
   }
   @include sm {
      transform: translateY(-170px);
      font-size: 180px;
   }
}

.content {
   display: flex;
   flex-direction: column;

   .controls {
      width: 100%;
      border-radius: 5px;
      margin-bottom: 20px;
      padding: 0;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .title {
         color: $c-02;
         font-size: 12px; 
         text-transform: uppercase;
         font-weight: 500;
         letter-spacing: 1px;      
      }

      .scoreNumber {
         font-weight: 500;
         font-size: 30px;
         font-family: "Barlow Condensed", sans-serif;
         color: $c-02;
         letter-spacing: 2px;
      }

      
   }

   .game {
      position: relative;
      padding: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: rgba(255,255,255,0.7);
      border-radius: 5px;
      
      @include sm {
         padding: 10px;
         }

      .grid-container {
         width: 500px;
         height: 500px;
         display: grid;
         grid-template-columns: 1fr 1fr 1fr 1fr;
         grid-template-rows: 1fr 1fr 1fr 1fr;
         grid-column-gap:20px;
         grid-row-gap: 20px;
         margin: 0;
         padding: 0;
         transition: all 0.5s ease;
         
         @include md {
            width: 400px;
            height: 400px;
         }
         
         @include sm {
            width: 280px;
            height: 280px;
            grid-column-gap:10px;
            grid-row-gap: 10px;
         }

         li {
            list-style: none;
            width: 100%;
            height: 100%;
            border-radius: 5px;
            box-shadow: inset 0px 0px 40px 0px darken($bg-01, 8%);
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
         }

         .piece {
            position: absolute;
            border-radius: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            font-weight: 500;
            width: 0;
            height: 0;
            font-size: 45px;
            
            @include md {
              font-size: 28px; 
            }
            
            @include sm {
               font-size: 22px;
            }
            

            &.pieceIn {
               border-radius: 5px;
               animation: pieceIn 0.5s ease;
               animation-fill-mode: forwards;

               @keyframes pieceIn {
                  0% {
                     border-radius: 100%;
                     width: 50%;
                     height: 50%;
                     font-size: 0;
                  }

                  80% {
                     width: 110%;
                     height: 110%;
                  }
                  100% {
                     width: 100%;
                     height: 100%;
                  }
               }
            }

            &.pieceOut {
               border-radius: 5px;
               animation: pieceOut 0.5s ease-out;
               animation-fill-mode: forwards;
               

               @keyframes pieceOut {
                  0% {
                     border-radius: 5px;
                     width: 100%;
                     height: 100%;
                  }

                  20% {
                     border-radius: 5px;
                     width: 110%;
                     height: 110%;
                  }

                  100% {
                     border-radius: 100%;
                     font-size: 0;
                     width: 0%;
                     height: 0%;
                  }
               }
            }

            &.n-2 {
               background-color: $n-2;
               color: darken($n-2, 35%);
            }
            &.n-4 {
               background-color: $n-4;
               color: lighten($n-4, 25%);
            }
            &.n-8 {
               background-color: $n-8;
               color: lighten($n-8, 25%);
            }

            &.n-16 {
               background-color: $n-16;
               color: darken($n-16, 20%);
            }
            &.n-32 {
               background-color: $n-32;
               color: lighten($n-32, 20%);
            }
            &.n-64 {
               background-color: $n-64;
               color: lighten($n-64, 30%);
            }
            &.n-128 {
               background-color: $n-128;
               color: darken($n-128, 35%);
            }
            &.n-256 {
               background-color: $n-256;
               color: darken($n-256, 30%);
            }
            &.n-512 {
               background-color: $n-512;
               color: lighten($n-512, 30%);
            }
            &.n-128,
            &.n-256,
            &.n-512 {
               font-family: "Barlow Semi Condensed", sans-serif;
               letter-spacing: 1px;
            }
            &.n-1024 {
               background-color: $n-1024;
               color: darken($n-1024, 30%);
            }
            &.n-2048 {
               background-color: $n-2048;
               color: darken($n-2048, 30%);
            }
            &.n-4096 {
               background-color: $n-4096;
               color: lighten($n-4096, 30%);
            }
            &.n-8192 {
               background-color: $n-8192;
               color: lighten($n-8192, 32%);
            }
            &.n-1024,
            &.n-2048,
            &.n-4096,
            &.n-8192 {
               
               font-family: "Barlow Condensed", sans-serif;
               letter-spacing: 1px;
            }

            &.generic {
               background-color: $n-16384;
               color: lighten($n-16384, 35%);
               font-family: "Barlow Condensed", sans-serif;
               letter-spacing: 1px;
               
            }
            
            &.pieceNone {
               font-size: 0;
               
            }
         }
      }
      
      .gameOver {
         position: absolute;
         width: 50%;
         height: 50%;
         display: flex;
         justify-content: center;
         align-items: center;
         transition: all 0.5s ease;
         opacity: 0;
         
         &:before, &:after {
         width: 100%;
         height: 100%;
         left: 0;
         top: 0;
         content: "";
         position: absolute; 
         border-radius: 100%;
         transition: all 0.4s ease;
      }
         &:before {
         background-color: white;
         opacity: 0.9;
      }
          &:after {
         background-color: $c-01;
         opacity: 0.5;
      }
         
         .text {
            position: absolute;
            z-index:1;
            opacity:0;
            text-align: center;
            color: $c-02;
            font-weight: 500;
            transition: all 0.6s ease;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            letter-spacing: 0px;
            font-size:30px;
         }
         
         p {
            margin-bottom: 40px;
         }
         
         .btn {
            transform: translateY(20px);
            transition: all 0.6s ease;
         }
         
         &.over {
            width: 100%;
            height: 100%;
            opacity:1;
            
            .text {
               font-size: 40px;
               opacity:1;
               letter-spacing: 3px;
               .btn {
            transform: translateY(0px);
         }
            }
            
               &:before, &:after {
               border-radius: 5px;
      }
         }
      }
   }
}

              
            
!

JS

              
                var number = document.querySelectorAll(".number"),
    piece = document.querySelectorAll(".piece"),
    btn = document.querySelectorAll(".btn"),
    btnOver = document.querySelector(".btnOver"),
    btnAdd = document.querySelector(".btnAdd"),
    btnRemove = document.querySelector(".btnRemove"),
    gameOver = document.querySelector(".gameOver");


/* ----------------------------------------------- */

/* Test Buttons */
btnAdd.addEventListener("click", addPieces);
btnRemove.addEventListener("click", removePieces);
btnOver.addEventListener("click", ifgameOver);

/* New Game Button */
btn.forEach(function(el) {
   el.addEventListener("click", started);
});

/* Number toggle */
number.forEach(function(el) {
   el.addEventListener("click", selectNumber);
});


/* ----------------------------------------------- */

/* New Game Button Animation */
function started(e) {
   var currentBtn = e.currentTarget;
   currentBtn.classList.add("start");

   setTimeout(function() {
      currentBtn.classList.remove("start");
   }, 1500);
   
   setTimeout(function() {
      gameOver.classList.remove("over");
      btnOver.innerText = "gameover";
      btnOver.style.backgroundColor = "rgba(255,255,255,1)";}, 1500);
}

/* Add Pieces */
function addPieces() {
   var piece = document.querySelectorAll(".piece");

   piece.forEach(function(el) {
      el.classList.remove("pieceOut");
      el.classList.remove("pieceNone");
      el.classList.add("pieceIn");
   });

   number.forEach(function(el) {
      if (el.classList.contains("pieceOut")) {
         el.classList.remove("on");

      } else {
         el.classList.add("on");

      }
   });
   btnRemove.style.display = "block";
   btnAdd.style.display = "none";
}

/* Remove Pieces */
function removePieces() {
   var piece = document.querySelectorAll(".piece");

   piece.forEach(function(el) {
      el.classList.remove("pieceIn");
      el.classList.remove("pieceNone");
      el.classList.add("pieceOut");
   });

   btnRemove.style.display = "none";
   btnAdd.style.display = "block";

   number.forEach(function(el) {
      if (el.classList.contains("pieceIn")) {
         el.classList.add("on");
      } else {
         el.classList.remove("on");
      }
   });
}

/* Toggle Numbers */
function selectNumber(el) {
   var currentNumber = el.currentTarget,
       number2 = currentNumber.dataset.number,
       pieceSelect = document.querySelector("#" + number2),
       piece = document.querySelectorAll(".piece");

   pieceSelect.classList.remove("pieceNone");

   if (currentNumber.classList.contains("on")) {
      currentNumber.classList.remove("on");
   } else {
      currentNumber.classList.add("on");
   }

   if (pieceSelect.classList.contains("pieceIn")) {
      pieceSelect.classList.remove("pieceIn");
      pieceSelect.classList.add("pieceOut");
   } else {
      pieceSelect.classList.remove("pieceOut");
      pieceSelect.classList.add("pieceIn");
   }

   if (currentNumber.classList.contains("on")) {
      btnRemove.style.display = "block";
   } else {
      btnRemove.style.display = "none";
   }
}

/* Game Over overlay */
function ifgameOver() {
   
   if(gameOver.classList.contains("over")) {
      gameOver.classList.remove("over");
      btnOver.innerText = "gameover";
      btnOver.style.backgroundColor = "rgba(255,255,255,1)";
      
   } else {
      gameOver.classList.add("over");
      btnOver.innerText = "close";
      btnOver.style.backgroundColor = "rgba(255,255,255,0.7)";
   }

}

              
            
!
999px

Console