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

              
                <g tabindex=0>
  <b>
    <m></m>
    <!-- as many <c> as the variable $c in the CSS -->
    <c><c><c><c><c><c><c><c><c><c><c><c><c><c><c><c><c><c><c><c> 
      <r></r>
    <!-- as many </c> as the variable $c in the CSS -->
    </c></c></c></c></c></c></c></c></c></c></c></c></c></c></c></c></c></c></c></c>
  </b>
</g>

              
            
!

CSS

              
                /* Control the grid */
$n: 11; /* rows */
$m: 5; /* columns */
$s: 60px; /* size */
/* the number of coins (don't forget to update the html code)
   some coins may overlap but it's not a big deal
*/
$c: 20;
/* keyboard sensitivity ]1 +infinity[
   bigger values will get you a slower move
*/
$v: 3;

@import url('https://fonts.cdnfonts.com/css/retro-mario');
@property --s1 {
	syntax: '<integer>';
	inherits: true;
	initial-value: 0
}
@property --s2 {
	syntax: '<integer>';
	inherits: true;
	initial-value: 0
}
@property --sum {
	syntax: '<integer>';
	inherits: true;
	initial-value: 0
}
b {
  display: grid;
  width: ($n + 1)*$s;
  height: ($m + 2)*$s;
  position: sticky;
  border: solid #0000;
  border-width: $s/2 $s/2 1.5*$s;
  box-sizing: border-box;
  left: 0;
  top: 0;
  font-weight: initial;
}
m {
  content:"";
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
  width: $s;
  aspect-ratio:1;
  opacity:0;
  background: url(https://assets.codepen.io/1480814/mm.png) center/cover;
  animation: x linear,y linear;
  animation-timeline: scroll(nearest inline),scroll(nearest block);
}
@keyframes x{to {left: 100%}}
@keyframes y{to {top: 100%}}
c {
  position: absolute;
  inset: 0;
  animation-timeline: scroll(nearest inline),scroll(nearest block)!important;
}
c:before {
  content:"";
  position: absolute;
  width: #{100%/$n};
  aspect-ratio: 1;
  border-radius: 50%;
  scale: .6;
  background: 
    url(https://assets.codepen.io/1480814/ccc.png)
    0 50%/600% auto no-repeat;
}
@keyframes b {to {background-position: 120% 50%}}
@keyframes e {to {opacity:0;translate:0 -100%}}
$sel: ("");
@for $i from 1 to ($c+1) {
  c#{$sel}{
    animation: c#{$i}-x linear,c#{$i}-y linear;
    container-name: c#{$i};
  }
  $x:random($n);
  $y:random($m);
  c#{$sel}:before {
    left: #{($x - 1)*100%/$n};
    top: #{($y - 1)*100%/$m};
    animation: 
      b .8s steps(6) infinite,
      e .05s forwards var(--e#{$i},paused);
    @container c#{$i} style(--c#{$i}-x: 1) and style(--c#{$i}-y: 1) {--e#{$i}: running}
  }
  @keyframes c#{$i}-x {
    0%,#{($x - 1)*(100%/$n)},#{$x*(100%/$n)},to{--c#{$i}-x:0}
    #{($x - 1)*(100%/$n) + .1%},#{$x*(100%/$n) - .1%}{--c#{$i}-x:1}
  }
  @keyframes c#{$i}-y {
    0%,#{($y - 1)*(100%/$m)},#{$y*(100%/$m)},to{--c#{$i}-y:0}
    #{($y - 1)*(100%/$m) + .1%},#{$y*(100%/$m) - .1%}{--c#{$i}-y:1}
  }
  $sel: append($sel,'>c',space);
}
r {
  color: #fefeff;
  font-size: 35px;
  visibility: hidden;
  $anim: ();
  @for $i from 1 to ($c+1) {
    --r#{$i}:0; 
    $anim: append($anim,'r#{$i} .1s forwards var(--s-r#{$i},paused)',comma);
    @container c#{$i} style(--c#{$i}-x: 1) and style(--c#{$i}-y: 1) {--s-r#{$i}: running}
    @keyframes r#{$i} {1%,to {--r#{$i}:1}}
  }
  $sum: ("var(--r1)");
  @for $i from 2 to ($c+1) {
    $sum: append($sum,'+ var(--r#{$i})' , space);
  }
  --sum: calc(#{$sum});
  animation: #{$anim};
  container-name: r;
}
r:before {
  content: "SCORE - " counter(r,decimal-leading-zero);
  position: absolute;
  right: $s/-2;
  bottom: -1.5*$s;
  padding: 8px 16px 8px 0;
  counter-reset: r var(--sum);
}
r:after {
  content: "TIME - " counter(s1,decimal-leading-zero) "s";
  font-variant-numeric: tabular-nums;
  counter-reset: s1 var(--s1) s2 var(--s2);
  position: absolute;
  left: $s/-2;
  bottom: -1.5*$s;
  padding: 8px;
  animation: s1 60s linear forwards paused;
  background: url(https://assets.codepen.io/1480814/win_1.png) bottom/auto 0 no-repeat;
  @container r style(--sum: #{$c}) {
    content:"You did it in " counter(s1,decimal-leading-zero) "s";
    background:
      url(https://assets.codepen.io/1480814/win_1.png) 50% 70%/auto 60% no-repeat
      var(--b) content-box;
    inset: $s/-2 $s/-2 -1.5*$s;
    padding-right: 6px;
    animation-play-state: paused !important;
    text-align: center;
    font-size: 55px;
    z-index: 99989;
    visibility: visible;
  }
}
@keyframes s1 {to{--s1:60}}
g {
  display: block;
  width: ($n + 1)*$s*$v;
  height: ($m + 2)*$s*$v;
}
body {
  position: relative;
  margin: auto auto $s/2;
  overflow: auto;
  scrollbar-width: none;
  width: ($n + 1)*$s;
  height: ($m + 2)*$s;
  box-shadow: 
    -6px 0 var(--c2),
    -6px 0 var(--c2) inset,
    0 -6px  var(--c2) inset;
  background: var(--b);
  cursor: pointer;
}
b:before {
  content:"Collect the Coins\aWith your keyboard!\a\a\a🖱️Click to start";
  font-size: 40px;
  white-space: pre;
  text-align: center;
  position: absolute;
  inset: $s/-4 $s/-4 -1*$s;
  padding-top: $s/2;
  pointer-events: none;
  z-index: 5896;
  color: #fefeff;
  background: 
    url(https://assets.codepen.io/1480814/mm.png) bottom/80px auto no-repeat,
    url(https://assets.codepen.io/1480814/k.png) 50% 43%/110px auto no-repeat var(--b);
}
body:focus-within {
  cursor: none;
}
body:focus-within b:before {
  opacity: 0;
}
body:focus-within m {
  opacity: 1;
}
body:focus-within r {
  visibility: visible;
}
body:focus-within r:after {
  animation-play-state: running;
}
html {
  font-family: 'Retro Mario', sans serif;
  min-height:100vh;
  overflow: hidden;
  display: grid;
  --c1: #954b0c;
  --c2: #000;
  --b: #6185f8;
  --g:conic-gradient(at 90% 40%,#0000 75%,var(--c1) 0);
  background: 
    var(--g) 50% 100%,
    var(--g) calc(50% + #{$s/2}) calc(100% + #{$s/2})
    var(--c2);
  background-size: $s $s;
}
html:before {
  content: "Super CSS Mario";
  position: absolute;
  inset: auto 0 ($m + 3)*$s;
  width: fit-content;
  margin: auto;
  color: #ffccc5;
  font-size: 50px;
  padding: 10px 25px;
  background: #994e00;
  text-shadow: 5px 5px #000;
  border: 3px solid;
}
@media (width < ($n + 1)*$s), (height < ($m + 4)*$s) {
  html:after {
    content: "Sorry but your screen is too small for this game\a\a Buy a bigger one and try again!";
    white-space: pre-wrap;
    background: var(--b);
    position: absolute;
    inset: 0;
    z-index: calc(infinity);
    display: grid;
    place-content: center;
    text-align: center;
    font-size: 40px;
    padding: 40px;
    color: #fff;
  }
}
@supports not (animation-timeline: scroll()) {
  html:after {
    content: "Firefox and Safari users aren't allowed\a✋ \aThis is a chromium experimentation\a(Use Chrome or Edge)";
    white-space: pre-wrap;
    background: var(--b);
    position: absolute;
    inset: 0;
    z-index: calc(infinity);
    display: grid;
    place-content: center;
    text-align: center;
    font-size: 40px;
    padding: 40px;
    color: #fff;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console