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

              
                <div class="content">
		<div class="lights-container">
			<ul class="lights">
				<li id="first" class="ok"><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li><span></span></li>
				<li id="last"><span></span></li>
			</ul>
		</div>
		<div class="levels">
			<span class="activeLevel">1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span><span>10</span><br>
			<input id="level" type="range" min="16" max="88" value="88" step="8">
		</div>
		<div class="buttons">
			<span id="loser">0</span>
			<button id="levelDown">-</button>
			<button id="startLights">Start</button>
			<button id="stopLights">Stop</button>
			<button id="levelUp">+</button>
			<span id="winner">0</span>
		</div>
		<div id="accuracy"></div>
	</div>
              
            
!

CSS

              
                body {
	background: #111;
	font-family: Arial, Helvetica, sans-serif;
}
.content {
    overflow: hidden;
}

/*** LIGHTS ***/
.lights-container {
    transform: rotate(45deg);
	position: relative;
    z-index: 0;
}
.lights-container:before {
    content: "CATCH THE LIGHT";
    color: #fc0;
    transform: rotate(-45deg);
    position: absolute;
    top: 46%;
    left: 0%;
    font-size: 2em;
    width: 100%;
    text-align: center;
    text-shadow: 0 0 5px #fc0, 0 0 15px #fc0;
}
.lights-container.level1:before  { content: "LEVEL 1"; }
.lights-container.level2:before  { content: "LEVEL 2"; }
.lights-container.level3:before  { content: "LEVEL 3"; }
.lights-container.level4:before  { content: "LEVEL 4"; }
.lights-container.level5:before  { content: "LEVEL 5"; }
.lights-container.level6:before  { content: "LEVEL 6"; }
.lights-container.level7:before  { content: "LEVEL 7"; }
.lights-container.level8:before  { content: "LEVEL 8"; }
.lights-container.level9:before  { content: "LEVEL 9"; }
.lights-container.level10:before { content: "LEVEL 10"; }

ul.lights {
    width: 50vw;
    height: 50vw;
    max-width: 425px;
    max-height: 425px;
    margin: 6vh auto 8vh;
    position: relative;
    padding: 0;
    border-radius: 100%;
}
ul.lights li {
    width: 80%;
    height: 80%;
    position: absolute;
    list-style: none;
    margin: 0;
    padding: 0;
    border-radius: 100%;
    margin: 10%;
}
ul.lights li:nth-child(2)  { transform: rotate(11.25deg);  }
ul.lights li:nth-child(3)  { transform: rotate(22.5deg);   }
ul.lights li:nth-child(4)  { transform: rotate(33.75deg);  }
ul.lights li:nth-child(5)  { transform: rotate(45deg);     }
ul.lights li:nth-child(6)  { transform: rotate(56.25deg);  }
ul.lights li:nth-child(7)  { transform: rotate(67.5deg);   }
ul.lights li:nth-child(8)  { transform: rotate(78.75deg);  }
ul.lights li:nth-child(9)  { transform: rotate(90deg);     }
ul.lights li:nth-child(10) { transform: rotate(101.25deg); }
ul.lights li:nth-child(11) { transform: rotate(112.5deg);  }
ul.lights li:nth-child(12) { transform: rotate(123.75deg); }
ul.lights li:nth-child(13) { transform: rotate(135deg);    }
ul.lights li:nth-child(14) { transform: rotate(146.25deg); }
ul.lights li:nth-child(15) { transform: rotate(157.5deg);  }
ul.lights li:nth-child(16) { transform: rotate(168.75deg); }
ul.lights li:nth-child(17) { transform: rotate(180deg);    }
ul.lights li:nth-child(18) { transform: rotate(191.25deg); }
ul.lights li:nth-child(19) { transform: rotate(202.5deg);  }
ul.lights li:nth-child(20) { transform: rotate(213.75deg); }
ul.lights li:nth-child(21) { transform: rotate(225deg);    }
ul.lights li:nth-child(22) { transform: rotate(236.25deg); }
ul.lights li:nth-child(23) { transform: rotate(247.5deg);  }
ul.lights li:nth-child(24) { transform: rotate(258.75deg); }
ul.lights li:nth-child(25) { transform: rotate(270deg);    }
ul.lights li:nth-child(26) { transform: rotate(281.25deg); }
ul.lights li:nth-child(27) { transform: rotate(292.5deg);  }
ul.lights li:nth-child(28) { transform: rotate(303.75deg); }
ul.lights li:nth-child(29) { transform: rotate(315deg);    }
ul.lights li:nth-child(30) { transform: rotate(326.25deg); }
ul.lights li:nth-child(31) { transform: rotate(337.5deg);  }
ul.lights li:nth-child(32) { transform: rotate(348.75deg); }

