Pen Settings



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


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


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.


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.




p    - pause
ESC  - abandon game

Click the big P to choose one of three levels:
- Casual
- Medium
- Hard

The game will save your stats locally, via localStorage.
Click the F to see your stats.

Click I for these intructions.

Flip is a timed card memory game. When starting a level, there's a red bar on top of the screen that shows how much time you have left.
Click the green cards to see what symbol they uncover and try to find the matching symbol underneath the other cards.
Uncover two matching symbols in a row to eliminate them from the game.
Eliminate all cards as fast as you can to win the game. Have fun FLIPing!

<div id="g"></div>
<div class="logo">
  <p>Click the P to get started.</p>
  <div class="card left">
    <div class="flipper">
      <div class="f c1">F</div>
      <div class="b contentbox" id="stats">
        <div class="padded">
          Looks like you haven't FLIPped yet.
          <a href="javascript:;" class="playnow">Play now</a>
  <div class="card active twist">
    <div class="flipper">
      <div class="b f">
        <div class="c2">L</div>
  <div class="card left">
    <div class="flipper">
      <div class="f c3">I</div>
      <div class="b contentbox instructions">
        <div class="padded">
          <p>Press [p] to pause, or [ESC] to abandon game.</p>
          <p>Flip is a timed card memory game. Click the green cards to see what symbol they uncover and try to find the matching symbol underneath the other cards.</p>
          <p>Uncover two matching symbols at once to eliminate them from the game.</p>
          <p>Eliminate all cards as fast as you can to win the game. Have fun FLIPing!</p>
  <div class="card">
    <div class="flipper">
      <div class="f c4">P</div>
      <div class="b contentbox levels">
        <a href="javascript:;" data-level="8" class="play">Casual</a>
        <a href="javascript:;" data-level="18" class="play">Medium</a>
        <a href="javascript:;" data-level="32" class="play">Hard</a>

  <p>Just for fun.</p>


                body, html{margin:0;font:normal 0/0 sans-serif;background:#FAFAF8;overflow:hidden;color:#fff;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
body, html, .flipper, .f, .b, #g {width:100%;height:100%;}

/* font-face */
@font-face{font-family: "GeneralFoundicons";font-weight:normal;font-style:normal;
	src: url("");
	src: url("") format("embedded-opentype"),
	     url("") format("woff"),
	     url("") format("truetype"),
	     url("") format("svg");
a{text-decoration:none;color:#fff;display:block;font:bold 18px/75px 'Open Sans';text-transform:uppercase;text-align:center;padding:0;margin:0 1px;}
a:hover{color:#fff;background:rgba(255, 255, 255, .1)}

.logo{width:450px;height:450px;position:absolute;top:50%;left:50%;margin:-225px 0 0 -225px}
.logo .card{width:50%;height:50%;cursor:default;position:relative}
.logo + .card{opacity:0}
.logo .b{margin-left:-100%}
.logo .f{font:normal 130px/225px 'Open Sans';text-align:center;text-transform:uppercase;}
.logo .c2{transform:scale(-1, 1);-webkit-transform:scale(-1, 1);-moz-transform:scale(-1, 1);-ms-transform:scale(-1, 1)}

.logo .contentbox{width:200%;font:normal 12px/16px 'Open Sans';text-align:left}
.logo .contentbox.levels{width:100%}
.logo .contentbox .padded{padding:0 15px;}
.logo .contentbox h2{font-size:24px;padding:0;margin:28px 0;text-transform:uppercase}
.logo .contentbox p{line-height:14px;margin:14px 0}

#stats h2 i{margin-right:10px;vertical-align:top;font:italic normal 9px/8px 'Open Sans';color:rgba(255,255,255, .4)}
#stats ul{width:50%;display:inline-block;margin:0;padding:0;list-style-type:none;vertical-align:top;line-height:22px}
#stats li{display:block;margin:0;padding:0;}
#stats li b{display:inline-block;font-size:12px;width:95px}
#stats a {position:absolute;bottom:0;width:100%;margin-left:-15px;}

.logo .info{font-size:11px;line-height:16px;text-align:center;color: rgba(255,255,255, .3);padding:0 25px;}

#g .timer{width:0%;height:5px;position:absolute;top:0;background:#668671;z-index:1}
@-webkit-keyframes timer {100% { width:100%; }}
@-moz-keyframes timer {100% { width:100%; }}
@-o-keyframes timer {100% { width:100%; }}
@keyframes timer {100% { width:100%; }}
.pause{position:absolute;width:100%;height:100%;left:0;top:0;z-index:100;background:rgba(51, 51, 51, 0.78)}
.pause::before{content:'PAUSED';width:100%;position:absolute;margin-top:-100px;top:50%;background:#F7941D;color:#fff;font:bold 80px/200px 'Open Sans';
/* card styles */
#g .found{display:inline-block}
.card .b::before{content:attr(data-f);display:block;font:normal 100px/100px "GeneralFoundicons";

/* flip cards */
.flipper {position:relative;-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d}
.f, .b {position:absolute;top:0;left:0;box-shadow:inset 0 0 0 1px #B0A791;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden}
.f {background:#668671;z-index:1}
.b {background:#f7941d;opacity:0} .b{z-index:2;opacity:1}

/*Grouped for easy prefixing*/
.card, .flipper, .logo .b{transition:400ms;-ms-transition:400ms;-webkit-transition:400ms;-moz-transition:400ms;-o-transition:400ms} .flipper, .b {transform:rotateY(180deg);-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg);-ms-transform:rotateY(180deg);-o-transform:rotateY(180deg)}
.logo .f, .card .b::before, .pause::before{-webkit-text-stroke: 1px #fff} /*webkit only*/

/*Responsive Stuff*/
@media all and (max-width: 1680px) and (min-width: 640px){
	.card .b::before{font-size:90px}
	#g.medium .card .b::before{font-size:70px}
	#g.hard .card .b::before{font-size:50px}
@media all and (max-width: 640px) and (min-width: 470px){
	.card .b::before{font-size:90px}
	#g.medium .card .b::before{font-size:60px}
	#g.hard .card .b::before{font-size:50px}

@media all and (max-width: 470px) and (min-width: 0px){
	.card .b::before{font-size:60px}
	#g.medium .card .b::before{font-size:35px;-webkit-text-stroke:0;}
	#g.hard .card .b::before{font-size:32px;-webkit-text-stroke:0;}

@media all and (max-width: 640px) and (min-width: 0px){
	.logo{width:300px;height:300px;margin:-150px 0 0 -150px}
	.logo .f{font:normal 80px/150px 'Open Sans'}
	.logo .contentbox h2{font-size:16px;margin:24px 0;}
	.logo .instructions h2{display:none}
	.logo .instructions.contentbox p:nth-child(3){display:none}
	#stats li b{width:auto}


  function set(key, value) { localStorage.setItem(key, value); }
  function get(key)        { return localStorage.getItem(key); }
  function increase(el)    { set(el, parseInt( get(el) ) + 1); }
  function decrease(el)    { set(el, parseInt( get(el) ) - 1); }

  var toTime = function(nr){
    if(nr == '-:-') return nr;
    else { var n = ' '+nr/1000+' '; return n.substr(0, n.length-1)+'s'; }

  function updateStats(){
    $('#stats').html('<div class="padded"><h2>Figures: <span>'+
      '<ul><li><b>Best Casual:</b> <span>'+toTime( get('flip_casual') )+'</span></li>'+
      '<li><b>Best Medium:</b> <span>'+toTime( get('flip_medium') )+'</span></li>'+
      '<li><b>Best Hard:</b> <span>'+toTime( get('flip_hard') )+'</span></li></ul>'+
      '<ul><li><b>Total Flips:</b> <span>'+parseInt( ( parseInt(get('flip_matched')) + parseInt(get('flip_wrong')) ) * 2)+'</span></li>'+
      '<li><b>Matched Flips:</b> <span>'+get('flip_matched')+'</span></li>'+
      '<li><b>Wrong Flips:</b> <span>'+get('flip_wrong')+'</span></li></ul></div>');

  function shuffle(array) {
    var currentIndex = array.length, temporaryValue, randomIndex;
    while (0 !== currentIndex) {
        randomIndex = Math.floor(Math.random() * currentIndex);
        currentIndex -= 1;
        temporaryValue = array[currentIndex];
        array[currentIndex] = array[randomIndex];
        array[randomIndex] = temporaryValue;
    return array;

  function startScreen(text){

    $('.c1').text(text.substring(0, 1));
    $('.c2').text(text.substring(1, 2));
    $('.c3').text(text.substring(2, 3));
    $('.c4').text(text.substring(3, 4));

    // If won game
    if(text == 'nice'){

    // If lost game
    else if(text == 'fail'){

    // Update stats


  // Init localStorage
  if( !get('flip_won') && !get('flip_lost') && !get('flip_abandoned') ){
    //Overall Game stats
    set('flip_won', 0);
    set('flip_lost', 0);
    set('flip_abandoned', 0);
    //Best times
    set('flip_casual', '-:-');
    set('flip_medium', '-:-');
    set('flip_hard', '-:-');
    //Cards stats
    set('flip_matched', 0);
    set('flip_wrong', 0);

  // Fill stats
  if( get('flip_won') > 0 || get('flip_lost') > 0 || get('flip_abandoned') > 0) {updateStats();}

  // Toggle start screen cards
  $('.logo .card:not(".twist")').on('click', function(e){
    if( $('.playnow') ) { $('.logo .card').last().addClass('active'); }

  // Start game
  $('.play').on('click', function(){

    var difficulty = '',
        timer      = 1000,
        level      = $(this).data('level');

    // Set game timer and difficulty   
    if     (level ==  8) { difficulty = 'casual'; timer *= level * 4; }
    else if(level == 18) { difficulty = 'medium'; timer *= level * 5; }
    else if(level == 32) { difficulty = 'hard';   timer *= level * 6; }	    


    $('.logo').fadeOut(250, function(){
      var startGame  = $.now(),
          obj = [];

      // Create and add shuffled cards to game
      for(i = 0; i < level; i++) { obj.push(i); }

      var shu      = shuffle( $.merge(obj, obj) ),
          cardSize = 100/Math.sqrt(shu.length);

      for(i = 0; i < shu.length; i++){
        var code = shu[i];
        if(code < 10) code = "0" + code;
        if(code == 30) code = 10;
        if(code == 31) code = 21;
        $('<div class="card" style="width:'+cardSize+'%;height:'+cardSize+'%;">'+
            '<div class="flipper"><div class="f"></div><div class="b" data-f="&#xf0'+code+';"></div></div>'+

      // Set card actions
      $('#g .card').on({
        'mousedown' : function(){
          if($('#g').attr('data-paused') == 1) {return;}
          var data = $(this).addClass('active').find('.b').attr('data-f');

          if( $('#g').find('').length > 1){
              var thisCard = $('#g .active .b[data-f='+data+']');

              if( thisCard.length > 1 ) {
                thisCard.parents('.card').toggleClass('active card found').empty(); //yey

                // Win game
                if( !$('#g .card').length ){
                  var time = $.now() - startGame;
                  if( get('flip_'+difficulty) == '-:-' || get('flip_'+difficulty) > time ){
                    set('flip_'+difficulty, time); // increase best score

              else {
                $('#g').removeClass('active'); // fail
            }, 401);

      // Add timer bar
      $('<i class="timer"></i>')
          'animation' : 'timer '+timer+'ms linear'
        .one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
          startScreen('fail'); // fail game

      // Set keyboard (p)ause and [esc] actions
      $(window).off().on('keyup', function(e){
        // Pause game. (p)
        if(e.keyCode == 80){
          if( $('#g').attr('data-paused') == 1 ) { //was paused, now resume
            $('#g').attr('data-paused', '0');
            $('.timer').css('animation-play-state', 'running');
          else {
            $('#g').attr('data-paused', '1');
            $('.timer').css('animation-play-state', 'paused');
            $('<div class="pause"></div>').appendTo('body');
        // Abandon game. (ESC)
        if(e.keyCode == 27){
          // If game was paused
          if( $('#g').attr('data-paused') == 1 ){
            $('#g').attr('data-paused', '0');