ul.lights li span {
    background: #fff;
    width: 2vw;
    height: 2vw;
    max-width: 20px;
    max-height: 20px;
    float: left;
    border-radius: 100%;
    box-shadow: 0px 0px 5px 1px #333 inset, 0px 0px 5px 10px #111111;
    border: 2px solid rgba(0,0,0,0.25);
	position: relative;
}
ul.lights li.ok span, ul.lights.winner {
	background: #36dc33;
    box-shadow: 0 0 5px 5px #36dc33, 0 0 15px 5px #36dc33, 0px 0px 6px 3px #ffffff2b inset, 0px 0px 5px 10px #111111;
}
ul.lights li.error span, ul.lights.loser {
	background: #ff2515;
    box-shadow: 0 0 5px 5px #ff2515;
}
ul.lights li#first span {
	background: #ffcc00;
    box-shadow: 0 0 5px 3px #ffcc00, 0 0 15px 5px #ffcc00, 0px 0px 5px 1px #333 inset, 0px 0px 5px 10px #111111;
    z-index: 2;
}
ul.lights li#first.ok span {
	background: #36dc33;
    box-shadow: 0 0 5px 3px #36dc33, 0 0 15px 5px #36dc33, 0px 0px 5px 1px #333 inset, 0px 0px 5px 10px #111111;
    z-index: 3;
}
ul.lights.loser li.ok span {
    background: #ff2515;
    box-shadow: 0 0 5px 3px #ff2515, 0 0 15px 5px #ff2515, 0px 0px 5px 1px #333 inset, 0px 0px 5px 10px #111111;
}
ul.lights:before {
    content: "";
    position: absolute;
    top: 46%;
    width: 100%;
    text-align: center;
    transform: rotate(-45deg);
    font-size: 2.25em;
    left: 0;
    margin-left: 0;
	text-shadow: 0 0 3px #111;
}
ul.lights.winner:before { content: "WINNER"; }
ul.lights.loser:before  { content: "LOSER"; }


/*** BUTTONS ***/
.buttons {
    text-align: center;
	z-index: 1;
    position: relative;
}
.buttons button {
    background: #FFCC00;
    border: none;
    font-size: 2em;
    padding: 0.5em 1em;
    border-radius: 5px;
    cursor: pointer;
    outline: none;
    text-align: center;
	text-shadow: 0 0 1px #111;
}
.buttons button:hover { background: #36dc33; }

#stopLights {
	display: none;
	padding: 0.5em 1.025em;
}

#stopLights:hover { background: #ff2515; }

.buttons span {
    font-size: 2em;
    padding: 0.5em 0.25em 0.05em;
    border-radius: 5px;
    width: 1.5em;
    line-height: 1.65em;
    position: relative;
    display: inline-table;
    top: 0.25em;
}
.buttons span:before {
	font-size: 0.35em;
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    line-height: 1em;
    background: rgba(0,0,0,0.25);
    padding: 0.35em 0;
	text-shadow: 0 0 1px #111111;
}

.buttons #loser:before  { content: "LOSER";  }
.buttons #winner:before { content: "WINNER"; }

#loser  { background: #ff2515;  }
#winner { background: #36dc33; }


/*** LEVELS ***/
.levels {
    left: calc(50% - 8.5em);
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.5em;
	z-index: 1;
}
.levels span {
    color: #777777;
    display: inline-block;
    width: 1.65em;
}
#level {
    width: 20em;
	border-left: 5px solid #777777;
    border-right: 5px solid #777777;
	box-sizing: border-box;
	transform: rotate(180deg);
	cursor: pointer;
	height: 5px;
    background: #111111;
}
#levelDown, #levelUp {
    padding: 0.5em;
    width: 2em;
    background: #777777;
}
#levelDown:hover, #levelUp:hover {
    background: #FFC107;
}
.levels .activeLevel {
    color: #fc0;
}
#level:disabled, button#levelUp:disabled, button#levelDown:disabled, .levels.disabled > span {
    cursor: not-allowed;
    opacity: 0.25;
}


/*** RANGE STYLES ***/
input[type='range']:focus { outline: none; }
input[type='range'],
input[type='range']::-webkit-slider-runnable-track,
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
}
input[type=range]::-webkit-slider-thumb {
  background-color: #FC0;
  width: 20px;
  height: 20px;
  border: 3px solid #111;
  border-radius: 50%;
  margin-top: -9px;
}
input[type=range]::-moz-range-thumb {
  background-color: #FC0;
  width: 15px;
  height: 15px;
  border: 3px solid #111;
  border-radius: 50%;
}
input[type=range]::-ms-thumb {
  background-color: #FC0;
  width: 20px;
  height: 20px;
  border: 3px solid #111;
  border-radius: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  background-color: #777;
  height: 3px;
}
input[type=range]:focus::-webkit-slider-runnable-track {
  outline: none;
}
input[type=range]::-moz-range-track {
  background-color: #777;
  height: 3px;
}
input[type=range]::-ms-track {
  background-color: #777;
  height: 3px;
}
input[type=range]::-ms-fill-lower {
  background-color: blue
}
input[type=range]::-ms-fill-upper {
  background-color: yellow;
} 


/*** LANDSCAPE VIEW ***/
.landscape .lights-container {
    float: left;
}
.landscape ul.lights {
    margin: 4vw;
    height: 80vh;
    width: 80vh;
}
.landscape .levels {
    float: right;
    margin-top: 6em;
    margin-right: 1.9em;
}
.landscape #loser, .landscape #winner {
	display: none;
}


/*** ACCURACY ***/
#accuracy {
    position: fixed;
    width: 100%;
    height: 2em;
    font-size: 2em;
    top: 10.5em;
    text-align: center;
    color: #111;
    display: none;
    text-shadow: 0 0 2px #111;
}
#accuracy:after {
    content: "ACCURACY";
    position: absolute;
    bottom: 0;
    font-size: 0.51em;
    margin-left: -45px;
    left: 50%;
}


/*** MEDIA QUERIES ***/
@media (max-width:480px){
	#loser, #winner {
		display: none;
	}
	ul.lights {
		width: 70vw;
		height: 70vw;
	}
}

/*** MOZILLA STYLES ***/
@-moz-document url-prefix() { 
	.buttons span {
		top: 0.175em;
	}
}
              
            
!

JS

              
                level = '88';
winner = loser = 0;

function elem(id){
  var e = document.getElementById(id);
  return e;
}

function activateLevelNum(inputValue){
	var spanNum;
	switch(inputValue){
		case "88": spanNum = 0; break;
		case "80": spanNum = 1; break;
		case "72": spanNum = 2; break;
		case "64": spanNum = 3; break;
		case "56": spanNum = 4; break;
		case "48": spanNum = 5; break;
		case "40": spanNum = 6; break;
		case "32": spanNum = 7; break;
		case "24": spanNum = 8; break;
		case "16": spanNum = 9; break;
		default  : spanNum = 0;
	}
	var spans = document.querySelectorAll('.levels span');
	for(var i = 0; i<spans.length; i++){spans[i].classList.remove('activeLevel');}
	spans[spanNum].classList.add('activeLevel');
	document.querySelector('.lights-container').className = 'lights-container';
	document.querySelector('.lights-container').classList.add('level'+ parseInt(spanNum+1));
}

function addDisable(){
	elem('level').setAttribute('disabled','disabled');
	elem('levelUp').setAttribute('disabled','disabled');
	elem('levelDown').setAttribute('disabled','disabled');
	document.querySelector('.levels').classList.add('disabled');
}

function removeDisable(){
	elem('level').removeAttribute('disabled');
	elem('levelUp').removeAttribute('disabled');
	elem('levelDown').removeAttribute('disabled');
	document.querySelector('.levels').classList.remove('disabled');
}


var btnStart = elem('startLights');
btnStart.addEventListener('click', function() {
	document.querySelector('.lights').classList.remove('loser','winner');
	addDisable();
	this.style.display='none';
	this.nextElementSibling.style.display='inline-block';
	elem('accuracy').style.display = 'none';
	
	if(level=='88')document.querySelector('.lights-container').classList.add('level1');
	
	timer = setInterval(function(){	
		var x = document.querySelector('li.ok');
		if(x.id=='last'){
			elem('first').classList.add('ok');
			x.classList.remove('ok');
		} else {
			x.nextElementSibling.classList.add('ok');
			x.classList.remove('ok');
		}
	}, level);
});

var btnStop = elem('stopLights');
btnStop.addEventListener('click', function() {
	document.querySelector('.lights').classList.remove('loser','winner');	
	removeDisable();
	this.style.display='none';
	this.previousElementSibling.style.display='inline-block';
	clearInterval(timer);	
	if(elem('first').classList == 'ok') {
		document.querySelector('.lights').classList.add('winner');
		winner++;
		elem('winner').innerHTML=winner;
		
		if(level == '16'){
			var total = parseInt(winner + loser);
			var percent = winner / total * 100;
			elem('accuracy').innerHTML = percent.toFixed() +'%';
			elem('accuracy').style.display = 'block';
		}
		
		levelSelector.stepDown(1);
		level = levelSelector.value;
		activateLevelNum(level);
		
	} else {
		document.querySelector('.lights').classList.add('loser');			
		loser++;
		elem('loser').innerHTML=loser;
	}
});

var levelSelector = elem('level');
levelSelector.addEventListener('change', function() {
	level = this.value;
	activateLevelNum(level);
});

var levelUpBtn = elem('levelUp');
levelUpBtn.addEventListener('click', function() {
	document.querySelector('.lights').classList.remove('loser','winner');
	levelSelector.stepDown(1);
	level = levelSelector.value;
	activateLevelNum(level);
});

var levelDownBtn = elem('levelDown');
levelDownBtn.addEventListener('click', function() {
	document.querySelector('.lights').classList.remove('loser','winner');
	levelSelector.stepUp(1);
	level = levelSelector.value;
	activateLevelNum(level);
});

              
            
!
999px

Console